Browse Source

Added option to disable the update checker (in alarm settings screen).

pull/11/head
Eric Kok 12 years ago
parent
commit
b800e14bc5
  1. 5
      android/AndroidManifest.xml
  2. 2
      android/res/values/strings.xml
  3. 4
      android/src/org/transdroid/preferences/Preferences.java
  4. 18
      android/src/org/transdroid/preferences/PreferencesAlarm.java
  5. 8
      android/src/org/transdroid/service/AlarmSettings.java
  6. 6
      android/src/org/transdroid/service/BootReceiver.java
  7. 8
      android/src/org/transdroid/service/UpdateService.java

5
android/AndroidManifest.xml

@ -23,7 +23,8 @@
android:installLocation="auto"> android:installLocation="auto">
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="13" /> <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="13" />
<supports-screens smallScreens="true" normalScreens="true" largeScreens="true" xlargeScreens="true" android:anyDensity="true" /> <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true"
android:xlargeScreens="true" android:anyDensity="true" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.VIBRATE" />
@ -63,7 +64,7 @@
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="application/x-bittorrent" /> <data android:mimeType="application/x-bittorrent" />
<data scheme="file" android:mimeType="application/x-bittorrent" /> <data android:scheme="file" android:mimeType="application/x-bittorrent" />
</intent-filter> </intent-filter>
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />

2
android/res/values/strings.xml

@ -233,6 +233,8 @@
<string name="pref_adwnotify_info">Show torrent counter in ADW Launcher</string> <string name="pref_adwnotify_info">Show torrent counter in ADW Launcher</string>
<string name="pref_adwonlydl">Count only downloads</string> <string name="pref_adwonlydl">Count only downloads</string>
<string name="pref_adwonlydl_info">ADW counter only includes downloading torrents</string> <string name="pref_adwonlydl_info">ADW counter only includes downloading torrents</string>
<string name="pref_checkforupdates">Check for updates</string>
<string name="pref_checkforupdates_info">Check transdroid.org for latest app version</string>
<string name="status_waiting">Waiting to check...</string> <string name="status_waiting">Waiting to check...</string>
<string name="status_checking">Verifying local data...</string> <string name="status_checking">Verifying local data...</string>

4
android/src/org/transdroid/preferences/Preferences.java

