Skip to content

Commit

Permalink
Set default value for "minimize_on_exit" to background for better UX.
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiGr committed Sep 22, 2020
1 parent 55c0aed commit 4e46fa8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public final class SettingMigrations {
/**
* Version number for preferences. Must be incremented every time a migration is necessary.
*/
public static final int VERSION = 1;
public static final int VERSION = 2;
private static SharedPreferences sp;

public static final Migration MIGRATION_0_1 = new Migration(0, 1) {
Expand All @@ -35,14 +35,34 @@ public void migrate(final Context context) {
}
};

public static final Migration MIGRATION_1_2 = new Migration(1, 2) {
@Override
protected void migrate(final Context context) {
// The new application workflow introduced in #2907 allows minimizing videos
// while playing to do other stuff within the app.
// For an even better workflow, we minimize a stream when switching the app to play in
// background.
// Therefore, set default value to background, if it has not been changed yet.
final String minimizeOnExitKey = context.getString(R.string.minimize_on_exit_key);
if (sp.getString(minimizeOnExitKey, "")
.equals(context.getString(R.string.minimize_on_exit_none_key))) {
final SharedPreferences.Editor editor = sp.edit();
editor.putString(minimizeOnExitKey,
context.getString(R.string.minimize_on_exit_background_key));
editor.apply();
}
}
};

/**
* List of all implemented migrations.
* <p>
* <b>Append new migrations to the end of the list</b> to keep it sorted ascending.
* If not sorted correctly, migrations which depend on each other, may fail.
*/
private static final Migration[] SETTING_MIGRATIONS = {
MIGRATION_0_1
MIGRATION_0_1,
MIGRATION_1_2
};


Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/settings_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
</string-array>

<string name="minimize_on_exit_key" translatable="false">minimize_on_exit_key</string>
<string name="minimize_on_exit_value" translatable="false">@string/minimize_on_exit_none_key</string>
<string name="minimize_on_exit_value" translatable="false">@string/minimize_on_exit_background_key</string>
<string name="minimize_on_exit_none_key" translatable="false">minimize_on_exit_none_key</string>
<string name="minimize_on_exit_background_key" translatable="false">minimize_on_exit_background_key</string>
<string name="minimize_on_exit_popup_key" translatable="false">minimize_on_exit_popup_key</string>
Expand Down

0 comments on commit 4e46fa8

Please sign in to comment.