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

Commit 23359bc0 authored by tom hsu's avatar tom hsu
Browse files

Unify Tick Preference from Physic keyboard and Regional preference

 - Also change icon color from colorAccentPrimaryVarient to colorAccentPrimary

Bug: b/272398108
Bug: b/264476709
Test: Manual test.
Change-Id: Ide602c6fb9501b832df646692ec618be8a76e7b9
parent e78b3d3f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0"
        android:tint="?androidprv:attr/colorAccentPrimaryVariant">
        android:tint="?androidprv:attr/colorAccent">
    <path
        android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"
        android:fillColor="@android:color/white"/>
+1 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
-->
<ImageView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/keyboard_check_icon"
    android:id="@+id/check_icon"
    android:src="@drawable/ic_check_24dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
+13 −12
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;

import com.android.settings.core.BasePreferenceController;
import com.android.settings.widget.TickButtonPreference;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop;
@@ -38,7 +39,7 @@ import java.util.Map;
public class NewKeyboardLayoutPickerController extends BasePreferenceController implements
        InputManager.InputDeviceListener, LifecycleObserver, OnStart, OnStop {
    private final InputManager mIm;
    private final Map<KeyboardLayoutPreference, KeyboardLayout> mPreferenceMap;
    private final Map<TickButtonPreference, KeyboardLayout> mPreferenceMap;

    private Fragment mParent;
    private int mInputDeviceId;
@@ -102,16 +103,15 @@ public class NewKeyboardLayoutPickerController extends BasePreferenceController

    @Override
    public boolean handlePreferenceTreeClick(Preference preference) {

        if (!(preference instanceof KeyboardLayoutPreference)) {
        if (!(preference instanceof TickButtonPreference)) {
            return false;
        }

        final KeyboardLayoutPreference pref = (KeyboardLayoutPreference) preference;
        pref.setCheckMark(true);
        final TickButtonPreference pref = (TickButtonPreference) preference;
        pref.setSelected(true);
        if (mPreviousSelection != null && !mPreviousSelection.equals(preference.getKey())) {
            KeyboardLayoutPreference preSelectedPref = mScreen.findPreference(mPreviousSelection);
            preSelectedPref.setCheckMark(false);
            TickButtonPreference preSelectedPref = mScreen.findPreference(mPreviousSelection);
            preSelectedPref.setSelected(false);
        }
        setLayout(pref);
        mPreviousSelection = preference.getKey();
@@ -140,12 +140,13 @@ public class NewKeyboardLayoutPickerController extends BasePreferenceController
            return;
        }
        for (KeyboardLayout layout : mKeyboardLayouts) {
            final KeyboardLayoutPreference pref;
            final TickButtonPreference pref;
            pref = new TickButtonPreference(mScreen.getContext());
            pref.setTitle(layout.getLabel());

            if (mLayout.equals(layout.getLabel())) {
                pref = new KeyboardLayoutPreference(mScreen.getContext(), layout.getLabel(), true);
                pref.setSelected(true);
                mPreviousSelection = layout.getDescriptor();
            } else {
                pref = new KeyboardLayoutPreference(mScreen.getContext(), layout.getLabel(), false);
            }
            pref.setKey(layout.getDescriptor());
            mScreen.addPreference(pref);
@@ -153,7 +154,7 @@ public class NewKeyboardLayoutPickerController extends BasePreferenceController
        }
    }

    private void setLayout(KeyboardLayoutPreference preference) {
    private void setLayout(TickButtonPreference preference) {
        mIm.setKeyboardLayoutForInputDevice(
                mInputDeviceIdentifier,
                mUserId,
+4 −3
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import com.android.internal.app.LocaleStore;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.widget.TickButtonPreference;

import java.util.Locale;

@@ -138,7 +139,7 @@ public class NumberingSystemItemController extends BasePreferenceController {
                String key = supportedLocale.getUnicodeLocaleType(
                        ExtensionTypes.NUMBERING_SYSTEM);
                pref.setKey(key == null ? RegionalPreferencesDataUtils.DEFAULT_VALUE : key);
                pref.setTickEnable(isSameNumberingSystem(targetLocale, supportedLocale));
                pref.setSelected(isSameNumberingSystem(targetLocale, supportedLocale));
                screen.addPreference(pref);
            }
        }
@@ -162,7 +163,7 @@ public class NumberingSystemItemController extends BasePreferenceController {
            TickButtonPreference pref = (TickButtonPreference) mPreferenceScreen.getPreference(i);
            Log.i(TAG, "[onPreferenceClick] key is " + pref.getKey());
            if (pref.getKey().equals(preference.getKey())) {
                pref.setTickEnable(true);
                pref.setSelected(true);
                Locale updatedLocale =
                        saveNumberingSystemToLocale(
                                Locale.forLanguageTag(mSelectedLanguage), pref.getKey());
@@ -176,7 +177,7 @@ public class NumberingSystemItemController extends BasePreferenceController {
                mParentFragment.setArguments(bundle);
                continue;
            }
            pref.setTickEnable(false);
            pref.setSelected(false);
        }
    }

+4 −3
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import androidx.preference.PreferenceScreen;

import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.widget.TickButtonPreference;

/** A fragment to include each kind of regional preferences. */
public class RegionalPreferencesFragment extends SettingsPreferenceFragment {
@@ -63,7 +64,7 @@ public class RegionalPreferencesFragment extends SettingsPreferenceFragment {
            TickButtonPreference pref = (TickButtonPreference) mPreferenceScreen.getPreference(i);
            Log.i(TAG, "[onPreferenceClick] key is " + pref.getKey());
            if (pref.getKey().equals(preference.getKey())) {
                pref.setTickEnable(true);
                pref.setSelected(true);
                RegionalPreferencesDataUtils.savePreference(
                        getPrefContext(),
                        mType,
@@ -72,7 +73,7 @@ public class RegionalPreferencesFragment extends SettingsPreferenceFragment {
                                ? null : preference.getKey());
                continue;
            }
            pref.setTickEnable(false);
            pref.setSelected(false);
        }
        return true;
    }
@@ -115,7 +116,7 @@ public class RegionalPreferencesFragment extends SettingsPreferenceFragment {
            String value = RegionalPreferencesDataUtils.getDefaultUnicodeExtensionData(
                    getPrefContext(), mType);
            pref.setKey(item);
            pref.setTickEnable(!value.isEmpty() && item.equals(value));
            pref.setSelected(!value.isEmpty() && item.equals(value));
            mPreferenceScreen.addPreference(pref);
        }
        return super.onCreateView(inflater, container, savedInstanceState);
Loading