Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add label with the current app language to the App Settings screen #17004

Merged
merged 4 commits into from
Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
-----
* [*] Use larger thumbnail previews for recommended themes during site creation [https://github.com/wordpress-mobile/WordPress-Android/pull/16848]
* [*] 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