Browse Source

Created a boolean property to easily enable/disable the app update feature at all via a bools.xml setting. Helpful for #60.

pull/90/head
Eric Kok 11 years ago
parent
commit
ed2b605b7f
  1. 2
      core/res/values/bools.xml
  2. 11
      core/src/org/transdroid/core/app/settings/SystemSettings.java
  3. 9
      core/src/org/transdroid/core/gui/navigation/NavigationHelper.java
  4. 5
      core/src/org/transdroid/core/gui/settings/SystemSettingsActivity.java
  5. 11
      core/src/org/transdroid/core/service/AppUpdateService.java
  6. 10
      core/src/org/transdroid/core/service/BootReceiver.java
  7. 2
      full/res/values/bools.xml
  8. 2
      lite/res/values/bools.xml

2
core/res/values/bools.xml

@ -21,6 +21,8 @@ @@ -21,6 +21,8 @@
<bool name="show_dialog_fullscreen">true</bool>
<!-- Used to enable the scrolling widget on Honeycomb (API 11) and higher only -->
<bool name="widget_available">false</bool>
<!-- Used to enable checking for app updates in the background -->
<bool name="updatecheck_available">true</bool>
<!-- Used to enable the search UI -->
<bool name="search_available">true</bool>
<!-- Used to enable the RSS UI and background service -->

11
core/src/org/transdroid/core/app/settings/SystemSettings.java

