diff --git a/res/xml/prefs.xml b/res/xml/prefs.xml index 449faf9..2022e3a 100644 --- a/res/xml/prefs.xml +++ b/res/xml/prefs.xml @@ -2,8 +2,25 @@ - - - - + + + + + + \ No newline at end of file diff --git a/src/kalsms/niryariv/itp/Main.java b/src/kalsms/niryariv/itp/Main.java index 1c9f5d3..1409a95 100644 --- a/src/kalsms/niryariv/itp/Main.java +++ b/src/kalsms/niryariv/itp/Main.java @@ -17,7 +17,7 @@ public class Main extends Activity { public String identifier = ""; public String targetUrl = ""; - + public Boolean polling = false; public void onResume() { Log.d("KALSMS", "RESUME"); @@ -27,11 +27,14 @@ public class Main extends Activity { this.identifier = settings.getString("pref_identifier", ""); this.targetUrl = settings.getString("pref_target_url", ""); - + this.polling = settings.getBoolean("pref_poll_switch", false); + Log.d("KALSMS", "onResume ident:" + this.identifier +"\ntarget:" + this.targetUrl); String infoText = new String(); + // Home Screen text + infoText = "All SMS messages"; if (this.identifier.trim() != "") { @@ -40,11 +43,16 @@ public class Main extends Activity { infoText += " are now sent to " + this.targetUrl +" in the following format:"; infoText += "

GET " + this.targetUrl + "?sender=<phone#>&msg=<message>

"; - infoText += "If the response body contains text, it will SMSed back to the sender."; + infoText += "If the response body contains text, it will SMS back to the originating phone."; + if (this.polling) { + infoText += "

The target URL will be polled every 15 minutes

"; + } + infoText += "

Press Menu to set SMS identifier or target URL."; infoText += "


Questions/feedback: niryariv@gmail.com"; + // /Home Screen text TextView info = (TextView) this.findViewById(R.id.info); info.setText(Html.fromHtml(infoText)); diff --git a/src/kalsms/niryariv/itp/Prefs.java b/src/kalsms/niryariv/itp/Prefs.java index ab02076..16fa71b 100755 --- a/src/kalsms/niryariv/itp/Prefs.java +++ b/src/kalsms/niryariv/itp/Prefs.java @@ -13,7 +13,6 @@ import android.preference.CheckBoxPreference; import android.preference.EditTextPreference; import android.preference.Preference; import android.preference.PreferenceActivity; -import android.preference.PreferenceManager; import android.util.Log; import android.view.Menu; @@ -54,11 +53,9 @@ public class Prefs extends PreferenceActivity implements OnSharedPreferenceChang Intent pintent = new Intent(this, SMSSender.class); PendingIntent pIntent = PendingIntent.getBroadcast(this,0,pintent, 0); if(checkbox.isChecked()) { - long interval = 60*Integer.valueOf(PreferenceManager.getDefaultSharedPreferences(this).getString("pref_poll_interval", "5000"));//5mins;//5mins - long firstPoll = SystemClock.elapsedRealtime() + 60*Integer.valueOf(PreferenceManager.getDefaultSharedPreferences(this).getString("pref_poll_interval", "5000")); - alarm.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstPoll, interval, pIntent); - Log.d("KALSMS", "alarm manager turned on "+interval); - }else { + alarm.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), AlarmManager.INTERVAL_FIFTEEN_MINUTES, pIntent); + Log.d("KALSMS", "alarm manager turned on"); + } else { alarm.cancel(pIntent); Log.d("SMS_GATEWAY", "alarm manager turned off"); }