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

Commit edb14a70 authored by Edgar Wang's avatar Edgar Wang Committed by Android (Google) Code Review
Browse files

Merge "Revert "Support gray out preference icon when the preference is restricted"" into main

parents 5d46b5c6 c5b7edfa
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -140,12 +140,6 @@ public class PrimarySwitchPreference extends RestrictedPreference {
        }
    }

    @Override
    public void setEnabled(boolean enabled) {
        super.setEnabled(enabled);
        setSwitchEnabled(enabled);
    }

    @VisibleForTesting(otherwise = VisibleForTesting.NONE)
    public boolean isSwitchEnabled() {
        return mEnableSwitch;
+4 −7
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.UserHandle;
import android.text.TextUtils;
@@ -237,15 +236,13 @@ public class RestrictedPreferenceHelper {
    }

    private void updateDisabledState() {
        boolean isEnabled = !(mDisabledByAdmin || mDisabledByAppOps);
        if (!(mPreference instanceof RestrictedTopLevelPreference)) {
            mPreference.setEnabled(isEnabled);
            mPreference.setEnabled(!(mDisabledByAdmin || mDisabledByAppOps));
        }

        Drawable icon = mPreference.getIcon();
        if (!isEnabled && icon != null) {
            Utils.convertToGrayscale(icon);
            mPreference.setIcon(icon);
        if (mPreference instanceof PrimarySwitchPreference) {
            ((PrimarySwitchPreference) mPreference)
                    .setSwitchEnabled(!(mDisabledByAdmin || mDisabledByAppOps));
        }
    }
}
+0 −10
Original line number Diff line number Diff line
@@ -728,14 +728,4 @@ public class Utils {
        return false;
    }

    /**
     *  Convert a drawable to grayscale drawable
     */
    public static void convertToGrayscale(@NonNull Drawable drawable) {
        ColorMatrix matrix = new ColorMatrix();
        matrix.setSaturation(0.0f);

        ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix);
        drawable.setColorFilter(filter);
    }
}