Deduplicate code to initialize ClickListeners on playlist controls
Add the separate utility class PlayButtonHelper to handle the initialization of the listeners. The ClickListeners on playlist controls had different behaviours. This commit fixes that. The commit also refactors the way how the app determines whether it is started for the first time. The previous version was not clean and recent in this PR caused it to fail.
This commit is contained in:
parent
0d9910cbbe
commit
109d06b4bb
8 changed files with 147 additions and 117 deletions
|
|
@ -44,21 +44,11 @@ public final class NewPipeSettings {
|
|||
private NewPipeSettings() { }
|
||||
|
||||
public static void initSettings(final Context context) {
|
||||
// check if there are entries in the prefs to determine whether this is the first app run
|
||||
Boolean isFirstRun = null;
|
||||
final Set<String> prefsKeys = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
.getAll().keySet();
|
||||
for (final String key: prefsKeys) {
|
||||
// ACRA stores some info in the prefs during app initialization
|
||||
// which happens before this method is called. Therefore ignore ACRA-related keys.
|
||||
if (!key.toLowerCase().startsWith("acra")) {
|
||||
isFirstRun = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isFirstRun == null) {
|
||||
isFirstRun = true;
|
||||
}
|
||||
// check if the last used preference version is set
|
||||
// to determine whether this is the first app run
|
||||
final int lastUsedPrefVersion = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
.getInt(context.getString(R.string.last_used_preferences_version), -1);
|
||||
final boolean isFirstRun = lastUsedPrefVersion == -1;
|
||||
|
||||
// first run migrations, then setDefaultValues, since the latter requires the correct types
|
||||
SettingMigrations.runMigrationsIfNeeded(context, isFirstRun);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue