diff --git a/app/src/main/java/de/danoeh/antennapod/PodcastApp.java b/app/src/main/java/de/danoeh/antennapod/PodcastApp.java index 4e6b8fa29..ed3f4e8f1 100644 --- a/app/src/main/java/de/danoeh/antennapod/PodcastApp.java +++ b/app/src/main/java/de/danoeh/antennapod/PodcastApp.java @@ -1,12 +1,15 @@ package de.danoeh.antennapod; import android.app.Application; +import android.content.ComponentName; +import android.content.Intent; import android.os.StrictMode; import com.joanzapata.iconify.Iconify; import com.joanzapata.iconify.fonts.FontAwesomeModule; import com.joanzapata.iconify.fonts.MaterialModule; +import de.danoeh.antennapod.activity.SplashActivity; import de.danoeh.antennapod.core.ApCoreEventBusIndex; import de.danoeh.antennapod.core.ClientConfig; import de.danoeh.antennapod.spa.SPAUtil; @@ -63,4 +66,12 @@ public class PodcastApp extends Application { .installDefaultEventBus(); } + public static void forceRestart() { + Intent intent = new Intent(getInstance(), SplashActivity.class); + ComponentName cn = intent.getComponent(); + Intent mainIntent = Intent.makeRestartActivityTask(cn); + getInstance().startActivity(mainIntent); + Runtime.getRuntime().exit(0); + } + } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/ImportExportPreferencesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/ImportExportPreferencesFragment.java index 761d6246e..f3b4d3003 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/ImportExportPreferencesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/ImportExportPreferencesFragment.java @@ -3,7 +3,6 @@ package de.danoeh.antennapod.fragment.preferences; import android.app.Activity; import android.app.ProgressDialog; import android.content.ActivityNotFoundException; -import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; @@ -17,10 +16,10 @@ import androidx.appcompat.app.AlertDialog; import androidx.core.content.FileProvider; import androidx.preference.PreferenceFragmentCompat; import com.google.android.material.snackbar.Snackbar; +import de.danoeh.antennapod.PodcastApp; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.OpmlImportActivity; import de.danoeh.antennapod.activity.PreferenceActivity; -import de.danoeh.antennapod.activity.SplashActivity; import de.danoeh.antennapod.asynctask.DocumentFileExportWorker; import de.danoeh.antennapod.asynctask.ExportWorker; import de.danoeh.antennapod.core.export.ExportWriter; @@ -212,13 +211,7 @@ public class ImportExportPreferencesFragment extends PreferenceFragmentCompat { AlertDialog.Builder d = new AlertDialog.Builder(getContext()); d.setMessage(R.string.import_ok); d.setCancelable(false); - d.setPositiveButton(android.R.string.ok, (dialogInterface, i) -> { - Intent intent = new Intent(getContext(), SplashActivity.class); - ComponentName cn = intent.getComponent(); - Intent mainIntent = Intent.makeRestartActivityTask(cn); - startActivity(mainIntent); - Runtime.getRuntime().exit(0); - }); + d.setPositiveButton(android.R.string.ok, (dialogInterface, i) -> PodcastApp.forceRestart()); d.show(); } diff --git a/app/src/play/java/de/danoeh/antennapod/preferences/PreferenceControllerFlavorHelper.java b/app/src/play/java/de/danoeh/antennapod/preferences/PreferenceControllerFlavorHelper.java index 810074bbe..b51fb40b0 100644 --- a/app/src/play/java/de/danoeh/antennapod/preferences/PreferenceControllerFlavorHelper.java +++ b/app/src/play/java/de/danoeh/antennapod/preferences/PreferenceControllerFlavorHelper.java @@ -7,6 +7,7 @@ import androidx.appcompat.app.AlertDialog; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.GoogleApiAvailability; +import de.danoeh.antennapod.PodcastApp; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.fragment.preferences.PlaybackPreferencesFragment; @@ -40,7 +41,7 @@ public class PreferenceControllerFlavorHelper { AlertDialog.Builder dialog = new AlertDialog.Builder(context); dialog.setTitle(android.R.string.dialog_alert_title); dialog.setMessage(R.string.pref_restart_required); - dialog.setPositiveButton(android.R.string.ok, null); + dialog.setPositiveButton(android.R.string.ok, (dialog1, which) -> PodcastApp.forceRestart()); dialog.setCancelable(false); dialog.show(); }