From 6ad5fc7b0d69f040cdd32b7c48b0f33b562d04da Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 1 Sep 2022 12:44:00 +0200 Subject: [PATCH] allow changing the app language on Android 13+ --- .../launcher/activities/SettingsActivity.kt | 17 ++++++++++--- app/src/main/res/layout/activity_settings.xml | 25 +++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/launcher/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/launcher/activities/SettingsActivity.kt index 4730bff..5d56c48 100644 --- a/app/src/main/kotlin/com/simplemobiletools/launcher/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/launcher/activities/SettingsActivity.kt @@ -3,12 +3,14 @@ package com.simplemobiletools.launcher.activities import android.os.Bundle import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.NavigationIcon +import com.simplemobiletools.commons.helpers.isTiramisuPlus import com.simplemobiletools.commons.models.FAQItem import com.simplemobiletools.launcher.BuildConfig import com.simplemobiletools.launcher.R import com.simplemobiletools.launcher.extensions.config import kotlinx.android.synthetic.main.activity_settings.* import java.util.* +import kotlin.system.exitProcess class SettingsActivity : SimpleActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -24,6 +26,7 @@ class SettingsActivity : SimpleActivity() { setupPurchaseThankYou() setupCustomizeColors() setupUseEnglish() + setupLanguage() updateTextColors(settings_holder) arrayOf(settings_color_customization_label, settings_general_settings_label).forEach { @@ -54,6 +57,7 @@ class SettingsActivity : SimpleActivity() { // make sure the corners at ripple fit the stroke rounded corners if (settings_purchase_thank_you_holder.isGone()) { settings_use_english_holder.background = resources.getDrawable(R.drawable.ripple_top_corners, theme) + settings_language_holder.background = resources.getDrawable(R.drawable.ripple_top_corners, theme) } settings_purchase_thank_you_holder.setOnClickListener { @@ -68,13 +72,20 @@ 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 - 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()) + 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 2a857f5..5c9bd2b 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -1,6 +1,7 @@ @@ -113,6 +114,30 @@ android:text="@string/use_english_language" /> + + + + + + + +