Changeset 101
- Timestamp:
- 02/03/09 18:37:06 (12 months ago)
- Location:
- trunk/rapidandroid/org.rapidandroid
- Files:
-
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/rapidandroid/org.rapidandroid/res/layout/add_field.xml
r75 r101 17 17 <EditText android:id="@+id/etx_fieldname" 18 18 android:layout_width="fill_parent" android:layout_height="wrap_content" 19 android:textSize="14sp" ></EditText>19 android:textSize="14sp" android:singleLine="true"></EditText> 20 20 21 21 <TableRow android:id="@+id/TableRow03" android:layout_width="wrap_content" … … 29 29 <EditText android:id="@+id/etx_fieldprompt" 30 30 android:layout_width="fill_parent" android:layout_height="wrap_content" 31 android:textSize="14sp" ></EditText>31 android:textSize="14sp" android:singleLine="true"></EditText> 32 32 <TextView android:id="@+id/lbl_fieldtypechoose" 33 33 android:layout_width="fill_parent" android:layout_height="wrap_content" -
trunk/rapidandroid/org.rapidandroid/res/layout/form_create.xml
r90 r101 14 14 <EditText android:id="@+id/etx_formname" 15 15 android:layout_width="fill_parent" android:layout_height="wrap_content" 16 android:textSize="14sp" android:layout_weight="2" ></EditText>16 android:textSize="14sp" android:layout_weight="2" android:singleLine="true"></EditText> 17 17 <TextView android:layout_width="wrap_content" 18 18 android:layout_height="wrap_content" android:text="@string/lbl_formprefix" android:id="@+id/lbl_formprefix" android:layout_weight="0"> … … 22 22 android:layout_width="fill_parent" 23 23 android:layout_height="wrap_content" 24 android:textSize="14sp" android:layout_weight="2" ></EditText>24 android:textSize="14sp" android:layout_weight="2" android:singleLine="true"></EditText> 25 25 26 26 </TableRow> … … 36 36 android:layout_width="fill_parent" 37 37 android:textSize="14sp" 38 android:singleLine="false" 39 android:gravity="top" android:layout_height="wrap_content" android:layout_weight="2"></EditText> 38 android:gravity="top" android:layout_height="wrap_content" android:layout_weight="2" android:singleLine="true"></EditText> 40 39 41 40 </TableRow> -
trunk/rapidandroid/org.rapidandroid/src/org/rapidandroid/activity/Dashboard.java
r97 r101 54 54 * 55 55 */ 56 public class Dashboard extends Activity { 57 58 private SingleRowHeaderView headerView; 56 public class Dashboard extends Activity { 57 59 58 private SummaryCursorAdapter summaryView; 60 59 private FormDataGridCursorAdapter rowView; 61 60 private MessageCursorAdapter messageCursorAdapter; 62 61 63 //private ProgressDialog mLoadingDialog; 64 62 //private ProgressDialog mLoadingDialog; 65 63 66 64 private Form mChosenForm = null; 67 68 69 private boolean mShowMonitors = false;70 65 private boolean mShowAllMessages = false; 71 66 … … 82 77 // private static final int MENU_EXIT = Menu.FIRST + 3; //waitaminute, we 83 78 // don't want to exit this thing, do we? 84 85 79 80 private static final String STATE_DATE_START = "startdate"; 81 private static final String STATE_DATE_END = "enddate"; 82 private static final String STATE_SPINNER_POSITION = "spinneritem"; 83 private static final String STATE_SELECTED_FORM = "selectedform"; 84 private static final String STATE_LSV_POSITION = "listposition"; 85 private static final String STATE_LSV_VIEWMODE = "viewmode"; 86 86 87 87 private static final int CONTEXT_ITEM_SUMMARY_VIEW = Menu.FIRST; … … 104 104 boolean resetCursor = true; 105 105 Cursor mListviewCursor = null; 106 private int selectedListViewPosition = -1; 106 107 107 108 private Date mStartDate; … … 115 116 requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); 116 117 setTitle("RapidAndroid :: Dashboard"); 117 setContentView(R.layout.dashboard); 118 119 // if (savedInstanceState != null) { 120 // String from = savedInstanceState.getString("from"); 121 // String body = savedInstanceState.getString("body"); 122 // //dialogMessage = "SMS :: " + from + " : " + body; 123 // //showDialog(160); 124 // } 125 126 // mLoadingDialog = new ProgressDialog(this,ProgressDialog.STYLE_HORIZONTAL); 127 // mLoadingDialog.setMessage("Loading data..."); 128 // mLoadingDialog.setTitle("Please wait"); 129 // mLoadingDialog.setIndeterminate(true); 130 // mLoadingDialog.setCancelable(false); 131 132 this.loadFormSpinner(); 133 118 setContentView(R.layout.dashboard); 119 this.initFormSpinner(); 134 120 // Set the event listeners for the spinner and the listview 135 121 Spinner spin_forms = (Spinner) findViewById(R.id.cbx_forms); … … 176 162 ((SummaryCursorAdapter) adapter.getAdapter()).toggle(position); 177 163 } 178 179 } 180 164 } 181 165 }); 182 166 … … 184 168 mEndDate = new Date(); 185 169 mStartDate = new Date(); 186 mStartDate.setDate(mEndDate.getDate() - 1); 170 mStartDate.setDate(mEndDate.getDate() - 1); 171 } 172 173 /* (non-Javadoc) 174 * @see android.app.Activity#onRestoreInstanceState(android.os.Bundle) 175 */ 176 @Override 177 protected void onRestoreInstanceState(Bundle savedInstanceState) { 178 super.onRestoreInstanceState(savedInstanceState); 179 if (savedInstanceState != null) { 180 if (savedInstanceState.containsKey(STATE_DATE_START) 181 && savedInstanceState.containsKey(STATE_DATE_END) 182 && savedInstanceState.containsKey(STATE_SPINNER_POSITION) 183 // && savedInstanceState.containsKey(STATE_LSV_POSITION) 184 && savedInstanceState.containsKey(STATE_LSV_VIEWMODE) 185 //&& savedInstanceState.containsKey(STATE_SELECTED_FORM) 186 ) { 187 188 try { 189 mStartDate = Message.SQLDateFormatter.parse(savedInstanceState.getString(STATE_DATE_START)); 190 mEndDate = Message.SQLDateFormatter.parse(savedInstanceState.getString(STATE_DATE_END)); 191 } catch (ParseException e) { 192 // TODO Auto-generated catch block 193 e.printStackTrace(); 194 } 195 formViewMode = savedInstanceState.getInt(STATE_LSV_VIEWMODE); 196 197 Spinner spin_forms = (Spinner) findViewById(R.id.cbx_forms); 198 spin_forms.setSelection(savedInstanceState.getInt(STATE_SPINNER_POSITION)); 199 } 200 201 202 // String from = savedInstanceState.getString("from"); 203 // String body = savedInstanceState.getString("body"); 204 // //dialogMessage = "SMS :: " + from + " : " + body; 205 // //showDialog(160); 206 } 207 } 208 209 /* (non-Javadoc) 210 * @see android.app.Activity#onSaveInstanceState(android.os.Bundle) 211 */ 212 @Override 213 protected void onSaveInstanceState(Bundle outState) { 214 // TODO Auto-generated method stub 215 super.onSaveInstanceState(outState); 216 outState.putString(STATE_DATE_START, Message.SQLDateFormatter.format(mStartDate)); 217 outState.putString(STATE_DATE_END, Message.SQLDateFormatter.format(mEndDate)); 218 outState.putInt(STATE_LSV_VIEWMODE, formViewMode); 219 Spinner spin_forms = (Spinner) findViewById(R.id.cbx_forms); 220 outState.putInt(STATE_SPINNER_POSITION,spin_forms.getSelectedItemPosition()); 187 221 } 188 222 … … 201 235 case ACTIVITY_CREATE: 202 236 // we should do an update of the view 203 loadFormSpinner();237 initFormSpinner(); 204 238 resetCursor = true; 205 239 beginListViewReload(); … … 350 384 351 385 // we want to chart for a form 352 if (mChosenForm != null && !mShowAllMessages && !mShowMonitors) {386 if (mChosenForm != null && !mShowAllMessages) { 353 387 Date endDate = new Date(); 354 388 endDate = ParsedDataReporter.getOldestMessageDate(this,mChosenForm); … … 364 398 i.putExtra(ChartData.CallParams.CHART_FORM, mChosenForm 365 399 .getFormId()); 366 } else if (mShowAllMessages && !mShowMonitors) {400 } else if (mShowAllMessages) { 367 401 // Chart for messages 368 402 i.putExtra(ChartData.CallParams.CHART_MESSAGES, true); 369 } else if (mShowMonitors && !mShowAllMessages) { 370 //Chart for monitors 371 } 403 } 372 404 i.putExtra(ChartData.CallParams.START_DATE, Message.SQLDateFormatter.format(mStartDate)); 373 405 i.putExtra(ChartData.CallParams.END_DATE, Message.SQLDateFormatter.format(mEndDate)); … … 377 409 378 410 // This is a call to the DB to get all the forms that this form can support. 379 private void loadFormSpinner() {411 private void initFormSpinner() { 380 412 // The steps: 381 413 // get the spinner control from the layouts … … 385 417 this.mAllForms = ModelTranslator.getAllForms(); 386 418 387 String[] monitors = new String[mAllForms.length + 2];419 String[] monitors = new String[mAllForms.length + 1]; 388 420 389 421 … … 393 425 394 426 //add some special selections: 395 monitors[monitors.length - 2] = "Show all Messages";396 monitors[monitors.length - 1] = "Show Monitors";427 monitors[monitors.length - 1] = "Show all Messages"; 428 //monitors[monitors.length - 1] = "Show Monitors"; 397 429 398 430 ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, monitors); … … 407 439 mChosenForm = null; 408 440 this.mShowAllMessages = true; 409 this.mShowMonitors = false;410 441 resetCursor = true; 411 442 beginListViewReload(); 412 //loadListViewWithRawMessages(); 413 414 415 } else if (position == mAllForms.length + 1) { 416 // then it's show all monitors 417 mChosenForm = null; 418 this.mShowAllMessages = false; 419 this.mShowMonitors = true; 420 resetCursor = true; 421 beginListViewReload(); 422 //loadListViewsWithMonitors(); 423 443 //loadListViewWithRawMessages(); 444 424 445 } else { 425 446 this.mShowAllMessages = false; 426 this.mShowMonitors = false;427 447 mChosenForm = mAllForms[position]; 428 448 resetCursor = true; 429 beginListViewReload(); 430 //loadListViewWithFormData(true); 431 } 449 beginListViewReload(); 450 } 432 451 } 433 452 … … 441 460 ListView lsv = (ListView) findViewById(R.id.lsv_dashboardmessages); 442 461 443 if(mChosenForm != null && !mShowAllMessages && !mShowMonitors) {462 if(mChosenForm != null && !mShowAllMessages) { 444 463 loadListViewWithFormData(); 445 464 } 446 else if(mShowAllMessages && mChosenForm == null && !mShowMonitors) {465 else if(mShowAllMessages && mChosenForm == null) { 447 466 this.messageCursorAdapter = new MessageCursorAdapter(this, mListviewCursor); 448 467 lsv.setAdapter(messageCursorAdapter); 449 468 } 450 else if(mShowMonitors && !mShowAllMessages && mChosenForm==null) { 451 lsv.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, new String[] {"todo"})); 452 453 } 469 454 470 } 455 471 … … 479 495 private void fillCursorInBackground() { 480 496 if(mListviewCursor == null) { 481 if(mChosenForm != null && !mShowAllMessages && !mShowMonitors) {482 String whereclause = " rapidandroid_message.time > '" + Message.SQLDateFormatter.format(mStartDate) + "' AND time <'" + Message.SQLDateFormatter.format(mEndDate) + "'";497 if(mChosenForm != null && !mShowAllMessages) { 498 String whereclause = " rapidandroid_message.time >= '" + Message.SQLDateFormatter.format(mStartDate) + "' AND time <= '" + Message.SQLDateFormatter.format(mEndDate) + "'"; 483 499 mListviewCursor = getContentResolver().query(Uri.parse(RapidSmsDBConstants.FormData.CONTENT_URI_PREFIX + mChosenForm.getFormId()), null,whereclause,null,null); 484 500 485 } else if(mShowAllMessages && mChosenForm == null && !mShowMonitors) {486 String whereclause = "time > '" + Message.SQLDateFormatter.format(mStartDate) + "' AND time <'" + Message.SQLDateFormatter.format(mEndDate) + "'";501 } else if(mShowAllMessages && mChosenForm == null) { 502 String whereclause = "time >= '" + Message.SQLDateFormatter.format(mStartDate) + "' AND time <= '" + Message.SQLDateFormatter.format(mEndDate) + "'"; 487 503 mListviewCursor = getContentResolver().query(RapidSmsDBConstants.Message.CONTENT_URI, null, whereclause, null, "time DESC"); 488 504 489 } else if(mShowMonitors && !mShowAllMessages && mChosenForm==null) { 490 //do something 491 // query.append("WHERE rapidandroid_message.time > '" + startDate.get(Calendar.YEAR) + "-" + (startDate.get(Calendar.MONTH)+1) + "-" + startDate.get(Calendar.DATE) + "' AND "); 492 // query.append(" rapidandroid_message.time < '" + endDate.get(Calendar.YEAR) + "-" + (1+endDate.get(Calendar.MONTH)) + "-" + endDate.get(Calendar.DATE) + "';"); 493 // 494 } 505 } 495 506 } 496 507 } -
trunk/rapidandroid/org.rapidandroid/src/org/rapidandroid/view/adapter/MessageCursorAdapter.java
r94 r101 9 9 import android.content.Context; 10 10 import android.database.Cursor; 11 import android.view.Gravity; 11 12 import android.view.View; 12 13 import android.view.ViewGroup; … … 14 15 import android.widget.LinearLayout; 15 16 import android.widget.TableLayout; 17 import android.widget.TableRow; 16 18 import android.widget.TextView; 17 19 … … 65 67 private class SimpleMessageView extends TableLayout { 66 68 69 70 private TableRow mHeaderRow; 71 private TextView txvDate; 72 private TextView txvFrom; 67 73 private TextView txvMessage; 68 private TextView txvHeader; 74 69 75 70 76 71 77 public SimpleMessageView(Context context, String message, Date timestamp, int monitorID, boolean isOutgoing) { 72 78 super(context); 73 txvHeader = new TextView(context); 74 txvHeader.setLayoutParams(new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT)); 79 mHeaderRow = new TableRow(context); 80 81 txvDate = new TextView(context); 82 txvDate.setTextSize(16); 83 txvDate.setPadding(3,3,3,3); 84 txvDate.setGravity(Gravity.LEFT); 85 txvFrom = new TextView(context); 86 txvFrom.setTextSize(16); 87 txvFrom.setPadding(3,3,8,3); 88 txvFrom.setGravity(Gravity.RIGHT); 89 75 90 //this.addView(txvHeader, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); 76 this.addView(txvHeader); 91 mHeaderRow.addView(txvDate); 92 mHeaderRow.addView(txvFrom); 93 addView(mHeaderRow); 77 94 78 95 txvMessage = new TextView(context); 96 txvMessage.setTextSize(12); 97 txvMessage.setPadding(8,2,8,2); 79 98 //this.addView(txvMessage, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); 80 99 this.addView(txvMessage); 100 101 this.setColumnStretchable(0, true); 102 this.setColumnStretchable(1, true); 81 103 82 104 setData(message,timestamp,monitorID,isOutgoing); … … 85 107 86 108 public void setData(String message, Date timestamp, int monitorID, boolean isOutgoing) { 87 StringBuilder sb = new StringBuilder(); 88 if(isOutgoing) { 89 sb.append("[Out] <<< "); 90 } else { 91 sb.append("[In] >>> " ); 92 } 109 txvDate.setText(Message.DisplayDateTimeFormat.format(timestamp)); 93 110 94 sb.append(Message.DisplayDateTimeFormat.format(timestamp) + " [");95 111 Monitor m = MessageTranslator.GetMonitor(getContext(), monitorID); 96 sb.append(m.getPhone() + "]"); 97 //txvHeader.setText(Message.DisplayDateTimeFormat.format(timestamp)); 98 txvHeader.setText(sb.toString()); 112 txvFrom.setText(m.getPhone()); 99 113 100 114 txvMessage.setText(message);