diff options
| author | 2023-03-11 00:38:25 -0500 | |
|---|---|---|
| committer | 2023-06-03 00:05:41 -0700 | |
| commit | b8eb8bd2b5a7a616836120aeb79c23939f60cc47 (patch) | |
| tree | 3ff4a3634fc9902325551cf4799a28c3a1ecf72e /src/android | |
| parent | android: Convert Log to Kotlin (diff) | |
| download | yuzu-b8eb8bd2b5a7a616836120aeb79c23939f60cc47.tar.gz yuzu-b8eb8bd2b5a7a616836120aeb79c23939f60cc47.tar.xz yuzu-b8eb8bd2b5a7a616836120aeb79c23939f60cc47.zip | |
android: Convert StartupHandler to Kotlin
Diffstat (limited to 'src/android')
| -rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/StartupHandler.java | 45 | ||||
| -rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/StartupHandler.kt | 45 |
2 files changed, 45 insertions, 45 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/StartupHandler.java b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/StartupHandler.java deleted file mode 100644 index 749a06b32..000000000 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/StartupHandler.java +++ /dev/null | |||
| @@ -1,45 +0,0 @@ | |||
| 1 | package org.yuzu.yuzu_emu.utils; | ||
| 2 | |||
| 3 | import android.content.SharedPreferences; | ||
| 4 | import android.preference.PreferenceManager; | ||
| 5 | import android.text.Html; | ||
| 6 | import android.text.method.LinkMovementMethod; | ||
| 7 | import android.widget.TextView; | ||
| 8 | |||
| 9 | import androidx.appcompat.app.AlertDialog; | ||
| 10 | |||
| 11 | import org.yuzu.yuzu_emu.R; | ||
| 12 | import org.yuzu.yuzu_emu.YuzuApplication; | ||
| 13 | import org.yuzu.yuzu_emu.ui.main.MainActivity; | ||
| 14 | import org.yuzu.yuzu_emu.ui.main.MainPresenter; | ||
| 15 | |||
| 16 | public final class StartupHandler { | ||
| 17 | private static SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(YuzuApplication.getAppContext()); | ||
| 18 | |||
| 19 | private static void handleStartupPromptDismiss(MainActivity parent) { | ||
| 20 | parent.launchFileListActivity(MainPresenter.REQUEST_INSTALL_KEYS); | ||
| 21 | } | ||
| 22 | |||
| 23 | private static void markFirstBoot() { | ||
| 24 | final SharedPreferences.Editor editor = mPreferences.edit(); | ||
| 25 | editor.putBoolean("FirstApplicationLaunch", false); | ||
| 26 | editor.apply(); | ||
| 27 | } | ||
| 28 | |||
| 29 | public static void handleInit(MainActivity parent) { | ||
| 30 | if (mPreferences.getBoolean("FirstApplicationLaunch", true)) { | ||
| 31 | markFirstBoot(); | ||
| 32 | |||
| 33 | AlertDialog.Builder builder = new AlertDialog.Builder(parent); | ||
| 34 | builder.setMessage(Html.fromHtml(parent.getResources().getString(R.string.app_disclaimer))); | ||
| 35 | builder.setTitle(R.string.app_name); | ||
| 36 | builder.setIcon(R.mipmap.ic_launcher); | ||
| 37 | builder.setPositiveButton(android.R.string.ok, null); | ||
| 38 | builder.setOnDismissListener(dialogInterface -> handleStartupPromptDismiss(parent)); | ||
| 39 | |||
| 40 | AlertDialog alert = builder.create(); | ||
| 41 | alert.show(); | ||
| 42 | ((TextView) alert.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); | ||
| 43 | } | ||
| 44 | } | ||
| 45 | } | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/StartupHandler.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/StartupHandler.kt new file mode 100644 index 000000000..8854c3d0f --- /dev/null +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/StartupHandler.kt | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | package org.yuzu.yuzu_emu.utils | ||
| 2 | |||
| 3 | import androidx.preference.PreferenceManager | ||
| 4 | import android.text.Html | ||
| 5 | import android.text.method.LinkMovementMethod | ||
| 6 | import android.view.View | ||
| 7 | import android.widget.TextView | ||
| 8 | import com.google.android.material.dialog.MaterialAlertDialogBuilder | ||
| 9 | import org.yuzu.yuzu_emu.R | ||
| 10 | import org.yuzu.yuzu_emu.YuzuApplication | ||
| 11 | import org.yuzu.yuzu_emu.features.settings.model.Settings | ||
| 12 | import org.yuzu.yuzu_emu.ui.main.MainActivity | ||
| 13 | import org.yuzu.yuzu_emu.ui.main.MainPresenter | ||
| 14 | |||
| 15 | object StartupHandler { | ||
| 16 | private val preferences = | ||
| 17 | PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext) | ||
| 18 | |||
| 19 | private fun handleStartupPromptDismiss(parent: MainActivity) { | ||
| 20 | parent.launchFileListActivity(MainPresenter.REQUEST_INSTALL_KEYS) | ||
| 21 | } | ||
| 22 | |||
| 23 | private fun markFirstBoot() { | ||
| 24 | preferences.edit() | ||
| 25 | .putBoolean(Settings.PREF_FIRST_APP_LAUNCH, false) | ||
| 26 | .apply() | ||
| 27 | } | ||
| 28 | |||
| 29 | fun handleInit(parent: MainActivity) { | ||
| 30 | if (preferences.getBoolean(Settings.PREF_FIRST_APP_LAUNCH, true)) { | ||
| 31 | markFirstBoot() | ||
| 32 | val alert = MaterialAlertDialogBuilder(parent) | ||
| 33 | .setMessage(Html.fromHtml(parent.resources.getString(R.string.app_disclaimer))) | ||
| 34 | .setTitle(R.string.app_name) | ||
| 35 | .setIcon(R.mipmap.ic_launcher) | ||
| 36 | .setPositiveButton(android.R.string.ok, null) | ||
| 37 | .setOnDismissListener { | ||
| 38 | handleStartupPromptDismiss(parent) | ||
| 39 | } | ||
| 40 | .show() | ||
| 41 | (alert.findViewById<View>(android.R.id.message) as TextView?)!!.movementMethod = | ||
| 42 | LinkMovementMethod.getInstance() | ||
| 43 | } | ||
| 44 | } | ||
| 45 | } | ||