From b581e6d1b224c8839f91d676b7bf3c177dd6a1cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Taofeek=E2=80=99s=20MacBook=20Pro?= Date: Sun, 13 Nov 2022 15:41:33 +0100 Subject: [PATCH 1/2] Added Portuguese to language selection settings and removed dead code. --- .../TreeTracker/models/LanguageSwitcher.kt | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/org/greenstand/android/TreeTracker/models/LanguageSwitcher.kt b/app/src/main/java/org/greenstand/android/TreeTracker/models/LanguageSwitcher.kt index acf6de363..c145ffbcb 100644 --- a/app/src/main/java/org/greenstand/android/TreeTracker/models/LanguageSwitcher.kt +++ b/app/src/main/java/org/greenstand/android/TreeTracker/models/LanguageSwitcher.kt @@ -14,7 +14,8 @@ import java.util.* enum class Language(val locale: Locale) { ENGLISH(Locale("en")), - SWAHILI(Locale("sw")); + SWAHILI(Locale("sw")), + PORTUGUESE(Locale("pt")); companion object { @@ -22,6 +23,7 @@ enum class Language(val locale: Locale) { return when (lang.lowercase()) { "en" -> ENGLISH "sw" -> SWAHILI + "pt" -> PORTUGUESE else -> null } } @@ -37,20 +39,6 @@ class LanguageSwitcher(private val prefs: Preferences) { } } - fun switch(activity: Activity) { - val res = activity.resources - currentLanguage()?.also{ language -> - val newLanguage = when (language) { - Language.ENGLISH -> Language.SWAHILI - Language.SWAHILI -> Language.ENGLISH - } - setLanguage(newLanguage, res) - } - - activity.finish() - activity.startActivity(Intent(activity, TreeTrackerActivity::class.java)) - } - fun setLanguage(language: Language, res: Resources) { prefs.edit().putString(LANGUAGE_PREF_KEY, language.locale.toLanguageTag()).commit() From bc9c77857d57a9668d0e51480dc5ba4bdc0c11f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Taofeek=E2=80=99s=20MacBook=20Pro?= Date: Sun, 13 Nov 2022 15:41:33 +0100 Subject: [PATCH 2/2] Added Portuguese to language selection settings and removed dead code. --- .../TreeTracker/models/LanguageSwitcher.kt | 18 +++--------------- .../android/TreeTracker/view/TextButton.kt | 2 +- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/org/greenstand/android/TreeTracker/models/LanguageSwitcher.kt b/app/src/main/java/org/greenstand/android/TreeTracker/models/LanguageSwitcher.kt index acf6de363..c145ffbcb 100644 --- a/app/src/main/java/org/greenstand/android/TreeTracker/models/LanguageSwitcher.kt +++ b/app/src/main/java/org/greenstand/android/TreeTracker/models/LanguageSwitcher.kt @@ -14,7 +14,8 @@ import java.util.* enum class Language(val locale: Locale) { ENGLISH(Locale("en")), - SWAHILI(Locale("sw")); + SWAHILI(Locale("sw")), + PORTUGUESE(Locale("pt")); companion object { @@ -22,6 +23,7 @@ enum class Language(val locale: Locale) { return when (lang.lowercase()) { "en" -> ENGLISH "sw" -> SWAHILI + "pt" -> PORTUGUESE else -> null } } @@ -37,20 +39,6 @@ class LanguageSwitcher(private val prefs: Preferences) { } } - fun switch(activity: Activity) { - val res = activity.resources - currentLanguage()?.also{ language -> - val newLanguage = when (language) { - Language.ENGLISH -> Language.SWAHILI - Language.SWAHILI -> Language.ENGLISH - } - setLanguage(newLanguage, res) - } - - activity.finish() - activity.startActivity(Intent(activity, TreeTrackerActivity::class.java)) - } - fun setLanguage(language: Language, res: Resources) { prefs.edit().putString(LANGUAGE_PREF_KEY, language.locale.toLanguageTag()).commit() diff --git a/app/src/main/java/org/greenstand/android/TreeTracker/view/TextButton.kt b/app/src/main/java/org/greenstand/android/TreeTracker/view/TextButton.kt index 35dfcef69..c8246ad5f 100644 --- a/app/src/main/java/org/greenstand/android/TreeTracker/view/TextButton.kt +++ b/app/src/main/java/org/greenstand/android/TreeTracker/view/TextButton.kt @@ -274,7 +274,7 @@ fun BoxScope.LanguageButton() { colors = AppButtonColors.ProgressGreen, modifier = Modifier .align(Alignment.Center) - .size(width = 100.dp, 60.dp), + .size(width = 120.dp, 60.dp), onClick = { navController.navigate(NavRoute.Language.create()) }