From 0a2acdd5024d0e71bc9ecc52491f55ecbf6685ec Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 18 Aug 2022 16:03:43 +0200 Subject: [PATCH] show a language selector in the app Settings on Android 13+ --- .../draw/pro/activities/SettingsActivity.kt | 22 +++++++++++----- app/src/main/res/layout/activity_settings.xml | 26 +++++++++++++++++++ 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/draw/pro/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/draw/pro/activities/SettingsActivity.kt index b276d7b..99fbdfc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/draw/pro/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/draw/pro/activities/SettingsActivity.kt @@ -3,6 +3,7 @@ package com.simplemobiletools.draw.pro.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.draw.pro.R import com.simplemobiletools.draw.pro.extensions.config import kotlinx.android.synthetic.main.activity_settings.* @@ -20,6 +21,7 @@ class SettingsActivity : SimpleActivity() { setupCustomizeColors() setupUseEnglish() + setupLanguage() setupPreventPhoneFromSleeping() setupBrushSize() setupAllowZoomingCanvas() @@ -42,13 +44,8 @@ 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_prevent_phone_from_sleeping_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 @@ -56,6 +53,19 @@ class SettingsActivity : SimpleActivity() { } } + 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_prevent_phone_from_sleeping_holder.background = resources.getDrawable(R.drawable.ripple_top_corners, theme) + } + + settings_language_holder.setOnClickListener { + launchChangeAppLanguageIntent() + } + } + private fun setupPreventPhoneFromSleeping() { settings_prevent_phone_from_sleeping.isChecked = config.preventPhoneFromSleeping settings_prevent_phone_from_sleeping_holder.setOnClickListener { diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index aa82294..5896456 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -1,6 +1,7 @@ @@ -15,6 +16,7 @@ android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="@color/color_primary" + app:layout_scrollFlags="scroll|enterAlways" app:title="@string/settings" app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" /> @@ -97,6 +99,30 @@ + + + + + + + +