Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ba1f3dc8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[Panlingual] Add error message on per-app language page." into tm-dev

parents 046d174a 40a6de1e
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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>
    <!-- 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] -->
    <plurals name="dlg_remove_locales_title">
        <item quantity="one">Remove selected language?</item>
+21 −11
Original line number Diff line number Diff line
@@ -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() {