mirror of
https://github.com/cwinfo/envayasms.git
synced 2024-11-12 19:30:26 +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.READ_SMS" />
|
||||||
<uses-permission android:name="android.permission.WRITE_SMS" />
|
<uses-permission android:name="android.permission.WRITE_SMS" />
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
||||||
<application android:icon="@drawable/icon" android:label="@string/app_name">
|
<application android:icon="@drawable/icon" android:label="@string/app_name">
|
||||||
@ -34,6 +35,12 @@
|
|||||||
<receiver android:name=".OutgoingMessagePoller">
|
<receiver android:name=".OutgoingMessagePoller">
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
|
<receiver android:name=".BootReceiver">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
|
|
||||||
<activity android:name=".Prefs"
|
<activity android:name=".Prefs"
|
||||||
android:label="@string/app_name">
|
android:label="@string/app_name">
|
||||||
</activity>
|
</activity>
|
||||||
|
@ -27,11 +27,8 @@
|
|||||||
android:entryValues="@array/check_intervals_values"
|
android:entryValues="@array/check_intervals_values"
|
||||||
></ListPreference>
|
></ListPreference>
|
||||||
|
|
||||||
<!--
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="detailed_log"
|
android:key="launch_on_boot"
|
||||||
android:title="Detailed log messages?"
|
android:title="Launch automatically?"
|
||||||
android:disableDependentsState="false"
|
|
||||||
></CheckBoxPreference>
|
></CheckBoxPreference>
|
||||||
-->
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
@ -236,6 +236,11 @@ public class App {
|
|||||||
return Integer.parseInt(settings.getString("outgoing_interval", "0"));
|
return Integer.parseInt(settings.getString("outgoing_interval", "0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getLaunchOnBoot()
|
||||||
|
{
|
||||||
|
return settings.getBoolean("launch_on_boot", true);
|
||||||
|
}
|
||||||
|
|
||||||
public String getPassword()
|
public String getPassword()
|
||||||
{
|
{
|
||||||
return settings.getString("password", "");
|
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
|
// source: http://www.devx.com/wireless/Article/39495/1954
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
try {
|
try {
|
||||||
this.app = App.getInstance(context);
|
this.app = App.getInstance(context.getApplicationContext());
|
||||||
|
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ public class Main extends Activity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
this.app = App.getInstance(this.getApplication());
|
this.app = App.getInstance(getApplicationContext());
|
||||||
|
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
PreferenceManager.setDefaultValues(this, R.xml.prefs, false);
|
PreferenceManager.setDefaultValues(this, R.xml.prefs, false);
|
||||||
@ -161,7 +161,7 @@ public class Main extends Activity {
|
|||||||
MenuItem item = menu.findItem(R.id.retry_now);
|
MenuItem item = menu.findItem(R.id.retry_now);
|
||||||
int stuckMessages = app.getStuckMessageCount();
|
int stuckMessages = app.getStuckMessageCount();
|
||||||
item.setEnabled(stuckMessages > 0);
|
item.setEnabled(stuckMessages > 0);
|
||||||
item.setTitle("Retry Now (" + stuckMessages + ")");
|
item.setTitle("Retry Fwd (" + stuckMessages + ")");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ public class MessageStatusNotifier extends BroadcastReceiver {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
App app = App.getInstance(context);
|
App app = App.getInstance(context.getApplicationContext());
|
||||||
|
|
||||||
String id = intent.getExtras().getString("id");
|
String id = intent.getExtras().getString("id");
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ public class OutgoingMessagePoller extends BroadcastReceiver {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
app = App.getInstance(context);
|
app = App.getInstance(context.getApplicationContext());
|
||||||
app.checkOutgoingMessages();
|
app.checkOutgoingMessages();
|
||||||
app.retryStuckMessages(false);
|
app.retryStuckMessages(false);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ public class Prefs extends PreferenceActivity implements OnSharedPreferenceChang
|
|||||||
|
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||||
|
|
||||||
App app = App.getInstance(this.getApplication());
|
App app = App.getInstance(this.getApplicationContext());
|
||||||
if (key.equals("outgoing_interval"))
|
if (key.equals("outgoing_interval"))
|
||||||
{
|
{
|
||||||
app.setOutgoingMessageAlarm();
|
app.setOutgoingMessageAlarm();
|
||||||
|
Loading…
Reference in New Issue
Block a user