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

Commit fee29f30 authored by Hai Zhang's avatar Hai Zhang Committed by Android (Google) Code Review
Browse files

Merge "Remove workaround for R class conflict in Settings unit test." into sc-dev

parents cccaa5a9 4d01a45c
Loading
Loading
Loading
Loading
+4 −12
Original line number Diff line number Diff line
@@ -72,9 +72,7 @@ public class MainSwitchBar extends LinearLayout implements CompoundButton.OnChec
            int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);

        LayoutInflater.from(context).inflate(
                resourceId(context, "layout", "settingslib_main_switch_bar"),
                this);
        LayoutInflater.from(context).inflate(R.layout.settingslib_main_switch_bar, this);

        if (!BuildCompat.isAtLeastS()) {
            final TypedArray a = context.obtainStyledAttributes(
@@ -90,12 +88,10 @@ public class MainSwitchBar extends LinearLayout implements CompoundButton.OnChec
        mFrameView = findViewById(R.id.frame);
        mTextView = (TextView) findViewById(R.id.switch_text);
        mSwitch = (Switch) findViewById(android.R.id.switch_widget);
        mBackgroundOn = getContext().getDrawable(
                resourceId(context, "drawable", "settingslib_switch_bar_bg_on"));
        mBackgroundOff = getContext().getDrawable(
                resourceId(context, "drawable", "settingslib_switch_bar_bg_off"));
        mBackgroundOn = getContext().getDrawable(R.drawable.settingslib_switch_bar_bg_on);
        mBackgroundOff = getContext().getDrawable(R.drawable.settingslib_switch_bar_bg_off);
        mBackgroundDisabled = getContext().getDrawable(
                resourceId(context, "drawable", "settingslib_switch_bar_bg_disabled"));
                R.drawable.settingslib_switch_bar_bg_disabled);

        addOnSwitchChangeListener((switchView, isChecked) -> setChecked(isChecked));

@@ -302,8 +298,4 @@ public class MainSwitchBar extends LinearLayout implements CompoundButton.OnChec

        requestLayout();
    }

    private int resourceId(Context context, String type, String name) {
        return context.getResources().getIdentifier(name, type, context.getPackageName());
    }
}
+2 −6
Original line number Diff line number Diff line
@@ -72,9 +72,9 @@ public class TwoTargetPreference extends Preference {
    private void init(Context context) {
        setLayoutResource(R.layout.preference_two_target);
        mSmallIconSize = context.getResources().getDimensionPixelSize(
                resourceId(context, "dimen", "two_target_pref_small_icon_size"));
                R.dimen.two_target_pref_small_icon_size);
        mMediumIconSize = context.getResources().getDimensionPixelSize(
                resourceId(context, "dimen", "two_target_pref_medium_icon_size"));
                R.dimen.two_target_pref_medium_icon_size);
        final int secondTargetResId = getSecondTargetResId();
        if (secondTargetResId != 0) {
            setWidgetLayoutResource(secondTargetResId);
@@ -116,8 +116,4 @@ public class TwoTargetPreference extends Preference {
    protected int getSecondTargetResId() {
        return 0;
    }

    private int resourceId(Context context, String type, String name) {
        return context.getResources().getIdentifier(name, type, context.getPackageName());
    }
}