Merge "[Panlingual] Add error message on per-app language page." into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
ba1f3dc8df
@@ -74,14 +74,15 @@ public class AppLocaleDetails extends SettingsPreferenceFragment {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.app_locale_details);
|
||||
Bundle bundle = getArguments();
|
||||
mPackageName = bundle.getString(AppInfoBase.ARG_PACKAGE_NAME, "");
|
||||
|
||||
if (mPackageName.isEmpty()) {
|
||||
Log.d(TAG, "No package name.");
|
||||
finish();
|
||||
}
|
||||
|
||||
addPreferencesFromResource(R.xml.app_locale_details);
|
||||
mPrefOfDescription = getPreferenceScreen().findPreference(KEY_APP_DESCRIPTION);
|
||||
}
|
||||
|
||||
// Override here so we don't have an empty screen
|
||||
@@ -98,17 +99,16 @@ public class AppLocaleDetails extends SettingsPreferenceFragment {
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
refreshUiInternal();
|
||||
super.onResume();
|
||||
refreshUi();
|
||||
}
|
||||
|
||||
private void refreshUiInternal() {
|
||||
if (!hasAppSupportedLocales()) {
|
||||
Log.d(TAG, "No supported language.");
|
||||
private void refreshUi() {
|
||||
int res = getAppDescription();
|
||||
if (res != -1) {
|
||||
mPrefOfDescription.setVisible(true);
|
||||
TextView description = (TextView) mPrefOfDescription.findViewById(R.id.description);
|
||||
description.setText(getContext().getString(R.string.no_multiple_language_supported,
|
||||
Locale.getDefault().getDisplayName(Locale.getDefault())));
|
||||
description.setText(getContext().getString(res));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -159,9 +159,19 @@ public class AppLocaleDetails extends SettingsPreferenceFragment {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasAppSupportedLocales() {
|
||||
LocaleList localeList = getPackageLocales();
|
||||
return (localeList != null && localeList.size() > 0) || getAssetLocales().length > 0;
|
||||
private int getAppDescription() {
|
||||
LocaleList packageLocaleList = getPackageLocales();
|
||||
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() {
|
||||
|
||||
Reference in New Issue
Block a user