@ -141,6 +141,7 @@ public class Preferences {
public static final String KEY_PREF_ALARMCOLOUR = "transdroid_alarm_colour"; public static final String KEY_PREF_ALARMCOLOUR = "transdroid_alarm_colour";
public static final String KEY_PREF_ADWNOTIFY = "transdroid_alarm_adwnotify"; public static final String KEY_PREF_ADWNOTIFY = "transdroid_alarm_adwnotify";
public static final String KEY_PREF_ADWONLYDL = "transdroid_alarm_adwonlydl"; public static final String KEY_PREF_ADWONLYDL = "transdroid_alarm_adwonlydl";
public static final String KEY_PREF_CHECKUPDATES = "transdroid_alarm_checkupdates";
public static final String KEY_WIDGET_DAEMON = "transdroid_widget_daemon"; public static final String KEY_WIDGET_DAEMON = "transdroid_widget_daemon";
public static final String KEY_WIDGET_REFRESH = "transdroid_widget_refresh"; public static final String KEY_WIDGET_REFRESH = "transdroid_widget_refresh";
@ -1030,7 +1031,8 @@ public class Preferences {
prefs.getBoolean(KEY_PREF_ALARMVIBRATE, false), prefs.getBoolean(KEY_PREF_ALARMVIBRATE, false),
prefs.getInt(KEY_PREF_ALARMCOLOUR, 0xff7dbb21), prefs.getInt(KEY_PREF_ALARMCOLOUR, 0xff7dbb21),
prefs.getBoolean(KEY_PREF_ADWNOTIFY, false), prefs.getBoolean(KEY_PREF_ADWNOTIFY, false),
prefs.getBoolean(KEY_PREF_ADWONLYDL, false)); prefs.getBoolean(KEY_PREF_ADWONLYDL, false),
prefs.getBoolean(KEY_PREF_CHECKUPDATES, true));
} }
/** /**

18
android/src/org/transdroid/preferences/PreferencesAlarm.java

@ -44,6 +44,7 @@ public class PreferencesAlarm extends PreferenceActivity {
private ColorPickerPreference alarmColour; private ColorPickerPreference alarmColour;
private TransdroidCheckBoxPreference adwNotify; private TransdroidCheckBoxPreference adwNotify;
private TransdroidCheckBoxPreference adwOnlyDl; private TransdroidCheckBoxPreference adwOnlyDl;
private TransdroidCheckBoxPreference checkForUpdates;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -128,6 +129,13 @@ public class PreferencesAlarm extends PreferenceActivity {
adwOnlyDl.setKey(Preferences.KEY_PREF_ADWONLYDL); adwOnlyDl.setKey(Preferences.KEY_PREF_ADWONLYDL);
adwOnlyDl.setEnabled(isEnabled && isAdwEnabled); adwOnlyDl.setEnabled(isEnabled && isAdwEnabled);
getPreferenceScreen().addItemFromInflater(adwOnlyDl); getPreferenceScreen().addItemFromInflater(adwOnlyDl);
// Enable
checkForUpdates = new TransdroidCheckBoxPreference(this);
checkForUpdates.setTitle(R.string.pref_checkforupdates);
checkForUpdates.setSummary(R.string.pref_checkforupdates_info);
checkForUpdates.setKey(Preferences.KEY_PREF_CHECKUPDATES);
checkForUpdates.setDefaultValue(true);
getPreferenceScreen().addItemFromInflater(checkForUpdates);
prefs.registerOnSharedPreferenceChangeListener(changesHandler); prefs.registerOnSharedPreferenceChangeListener(changesHandler);
} }
@ -149,6 +157,16 @@ public class PreferencesAlarm extends PreferenceActivity {
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key.equals(Preferences.KEY_PREF_CHECKUPDATES)) {
// Only the update checker setting changed
BootReceiver.cancelUpdateCheck();
boolean shouldCheckForUpdates = sharedPreferences.getBoolean(Preferences.KEY_PREF_CHECKUPDATES, true);
if (shouldCheckForUpdates) {
BootReceiver.startUpdateCheck(getApplicationContext());
}
return;
}
// First cancel the alarm // First cancel the alarm
BootReceiver.cancelAlarm(); BootReceiver.cancelAlarm();

8
android/src/org/transdroid/service/AlarmSettings.java

@ -34,8 +34,9 @@ public class AlarmSettings{
private int alarmColour; private int alarmColour;
private boolean adwNotify; private boolean adwNotify;
private boolean adwOnlyDl; private boolean adwOnlyDl;
private boolean checkForUpdates;
public AlarmSettings(boolean enableAlarm, int alarmInterval, boolean checkRssFeeds, boolean alarmPlaySound, String alarmSoundURI, boolean alarmVibrate, int alarmColour, boolean adwNotify, boolean adwOnlyDl) { public AlarmSettings(boolean enableAlarm, int alarmInterval, boolean checkRssFeeds, boolean alarmPlaySound, String alarmSoundURI, boolean alarmVibrate, int alarmColour, boolean adwNotify, boolean adwOnlyDl, boolean checkForUpdates) {
this.enableAlarm = enableAlarm; this.enableAlarm = enableAlarm;
this.alarmInterval = alarmInterval; this.alarmInterval = alarmInterval;
this.checkRssFeeds = checkRssFeeds; this.checkRssFeeds = checkRssFeeds;
@ -45,6 +46,7 @@ public class AlarmSettings{
this.alarmColour = alarmColour; this.alarmColour = alarmColour;
this.adwNotify = adwNotify; this.adwNotify = adwNotify;
this.adwOnlyDl = adwOnlyDl; this.adwOnlyDl = adwOnlyDl;
this.checkForUpdates = checkForUpdates;
} }
public boolean isAlarmEnabled() { public boolean isAlarmEnabled() {
@ -86,6 +88,10 @@ public class AlarmSettings{
public boolean showOnlyDownloadsInAdw() { public boolean showOnlyDownloadsInAdw() {
return adwOnlyDl; return adwOnlyDl;
} }
public boolean shouldCheckForUpdates() {
return checkForUpdates;
}
} }

6
android/src/org/transdroid/service/BootReceiver.java

@ -71,6 +71,12 @@ public class BootReceiver extends BroadcastReceiver {
} }
} }
public static void cancelUpdateCheck() {
if (mgr != null) {
mgr.cancel(pui);
}
}
public static void startUpdateCheck(Context context) { public static void startUpdateCheck(Context context) {
// Set up PendingIntent for the alarm service // Set up PendingIntent for the alarm service
if (mgr == null) if (mgr == null)

8
android/src/org/transdroid/service/UpdateService.java

@ -77,6 +77,14 @@ public class UpdateService extends IntentService {
return; return;
} }
// Check if the update service should run
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
AlarmSettings settings = Preferences.readAlarmSettings(prefs);
if (!settings.shouldCheckForUpdates()) {
TLog.d(LOG_NAME, "The user disabled the update checker service.");
return;
}
DefaultHttpClient httpclient = new DefaultHttpClient(); DefaultHttpClient httpclient = new DefaultHttpClient();
try { try {

Loading…
Cancel
Save