|
27 | 27 | import android.content.IntentFilter; |
28 | 28 | import android.content.SharedPreferences; |
29 | 29 | import android.content.pm.PackageManager; |
| 30 | +import android.os.Build; |
30 | 31 | import android.os.Bundle; |
31 | 32 | import android.os.Handler; |
32 | 33 | import android.os.Looper; |
@@ -203,6 +204,7 @@ protected void onCreate(final Bundle savedInstanceState) { |
203 | 204 | // We want every release build (nightly, nightly-refactor) to show the popup |
204 | 205 | if (!DEBUG) { |
205 | 206 | showKeepAndroidDialog(); |
| 207 | + showApi23RequirementDialog(); |
206 | 208 | } |
207 | 209 |
|
208 | 210 | MigrationManager.showUserInfoIfPresent(this); |
@@ -1028,4 +1030,32 @@ private static String getKeepAndroidOpenDetailsUrl() { |
1028 | 1030 | return kaoBaseUrl; |
1029 | 1031 | } |
1030 | 1032 | } |
| 1033 | + |
| 1034 | + private void showApi23RequirementDialog() { |
| 1035 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { |
| 1036 | + return; // only show dialog on the devices that will stop being supported |
| 1037 | + } |
| 1038 | + |
| 1039 | + final var prefs = PreferenceManager.getDefaultSharedPreferences(this); |
| 1040 | + final var shownKey = getString(R.string.api23_requirement_dialog_shown_key); |
| 1041 | + if (prefs.getBoolean(shownKey, false)) { |
| 1042 | + return; // dialog was already shown in the past, no need to show it again |
| 1043 | + } |
| 1044 | + |
| 1045 | + final var dialog = new AlertDialog.Builder(this) |
| 1046 | + .setTitle(R.string.api23_requirement_dialog_title) |
| 1047 | + .setCancelable(false) |
| 1048 | + .setMessage(R.string.api23_requirement_dialog_message) |
| 1049 | + .setPositiveButton(android.R.string.ok, (d, w) -> prefs.edit() |
| 1050 | + .putBoolean(shownKey, true) |
| 1051 | + .apply()) |
| 1052 | + .setNegativeButton(R.string.api23_requirement_dialog_blogpost, null) |
| 1053 | + .show(); |
| 1054 | + |
| 1055 | + // If we use setNegativeButton, dialog will close after pressing the button, |
| 1056 | + // but we want it to close only when positive button is pressed |
| 1057 | + final var blogpostUrl = "https://newpipe.net/blog/pinned/announcement/drop-android-5/"; |
| 1058 | + dialog.getButton(AlertDialog.BUTTON_NEGATIVE) |
| 1059 | + .setOnClickListener(v -> ShareUtils.openUrlInBrowser(this, blogpostUrl)); |
| 1060 | + } |
1031 | 1061 | } |
0 commit comments