Changeset 97
- Timestamp:
- 02/03/09 01:43:24 (12 months ago)
- Location:
- trunk/rapidandroid/org.rapidandroid
- Files:
-
- 14 modified
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/rapidandroid/org.rapidandroid/AndroidManifest.xml
r94 r97 58 58 <activity android:name=".activity.AddField" android:theme="@android:style/Theme.Dialog"></activity> 59 59 <activity android:name=".activity.FileBrowser"></activity> 60 <activity android:name=".activity.DateRange" android:theme="@android:style/Theme.Dialog"></activity>60 <activity android:name=".activity.DateRange"></activity> 61 61 <receiver android:name=".receiver.SmsReplyReceiver"> 62 62 <intent-filter><action android:name="org.rapidandroid.intents.SMS_REPLY"></action> -
trunk/rapidandroid/org.rapidandroid/res/layout/date_range.xml
r94 r97 2 2 <TableLayout android:id="@+id/TableLayout01" 3 3 android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android" 4 android:layout_width="fill_parent" >4 android:layout_width="fill_parent" android:scrollbarStyle="outsideOverlay"> 5 5 <TableRow android:id="@+id/TableRow01" android:layout_height="wrap_content" 6 6 android:layout_width="fill_parent"> 7 <TextView android:id="@+id/TextView01" android:layout_width="wrap_content" 8 android:text="@string/lbl_startdate" android:layout_height="wrap_content"></TextView> 9 <TextView android:id="@+id/txv_startdate" 10 android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView> 11 </TableRow> 12 <SeekBar android:id="@+id/range_startseek" 13 android:layout_width="fill_parent" android:secondaryProgress="100" android:layout_height="50px" android:paddingLeft="8px" android:paddingRight="8px"></SeekBar> 7 <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/btn_daterange_startdate" android:id="@+id/range_btn_startdate"></Button> 8 <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/txv_startdate" android:layout_weight="2" android:textSize="16sp"></TextView> 9 10 </TableRow> 11 14 12 15 13 <TableRow android:id="@+id/TableRow02" android:layout_height="wrap_content" 16 14 android:layout_width="fill_parent"> 17 <TextView android:id="@+id/TextView03" android:layout_width="wrap_content" 18 android:layout_height="wrap_content" android:text="@string/lbl_enddate"></TextView> 15 19 16 <TextView android:id="@+id/txv_enddate" android:layout_width="wrap_content" 20 android:layout_height="wrap_content" ></TextView>21 < /TableRow>22 <SeekBar android:layout_width="fill_parent" android:id="@+id/range_endseek" 23 android:progress="100" android:layout_height="50px" android:paddingRight="8px" android:paddingLeft="8px"></SeekBar>17 android:layout_height="wrap_content" android:layout_weight="2" android:textSize="16sp"></TextView> 18 <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/btn_daterange_enddate" android:id="@+id/range_btn_enddate"></Button> 19 </TableRow> 20 24 21 <TextView android:id="@+id/TextView02" android:layout_width="wrap_content" 25 22 android:layout_height="20px" android:text=" " ></TextView> … … 35 32 android:text="@string/range_btn_lastmonth"></Button> 36 33 34 <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/range_btn_last_threemonth" android:text="@string/range_btn_lastthreemonth"></Button> 37 35 </TableLayout> -
trunk/rapidandroid/org.rapidandroid/res/layout/form_edit.xml
r96 r97 1 1 <?xml version="1.0" encoding="utf-8"?> 2 3 <LinearLayout 4 android:id="@+id/widget28" 2 <TableLayout 3 android:id="@+id/TableLayout01" 5 4 android:layout_width="fill_parent" 6 5 android:layout_height="fill_parent" 7 6 android:orientation="vertical" 8 7 xmlns:android="http://schemas.android.com/apk/res/android" 8 android:stretchColumns="0,1" 9 9 > 10 <TableLayout android:id="@+id/TableLayout01" 11 android:layout_height="wrap_content" android:layout_width="fill_parent"> 12 <TableRow android:id="@+id/TableRow01" android:layout_height="wrap_content" android:layout_width="fill_parent"> 13 <TextView 10 <TableRow> 11 <TextView 12 android:id="@+id/lbl_formname" 14 13 android:layout_width="wrap_content" 15 14 android:layout_height="wrap_content" 16 17 15 android:text="@string/lbl_formname" 18 android:id="@+id/lbl_formname"> 16 android:padding="3dip" 17 android:layout_weight="1" android:textStyle="bold"> 19 18 </TextView> 20 19 <TextView 20 android:id="@+id/lbl_formprefix" 21 21 android:layout_width="wrap_content" 22 22 android:layout_height="wrap_content" 23 24 23 android:text="@string/lbl_formprefix" 25 android:id="@+id/lbl_formprefix"> 24 android:padding="3dip" 25 android:layout_weight="1" android:textStyle="bold"> 26 26 </TextView> 27 28 </TableRow> 29 30 31 <TableRow android:id="@+id/TableRow02" android:layout_height="wrap_content" android:layout_width="fill_parent"> 32 <TextView 27 </TableRow> 28 <TableRow> 29 <TextView 30 android:id="@+id/txv_formname" 33 31 android:layout_width="wrap_content" 34 32 android:layout_height="wrap_content" 35 33 android:text="@+string/txv_formname" 36 android:id="@+id/txv_formname"> 34 android:padding="3dip" 35 android:layout_weight="1"> 37 36 </TextView> 38 37 <TextView 38 android:id="@+id/txv_formprefix" 39 39 android:layout_width="wrap_content" 40 40 android:layout_height="wrap_content" 41 41 android:text="@+string/txv_formprefix" 42 android:id="@+id/txv_formprefix"> 42 android:padding="3dip" 43 android:layout_weight="1"> 43 44 </TextView> 44 45 </TableRow> 46 47 <TextView 45 </TableRow> 46 <TextView 47 android:id="@+id/lbl_description" 48 48 android:layout_width="wrap_content" 49 49 android:layout_height="wrap_content" 50 51 50 android:text="@string/lbl_description" 52 android:id="@+id/lbl_description"> 51 android:padding="3dip" 52 android:textStyle="bold"> 53 53 </TextView> 54 54 <TextView 55 android:id="@+id/txv_description" 55 56 android:layout_width="fill_parent" 56 57 android:layout_height="wrap_content" 57 58 android:text="@+string/txv_description" 58 android:id="@+id/txv_description"> 59 android:padding="3dip" 60 > 59 61 </TextView> 60 </TableLayout>61 62 63 62 <LinearLayout 64 63 android:id="@+id/FormFieldsLayout" 65 64 android:layout_width="fill_parent" 66 65 android:layout_height="wrap_content" 67 android:orientation="vertical" > 66 android:orientation="vertical" 67 > 68 68 <TextView 69 android:id="@+id/lbl_fields" 69 70 android:layout_width="fill_parent" 70 71 android:layout_height="wrap_content" 72 android:text="@string/lbl_fields" 71 73 style="?android:attr/listSeparatorTextViewStyle" 72 android:text="@string/lbl_fields" 73 android:id="@+id/lbl_fields"> 74 > 74 75 </TextView> 75 76 <ListView 77 android:id="@+id/lsv_fields" 76 78 android:layout_width="fill_parent" 77 79 android:layout_height="wrap_content" 78 android:id="@+id/lsv_fields">80 > 79 81 </ListView> 80 82 </LinearLayout> 81 </ LinearLayout>83 </TableLayout> -
trunk/rapidandroid/org.rapidandroid/res/values/colors.xml
r96 r97 31 31 32 32 <color name="background_red">#C14747</color> 33 <color name="background_gray">#636363</color> 33 34 </resources> -
trunk/rapidandroid/org.rapidandroid/res/values/strings.xml
r96 r97 3 3 <string name="hello">Hello World, rapidandroid</string> 4 4 <string name="app_name">RapidAndroid</string> 5 <string name="lbl_formname">Name :</string>6 <string name="lbl_description">Description :</string>7 <string name="lbl_formprefix">Prefix :</string>5 <string name="lbl_formname">Name</string> 6 <string name="lbl_description">Description</string> 7 <string name="lbl_formprefix">Prefix</string> 8 8 <string name="lbl_formchoose">Forms:</string> 9 9 <string name="lbl_dashboardmessages">Recent Messages:</string> … … 41 41 <string name="lbl_chart_datasummary">Data Summary:</string> 42 42 <string name="lbl_chart_totalmessages">Total Messages:</string> 43 <string name="btn_daterange_startdate">Start Date</string> 44 <string name="btn_daterange_enddate">End Date</string> 45 <string name="range_btn_lastthreemonth">End Date</string> 43 46 </resources> -
trunk/rapidandroid/org.rapidandroid/src/org/rapidandroid/activity/ChartData.java
r94 r97 173 173 Date endDate = new Date(); 174 174 if(mForm != null) { 175 ParsedDataReporter pdr = new ParsedDataReporter(this); 176 endDate = pdr.getOldestMessage(mForm); 177 pdr.done(); 175 endDate = ParsedDataReporter.getOldestMessageDate(this,mForm); 178 176 } else { 179 177 endDate = MessageDataReporter.getOldestMessageDate(this); 180 178 } 181 179 182 i.putExtra(DateRange.CallParams.ACTIVITY_ARG_ ENDDATE, Message.SQLDateFormatter.format(endDate));180 i.putExtra(DateRange.CallParams.ACTIVITY_ARG_STARTDATE, Message.SQLDateFormatter.format(endDate)); 183 181 startActivityForResult(i, ACTIVITY_DATERANGE); 184 182 … … 199 197 if(extras != null) { 200 198 try { 201 Date startDate = Message. DisplayDateTimeFormat.parse(extras.getString(DateRange.ResultParams.RESULT_START_DATE));202 Date endDate = Message. DisplayDateTimeFormat.parse(extras.getString(DateRange.ResultParams.RESULT_END_DATE));199 Date startDate = Message.SQLDateFormatter.parse(extras.getString(DateRange.ResultParams.RESULT_START_DATE)); 200 Date endDate = Message.SQLDateFormatter.parse(extras.getString(DateRange.ResultParams.RESULT_END_DATE)); 203 201 mBroker.setRange(startDate, endDate); 204 202 mBroker.loadGraph(); -
trunk/rapidandroid/org.rapidandroid/src/org/rapidandroid/activity/Dashboard.java
r96 r97 13 13 import org.rapidandroid.data.controller.ParsedDataReporter; 14 14 import org.rapidandroid.view.SingleRowHeaderView; 15 import org.rapidandroid.view.adapter.FormData CursorAdapter;15 import org.rapidandroid.view.adapter.FormDataGridCursorAdapter; 16 16 import org.rapidandroid.view.adapter.MessageCursorAdapter; 17 17 import org.rapidandroid.view.adapter.SummaryCursorAdapter; 18 import org.rapidsms.java.core.Constants; 18 19 import org.rapidsms.java.core.model.Form; 19 20 import org.rapidsms.java.core.model.Message; 20 21 21 22 import android.app.Activity; 23 import android.app.AlertDialog; 24 import android.app.Dialog; 25 import android.app.AlertDialog.Builder; 22 26 import android.content.Intent; 23 27 import android.database.Cursor; … … 25 29 import android.os.Bundle; 26 30 import android.os.Handler; 31 import android.util.DisplayMetrics; 27 32 import android.view.ContextMenu; 28 33 import android.view.Menu; … … 53 58 private SingleRowHeaderView headerView; 54 59 private SummaryCursorAdapter summaryView; 55 private FormData CursorAdapter rowView;60 private FormDataGridCursorAdapter rowView; 56 61 private MessageCursorAdapter messageCursorAdapter; 57 62 … … 102 107 private Date mStartDate; 103 108 private Date mEndDate; 109 private int mScreenWidth; 104 110 105 111 … … 146 152 ListView lsv = (ListView) findViewById(R.id.lsv_dashboardmessages); 147 153 148 154 DisplayMetrics dm = new DisplayMetrics(); 155 getWindowManager().getDefaultDisplay().getMetrics(dm); 156 mScreenWidth = dm.widthPixels - 8; 157 149 158 lsv.setChoiceMode(ListView.CHOICE_MODE_SINGLE); 150 159 … … 173 182 174 183 //by default on startup: 184 mEndDate = new Date(); 175 185 mStartDate = new Date(); 176 mEndDate = new Date(); 177 mEndDate.setDate(mStartDate.getDate() - 1); 186 mStartDate.setDate(mEndDate.getDate() - 1); 178 187 } 179 188 … … 192 201 case ACTIVITY_CREATE: 193 202 // we should do an update of the view 194 loadFormSpinner(); 203 loadFormSpinner(); 204 resetCursor = true; 205 beginListViewReload(); 195 206 break; 196 207 case ACTIVITY_FORM_REVIEW: 197 208 // dialogMessage = "Activity Done"; 198 209 // showDialog(12); 210 resetCursor = true; 211 beginListViewReload(); 199 212 break; 200 213 case ACTIVITY_CHARTS: 201 214 // dialogMessage = "Activity Done"; 202 215 // showDialog(13); 216 resetCursor = true; 217 beginListViewReload(); 203 218 break; 204 219 case ACTIVITY_DATERANGE: 205 220 if (extras != null) { 206 221 try { 207 this.mStartDate = Message.DisplayDateTimeFormat.parse(extras.getString(DateRange.ResultParams.RESULT_START_DATE)); 208 this.mEndDate = Message.DisplayDateTimeFormat 209 .parse(extras 210 .getString(DateRange.ResultParams.RESULT_END_DATE)); 222 mStartDate = Message.SQLDateFormatter.parse(extras.getString(DateRange.ResultParams.RESULT_START_DATE)); 223 mEndDate = Message.SQLDateFormatter.parse(extras.getString(DateRange.ResultParams.RESULT_END_DATE)); 211 224 } catch (ParseException e) { 212 225 // TODO Auto-generated catch block … … 300 313 Date endDate = new Date(); 301 314 if(mChosenForm != null) { 302 ParsedDataReporter pdr = new ParsedDataReporter(this); 303 if(this.mListviewCursor.getCount() == 0) { 304 305 } else { 306 endDate = pdr.getOldestMessage(this.mChosenForm); 307 } 308 pdr.done(); 309 } else { 315 endDate = ParsedDataReporter.getOldestMessageDate(this,mChosenForm); 316 if(endDate.equals(Constants.NULLDATE)) { 317 Builder noDateDialog = new AlertDialog.Builder(this); 318 noDateDialog.setPositiveButton("Ok", null); 319 noDateDialog.setTitle("Alert"); 320 noDateDialog.setMessage("This form has no messages or data to chart"); 321 noDateDialog.show(); 322 return; 323 } 324 } 325 else { 310 326 endDate = MessageDataReporter.getOldestMessageDate(this); 311 327 } 312 i.putExtra(DateRange.CallParams.ACTIVITY_ARG_ ENDDATE, Message.SQLDateFormatter.format(endDate));328 i.putExtra(DateRange.CallParams.ACTIVITY_ARG_STARTDATE, Message.SQLDateFormatter.format(endDate)); 313 329 startActivityForResult(i, ACTIVITY_DATERANGE); 314 330 … … 332 348 private void startActivityChart() { 333 349 Intent i = new Intent(this, ChartData.class); 334 335 if(mChosenForm != null && !mShowAllMessages && !mShowMonitors) { 336 i.putExtra(ChartData.CallParams.CHART_FORM, mChosenForm.getFormId()); 337 } else if(mShowAllMessages && !mShowMonitors) { 338 //show the messages 350 351 // we want to chart for a form 352 if (mChosenForm != null && !mShowAllMessages && !mShowMonitors) { 353 Date endDate = new Date(); 354 endDate = ParsedDataReporter.getOldestMessageDate(this,mChosenForm); 355 if(endDate.equals(Constants.NULLDATE)) { 356 Builder noDateDialog = new AlertDialog.Builder(this); 357 noDateDialog.setPositiveButton("Ok", null); 358 noDateDialog.setTitle("Alert"); 359 noDateDialog.setMessage("This form has no messages or data to chart"); 360 noDateDialog.show(); 361 return; 362 } 363 364 i.putExtra(ChartData.CallParams.CHART_FORM, mChosenForm 365 .getFormId()); 366 } else if (mShowAllMessages && !mShowMonitors) { 367 // Chart for messages 339 368 i.putExtra(ChartData.CallParams.CHART_MESSAGES, true); 340 369 } else if (mShowMonitors && !mShowAllMessages) { 341 // show all the monitrors370 //Chart for monitors 342 371 } 343 372 i.putExtra(ChartData.CallParams.START_DATE, Message.SQLDateFormatter.format(mStartDate)); … … 408 437 private void finishListViewReload() { 409 438 TextView lbl_recents = (TextView) findViewById(R.id.lbl_dashboardmessages); 410 lbl_recents.setText("Messages: " + Message.DisplayShortDateFormat.format(m EndDate) + " to " + Message.DisplayShortDateFormat.format(mStartDate));439 lbl_recents.setText("Messages: " + Message.DisplayShortDateFormat.format(mStartDate) + "-" + Message.DisplayShortDateFormat.format(mEndDate)); 411 440 412 441 ListView lsv = (ListView) findViewById(R.id.lsv_dashboardmessages); … … 451 480 if(mListviewCursor == null) { 452 481 if(mChosenForm != null && !mShowAllMessages && !mShowMonitors) { 453 String whereclause = " rapidandroid_message.time > '" + Message.SQLDateFormatter.format(m EndDate) + "' AND time < '" + Message.SQLDateFormatter.format(mStartDate) + "'";482 String whereclause = " rapidandroid_message.time > '" + Message.SQLDateFormatter.format(mStartDate) + "' AND time < '" + Message.SQLDateFormatter.format(mEndDate) + "'"; 454 483 mListviewCursor = getContentResolver().query(Uri.parse(RapidSmsDBConstants.FormData.CONTENT_URI_PREFIX + mChosenForm.getFormId()), null,whereclause,null,null); 455 484 456 485 } else if(mShowAllMessages && mChosenForm == null && !mShowMonitors) { 457 String whereclause = "time > '" + Message.SQLDateFormatter.format(m EndDate) + "' AND time < '" + Message.SQLDateFormatter.format(mStartDate) + "'";486 String whereclause = "time > '" + Message.SQLDateFormatter.format(mStartDate) + "' AND time < '" + Message.SQLDateFormatter.format(mEndDate) + "'"; 458 487 mListviewCursor = getContentResolver().query(RapidSmsDBConstants.Message.CONTENT_URI, null, whereclause, null, "time DESC"); 459 488 … … 498 527 lsv.setAdapter(summaryView); 499 528 } else if(this.formViewMode == Dashboard.LISTVIEW_MODE_TABLE_VIEW) { 500 rowView = new FormData CursorAdapter(this, mChosenForm, mListviewCursor);529 rowView = new FormDataGridCursorAdapter(this, mChosenForm, mListviewCursor, mScreenWidth); 501 530 lsv.setAdapter(rowView); 502 531 } -
trunk/rapidandroid/org.rapidandroid/src/org/rapidandroid/activity/DateRange.java
r94 r97 9 9 10 10 import android.app.Activity; 11 import android.app.DatePickerDialog; 12 import android.app.Dialog; 13 import android.app.TimePickerDialog; 11 14 import android.content.Intent; 12 15 import android.os.Bundle; … … 16 19 import android.view.View.OnClickListener; 17 20 import android.widget.Button; 21 import android.widget.DatePicker; 18 22 import android.widget.SeekBar; 19 23 import android.widget.TextView; … … 37 41 * How far back does this dataset go back in time. 38 42 */ 39 public static final String ACTIVITY_ARG_ ENDDATE = "enddate";43 public static final String ACTIVITY_ARG_STARTDATE = "startdate"; 40 44 41 45 } … … 55 59 56 60 57 private Date mStartNow; 58 private Date mAbsoluteEndDate; 59 60 private SeekBar seekEnd; 61 private SeekBar seekStart; 62 61 private Date mStartDate; 62 private Date mEndDate; 63 63 64 private TextView txvStartDate; 64 65 private TextView txvEndDate; … … 66 67 private static final int MENU_DONE = Menu.FIRST; 67 68 private static final int MENU_CANCEL = Menu.FIRST + 1; 69 70 71 private int mStartYear; 72 private int mStartMonth; 73 private int mStartDay; 74 75 private int mEndYear; 76 private int mEndMonth; 77 private int mEndDay; 78 79 80 81 82 static final int DATE_DIALOG_START_ID = 0; 83 static final int DATE_DIALOG_END_ID = 1; 68 84 69 85 @Override … … 77 93 78 94 if (extras != null) { 79 if(!extras.containsKey(CallParams.ACTIVITY_ARG_ ENDDATE)) {80 throw new IllegalArgumentException("This activity must be called with an appropriate enddate");81 } 82 String datestring = extras.getString(CallParams.ACTIVITY_ARG_ ENDDATE);95 if(!extras.containsKey(CallParams.ACTIVITY_ARG_STARTDATE)) { 96 throw new IllegalArgumentException("This activity must be called with an appropriate startdate in the past."); 97 } 98 String datestring = extras.getString(CallParams.ACTIVITY_ARG_STARTDATE); 83 99 try { 84 mStart Now = new Date();85 m AbsoluteEndDate = Message.SQLDateFormatter.parse(datestring);100 mStartDate = Message.SQLDateFormatter.parse(datestring); 101 mEndDate = new Date(); //now 86 102 87 103 } catch (Exception ex) { … … 89 105 } 90 106 } 91 setSliders(); 92 } 93 94 private void setSliders() { 95 96 } 107 108 txvStartDate = (TextView)findViewById(R.id.txv_startdate); 109 txvEndDate = (TextView)findViewById(R.id.txv_enddate); 110 Calendar s = Calendar.getInstance(); 111 s.setTime(mStartDate); 112 Calendar e = Calendar.getInstance(); 113 e.setTime(mEndDate); 114 115 116 setUpdateCalendar(s,e); 117 } 118 119 private void setUpdateCalendar(Calendar s, Calendar e) { 120 mStartYear = s.get(Calendar.YEAR); 121 mStartMonth = s.get(Calendar.MONTH); 122 mStartDay = s.get(Calendar.DAY_OF_MONTH); 123 124 mEndYear = e.get(Calendar.YEAR); 125 mEndMonth = e.get(Calendar.MONTH); 126 mEndDay = e.get(Calendar.DAY_OF_MONTH); 127 updateDisplay(); 128 } 129 130 131 private void updateDisplay() { 132 txvStartDate.setText( 133 new StringBuilder() 134 // Month is 0 based so add 1 135 .append(mStartMonth + 1).append("-") 136 .append(mStartDay).append("-") 137 .append(mStartYear)); 138 139 txvEndDate.setText( 140 new StringBuilder() 141 // Month is 0 based so add 1 142 .append(mEndMonth + 1).append("-") 143 .append(mEndDay).append("-") 144 .append(mEndYear)); 145 } 146 147 private DatePickerDialog.OnDateSetListener mStartDateSetListener = 148 new DatePickerDialog.OnDateSetListener() { 149 150 public void onDateSet(DatePicker view, int year, int monthOfYear, 151 int dayOfMonth) { 152 mStartYear = year; 153 mStartMonth = monthOfYear; 154 mStartDay = dayOfMonth; 155 updateDisplay(); 156 } 157 }; 158 159 private DatePickerDialog.OnDateSetListener mEndDateSetListener = 160 new DatePickerDialog.OnDateSetListener() { 161 162 public void onDateSet(DatePicker view, int year, int monthOfYear, 163 int dayOfMonth) { 164 mEndYear = year; 165 mEndMonth = monthOfYear; 166 mEndDay = dayOfMonth; 167 updateDisplay(); 168 } 169 }; 170 171 172 @Override 173 protected void onPrepareDialog(int id, Dialog dialog) { 174 switch (id) { 175 case DATE_DIALOG_START_ID: 176 ((DatePickerDialog) dialog).updateDate(mStartYear, mStartMonth, mStartDay); 177 break; 178 case DATE_DIALOG_END_ID: 179 ((DatePickerDialog) dialog).updateDate(mEndYear, mEndMonth, mEndDay); 180 break; 181 } 182 } 183 184 @Override 185 protected Dialog onCreateDialog(int id) { 186 switch (id) { 187 case DATE_DIALOG_START_ID: 188 return new DatePickerDialog(this, mStartDateSetListener, 189 mStartYear, mStartMonth, mStartDay); 190 case DATE_DIALOG_END_ID: 191 return new DatePickerDialog(this, mEndDateSetListener, mEndYear, 192 mEndMonth, mEndDay); 193 } 194 return null; 195 } 97 196 98 197 99 198 100 199 private void setEventListeners() { 101 seekEnd = (SeekBar) findViewById(R.id.range_endseek); 102 103 seekEnd.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { 104 105 public void onProgressChanged(SeekBar seekBar, int progress, 106 boolean fromTouch) { 107 updateDisplayFromSliders(); 108 109 } 110 111 public void onStartTrackingTouch(SeekBar seekBar) { 112 updateDisplayFromSliders(); 113 114 } 115 116 public void onStopTrackingTouch(SeekBar seekBar) { 117 updateDisplayFromSliders(); 118 } 119 120 }); 121 122 seekStart = (SeekBar) findViewById(R.id.range_startseek); 123 seekStart.setSecondaryProgress(seekEnd.getProgress()); 124 seekStart.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { 125 126 public void onProgressChanged(SeekBar seekBar, int progress, 127 boolean fromTouch) { 128 updateDisplayFromSliders(); 129 130 } 131 132 public void onStartTrackingTouch(SeekBar seekBar) { 133 updateDisplayFromSliders(); 134 } 135 136 public void onStopTrackingTouch(SeekBar seekBar) { 137 updateDisplayFromSliders(); 200 Button btnStartDate = (Button) findViewById(R.id.range_btn_startdate); 201 btnStartDate.setOnClickListener(new OnClickListener() { 202 203 public void onClick(View v) { 204 showDialog(DATE_DIALOG_START_ID); 205 } 206 207 }); 208 209 210 Button btnEndDate = (Button) findViewById(R.id.range_btn_enddate); 211 btnEndDate.setOnClickListener(new OnClickListener() { 212 213 public void onClick(View v) { 214 showDialog(DATE_DIALOG_END_ID); 138 215 } 139 216 … … 145 222 public void onClick(View v) { 146 223 // TODO Auto-generated method stub 147 Calendar delta = Calendar.getInstance(); 148 delta.setTimeInMillis(mStartNow.getTime()); 149 delta.set(Calendar.DATE, delta.get(Calendar.DATE) - 30); 150 updateDisplayFromDate(delta); 224 Calendar newEnd = Calendar.getInstance(); 225 Calendar newStart = Calendar.getInstance(); 226 newStart.set(Calendar.DATE, newEnd.get(Calendar.DATE) - 30); 227 setUpdateCalendar(newStart,newEnd); 228 151 229 } 152 230 … … 156 234 157 235 public void onClick(View v) { 158 Calendar delta= Calendar.getInstance();159 delta.setTimeInMillis(mStartNow.getTime());160 delta.set(Calendar.DATE, delta.get(Calendar.DATE) - 7);161 updateDisplayFromDate(delta);236 Calendar newEnd = Calendar.getInstance(); 237 Calendar newStart = Calendar.getInstance(); 238 newStart.set(Calendar.DATE, newEnd.get(Calendar.DATE) - 7); 239 setUpdateCalendar(newStart,newEnd); 162 240 163 241 } … … 168 246 169 247 public void onClick(View v) { 170 Calendar delta = Calendar.getInstance(); 171 delta.setTimeInMillis(mStartNow.getTime()); 172 delta.set(Calendar.DATE, delta.get(Calendar.DATE) - 1); 173 updateDisplayFromDate(delta); 174 } 175 }); 176 } 177 178 private void updateDisplayFromDate(Calendar delta) { 179 long tickDelta = mStartNow.getTime() - mAbsoluteEndDate.getTime(); 180 long increment = tickDelta / 100; 181 long slice = mStartNow.getTime() - delta.getTimeInMillis(); 182 183 if (increment > 0) { 184 int ticks = (int) (slice / increment); 185 seekStart.setProgress(0); 186 seekEnd.setProgress(ticks); 187 seekStart.setSecondaryProgress(seekEnd.getProgress()); 188 189 txvStartDate = (TextView) findViewById(R.id.txv_startdate); 190 txvStartDate.setText(Message.DisplayDateTimeFormat.format(mStartNow 191 .getTime() 192 - (seekStart.getProgress() * increment))); 193 194 txvEndDate = (TextView) findViewById(R.id.txv_enddate); 195 txvEndDate.setText(Message.DisplayDateTimeFormat.format(delta.getTimeInMillis())); 196 197 } 198 } 199 200 private void updateDisplayFromSliders() { 201 // Let's make sure the displays are ok 202 if (seekEnd.getProgress() < seekStart.getProgress()) { 203 seekEnd.setProgress(seekStart.getProgress()); 204 } 205 seekStart.setSecondaryProgress(seekEnd.getProgress()); 206 long tickDelta = mStartNow.getTime() - mAbsoluteEndDate.getTime(); 207 long increment = tickDelta / 100; 208 209 if (increment > 0) { 210 txvStartDate = (TextView) findViewById(R.id.txv_startdate); 211 txvStartDate.setText(Message.DisplayDateTimeFormat.format(mStartNow 212 .getTime() 213 - (seekStart.getProgress() * increment))); 214 215 txvEndDate = (TextView) findViewById(R.id.txv_enddate); 216 txvEndDate.setText(Message.DisplayDateTimeFormat.format(mStartNow 217 .getTime() 218 - (seekEnd.getProgress() * increment))); 219 } 220 221 } 248 Calendar newEnd = Calendar.getInstance(); 249 Calendar newStart = Calendar.getInstance(); 250 newStart.set(Calendar.DATE, newEnd.get(Calendar.DATE) - 1); 251 setUpdateCalendar(newStart,newEnd); 252 } 253 }); 254 255 Button btnThreeMonth = (Button) findViewById(R.id.range_btn_last_threemonth); 256 btnThreeMonth.setOnClickListener(new OnClickListener() { 257 258 public void onClick(View v) { 259 Calendar newEnd = Calendar.getInstance(); 260 Calendar newStart = Calendar.getInstance(); 261 newStart.set(Calendar.MONTH, newEnd.get(Calendar.MONTH) - 3); 262 setUpdateCalendar(newStart,newEnd); 263 } 264 }); 265 } 266 267 268 269 222 270 223 271 @Override … … 238 286 case MENU_DONE: 239 287 Intent ret = new Intent(); 288 Calendar finalStart = Calendar.getInstance(); 289 finalStart.set(mStartYear, mStartMonth, mStartDay); 290 291 Calendar finalEnd= Calendar.getInstance(); 292 finalEnd.set(mEndYear, mEndMonth, mEndDay); 240 293 241 txvStartDate = (TextView) findViewById(R.id.txv_startdate); 242 243 244 txvEndDate = (TextView) findViewById(R.id.txv_enddate); 245 246 ret.putExtra(ResultParams.RESULT_START_DATE, txvStartDate.getText().toString()); 247 ret.putExtra(ResultParams.RESULT_END_DATE, txvEndDate.getText().toString()); 294 ret.putExtra(ResultParams.RESULT_START_DATE, Message.SQLDateFormatter.format(finalStart.getTime())); 295 ret.putExtra(ResultParams.RESULT_END_DATE, Message.SQLDateFormatter.format(finalEnd.getTime())); 248 296 setResult(ACTIVITYRESULT_DATERANGE, ret); 249 297 finish(); -
trunk/rapidandroid/org.rapidandroid/src/org/rapidandroid/activity/FormReviewer.java
r94 r97 33 33 import org.rapidandroid.data.RapidSmsDBConstants; 34 34 import org.rapidandroid.data.controller.ParsedDataReporter; 35 import org.rapidsms.java.core.Constants; 35 36 import org.rapidsms.java.core.model.Field; 36 37 import org.rapidsms.java.core.model.Form; … … 43 44 import android.app.AlertDialog; 44 45 import android.app.Dialog; 46 import android.app.AlertDialog.Builder; 45 47 import android.content.ContentValues; 46 48 import android.content.Context; … … 186 188 return true; 187 189 case MENU_DUMP_CSV: 190 if(ParsedDataReporter.getOldestMessageDate(this, mForm).equals(Constants.NULLDATE)) { 191 Builder noDateDialog = new AlertDialog.Builder(this); 192 noDateDialog.setPositiveButton("Ok", null); 193 noDateDialog.setTitle("Alert"); 194 noDateDialog.setMessage("This form has no messages or data to output"); 195 noDateDialog.show(); 196 return true; 197 } 198 188 199 outputCSV(); 189 200 break; … … 321 332 Thread t = new Thread() { 322 333 public void run() { 323 ParsedDataReporter pdr = new ParsedDataReporter(324 getBaseContext());325 334 Calendar now = Calendar.getInstance(); 326 Calendar then = Calendar.getInstance(); 335 Calendar then = Calendar.getInstance(); 327 336 then.set(Calendar.YEAR, 1990); 328 329 pdr.exportFormDataToCSV(mForm, then, now); 337 ParsedDataReporter.exportFormDataToCSV(getBaseContext(), mForm, then, now); 330 338 mDebugHandler.post(mCsvSaveCompleted); 339 331 340 } 332 341 }; -
trunk/rapidandroid/org.rapidandroid/src/org/rapidandroid/activity/chart/form/FormDataBroker.java
r94 r97 105 105 106 106 if(mStartDate.compareTo(Constants.NULLDATE) != 0 && mEndDate.compareTo(Constants.NULLDATE) != 0) { 107 rawQuery.append(" WHERE rapidandroid_message.time > '" + Message.SQLDateFormatter.format(m EndDate) + "' AND rapidandroid_message.time < '" + Message.SQLDateFormatter.format(mStartDate) + "' ");107 rawQuery.append(" WHERE rapidandroid_message.time > '" + Message.SQLDateFormatter.format(mStartDate) + "' AND rapidandroid_message.time < '" + Message.SQLDateFormatter.format(mEndDate) + "' "); 108 108 } 109 109 … … 194 194 195 195 if(mStartDate.compareTo(Constants.NULLDATE) != 0 && mEndDate.compareTo(Constants.NULLDATE) != 0) { 196 rawQuery.append(" WHERE rapidandroid_message.time > '" + Message.SQLDateFormatter.format(m EndDate) + "' AND rapidandroid_message.time < '" + Message.SQLDateFormatter.format(mStartDate) + "' ");196 rawQuery.append(" WHERE rapidandroid_message.time > '" + Message.SQLDateFormatter.format(mStartDate) + "' AND rapidandroid_message.time < '" + Message.SQLDateFormatter.format(mEndDate) + "' "); 197 197 } 198 198 -
trunk/rapidandroid/org.rapidandroid/src/org/rapidandroid/activity/chart/message/MessageDataBroker.java
r94 r97 91 91 92 92 if(mStartDate.compareTo(Constants.NULLDATE) != 0 && mEndDate.compareTo(Constants.NULLDATE) != 0) { 93 rawQuery.append(" WHERE time > '" + Message.SQLDateFormatter.format(m EndDate) + "' AND time < '" + Message.SQLDateFormatter.format(mStartDate) + "' ");93 rawQuery.append(" WHERE time > '" + Message.SQLDateFormatter.format(mStartDate) + "' AND time < '" + Message.SQLDateFormatter.format(mEndDate) + "' "); 94 94 } 95 95 -
trunk/rapidandroid/org.rapidandroid/src/org/rapidandroid/data/controller/ParsedDataReporter.java
r94 r97 16 16 import org.rapidandroid.data.RapidSmsDBConstants; 17 17 import org.rapidandroid.data.SmsDbHelper; 18 import org.rapidsms.java.core.Constants; 18 19 import org.rapidsms.java.core.model.Form; 19 20 import org.rapidsms.java.core.model.Message; … … 33 34 public class ParsedDataReporter { 34 35 35 SmsDbHelper mHelper;36 Context mContext;37 38 36 private String[] messageColumns = new String[] {"message_time", "monitor_id", "monitor_phone", "message_text"}; 39 37 40 public Date getOldestMessage(Form f) { 38 public synchronized static Date getOldestMessageDate(Context context, Form f) { 39 SmsDbHelper mHelper = new SmsDbHelper(context); 41 40 StringBuilder query = new StringBuilder(); 42 41 query.append("select min(rapidandroid_message.time) "); … … 48 47 49 48 Cursor cr = mHelper.getReadableDatabase().rawQuery(query.toString(), null); 49 if(cr.getCount() == 0) { 50 mHelper.close(); 51 cr.close(); 52 return Constants.NULLDATE; 53 54 } 50 55 cr.moveToFirst(); 51 56 String dateString = cr.getString(0); 57 58 if(dateString == null) { 59 mHelper.close(); 60 cr.close(); 61 return Constants.NULLDATE; 62 } 63 52 64 Date ret = new Date(); 53 65 try { … … 58 70 } 59 71 cr.close(); 72 mHelper.close(); 60 73 return ret; 61 74 } 62 75 63 public ParsedDataReporter(Context context) { 64 mHelper = new SmsDbHelper(context); 65 mContext = context; 66 } 67 68 public void done() { 69 mHelper.close(); 70 } 71 public void exportFormDataToCSV(Form f, Calendar startDate, Calendar endDate) { 72 76 public synchronized static void exportFormDataToCSV(Context context, Form f, Calendar startDate, Calendar endDate) { 77 SmsDbHelper mHelper = new SmsDbHelper(context); 73 78 //build the query 74 79 StringBuilder query = new StringBuilder(); … … 133 138 finally { 134 139 cr.close(); 140 mHelper.close(); 135 141 if(fOut != null) { 136 142 try { -
trunk/rapidandroid/org.rapidandroid/src/org/rapidandroid/view/SingleGridRowView.java
r90 r97 3 3 import java.util.Vector; 4 4 5 import android.R; 5 6 6 import android.content.Context; 7 7 import android.database.Cursor; 8 import android.graphics.Color; 9 import android.text.TextUtils.TruncateAt; 8 10 import android.view.Gravity; 11 import android.view.ViewGroup; 12 import android.widget.LinearLayout; 9 13 import android.widget.TableLayout; 10 14 import android.widget.TableRow; … … 16 20 * Summary: 17 21 */ 18 public class Single RowView extends TableLayout {22 public class SingleGridRowView extends TableLayout { 19 23 20 24 private int mColCount; 21 25 22 26 TableRow mRow; 23 TextView mMessageIDCol;24 TextView mMonitorCol;27 //TextView mMessageIDCol; 28 //TextView mMonitorCol; 25 29 Vector<TextView> mDataCols; 26 30 boolean isOdd = false; 31 private int mColWidth; 27 32 28 33 /** 29 34 * @param context 30 35 */ 31 public Single RowView(Context context, Cursor c) {36 public SingleGridRowView(Context context, Cursor c, int colwidth) { 32 37 super(context); 33 int itemCounter = 0;38 mColWidth = colwidth; 34 39 35 context.setTheme(R.style.Theme_Translucent); 36 mColCount = c.getColumnCount(); 40 mColCount = c.getColumnCount()-2; 37 41 38 42 mRow = new TableRow(context); 39 mRow.setGravity(Gravity.LEFT); 43 40 44 isOdd = (c.getPosition() % 2) == 1 ; 41 45 if(isOdd) { 42 mRow.setBackgroundColor( android.R.color.background_light);46 mRow.setBackgroundColor(org.rapidandroid.R.color.background_gray); 43 47 } else { 44 mRow.setBackgroundColor(android.R.color.background_dark);48 //mRow.setBackgroundColor(android.R.color.background_dark); 45 49 } 46 mMessageIDCol = new TextView(context);50 //mMessageIDCol = new TextView(context); 47 51 //mMessageIDCol.setGravity(Gravity.LEFT); 48 52 //mMessageIDCol.setWidth(getWidth()/mColCount); 49 53 //mMessageIDCol.setPadding(3, 3, 3, 3); 50 mRow.addView(mMessageIDCol, itemCounter++);54 //mRow.addView(mMessageIDCol, itemCounter++); 51 55 52 mMonitorCol = new TextView(context);56 //mMonitorCol = new TextView(context); 53 57 //mMonitorCol.setGravity(Gravity.LEFT); 54 58 //mMonitorCol.setPadding(3, 3, 3, 3); 55 59 56 60 //mMonitorCol.setWidth(getWidth()/mColCount); 57 mRow.addView(mMonitorCol, itemCounter++);61 //mRow.addView(mMonitorCol, itemCounter++); 58 62 59 63 mDataCols = new Vector<TextView>(); 60 64 61 for(int i = 0; i < mColCount -2; i++) {65 for(int i = 0; i < mColCount; i++) { 62 66 TextView coldata = new TextView(getContext()); 63 //coldata.setPadding(3, 3, 3, 3); 64 //coldata.setWidth(getWidth()/mColCount); 65 //coldata.setGravity(Gravity.LEFT); 66 //coldata.setText("null"); 67 coldata.setSingleLine(); //no wrapping bab! 68 coldata.setEllipsize(TruncateAt.END); //makeit ellipsize instead of spillage!!! 69 coldata.setWidth(mColWidth); 70 coldata.setBackgroundColor(Color.TRANSPARENT); 71 72 coldata.setPadding(0, 4, 0, 4); 73 67 74 mDataCols.add(coldata); 68 mRow.addView(coldata, i temCounter++);75 mRow.addView(coldata, i); 69 76 } 70 77 71 //mRow.setWeightSum(itemCounter); 72 addView(mRow); 73 74 for(int i = 0; i < mColCount; i++) { 75 this.setColumnCollapsed(i, false); 76 this.setColumnShrinkable(i, false); 77 this.setColumnStretchable(i, false); 78 } 79 78 //mRow.setWeightSum(mColCount); 79 addView(mRow); 80 80 setData(c); 81 81 } 82 82 83 public void setData(Cursor c) { 84 mMessageIDCol.setText(c.getString(0) + " | "); 85 mMonitorCol.setText(c.getString(1) + " | "); 86 87 String suffix = " | "; 88 for(int i = 0; i < mColCount - 2; i++) { 89 if(i == mColCount - 3) { 90 suffix = ""; 91 } 83 public void setData(Cursor c) { 84 85 for(int i = 0; i < mColCount; i++) { 92 86 TextView coldata = mDataCols.get(i); 93 if(c.getString(i+2) == "") {94 coldata.setText("(null)" + suffix);87 if(c.getString(i+2).equals("")) { 88 coldata.setText("(null)"); 95 89 } else { 96 coldata.setText(c.getString(i+2) + suffix);90 coldata.setText(c.getString(i+2)); 97 91 } 98 92 } -
trunk/rapidandroid/org.rapidandroid/src/org/rapidandroid/view/SingleRowHeaderView.java
r74 r97 14 14 * @author Daniel Myung [email protected] 15 15 * @created Jan 27, 2009 16 * Summary:16 * @deprecated 17 17 */ 18 18 public class SingleRowHeaderView extends TableLayout { -
trunk/rapidandroid/org.rapidandroid/src/org/rapidandroid/view/SummaryCursorView.java
r96 r97 92 92 93 93 TextView txvFieldData = new TextView(getContext()); 94 txvFieldData.setGravity(Gravity. RIGHT);94 txvFieldData.setGravity(Gravity.LEFT); 95 95 txvFieldData.setTextSize(14); 96 96 mFieldValues[i] = txvFieldData; … … 102 102 103 103 this.addView(row, new TableRow.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); 104 104 105 } 105 106 107 this.setColumnStretchable(0, true); 108 this.setColumnStretchable(1, true); 106 109 //this.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); 107 110 setMessageTop(formDataCursor); -
trunk/rapidandroid/org.rapidandroid/src/org/rapidandroid/view/adapter/FormDataGridCursorAdapter.java
r74 r97 2 2 3 3 4 import org.rapidandroid.view.Single RowView;4 import org.rapidandroid.view.SingleGridRowView; 5 5 import org.rapidsms.java.core.model.Form; 6 6 … … 17 17 * Summary: 18 18 */ 19 public class FormData CursorAdapter extends CursorAdapter {19 public class FormDataGridCursorAdapter extends CursorAdapter { 20 20 21 21 Form mForm; 22 22 Context mContext; 23 int mWidth; 24 int mColWidth; 23 25 24 26 /** … … 26 28 * @param c 27 29 */ 28 public FormData CursorAdapter(Context context, Form form, Cursor c) {30 public FormDataGridCursorAdapter(Context context, Form form, Cursor c, int screenWidth) { 29 31 super(context, c); 30 32 mForm = form; 31 33 mContext = context; 34 mWidth = screenWidth; 35 mColWidth = screenWidth/(c.getColumnCount()-2); 32 36 33 37 } … … 39 43 public void bindView(View view, Context context, Cursor cursor) { 40 44 if(view != null) { 41 Single RowView srv = (SingleRowView)view;45 SingleGridRowView srv = (SingleGridRowView)view; 42 46 srv.setData(cursor); 43 47 } … … 50 54 @Override 51 55 public View newView(Context context, Cursor cursor, ViewGroup parent) { 52 Single RowView srv = new SingleRowView(context, cursor);56 SingleGridRowView srv = new SingleGridRowView(context, cursor, mColWidth); 53 57 return srv; 54 58 }