Skip to content

Commit

Permalink
Make some constants private and annotate params
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiGr committed Jun 4, 2023
1 parent 6cf13ed commit a3f10fe
Showing 1 changed file with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.SharedPreferences;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.preference.PreferenceManager;

import org.schabi.newpipe.R;
Expand All @@ -30,9 +31,9 @@ public final class SettingMigrations {
private static final String TAG = SettingMigrations.class.toString();
private static SharedPreferences sp;

public static final Migration MIGRATION_0_1 = new Migration(0, 1) {
private static final Migration MIGRATION_0_1 = new Migration(0, 1) {
@Override
public void migrate(final Context context) {
public void migrate(@NonNull final Context context) {
// We changed the content of the dialog which opens when sharing a link to NewPipe
// by removing the "open detail page" option.
// Therefore, show the dialog once again to ensure users need to choose again and are
Expand All @@ -44,9 +45,9 @@ public void migrate(final Context context) {
}
};

public static final Migration MIGRATION_1_2 = new Migration(1, 2) {
private static final Migration MIGRATION_1_2 = new Migration(1, 2) {
@Override
protected void migrate(final Context context) {
protected void migrate(@NonNull 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
Expand All @@ -63,9 +64,9 @@ protected void migrate(final Context context) {
}
};

public static final Migration MIGRATION_2_3 = new Migration(2, 3) {
private static final Migration MIGRATION_2_3 = new Migration(2, 3) {
@Override
protected void migrate(final Context context) {
protected void migrate(@NonNull final Context context) {
// Storage Access Framework implementation was improved in #5415, allowing the modern
// and standard way to access folders and files to be used consistently everywhere.
// We reset the setting to its default value, i.e. "use SAF", since now there are no
Expand All @@ -79,9 +80,9 @@ protected void migrate(final Context context) {
}
};

public static final Migration MIGRATION_3_4 = new Migration(3, 4) {
private static final Migration MIGRATION_3_4 = new Migration(3, 4) {
@Override
protected void migrate(final Context context) {
protected void migrate(@NonNull final Context context) {
// Pull request #3546 added support for choosing the type of search suggestions to
// show, replacing the on-off switch used before, so migrate the previous user choice

Expand All @@ -108,9 +109,9 @@ protected void migrate(final Context context) {
}
};

public static final Migration MIGRATION_4_5 = new Migration(4, 5) {
private static final Migration MIGRATION_4_5 = new Migration(4, 5) {
@Override
protected void migrate(final Context context) {
protected void migrate(@NonNull final Context context) {
final boolean brightness = sp.getBoolean("brightness_gesture_control", true);
final boolean volume = sp.getBoolean("volume_gesture_control", true);

Expand Down Expand Up @@ -144,10 +145,10 @@ protected void migrate(final Context context) {
/**
* Version number for preferences. Must be incremented every time a migration is necessary.
*/
public static final int VERSION = 5;
private static final int VERSION = 5;


public static void initMigrations(final Context context, final boolean isFirstRun) {
public static void initMigrations(@NonNull final Context context, final boolean isFirstRun) {
// setup migrations and check if there is something to do
sp = PreferenceManager.getDefaultSharedPreferences(context);
final String lastPrefVersionKey = context.getString(R.string.last_used_preferences_version);
Expand Down Expand Up @@ -212,7 +213,7 @@ private boolean shouldMigrate(final int currentVersion) {
return oldVersion >= currentVersion;
}

protected abstract void migrate(Context context);
protected abstract void migrate(@NonNull Context context);

}

Expand Down

0 comments on commit a3f10fe

Please sign in to comment.