mirror of
https://github.com/cwinfo/envayasms.git
synced 2025-06-28 03:39:23 +00:00
simplify polling UI to use fixed, 15 min intervals
This commit is contained in:
@ -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 <b>" + this.targetUrl +"</b> in the following format:";
|
||||
infoText += "<p><tt>GET " + this.targetUrl + "?sender=<phone#>&msg=<message></tt></p>";
|
||||
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 += "<p>The target URL will be polled every 15 minutes</p>";
|
||||
}
|
||||
|
||||
infoText += "<br /><br /><b>Press Menu to set SMS identifier or target URL.</b>";
|
||||
|
||||
infoText += "<br /><br /><br />Questions/feedback: niryariv@gmail.com";
|
||||
// /Home Screen text
|
||||
|
||||
TextView info = (TextView) this.findViewById(R.id.info);
|
||||
info.setText(Html.fromHtml(infoText));
|
||||
|
@ -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");
|
||||
}
|
||||
|
Reference in New Issue
Block a user