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

This commit is contained in:
Hai Zhang
2021-05-11 22:44:09 +00:00
committed by Android (Google) Code Review
2 changed files with 6 additions and 18 deletions

View File

@@ -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());
}
}

View File

@@ -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());
}
}