From 941f85781b7ad63f97f1a2c21eb07bc907de9fb9 Mon Sep 17 00:00:00 2001 From: tobigr Date: Fri, 18 Jul 2025 12:13:51 +0200 Subject: [PATCH] Display dialog informing the user about the removal of the Top 50 kiosk --- .../java/org/schabi/newpipe/MainActivity.java | 2 ++ .../newpipe/settings/SettingMigrations.java | 33 ++++++++++++++++++- app/src/main/res/values/strings.xml | 2 ++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java index b709c1107..ef0f78fc0 100644 --- a/app/src/main/java/org/schabi/newpipe/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java @@ -80,6 +80,7 @@ import org.schabi.newpipe.player.Player; import org.schabi.newpipe.player.event.OnKeyDownListener; import org.schabi.newpipe.player.helper.PlayerHolder; import org.schabi.newpipe.player.playqueue.PlayQueue; +import org.schabi.newpipe.settings.SettingMigrations; import org.schabi.newpipe.settings.UpdateSettingsFragment; import org.schabi.newpipe.util.Constants; import org.schabi.newpipe.util.DeviceUtils; @@ -197,6 +198,7 @@ public class MainActivity extends AppCompatActivity { } Localization.migrateAppLanguageSettingIfNecessary(getApplicationContext()); + SettingMigrations.showUserInfoIfPresent(this); } @Override diff --git a/app/src/main/java/org/schabi/newpipe/settings/SettingMigrations.java b/app/src/main/java/org/schabi/newpipe/settings/SettingMigrations.java index 6bdfc287e..88ab3eaeb 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/SettingMigrations.java +++ b/app/src/main/java/org/schabi/newpipe/settings/SettingMigrations.java @@ -5,6 +5,8 @@ import android.content.SharedPreferences; import android.util.Log; import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; +import androidx.core.util.Consumer; import androidx.preference.PreferenceManager; import org.schabi.newpipe.App; @@ -12,11 +14,11 @@ import org.schabi.newpipe.R; import org.schabi.newpipe.error.ErrorInfo; import org.schabi.newpipe.error.ErrorUtil; import org.schabi.newpipe.error.UserAction; -import org.schabi.newpipe.extractor.ServiceList; import org.schabi.newpipe.settings.tabs.Tab; import org.schabi.newpipe.settings.tabs.TabsManager; import org.schabi.newpipe.util.DeviceUtils; +import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; @@ -38,6 +40,12 @@ public final class SettingMigrations { private static final String TAG = SettingMigrations.class.toString(); private static SharedPreferences sp; + /** + * List of UI actions that are performed after the UI is initialized + * to inform the user about changes that were applied by migrations. + */ + private static final List> MIGRATION_INFO = new ArrayList<>(); + private static final Migration MIGRATION_0_1 = new Migration(0, 1) { @Override public void migrate(@NonNull final Context context) { @@ -163,6 +171,14 @@ public final class SettingMigrations { .collect(Collectors.toUnmodifiableList()); if (tabs.size() != cleanedTabs.size()) { tabsManager.saveTabs(cleanedTabs); + // create an AlertDialog to inform the user about the change + MIGRATION_INFO.add((Context uiContext) -> new AlertDialog.Builder(uiContext) + .setTitle(R.string.migration_info_6_7_title) + .setMessage(R.string.migration_info_6_7_message) + .setPositiveButton(R.string.ok, null) + .setCancelable(false) + .create() + .show()); } } }; @@ -233,6 +249,21 @@ public final class SettingMigrations { sp.edit().putInt(lastPrefVersionKey, currentVersion).apply(); } + /** + * Perform UI actions informing about migrations that took place if they are present. + * @param context Context that can be used to show dialogs/snackbars/toasts + */ + public static void showUserInfoIfPresent(@NonNull final Context context) { + for (final Consumer consumer : MIGRATION_INFO) { + try { + consumer.accept(context); + } catch (final Exception e) { + ErrorUtil.showUiErrorSnackbar(context, "Showing migration info to the user", e); + } + } + MIGRATION_INFO.clear(); + } + private SettingMigrations() { } abstract static class Migration { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c909a0632..ddf49c65b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -865,4 +865,6 @@ Show more Show less The settings in the export being imported use a vulnerable format that was deprecated since NewPipe 0.27.0. Make sure the export being imported is from a trusted source, and prefer using only exports obtained from NewPipe 0.27.0 or newer in the future. Support for importing settings in this vulnerable format will soon be removed completely, and then old versions of NewPipe will not be able to import settings of exports from new versions anymore. + SoundCloud Top 50 page removed + SoundCloud has discontinued the original Top 50 charts. The corresponding tab has been removed from your main page.