add preference to control storing install history
For now, this is disabled by default and hidden in the expert preferences since it doesn't do anything yet inside of F-Droid. It is useful now for whitelabel builds to fetch the install history from another app. #396
This commit is contained in:
		
							parent
							
								
									0a1baa9e67
								
							
						
					
					
						commit
						58959b2e74
					
				| @ -301,8 +301,9 @@ public class FDroidApp extends Application { | ||||
| 
 | ||||
|         configureTor(Preferences.get().isTorEnabled()); | ||||
| 
 | ||||
|         // TODO enable this based on a preference | ||||
|         InstallHistoryService.register(this); | ||||
|         if (Preferences.get().isKeepingInstallHistory()) { | ||||
|             InstallHistoryService.register(this); | ||||
|         } | ||||
| 
 | ||||
|         String packageName = getString(R.string.install_history_reader_packageName); | ||||
|         String unset = getString(R.string.install_history_reader_packageName_UNSET); | ||||
|  | ||||
| @ -55,6 +55,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh | ||||
|     public static final String PREF_IGN_TOUCH = "ignoreTouchscreen"; | ||||
|     public static final String PREF_KEEP_CACHE_TIME = "keepCacheFor"; | ||||
|     public static final String PREF_UNSTABLE_UPDATES = "unstableUpdates"; | ||||
|     public static final String PREF_KEEP_INSTALL_HISTORY = "keepInstallHistory"; | ||||
|     public static final String PREF_EXPERT = "expert"; | ||||
|     public static final String PREF_PRIVILEGED_INSTALLER = "privilegedInstaller"; | ||||
|     public static final String PREF_UNINSTALL_PRIVILEGED_APP = "uninstallPrivilegedApp"; | ||||
| @ -75,6 +76,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh | ||||
|     //private static final boolean DEFAULT_LOCAL_REPO_BONJOUR = true; | ||||
|     private static final long DEFAULT_KEEP_CACHE_TIME = TimeUnit.DAYS.toMillis(1); | ||||
|     private static final boolean DEFAULT_UNSTABLE_UPDATES = false; | ||||
|     private static final boolean DEFAULT_KEEP_INSTALL_HISTORY = false; | ||||
|     //private static final boolean DEFAULT_LOCAL_REPO_HTTPS = false; | ||||
|     private static final boolean DEFAULT_INCOMP_VER = false; | ||||
|     private static final boolean DEFAULT_EXPERT = false; | ||||
| @ -184,6 +186,10 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh | ||||
|         return preferences.getBoolean(PREF_UNSTABLE_UPDATES, DEFAULT_UNSTABLE_UPDATES); | ||||
|     } | ||||
| 
 | ||||
|     public boolean isKeepingInstallHistory() { | ||||
|         return preferences.getBoolean(PREF_KEEP_INSTALL_HISTORY, DEFAULT_KEEP_INSTALL_HISTORY); | ||||
|     } | ||||
| 
 | ||||
|     public boolean showIncompatibleVersions() { | ||||
|         return preferences.getBoolean(PREF_INCOMP_VER, DEFAULT_INCOMP_VER); | ||||
|     } | ||||
|  | ||||
| @ -52,6 +52,9 @@ public class InstallHistoryService extends IntentService { | ||||
|     private static BroadcastReceiver broadcastReceiver; | ||||
| 
 | ||||
|     public static void register(Context context) { | ||||
|         if (broadcastReceiver != null) { | ||||
|             return;  // already registered | ||||
|         } | ||||
|         IntentFilter intentFilter = new IntentFilter(); | ||||
|         intentFilter.addDataScheme("http"); | ||||
|         intentFilter.addDataScheme("https"); | ||||
| @ -78,6 +81,7 @@ public class InstallHistoryService extends IntentService { | ||||
|     public static void unregister(Context context) { | ||||
|         LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context); | ||||
|         localBroadcastManager.unregisterReceiver(broadcastReceiver); | ||||
|         broadcastReceiver = null; | ||||
|     } | ||||
| 
 | ||||
|     public static void queue(Context context, Intent intent) { | ||||
|  | ||||
| @ -19,6 +19,7 @@ import org.fdroid.fdroid.FDroidApp; | ||||
| import org.fdroid.fdroid.Preferences; | ||||
| import org.fdroid.fdroid.PreferencesActivity; | ||||
| import org.fdroid.fdroid.R; | ||||
| import org.fdroid.fdroid.installer.InstallHistoryService; | ||||
| import org.fdroid.fdroid.installer.PrivilegedInstaller; | ||||
| 
 | ||||
| import info.guardianproject.netcipher.NetCipher; | ||||
| @ -193,6 +194,14 @@ public class PreferencesFragment extends PreferenceFragment | ||||
|                 } | ||||
|                 break; | ||||
| 
 | ||||
|             case Preferences.PREF_KEEP_INSTALL_HISTORY: | ||||
|                 CheckBoxPreference p = (CheckBoxPreference) findPreference(key); | ||||
|                 if (p.isChecked()) { | ||||
|                     InstallHistoryService.register(getContext()); | ||||
|                 } else { | ||||
|                     InstallHistoryService.unregister(getContext()); | ||||
|                 } | ||||
|                 break; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -14,6 +14,8 @@ | ||||
|     <string name="updates">Updates</string> | ||||
|     <string name="unstable_updates">Unstable updates</string> | ||||
|     <string name="unstable_updates_summary">Suggest updates to unstable versions</string> | ||||
|     <string name="keep_install_history">Keep install history</string> | ||||
|     <string name="keep_install_history_summary">Store a log of all installs and uninstalls inside F-Droid</string> | ||||
|     <string name="other">Other</string> | ||||
| 
 | ||||
|     <string name="update_interval">Automatic update interval</string> | ||||
|  | ||||
| @ -91,6 +91,12 @@ | ||||
|             android:summary="@string/unstable_updates_summary" | ||||
|             android:defaultValue="false" | ||||
|             android:dependency="expert" /> | ||||
|         <CheckBoxPreference | ||||
|             android:key="keepInstallHistory" | ||||
|             android:title="@string/keep_install_history" | ||||
|             android:summary="@string/keep_install_history_summary" | ||||
|             android:defaultValue="false" | ||||
|             android:dependency="expert" /> | ||||
|         <CheckBoxPreference android:title="@string/system_installer" | ||||
|             android:defaultValue="false" | ||||
|             android:key="privilegedInstaller" | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Hans-Christoph Steiner
						Hans-Christoph Steiner