Changeset 136
- Timestamp:
- 02/19/09 11:03:17 (17 months ago)
- Location:
- trunk/rapidandroid/org.rapidandroid
- Files:
-
- 8 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/rapidandroid/org.rapidandroid/AndroidManifest.xml
r134 r136 1 1 <?xml version="1.0" encoding="utf-8"?> 2 2 <manifest xmlns:android="http://schemas.android.com/apk/res/android" 3 package="org.rapidandroid" android:versionName="0.5. 0" android:versionCode="97">3 package="org.rapidandroid" android:versionName="0.5.1" android:versionCode="98"> 4 4 5 5 -
trunk/rapidandroid/org.rapidandroid/res/layout/global_settings.xml
r134 r136 1 1 <?xml version="1.0" encoding="utf-8"?> 2 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="fill_parent" 4 android:layout_height="wrap_content" 5 android:scrollbars="none"> 6 2 7 <LinearLayout 3 8 android:id="@+id/widget48" … … 6 11 android:orientation="vertical" 7 12 xmlns:android="http://schemas.android.com/apk/res/android" 8 >13 android:scrollbars="vertical"> 9 14 <TextView android:id="@+id/TextView02" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/glbsettings_heading" style="?android:attr/listSeparatorTextViewStyle"> 10 </TextView> 15 </TextView><CheckBox android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/glb_chk_activeall" android:text="@string/glb_lbl_activeall"></CheckBox> 11 16 12 17 <CheckBox … … 32 37 33 38 <EditText android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/glb_etx_failed"></EditText> 39 40 41 34 42 </LinearLayout> 43 44 </ScrollView> -
trunk/rapidandroid/org.rapidandroid/res/values/strings.xml
r134 r136 53 53 <string name="glb_chk_parse_text">Reply on successful parses</string> 54 54 <string name="glbsettings_heading">Global reply settings</string> 55 <string name="glb_lbl_activeall">Activate all SMS features</string> 55 56 </resources> -
trunk/rapidandroid/org.rapidandroid/src/org/rapidandroid/ApplicationGlobals.java
r134 r136 22 22 public class ApplicationGlobals { 23 23 24 private static boolean globalsLoaded = false; 25 26 private static boolean mActive = false; 27 private static boolean mReplyParse = false; 28 private static boolean mReplyFail = false; 29 30 private static String mReplyParseText = ""; 31 private static String mReplyFailText = ""; 32 33 34 public static void initGlobals(Context context) { 35 if(!globalsLoaded) { 36 JSONObject globals = ApplicationGlobals.loadSettingsFromFile(context); 37 try { 38 39 if(globals.has(KEY_ACTIVE_ALL)) { 40 mActive = globals.getBoolean(KEY_ACTIVE_ALL); 41 42 } else { 43 mActive = false; 44 } 45 mReplyParse = globals.getBoolean(KEY_PARSE_REPLY); 46 mReplyFail = globals.getBoolean(KEY_FAILED_REPLY); 47 mReplyParseText = globals.getString(KEY_PARSE_REPLY_TEXT); 48 mReplyFailText = globals.getString(KEY_FAILED_REPLY_TEXT); 49 globalsLoaded = true; 50 } catch (JSONException e) { 51 // TODO Auto-generated catch block 52 e.printStackTrace(); 53 } 54 55 } 56 } 57 58 public static boolean doReplyOnFail() { 59 if(mActive) { 60 return mReplyFail; 61 } else { 62 return false; 63 } 64 } 65 66 public static boolean doReplyOnParse() { 67 if(mActive) { 68 return mReplyParse; 69 } else { 70 return false; 71 } 72 } 73 74 public static String getParseSuccessText() { 75 return mReplyParseText; 76 } 77 78 public static String getParseFailText() { 79 return mReplyFailText; 80 } 81 24 82 25 83 public static void checkGlobals(Context context) { … … 32 90 e.printStackTrace(); 33 91 } 34 saveGlobalSettings(context, true, "Message parsed successfully, thank you", true, "Unable to understand your message, please try again"); 35 } 36 } 92 saveGlobalSettings(context, false, false, "Message parsed successfully, thank you", false, "Unable to understand your message, please try again"); 93 94 } 95 } 96 97 /** 98 * 99 */ 100 public static final String KEY_ACTIVE_ALL = "ActivateAll"; 101 37 102 38 103 /** … … 81 146 String contents = new String(data); 82 147 readobject = new JSONObject(contents); 148 149 if(!readobject.has(KEY_ACTIVE_ALL)) { 150 //dmyung hack to keep compatability with new version 151 readobject.put(KEY_ACTIVE_ALL, false); 152 } 153 83 154 // mParseCheckbox.setChecked(readobject.getBoolean(KEY_PARSE_REPLY)); 84 155 // mParseReplyText.setText(readobject.getString(KEY_PARSE_REPLY_TEXT)); … … 114 185 * 115 186 */ 116 public static void saveGlobalSettings(Context context, boolean parseReply, String parseReplyText, boolean failedReply, String failedReplyText) {187 public static void saveGlobalSettings(Context context,boolean activateAll, boolean parseReply, String parseReplyText, boolean failedReply, String failedReplyText) { 117 188 JSONObject settingsObj = new JSONObject(); 118 189 FileOutputStream fos = null; 119 190 try { 191 settingsObj.put(KEY_ACTIVE_ALL, activateAll); 120 192 settingsObj.put(KEY_PARSE_REPLY, parseReply); 121 193 settingsObj.put(KEY_PARSE_REPLY_TEXT, parseReplyText); … … 147 219 } 148 220 } 149 SmsParseReceiver.initGlobals(context); 221 globalsLoaded = false; 222 ApplicationGlobals.initGlobals(context); 150 223 } 151 224 } -
trunk/rapidandroid/org.rapidandroid/src/org/rapidandroid/activity/FormReviewer.java
r134 r136 444 444 messageValues.put(RapidSmsDBConstants.Message.MONITOR, monitor.getID()); 445 445 446 messageValues.put(RapidSmsDBConstants.Message.TIME, Message.SQLDateFormatter.format( getRandomDate()));446 messageValues.put(RapidSmsDBConstants.Message.TIME, Message.SQLDateFormatter.format(dateval)); 447 447 messageValues.put(RapidSmsDBConstants.Message.RECEIVE_TIME, Message.SQLDateFormatter.format(dateval)); 448 448 messageValues.put(RapidSmsDBConstants.Message.IS_OUTGOING, false); -
trunk/rapidandroid/org.rapidandroid/src/org/rapidandroid/activity/GlobalSettings.java
r135 r136 43 43 private static final int MENU_DONE = Menu.FIRST; 44 44 45 private CheckBox mActiveSwitch; 45 46 private CheckBox mParseCheckbox; 46 47 private EditText mParseReplyText; … … 52 53 53 54 public void onClick(View v) { 54 if (v.equals(mParseCheckbox)) { 55 mParseReplyText.setEnabled(mParseCheckbox.isChecked()); 56 } else if (v.equals(mNoparseCheckBox)) { 57 mNoparseReplyText.setEnabled(mNoparseCheckBox.isChecked()); 55 if(v.equals(mActiveSwitch)) { 56 mParseReplyText.setEnabled(mActiveSwitch.isChecked()); 57 mNoparseReplyText.setEnabled(mActiveSwitch.isChecked()); 58 59 mParseCheckbox.setEnabled(mActiveSwitch.isChecked()); 60 mNoparseCheckBox.setEnabled(mActiveSwitch.isChecked()); 58 61 } 62 63 if (mActiveSwitch.isChecked()) { 64 if (v.equals(mParseCheckbox)) { 65 mParseReplyText.setEnabled(mParseCheckbox.isChecked()); 66 } else if (v.equals(mNoparseCheckBox)) { 67 mNoparseReplyText.setEnabled(mNoparseCheckBox.isChecked()); 68 } 69 } 59 70 } 60 71 }; … … 73 84 setContentView(R.layout.global_settings); 74 85 86 87 mActiveSwitch = (CheckBox) findViewById(R.id.glb_chk_activeall); 88 mActiveSwitch.setOnClickListener(mCheckChangeListener); 89 75 90 mParseCheckbox = (CheckBox) findViewById(R.id.glb_chk_parse); 76 91 mParseCheckbox.setOnClickListener(mCheckChangeListener); … … 82 97 83 98 loadSettingsFromGlobals(); 99 100 mParseReplyText.setEnabled(mActiveSwitch.isChecked()); 101 mNoparseReplyText.setEnabled(mActiveSwitch.isChecked()); 102 103 mParseCheckbox.setEnabled(mActiveSwitch.isChecked()); 104 mNoparseCheckBox.setEnabled(mActiveSwitch.isChecked()); 84 105 } 85 106 … … 91 112 JSONObject globals = ApplicationGlobals.loadSettingsFromFile(this); 92 113 try { 114 mActiveSwitch.setChecked(globals.getBoolean(ApplicationGlobals.KEY_ACTIVE_ALL)); 93 115 mParseCheckbox.setChecked(globals.getBoolean(ApplicationGlobals.KEY_PARSE_REPLY)); 94 116 mParseReplyText.setText(globals.getString(ApplicationGlobals.KEY_PARSE_REPLY_TEXT)); … … 137 159 protected void onPause() { 138 160 super.onPause(); 139 ApplicationGlobals.saveGlobalSettings(this, 161 ApplicationGlobals.saveGlobalSettings(this,mActiveSwitch.isChecked(),mParseCheckbox.isChecked(), 140 162 mParseReplyText.getText().toString(), 141 163 mNoparseCheckBox.isChecked(), -
trunk/rapidandroid/org.rapidandroid/src/org/rapidandroid/receiver/SmsParseReceiver.java
r134 r136 55 55 56 56 57 private static boolean globalsLoaded = false;58 private static boolean mReplyParse = true;59 private static boolean mReplyFail = true;60 57 61 private static String mReplyParseText = "";62 private static String mReplyFailText = "";63 64 65 public static void initGlobals(Context context) {66 if(!globalsLoaded) {67 JSONObject globals = ApplicationGlobals.loadSettingsFromFile(context);68 try {69 mReplyParse = globals.getBoolean(ApplicationGlobals.KEY_PARSE_REPLY);70 mReplyFail = globals.getBoolean(ApplicationGlobals.KEY_FAILED_REPLY);71 mReplyParseText = globals.getString(ApplicationGlobals.KEY_PARSE_REPLY_TEXT);72 mReplyFailText = globals.getString(ApplicationGlobals.KEY_FAILED_REPLY_TEXT);73 globalsLoaded = true;74 } catch (JSONException e) {75 // TODO Auto-generated catch block76 e.printStackTrace();77 }78 }79 }80 58 81 59 // private Context mContext = null; … … 106 84 @Override 107 85 public void onReceive(Context context, Intent intent) { 108 initGlobals(context);86 ApplicationGlobals.initGlobals(context); 109 87 110 88 if (prefixes == null) { … … 123 101 124 102 Form form = determineForm(body); 125 if (form == null) { 126 127 128 if (mReplyFail) { 103 if (form == null) { 104 if (ApplicationGlobals.doReplyOnFail()) { 129 105 Intent broadcast = new Intent("org.rapidandroid.intents.SMS_REPLY"); 130 106 broadcast.putExtra(SmsReplyReceiver.KEY_DESTINATION_PHONE, intent.getStringExtra("from")); 131 broadcast.putExtra(SmsReplyReceiver.KEY_MESSAGE, mReplyFailText);107 broadcast.putExtra(SmsReplyReceiver.KEY_MESSAGE, ApplicationGlobals.getParseFailText()); 132 108 context.sendBroadcast(broadcast); 133 109 } … … 136 112 Monitor mon = MessageTranslator.GetMonitorAndInsertIfNew(context, intent.getStringExtra("from")); 137 113 // if(mon.getReplyPreference()) { 138 if ( mReplyParse) {114 if (ApplicationGlobals.doReplyOnParse()) { 139 115 // for debug purposes, we'll just ack every time. 140 116 Intent broadcast = new Intent("org.rapidandroid.intents.SMS_REPLY"); 141 117 broadcast.putExtra(SmsReplyReceiver.KEY_DESTINATION_PHONE, intent.getStringExtra("from")); 142 broadcast.putExtra(SmsReplyReceiver.KEY_MESSAGE, mReplyParseText);118 broadcast.putExtra(SmsReplyReceiver.KEY_MESSAGE, ApplicationGlobals.getParseSuccessText()); 143 119 context.sendBroadcast(broadcast); 144 120 } -
trunk/rapidandroid/org.rapidandroid/src/org/rapidandroid/receiver/SmsReceiver.java
r133 r136 117 117 broadcast.putExtra("body", mesg.getMessageBody()); 118 118 broadcast.putExtra("msgid", Integer.valueOf(msgUri.getPathSegments().get(1))); 119 DeleteSMSFromInbox(context, mesg);119 //DeleteSMSFromInbox(context, mesg); 120 120 context.sendBroadcast(broadcast); 121 121 }