From 67d056aca5663053be1734770253ceb83621b06b Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 20 Aug 2022 21:28:51 +0200 Subject: [PATCH] allow picking any language on Android 13+ --- .../pro/activities/SettingsActivity.kt | 24 +++++++++++++------ app/src/main/res/layout/activity_settings.xml | 24 +++++++++++++++++++ 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/SettingsActivity.kt index 66b062e3..37f82c4a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/SettingsActivity.kt @@ -15,6 +15,7 @@ import com.simplemobiletools.filemanager.pro.extensions.config import com.simplemobiletools.filemanager.pro.helpers.RootHelpers import kotlinx.android.synthetic.main.activity_settings.* import java.util.* +import kotlin.system.exitProcess class SettingsActivity : SimpleActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -28,6 +29,7 @@ class SettingsActivity : SimpleActivity() { setupCustomizeColors() setupUseEnglish() + setupLanguage() setupManageFavorites() setupManageShownTabs() setupChangeDateTimeFormat() @@ -73,17 +75,25 @@ class SettingsActivity : SimpleActivity() { } private fun setupUseEnglish() { - settings_use_english_holder.beVisibleIf(config.wasUseEnglishToggled || Locale.getDefault().language != "en") + settings_use_english_holder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus()) settings_use_english.isChecked = config.useEnglish - - if (settings_use_english_holder.isGone()) { - settings_manage_favorites_holder.background = resources.getDrawable(R.drawable.ripple_top_corners, theme) - } - settings_use_english_holder.setOnClickListener { settings_use_english.toggle() config.useEnglish = settings_use_english.isChecked - System.exit(0) + exitProcess(0) + } + } + + private fun setupLanguage() { + settings_language.text = Locale.getDefault().displayLanguage + settings_language_holder.beVisibleIf(isTiramisuPlus()) + + if (settings_use_english_holder.isGone() && settings_language_holder.isGone()) { + settings_manage_favorites_holder.background = resources.getDrawable(R.drawable.ripple_top_corners, theme) + } + + settings_language_holder.setOnClickListener { + launchChangeAppLanguageIntent() } } diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 2a09db8b..bbc99694 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -99,6 +99,30 @@ + + + + + + + +