Merge branch 'show-upgrade-notice' into 'master'

Show upgrade notice when migrating to new DB

See merge request fdroid/fdroidclient!1168
This commit is contained in:
Hans-Christoph Steiner
2022-12-21 14:55:06 +00:00
6 changed files with 24 additions and 3 deletions

View File

@@ -353,9 +353,9 @@ public class FDroidApp extends Application implements androidx.work.Configuratio
if (preferences.isIndexNeverUpdated()) {
preferences.setDefaultForDataOnlyConnection(this);
// force this check to ensure it starts fetching the index on initial runs
networkState = ConnectivityMonitorService.getNetworkState(this);
}
// force setting network state to ensure it is set before UpdateService checks it
networkState = ConnectivityMonitorService.getNetworkState(this);
ConnectivityMonitorService.registerAndStart(this);
UpdateService.schedule(getApplicationContext());

View File

@@ -102,6 +102,7 @@ public class UpdateService extends JobIntentService {
private static final int NOTIFY_ID_UPDATING = 0;
private static UpdateService updateService;
private static boolean isForcedUpdate;
private FDroidDatabase db;
private NotificationManager notificationManager;
@@ -211,6 +212,15 @@ public class UpdateService extends JobIntentService {
return updateService != null;
}
/**
* Whether or not a forced repo update is currently in progress.
* This is typically the case when the phone was updated to a new major OS version
* or the client DB was updated, so that all data needed to be purged.
*/
public static boolean isUpdatingForced() {
return updateService != null && isForcedUpdate;
}
public static void stopNow() {
if (updateService != null) {
updateService.stopSelf(JOB_ID);
@@ -261,6 +271,7 @@ public class UpdateService extends JobIntentService {
super.onDestroy();
notificationManager.cancel(NOTIFY_ID_UPDATING);
LocalBroadcastManager.getInstance(this).unregisterReceiver(updateStatusReceiver);
isForcedUpdate = false;
updateService = null;
}
@@ -378,6 +389,7 @@ public class UpdateService extends JobIntentService {
final long startTime = System.currentTimeMillis();
boolean manualUpdate = intent.getBooleanExtra(EXTRA_MANUAL_UPDATE, false);
boolean forcedUpdate = intent.getBooleanExtra(EXTRA_FORCED_UPDATE, false);
isForcedUpdate = forcedUpdate;
String fingerprint = intent.getStringExtra(EXTRA_REPO_FINGERPRINT);
String address = intent.getDataString();
@@ -402,6 +414,7 @@ public class UpdateService extends JobIntentService {
if (manualUpdate) {
Utils.showToastFromService(this, getString(R.string.warning_no_internet), Toast.LENGTH_SHORT);
}
isForcedUpdate = false;
return;
}
} else if ((manualUpdate || forcedUpdate) && fdroidPrefs.isOnDemandDownloadAllowed()) {
@@ -409,6 +422,7 @@ public class UpdateService extends JobIntentService {
if (forcedUpdate) DBHelper.resetTransient(this);
} else if (!fdroidPrefs.isBackgroundDownloadAllowed() && !fdroidPrefs.isOnDemandDownloadAllowed()) {
Utils.debugLog(TAG, "don't run update");
isForcedUpdate = false;
return;
}
@@ -503,6 +517,7 @@ public class UpdateService extends JobIntentService {
sendStatus(this, STATUS_ERROR_GLOBAL, e.getMessage());
}
isForcedUpdate = false;
long time = System.currentTimeMillis() - startTime;
Log.i(TAG, "Updating repo(s) complete, took " + time / 1000 + " seconds to complete.");
}

View File

@@ -84,6 +84,7 @@ public class DBHelper {
// Added end of 2022 for alphas, can be removed after sufficient time has passed.
ContentProviderMigrator migrator = new ContentProviderMigrator();
if (migrator.needsMigration(context)) {
Log.d(TAG, "Migrating DB...");
migrator.migrateOldRepos(context, db);
migrator.removeOldDb(context);
UpdateService.forceUpdateRepo(context);

View File

@@ -183,6 +183,10 @@ class LatestViewBinder implements Observer<List<AppOverviewItem>>, ChangeListene
appList.setVisibility(View.GONE);
return;
}
if (UpdateService.isUpdatingForced()) {
emptyState.setText(R.string.latest__empty_state__upgrading);
return;
}
StringBuilder emptyStateText = new StringBuilder();
emptyStateText.append(activity.getString(R.string.latest__empty_state__no_recent_apps));

View File

@@ -263,6 +263,7 @@ This often occurs with apps installed via Google Play or other sources, if they
<string name="menu_show_install_history">Show install history</string>
<string name="latest__empty_state__no_recent_apps">No recent apps found</string>
<string name="latest__empty_state__upgrading">Upgrading database…</string>
<string name="latest__empty_state__never_updated">Once your list of apps has been updated, the latest apps should
show here
</string>

View File

@@ -177,7 +177,7 @@ public data class Repository internal constructor(
public fun getMirrors(): List<org.fdroid.download.Mirror> {
return getAllMirrors(true).filter {
!disabledMirrors.contains(it.baseUrl)
}
}.ifEmpty { listOf(org.fdroid.download.Mirror(address)) }
}
/**