diff options
author | Charles Lombardo <clombardo169@gmail.com> | 2023-03-11 06:38:25 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2023-06-03 09:05:41 +0200 |
commit | b8eb8bd2b5a7a616836120aeb79c23939f60cc47 (patch) | |
tree | 3ff4a3634fc9902325551cf4799a28c3a1ecf72e /src/android | |
parent | android: Convert Log to Kotlin (diff) | |
download | yuzu-b8eb8bd2b5a7a616836120aeb79c23939f60cc47.tar yuzu-b8eb8bd2b5a7a616836120aeb79c23939f60cc47.tar.gz yuzu-b8eb8bd2b5a7a616836120aeb79c23939f60cc47.tar.bz2 yuzu-b8eb8bd2b5a7a616836120aeb79c23939f60cc47.tar.lz yuzu-b8eb8bd2b5a7a616836120aeb79c23939f60cc47.tar.xz yuzu-b8eb8bd2b5a7a616836120aeb79c23939f60cc47.tar.zst yuzu-b8eb8bd2b5a7a616836120aeb79c23939f60cc47.zip |
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 @@ -package org.yuzu.yuzu_emu.utils; - -import android.content.SharedPreferences; -import android.preference.PreferenceManager; -import android.text.Html; -import android.text.method.LinkMovementMethod; -import android.widget.TextView; - -import androidx.appcompat.app.AlertDialog; - -import org.yuzu.yuzu_emu.R; -import org.yuzu.yuzu_emu.YuzuApplication; -import org.yuzu.yuzu_emu.ui.main.MainActivity; -import org.yuzu.yuzu_emu.ui.main.MainPresenter; - -public final class StartupHandler { - private static SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(YuzuApplication.getAppContext()); - - private static void handleStartupPromptDismiss(MainActivity parent) { - parent.launchFileListActivity(MainPresenter.REQUEST_INSTALL_KEYS); - } - - private static void markFirstBoot() { - final SharedPreferences.Editor editor = mPreferences.edit(); - editor.putBoolean("FirstApplicationLaunch", false); - editor.apply(); - } - - public static void handleInit(MainActivity parent) { - if (mPreferences.getBoolean("FirstApplicationLaunch", true)) { - markFirstBoot(); - - AlertDialog.Builder builder = new AlertDialog.Builder(parent); - builder.setMessage(Html.fromHtml(parent.getResources().getString(R.string.app_disclaimer))); - builder.setTitle(R.string.app_name); - builder.setIcon(R.mipmap.ic_launcher); - builder.setPositiveButton(android.R.string.ok, null); - builder.setOnDismissListener(dialogInterface -> handleStartupPromptDismiss(parent)); - - AlertDialog alert = builder.create(); - alert.show(); - ((TextView) alert.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); - } - } -} 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 @@ +package org.yuzu.yuzu_emu.utils + +import androidx.preference.PreferenceManager +import android.text.Html +import android.text.method.LinkMovementMethod +import android.view.View +import android.widget.TextView +import com.google.android.material.dialog.MaterialAlertDialogBuilder +import org.yuzu.yuzu_emu.R +import org.yuzu.yuzu_emu.YuzuApplication +import org.yuzu.yuzu_emu.features.settings.model.Settings +import org.yuzu.yuzu_emu.ui.main.MainActivity +import org.yuzu.yuzu_emu.ui.main.MainPresenter + +object StartupHandler { + private val preferences = + PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext) + + private fun handleStartupPromptDismiss(parent: MainActivity) { + parent.launchFileListActivity(MainPresenter.REQUEST_INSTALL_KEYS) + } + + private fun markFirstBoot() { + preferences.edit() + .putBoolean(Settings.PREF_FIRST_APP_LAUNCH, false) + .apply() + } + + fun handleInit(parent: MainActivity) { + if (preferences.getBoolean(Settings.PREF_FIRST_APP_LAUNCH, true)) { + markFirstBoot() + val alert = MaterialAlertDialogBuilder(parent) + .setMessage(Html.fromHtml(parent.resources.getString(R.string.app_disclaimer))) + .setTitle(R.string.app_name) + .setIcon(R.mipmap.ic_launcher) + .setPositiveButton(android.R.string.ok, null) + .setOnDismissListener { + handleStartupPromptDismiss(parent) + } + .show() + (alert.findViewById<View>(android.R.id.message) as TextView?)!!.movementMethod = + LinkMovementMethod.getInstance() + } + } +} |