@ -70,14 +70,5 @@ public class SystemSettings { @@ -70,14 +70,5 @@ public class SystemSettings {
public void setLastCheckedForAppUpdates(Date lastChecked) {
prefs.edit().putLong("system_lastappupdatecheck", lastChecked == null ? -1L : lastChecked.getTime()).commit();
}
/**
* Whether the custom app update checker should be used to check for new app and search module versions.
* @return True if it should be checked against transdroid.org if there are app updates (as opposed to using the
* Play Store for updates), false otherwise
*/
public static boolean enableUpdateChecker(Context context) {
return !context.getPackageName().equals("org.transdroid.lite");
}
}

9
core/src/org/transdroid/core/gui/navigation/NavigationHelper.java

@ -162,6 +162,15 @@ public class NavigationHelper { @@ -162,6 +162,15 @@ public class NavigationHelper {
return context.getResources().getBoolean(R.bool.seedboxes_available);
}
/**
* Whether the custom app update checker should be used to check for new app and search module versions.
* @return True if it should be checked against transdroid.org if there are app updates (as opposed to using the
* Play Store for updates, for example), false otherwise
*/
public boolean enableUpdateChecker() {
return context.getResources().getBoolean(R.bool.updatecheck_available);
}
/**
* Converts a string into a {@link Spannable} that displays the string in the Roboto Condensed font
* @param string A plain text {@link String}

5
core/src/org/transdroid/core/gui/settings/SystemSettingsActivity.java

@ -26,7 +26,6 @@ import org.json.JSONException; @@ -26,7 +26,6 @@ import org.json.JSONException;
import org.transdroid.core.R;
import org.transdroid.core.app.settings.ApplicationSettings;
import org.transdroid.core.app.settings.SettingsPersistence;
import org.transdroid.core.app.settings.SystemSettings;
import org.transdroid.core.gui.log.ErrorLogSender;
import org.transdroid.core.gui.navigation.DialogHelper;
import org.transdroid.core.gui.navigation.NavigationHelper;
@ -61,6 +60,8 @@ public class SystemSettingsActivity extends SherlockPreferenceActivity { @@ -61,6 +60,8 @@ public class SystemSettingsActivity extends SherlockPreferenceActivity {
protected static final int DIALOG_EXPORTSETTINGS = 3;
protected static final String INSTALLHELP_URI = "http://www.transdroid.org/download/";
@Bean
protected NavigationHelper navigationHelper;
@Bean
protected ApplicationSettings applicationSettings;
@Bean
@ -79,7 +80,7 @@ public class SystemSettingsActivity extends SherlockPreferenceActivity { @@ -79,7 +80,7 @@ public class SystemSettingsActivity extends SherlockPreferenceActivity {
addPreferencesFromResource(R.xml.pref_system);
// Handle outgoing links and preference changes
if (SystemSettings.enableUpdateChecker(this)) {
if (navigationHelper.enableUpdateChecker()) {
findPreference("system_checkupdates").setOnPreferenceClickListener(onCheckUpdatesClick);
} else {
getPreferenceScreen().removePreference(findPreference("system_checkupdates"));

11
core/src/org/transdroid/core/service/AppUpdateService.java

@ -34,6 +34,7 @@ import org.transdroid.core.R; @@ -34,6 +34,7 @@ import org.transdroid.core.R;
import org.transdroid.core.app.settings.NotificationSettings;
import org.transdroid.core.app.settings.SystemSettings;
import org.transdroid.core.gui.log.Log;
import org.transdroid.core.gui.navigation.NavigationHelper;
import org.transdroid.daemon.util.HttpHelper;
import android.app.IntentService;
@ -54,6 +55,8 @@ public class AppUpdateService extends IntentService { @@ -54,6 +55,8 @@ public class AppUpdateService extends IntentService {
private static final String DOWNLOAD_URL_APP = "http://www.transdroid.org/latest";
private static final String DOWNLOAD_URL_SEARCH = "http://www.transdroid.org/latest-search";
@Bean
protected NavigationHelper navigationHelper;
@Bean
protected ConnectivityHelper connectivityHelper;
@Bean
@ -70,9 +73,13 @@ public class AppUpdateService extends IntentService { @@ -70,9 +73,13 @@ public class AppUpdateService extends IntentService {
@Override
protected void onHandleIntent(Intent intent) {
// Only run this service if app updates are handled via transdroid.org at all
if (!navigationHelper.enableUpdateChecker())
return;
if (!connectivityHelper.shouldPerformBackgroundActions() || !systemSettings.checkForUpdates()) {
Log.d(this,
"Skip the app update service, as background data is disabled, the service is disabled or we are not connected.");
Log.d(this, "Skip the app update service, as background data is disabled, the service is explicitly " +
"disabled or we are not connected.");
return;
}

10
core/src/org/transdroid/core/service/BootReceiver.java

@ -21,6 +21,7 @@ import org.transdroid.core.app.settings.NotificationSettings_; @@ -21,6 +21,7 @@ import org.transdroid.core.app.settings.NotificationSettings_;
import org.transdroid.core.app.settings.SystemSettings;
import org.transdroid.core.app.settings.SystemSettings_;
import org.transdroid.core.gui.log.Log;
import org.transdroid.core.gui.navigation.NavigationHelper_;
import android.app.AlarmManager;
import android.app.PendingIntent;
@ -50,10 +51,10 @@ public class BootReceiver extends BroadcastReceiver { @@ -50,10 +51,10 @@ public class BootReceiver extends BroadcastReceiver {
public static void startBackgroundServices(Context context, boolean forceReload) {
NotificationSettings notificationSettings = NotificationSettings_.getInstance_(context);
AlarmManager alarms = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// Start the alarms if one of the notifications are enabled and we do not yet have the alarms running
// Start the alarms if one of the notifications are enabled and we do not yet have the alarms running
// (or should reload it forcefully)
if ((notificationSettings.isEnabledForRss() || notificationSettings.isEnabledForTorrents()) &&
(forceReload || (piServerChecker == null && piRssChecker == null))) {
if ((notificationSettings.isEnabledForRss() || notificationSettings.isEnabledForTorrents())
&& (forceReload || (piServerChecker == null && piRssChecker == null))) {
Log.d(context, "Boot signal received, starting server and rss checker background services");
// Schedule repeating alarms, with the first being (somewhat) in 1 second from now
@ -72,7 +73,8 @@ public class BootReceiver extends BroadcastReceiver { @@ -72,7 +73,8 @@ public class BootReceiver extends BroadcastReceiver {
public static void startAppUpdatesService(Context context) {
SystemSettings systemSettings = SystemSettings_.getInstance_(context);
AlarmManager alarms = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
if (SystemSettings.enableUpdateChecker(context) && systemSettings.checkForUpdates() && piAppUpdates == null) {
if (NavigationHelper_.getInstance_(context).enableUpdateChecker() && systemSettings.checkForUpdates()
&& piAppUpdates == null) {
Log.d(context, "Boot signal received, starting app update checker service");
// Schedule a daily, with the first being (somewhat) in 1 second from now

2
full/res/values/bools.xml

@ -17,6 +17,8 @@ @@ -17,6 +17,8 @@
-->
<resources>
<!-- Used to enable checking for app updates in the background -->
<bool name="updatecheck_available">true</bool>
<!-- Used to enable the search UI -->
<bool name="search_available">true</bool>
<!-- Used to enable the RSS UI and background service -->

2
lite/res/values/bools.xml

@ -17,6 +17,8 @@ @@ -17,6 +17,8 @@
-->
<resources>
<!-- Used to enable checking for app updates in the background -->
<bool name="updatecheck_available">false</bool>
<!-- Used to enable the search UI -->
<bool name="search_available">false</bool>
<!-- Used to enable the RSS UI and background service -->

Loading…
Cancel
Save