5
0
mirror of https://github.com/cwinfo/envayasms.git synced 2024-11-09 10:20:25 +00:00

start alarm to poll for outgoing messages when phone boots; add option to automatically start main activity on boot

This commit is contained in:
Jesse Young 2011-09-12 22:52:45 -07:00
parent 2911111490
commit d29e7b2c58
9 changed files with 45 additions and 12 deletions

View File

@ -9,6 +9,7 @@
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
@ -34,6 +35,12 @@
<receiver android:name=".OutgoingMessagePoller">
</receiver>
<receiver android:name=".BootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<activity android:name=".Prefs"
android:label="@string/app_name">
</activity>

View File

@ -27,11 +27,8 @@
android:entryValues="@array/check_intervals_values"
></ListPreference>
<!--
<CheckBoxPreference
android:key="detailed_log"
android:title="Detailed log messages?"
android:disableDependentsState="false"
android:key="launch_on_boot"
android:title="Launch automatically?"
></CheckBoxPreference>
-->
</PreferenceScreen>

View File

@ -236,6 +236,11 @@ public class App {
return Integer.parseInt(settings.getString("outgoing_interval", "0"));
}
public boolean getLaunchOnBoot()
{
return settings.getBoolean("launch_on_boot", true);
}
public String getPassword()
{
return settings.getString("password", "");

View File

@ -0,0 +1,24 @@
package org.envaya.kalsms;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class BootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent)
{
App app = App.getInstance(context.getApplicationContext());
app.setOutgoingMessageAlarm();
if (app.getLaunchOnBoot())
{
Intent i = new Intent(context, Main.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
}

View File

@ -17,7 +17,7 @@ public class IncomingMessageForwarder extends BroadcastReceiver {
// source: http://www.devx.com/wireless/Article/39495/1954
public void onReceive(Context context, Intent intent) {
try {
this.app = App.getInstance(context);
this.app = App.getInstance(context.getApplicationContext());
String action = intent.getAction();

View File

@ -98,7 +98,7 @@ public class Main extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.app = App.getInstance(this.getApplication());
this.app = App.getInstance(getApplicationContext());
setContentView(R.layout.main);
PreferenceManager.setDefaultValues(this, R.xml.prefs, false);
@ -161,7 +161,7 @@ public class Main extends Activity {
MenuItem item = menu.findItem(R.id.retry_now);
int stuckMessages = app.getStuckMessageCount();
item.setEnabled(stuckMessages > 0);
item.setTitle("Retry Now (" + stuckMessages + ")");
item.setTitle("Retry Fwd (" + stuckMessages + ")");
return true;
}

View File

@ -13,7 +13,7 @@ public class MessageStatusNotifier extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
App app = App.getInstance(context);
App app = App.getInstance(context.getApplicationContext());
String id = intent.getExtras().getString("id");

View File

@ -10,7 +10,7 @@ public class OutgoingMessagePoller extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
app = App.getInstance(context);
app = App.getInstance(context.getApplicationContext());
app.checkOutgoingMessages();
app.retryStuckMessages(false);
}

View File

@ -43,7 +43,7 @@ public class Prefs extends PreferenceActivity implements OnSharedPreferenceChang
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
App app = App.getInstance(this.getApplication());
App app = App.getInstance(this.getApplicationContext());
if (key.equals("outgoing_interval"))
{
app.setOutgoingMessageAlarm();