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:
parent
2911111490
commit
d29e7b2c58
@ -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>
|
||||
|
@ -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>
|
@ -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", "");
|
||||
|
24
src/org/envaya/kalsms/BootReceiver.java
Executable file
24
src/org/envaya/kalsms/BootReceiver.java
Executable 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user