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

Commit 1c203ca7 authored by Chaohui Wang's avatar Chaohui Wang
Browse files

Migrate RestrictedSwitchPreference to compat

UI keep unchanged in this cl.

Bug: 285231003
Test: manual - on affected pages
Change-Id: I05f86b2ee24d59f7f90ba5cfeb1a3e58901d9487
parent b0280239
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -36,18 +36,17 @@ import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.VisibleForTesting;
import androidx.core.content.res.TypedArrayUtils;
import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceViewHolder;
import androidx.preference.SwitchPreference;
import androidx.preference.SwitchPreferenceCompat;

import com.android.settingslib.utils.BuildCompatUtils;

/**
 * Version of SwitchPreference that can be disabled by a device admin
 * Version of SwitchPreferenceCompat that can be disabled by a device admin
 * using a user restriction.
 */
public class RestrictedSwitchPreference extends SwitchPreference {
public class RestrictedSwitchPreference extends SwitchPreferenceCompat {
    RestrictedPreferenceHelper mHelper;
    AppOpsManager mAppOpsManager;
    boolean mUseAdditionalSummary = false;
@@ -93,8 +92,7 @@ public class RestrictedSwitchPreference extends SwitchPreference {
    }

    public RestrictedSwitchPreference(Context context, AttributeSet attrs) {
        this(context, attrs, TypedArrayUtils.getAttr(context, R.attr.switchPreferenceStyle,
                android.R.attr.switchPreferenceStyle));
        this(context, attrs, androidx.preference.R.attr.switchPreferenceCompatStyle);
    }

    public RestrictedSwitchPreference(Context context) {
@@ -113,7 +111,7 @@ public class RestrictedSwitchPreference extends SwitchPreference {
    @Override
    public void onBindViewHolder(PreferenceViewHolder holder) {
        super.onBindViewHolder(holder);
        final View switchView = holder.findViewById(android.R.id.switch_widget);
        final View switchView = holder.findViewById(androidx.preference.R.id.switchWidget);
        if (switchView != null) {
            final View rootView = switchView.getRootView();
            rootView.setFilterTouchesWhenObscured(true);
+1 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ object SettingsJankMonitor {
    const val MONITORED_ANIMATION_DURATION_MS = 300L

    /**
     * Detects the jank when click on a SwitchPreference.
     * Detects the jank when click on a TwoStatePreference.
     *
     * @param recyclerView the recyclerView contains the preference
     * @param preference the clicked preference