parent
8ed62d22e1
commit
61d7ba9f29
@ -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.UpdateService;
|
||||
import org.fdroid.fdroid.installer.InstallHistoryService;
|
||||
import org.fdroid.fdroid.installer.PrivilegedInstaller;
|
||||
|
||||
@ -271,21 +272,34 @@ public class PreferencesFragment extends PreferenceFragment
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
/**
|
||||
* If a user specifies they want to fetch updates automatically, then start the download of relevant
|
||||
* updates as soon as they enable the feature.
|
||||
* Also, if the user has the priv extention installed then change the label to indicate that it
|
||||
* will actually _install_ apps, not just fetch their .apk file automatically.
|
||||
*/
|
||||
private void initAutoFetchUpdatesPreference() {
|
||||
updateAutoDownloadPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
|
||||
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
if (newValue instanceof Boolean && (boolean) newValue) {
|
||||
UpdateService.autoDownloadUpdates(getContext());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
for (final String key : SUMMARIES_TO_UPDATE) {
|
||||
updateSummary(key, false);
|
||||
if (PrivilegedInstaller.isDefault(getContext())) {
|
||||
updateAutoDownloadPref.setTitle(R.string.update_auto_install);
|
||||
updateAutoDownloadPref.setSummary(R.string.update_auto_install_summary);
|
||||
}
|
||||
}
|
||||
|
||||
currentKeepCacheTime = Preferences.get().getKeepCacheTime();
|
||||
|
||||
initPrivilegedInstallerPreference();
|
||||
initUpdatePrivilegedExtensionPreference();
|
||||
// this pref's default is dynamically set based on whether Orbot is installed
|
||||
/**
|
||||
* The default for "Use Tor" is dynamically set based on whether Orbot is installed.
|
||||
*/
|
||||
private void initUseTorPreference() {
|
||||
boolean useTor = Preferences.get().isTorEnabled();
|
||||
useTorCheckPref.setDefaultValue(useTor);
|
||||
useTorCheckPref.setChecked(useTor);
|
||||
@ -308,11 +322,24 @@ public class PreferencesFragment extends PreferenceFragment
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (PrivilegedInstaller.isDefault(getContext())) {
|
||||
updateAutoDownloadPref.setTitle(R.string.update_auto_install);
|
||||
updateAutoDownloadPref.setSummary(R.string.update_auto_install_summary);
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
|
||||
|
||||
for (final String key : SUMMARIES_TO_UPDATE) {
|
||||
updateSummary(key, false);
|
||||
}
|
||||
|
||||
currentKeepCacheTime = Preferences.get().getKeepCacheTime();
|
||||
|
||||
initAutoFetchUpdatesPreference();
|
||||
initPrivilegedInstallerPreference();
|
||||
initUpdatePrivilegedExtensionPreference();
|
||||
initUseTorPreference();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -57,6 +57,9 @@ import java.util.List;
|
||||
* repopulate it from the original source lists of data. When this is done, the adapter will notify
|
||||
* the recycler view that its data has changed. Sometimes it will also ask the recycler view to
|
||||
* scroll to the newly added item (if attached to the recycler view).
|
||||
*
|
||||
* TODO: If a user downloads an old version of an app (resulting in a new update being available
|
||||
* instantly), then we need to refresh the list of apps to update.
|
||||
*/
|
||||
public class UpdatesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements LoaderManager.LoaderCallbacks<Cursor> {
|
||||
|
||||
@ -84,9 +87,6 @@ public class UpdatesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||
.addDelegate(new UpdateableApp.Delegate(activity))
|
||||
.addDelegate(new UpdateableAppsHeader.Delegate(activity));
|
||||
|
||||
populateAppStatuses();
|
||||
notifyDataSetChanged();
|
||||
|
||||
activity.getSupportLoaderManager().initLoader(0, null, this);
|
||||
}
|
||||
|
||||
@ -245,11 +245,18 @@ public class UpdatesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||
public void onLoaderReset(Loader<Cursor> loader) { }
|
||||
|
||||
/**
|
||||
* If this adapter is "active" then it is part of the current UI that the user is looking to.
|
||||
* Under those circumstances, we want to make sure it is up to date, and also listen to the
|
||||
* correct set of broadcasts.
|
||||
* Doesn't listen for {@link AppUpdateStatusManager#BROADCAST_APPSTATUS_CHANGED} because the
|
||||
* individual items in the recycler view will listen for the appropriate changes in state and
|
||||
* update themselves accordingly (if they are displayed).
|
||||
*/
|
||||
public void listenForStatusUpdates() {
|
||||
public void setIsActive() {
|
||||
appsToShowStatus.clear();
|
||||
populateAppStatuses();
|
||||
notifyDataSetChanged();
|
||||
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_ADDED);
|
||||
filter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_REMOVED);
|
||||
|
@ -24,7 +24,7 @@ public class UpdatesViewBinder {
|
||||
}
|
||||
|
||||
public void bind() {
|
||||
adapter.listenForStatusUpdates();
|
||||
adapter.setIsActive();
|
||||
}
|
||||
|
||||
public void unbind() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user