mirror of
https://github.com/SimpleMobileTools/Simple-Draw.git
synced 2025-04-16 19:39:38 +02:00
show a language selector in the app Settings on Android 13+
This commit is contained in:
parent
3ed0479a4d
commit
0a2acdd502
@ -3,6 +3,7 @@ package com.simplemobiletools.draw.pro.activities
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.NavigationIcon
|
import com.simplemobiletools.commons.helpers.NavigationIcon
|
||||||
|
import com.simplemobiletools.commons.helpers.isTiramisuPlus
|
||||||
import com.simplemobiletools.draw.pro.R
|
import com.simplemobiletools.draw.pro.R
|
||||||
import com.simplemobiletools.draw.pro.extensions.config
|
import com.simplemobiletools.draw.pro.extensions.config
|
||||||
import kotlinx.android.synthetic.main.activity_settings.*
|
import kotlinx.android.synthetic.main.activity_settings.*
|
||||||
@ -20,6 +21,7 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
|
|
||||||
setupCustomizeColors()
|
setupCustomizeColors()
|
||||||
setupUseEnglish()
|
setupUseEnglish()
|
||||||
|
setupLanguage()
|
||||||
setupPreventPhoneFromSleeping()
|
setupPreventPhoneFromSleeping()
|
||||||
setupBrushSize()
|
setupBrushSize()
|
||||||
setupAllowZoomingCanvas()
|
setupAllowZoomingCanvas()
|
||||||
@ -42,13 +44,8 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupUseEnglish() {
|
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.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_holder.setOnClickListener {
|
||||||
settings_use_english.toggle()
|
settings_use_english.toggle()
|
||||||
config.useEnglish = settings_use_english.isChecked
|
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() {
|
private fun setupPreventPhoneFromSleeping() {
|
||||||
settings_prevent_phone_from_sleeping.isChecked = config.preventPhoneFromSleeping
|
settings_prevent_phone_from_sleeping.isChecked = config.preventPhoneFromSleeping
|
||||||
settings_prevent_phone_from_sleeping_holder.setOnClickListener {
|
settings_prevent_phone_from_sleeping_holder.setOnClickListener {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/settings_coordinator"
|
android:id="@+id/settings_coordinator"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
@ -15,6 +16,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="?attr/actionBarSize"
|
||||||
android:background="@color/color_primary"
|
android:background="@color/color_primary"
|
||||||
|
app:layout_scrollFlags="scroll|enterAlways"
|
||||||
app:title="@string/settings"
|
app:title="@string/settings"
|
||||||
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
|
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
|
||||||
|
|
||||||
@ -97,6 +99,30 @@
|
|||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/settings_language_holder"
|
||||||
|
style="@style/SettingsHolderTextViewStyle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/ripple_background">
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
|
android:id="@+id/settings_language_label"
|
||||||
|
style="@style/SettingsTextLabelStyle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/language" />
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
|
android:id="@+id/settings_language"
|
||||||
|
style="@style/SettingsTextValueStyle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/settings_language_label"
|
||||||
|
tools:text="English" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/settings_prevent_phone_from_sleeping_holder"
|
android:id="@+id/settings_prevent_phone_from_sleeping_holder"
|
||||||
style="@style/SettingsHolderCheckboxStyle"
|
style="@style/SettingsHolderCheckboxStyle"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user