Skip to content

Commit

Permalink
Merge pull request #17004 from wordpress-mobile/issue/16483-add-curre…
Browse files Browse the repository at this point in the history
…nt-locale-label-to-appsettings

Add label with the current app language to the App Settings screen
  • Loading branch information
Antonis Lilis authored Aug 5, 2022
2 parents 46fd124 + a5985da commit 6fb4a46
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* [*] Use larger thumbnail previews for recommended themes during site creation [https://github.com/wordpress-mobile/WordPress-Android/pull/16848]
* [***] [internal] Block Editor: List block: Adds support for V2 behind a feature flag [https://github.com/WordPress/gutenberg/pull/42702]
* [*] Jetpack App: Use the Jetpack green color for the skip buttons text in site creation [https://github.com/wordpress-mobile/WordPress-Android/pull/16994]
* [**] App Settings: Show a label with the current language of the app under "Interface Language". [https://github.com/wordpress-mobile/WordPress-Android/pull/17004]

20.4
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import org.wordpress.android.util.JetpackBrandingUtils;
import org.wordpress.android.util.JetpackBrandingUtils.Screen;
import org.wordpress.android.util.LocaleManager;
import org.wordpress.android.util.LocaleProvider;
import org.wordpress.android.util.NetworkUtils;
import org.wordpress.android.util.ToastUtils;
import org.wordpress.android.util.WPActivityUtils;
Expand Down Expand Up @@ -106,6 +107,7 @@ public class AppSettingsFragment extends PreferenceFragment
@Inject UnifiedAboutFeatureConfig mUnifiedAboutFeatureConfig;
@Inject MySiteDashboardTabsFeatureConfig mMySiteDashboardTabsFeatureConfig;
@Inject JetpackBrandingUtils mJetpackBrandingUtils;
@Inject LocaleProvider mLocaleProvider;

private static final String TRACK_STYLE = "style";
private static final String TRACK_ENABLED = "enabled";
Expand Down Expand Up @@ -144,6 +146,7 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
mLanguagePreference = (WPPreference) findPreference(getString(R.string.pref_key_language));
mLanguagePreference.setOnPreferenceChangeListener(this);
mLanguagePreference.setOnPreferenceClickListener(this);
mLanguagePreference.setSummary(mLocaleProvider.getAppLanguageDisplayString());

mAppThemePreference = (ListPreference) findPreference(getString(R.string.pref_key_app_theme));
mAppThemePreference.setOnPreferenceChangeListener(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class LocalePickerViewModel @Inject constructor(
private fun loadLocales() {
val appLocale = localeProvider.getAppLocale()

val displayLabel = localeProvider.getLanguageDisplayString(appLocale.toString(), appLocale)
val displayLabel = localeProvider.getAppLanguageDisplayString()
_suggestedLocale.postValue(CurrentLocale(displayLabel, appLocale.toString()))

val availableLocales = resourceProvider.getStringArray(array.available_languages).distinct()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class LocaleProvider @Inject constructor() {
return LanguageUtils.getCurrentDeviceLanguage()
}

fun getLanguageDisplayString(languageCode: String, displayLocale: Locale): String {
return LocaleManager.getLanguageString(languageCode, displayLocale)
fun getAppLanguageDisplayString(): String {
return LocaleManager.getLanguageString(getAppLocale().toString(), getAppLocale())
}

fun createSortedLocalizedLanguageDisplayStrings(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class LocalePickerViewModelTest : BaseUnitTest() {

whenever(currentLocale.toString()).thenReturn("en_US")
whenever(localeProvider.getAppLocale()).thenReturn(currentLocale)
whenever(localeProvider.getLanguageDisplayString(any(), any())).thenReturn("English (United States)")
whenever(localeProvider.getAppLanguageDisplayString()).thenReturn("English (United States)")
whenever(localeProvider.createSortedLocalizedLanguageDisplayStrings(any(), any())).thenReturn(dummyLocales)
whenever(resourceProvider.getStringArray(any())).thenReturn(languageCodes)

Expand Down

0 comments on commit 6fb4a46

Please sign in to comment.