Merge "Set Default APN radio button's size to 48dp" into main

This commit is contained in:
Chaohui Wang
2024-03-25 23:48:37 +00:00
committed by Android (Google) Code Review
3 changed files with 40 additions and 36 deletions

View File

@@ -57,14 +57,19 @@
</RelativeLayout>
<RadioButton
android:id="@+id/apn_radiobutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dip"
android:layout_marginEnd="8dip"
android:layout_gravity="center_vertical"
android:focusable="true"
android:clickable="true" />
<FrameLayout
android:id="@+id/apn_radio_button_frame"
android:layout_width="@dimen/min_tap_target_size"
android:layout_height="@dimen/min_tap_target_size"
android:layout_margin="8dp">
<RadioButton
android:id="@+id/apn_radiobutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:clickable="false"
android:focusable="false" />
</FrameLayout>
</LinearLayout>

47
src/com/android/settings/network/apn/ApnPreference.java Executable file → Normal file
View File

@@ -49,7 +49,7 @@ public class ApnPreference extends Preference
private static CompoundButton sCurrentChecked = null;
private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
private boolean mProtectFromCheckedChange = false;
private boolean mSelectable = true;
private boolean mDefaultSelectable = true;
private boolean mHideDetails = false;
/**
@@ -57,6 +57,9 @@ public class ApnPreference extends Preference
*/
public ApnPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// Primary target and radio button could be selectable, but entire preference itself is not
// selectable.
setSelectable(false);
}
/**
@@ -80,25 +83,25 @@ public class ApnPreference extends Preference
final RelativeLayout textArea = (RelativeLayout) view.findViewById(R.id.text_layout);
textArea.setOnClickListener(this);
final View widget = view.findViewById(R.id.apn_radiobutton);
if ((widget != null) && widget instanceof RadioButton) {
final RadioButton rb = (RadioButton) widget;
if (mSelectable) {
rb.setOnCheckedChangeListener(this);
final RadioButton rb = view.itemView.requireViewById(R.id.apn_radiobutton);
if (mDefaultSelectable) {
view.itemView.requireViewById(R.id.apn_radio_button_frame).setOnClickListener((v) -> {
rb.performClick();
});
rb.setOnCheckedChangeListener(this);
final boolean isChecked = getKey().equals(sSelectedKey);
if (isChecked) {
sCurrentChecked = rb;
sSelectedKey = getKey();
}
mProtectFromCheckedChange = true;
rb.setChecked(isChecked);
mProtectFromCheckedChange = false;
rb.setVisibility(View.VISIBLE);
} else {
rb.setVisibility(View.GONE);
final boolean isChecked = getKey().equals(sSelectedKey);
if (isChecked) {
sCurrentChecked = rb;
sSelectedKey = getKey();
}
mProtectFromCheckedChange = true;
rb.setChecked(isChecked);
mProtectFromCheckedChange = false;
rb.setVisibility(View.VISIBLE);
} else {
rb.setVisibility(View.GONE);
}
}
@@ -167,12 +170,8 @@ public class ApnPreference extends Preference
}
}
public boolean getSelectable() {
return mSelectable;
}
public void setSelectable(boolean selectable) {
mSelectable = selectable;
public void setDefaultSelectable(boolean defaultSelectable) {
mDefaultSelectable = defaultSelectable;
}
public void setSubId(int subId) {

6
src/com/android/settings/network/apn/ApnSettings.java Executable file → Normal file
View File

@@ -369,10 +369,10 @@ public class ApnSettings extends RestrictedSettingsFragment
pref.setSummary(apn);
}
final boolean selectable =
final boolean defaultSelectable =
((type == null) || type.contains(ApnSetting.TYPE_DEFAULT_STRING));
pref.setSelectable(selectable);
if (selectable) {
pref.setDefaultSelectable(defaultSelectable);
if (defaultSelectable) {
if ((mSelectedKey != null) && mSelectedKey.equals(key)) {
pref.setChecked();
}