[Panlingual] Add error message on per-app language page.
Bug: 226032712
Test: local
Change-Id: I12aae66116cc8c00fa7c6b0ba256d4726620ea4c
(cherry picked from commit a9184f43c5
)
This commit is contained in:
@@ -513,7 +513,11 @@
|
|||||||
<string name="preference_of_system_locale_summary">System default - <xliff:g id="default_language" example="English (United States)">%1$s</xliff:g></string>
|
<string name="preference_of_system_locale_summary">System default - <xliff:g id="default_language" example="English (United States)">%1$s</xliff:g></string>
|
||||||
|
|
||||||
<!-- Description for the app without any supported languages. [CHAR LIMIT=NONE]-->
|
<!-- Description for the app without any supported languages. [CHAR LIMIT=NONE]-->
|
||||||
<string name="no_multiple_language_supported">The app is set to <xliff:g id="default_language" example="English (United States)">%1$s</xliff:g> by default and doesn\u2019t support multiple languages.</string>
|
<string name="desc_no_available_supported_locale">Language selection for this app isn\u2019t available from Settings.</string>
|
||||||
|
|
||||||
|
<!-- Description for the app without any supported languages. [CHAR LIMIT=NONE]-->
|
||||||
|
<string name="desc_disallow_locale_change_in_settings">You can\u2019t select a language for this app from Settings.</string>
|
||||||
|
|
||||||
<!-- The title of the confirmation dialog shown when the user selects one / several languages and tries to remove them [CHAR LIMIT=60] -->
|
<!-- The title of the confirmation dialog shown when the user selects one / several languages and tries to remove them [CHAR LIMIT=60] -->
|
||||||
<plurals name="dlg_remove_locales_title">
|
<plurals name="dlg_remove_locales_title">
|
||||||
<item quantity="one">Remove selected language?</item>
|
<item quantity="one">Remove selected language?</item>
|
||||||
|
@@ -74,14 +74,15 @@ public class AppLocaleDetails extends SettingsPreferenceFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
addPreferencesFromResource(R.xml.app_locale_details);
|
|
||||||
Bundle bundle = getArguments();
|
Bundle bundle = getArguments();
|
||||||
mPackageName = bundle.getString(AppInfoBase.ARG_PACKAGE_NAME, "");
|
mPackageName = bundle.getString(AppInfoBase.ARG_PACKAGE_NAME, "");
|
||||||
|
|
||||||
if (mPackageName.isEmpty()) {
|
if (mPackageName.isEmpty()) {
|
||||||
Log.d(TAG, "No package name.");
|
Log.d(TAG, "No package name.");
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addPreferencesFromResource(R.xml.app_locale_details);
|
||||||
|
mPrefOfDescription = getPreferenceScreen().findPreference(KEY_APP_DESCRIPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Override here so we don't have an empty screen
|
// Override here so we don't have an empty screen
|
||||||
@@ -98,17 +99,16 @@ public class AppLocaleDetails extends SettingsPreferenceFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
refreshUiInternal();
|
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
refreshUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshUiInternal() {
|
private void refreshUi() {
|
||||||
if (!hasAppSupportedLocales()) {
|
int res = getAppDescription();
|
||||||
Log.d(TAG, "No supported language.");
|
if (res != -1) {
|
||||||
mPrefOfDescription.setVisible(true);
|
mPrefOfDescription.setVisible(true);
|
||||||
TextView description = (TextView) mPrefOfDescription.findViewById(R.id.description);
|
TextView description = (TextView) mPrefOfDescription.findViewById(R.id.description);
|
||||||
description.setText(getContext().getString(R.string.no_multiple_language_supported,
|
description.setText(getContext().getString(res));
|
||||||
Locale.getDefault().getDisplayName(Locale.getDefault())));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -159,9 +159,19 @@ public class AppLocaleDetails extends SettingsPreferenceFragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasAppSupportedLocales() {
|
private int getAppDescription() {
|
||||||
LocaleList localeList = getPackageLocales();
|
LocaleList packageLocaleList = getPackageLocales();
|
||||||
return (localeList != null && localeList.size() > 0) || getAssetLocales().length > 0;
|
String[] assetLocaleList = getAssetLocales();
|
||||||
|
// TODO add apended url string, "Learn more", to these both sentenses.
|
||||||
|
if (packageLocaleList == null && assetLocaleList.length == 0) {
|
||||||
|
// There is no locale info from PackageManager amd AssetManager.
|
||||||
|
return R.string.desc_no_available_supported_locale;
|
||||||
|
} else if (packageLocaleList != null && packageLocaleList.isEmpty()) {
|
||||||
|
// LocaleConfig is empty, and this means only allow user modify language
|
||||||
|
// by the application.
|
||||||
|
return R.string.desc_disallow_locale_change_in_settings;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] getAssetLocales() {
|
private String[] getAssetLocales() {
|
||||||
|
Reference in New Issue
Block a user