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

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

Merge "Add summary provider for system tile."

parents dc7ac748 e0c253fc
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -5929,6 +5929,8 @@
    <string name="network_dashboard_title">Network &amp; Internet</string>
    <!-- Title for setting tile leading to Connected devices settings [CHAR LIMIT=40]-->
    <string name="connected_devices_dashboard_title">Connected devices</string>
    <!-- Summary text for system preference tile, showing current display language of device [CHAR LIMIT=NONE]-->
    <string name="system_dashboard_summary">Language: <xliff:g id="language">%1$s</xliff:g></string>
    <!-- Search strings -->
    <!-- Text to describe the search results fragment title [CHAR LIMIT=16] -->
+2 −2
Original line number Diff line number Diff line
@@ -234,8 +234,8 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
            if (tile.icon != null) {
                pref.setIcon(tile.icon.loadDrawable(context));
            }
            if (tile.intent != null) {
                final Intent intent = new Intent(tile.intent);
            if (intent != null) {
                pref.setOnPreferenceClickListener(preference -> {
                    intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, true);
                    getActivity().startActivityForResult(intent, 0);
+10 −15
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ import android.hardware.input.InputManager;
import android.hardware.input.KeyboardLayout;
import android.os.Bundle;
import android.os.Handler;
import android.os.LocaleList;
import android.provider.Settings;
import android.provider.Settings.System;
import android.speech.tts.TtsEngines;
@@ -51,8 +50,6 @@ import android.view.inputmethod.InputMethodSubtype;
import android.view.textservice.SpellCheckerInfo;
import android.view.textservice.TextServicesManager;

import com.android.internal.app.LocaleHelper;
import com.android.internal.app.LocalePicker;
import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.Settings.KeyboardLayoutPickerActivity;
@@ -63,6 +60,8 @@ import com.android.settings.UserDictionarySettings;
import com.android.settings.Utils;
import com.android.settings.VoiceInputOutputSettings;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.localepicker.LocaleFeatureProvider;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settings.search.SearchIndexableRaw;
@@ -74,7 +73,6 @@ import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.TreeSet;

public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment
@@ -275,7 +273,8 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment

        if (!mShowsOnlyFullImeAndKeyboardList) {
            if (mLanguagePref != null) {
                String localeNames = getLocaleNames(getActivity());
                final String localeNames = FeatureFactory.getFactory(getContext())
                        .getLocaleFeatureProvider().getLocaleNames();
                mLanguagePref.setSummary(localeNames);
            }

@@ -349,14 +348,7 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment
        return super.onPreferenceTreeClick(preference);
    }

    private static String getLocaleNames(Context context) {
        final LocaleList locales = LocalePicker.getLocales();
        final Locale displayLocale = Locale.getDefault();
        return LocaleHelper.toSentenceCase(
                LocaleHelper.getDisplayLocaleList(
                        locales, displayLocale, 2 /* Show up to two locales from the list */),
                displayLocale);
    }


    private void saveInputMethodSelectorVisibility(String value) {
        try {
@@ -667,16 +659,18 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment

        private final Context mContext;
        private final SummaryLoader mSummaryLoader;
        private LocaleFeatureProvider mLocaleFeatureProvider;

        public SummaryProvider(Context context, SummaryLoader summaryLoader) {
            mContext = context;
            mSummaryLoader = summaryLoader;
            mLocaleFeatureProvider = FeatureFactory.getFactory(context).getLocaleFeatureProvider();
        }

        @Override
        public void setListening(boolean listening) {
            if (listening) {
                String localeNames = getLocaleNames(mContext);
                String localeNames = mLocaleFeatureProvider.getLocaleNames();
                mSummaryLoader.setSummary(this, localeNames);
            }
        }
@@ -701,7 +695,8 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment

            // Locale picker.
            if (context.getAssets().getLocales().length > 1) {
                String localeNames = getLocaleNames(context);
                String localeNames = FeatureFactory.getFactory(context).getLocaleFeatureProvider()
                        .getLocaleNames();
                SearchIndexableRaw indexable = new SearchIndexableRaw(context);
                indexable.key = KEY_PHONE_LANGUAGE;
                indexable.title = context.getString(R.string.phone_language);
+25 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settings.localepicker;

public interface LocaleFeatureProvider {

    /**
     * Returns displayable string of device locales.
     */
    String getLocaleNames();
}
+36 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settings.localepicker;

import android.os.LocaleList;

import com.android.internal.app.LocaleHelper;
import com.android.internal.app.LocalePicker;

import java.util.Locale;

public class LocaleFeatureProviderImpl implements LocaleFeatureProvider {
    @Override
    public String getLocaleNames() {
        final LocaleList locales = LocalePicker.getLocales();
        final Locale displayLocale = Locale.getDefault();
        return LocaleHelper.toSentenceCase(
                LocaleHelper.getDisplayLocaleList(
                        locales, displayLocale, 2 /* Show up to two locales from the list */),
                displayLocale);
    }
}
Loading