Merge "Set Default APN radio button's size to 48dp" into main
This commit is contained in:
@@ -57,14 +57,19 @@
|
|||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<RadioButton
|
<FrameLayout
|
||||||
android:id="@+id/apn_radiobutton"
|
android:id="@+id/apn_radio_button_frame"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="@dimen/min_tap_target_size"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="@dimen/min_tap_target_size"
|
||||||
android:layout_marginStart="8dip"
|
android:layout_margin="8dp">
|
||||||
android:layout_marginEnd="8dip"
|
|
||||||
android:layout_gravity="center_vertical"
|
<RadioButton
|
||||||
android:focusable="true"
|
android:id="@+id/apn_radiobutton"
|
||||||
android:clickable="true" />
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:clickable="false"
|
||||||
|
android:focusable="false" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
47
src/com/android/settings/network/apn/ApnPreference.java
Executable file → Normal file
47
src/com/android/settings/network/apn/ApnPreference.java
Executable file → Normal file
@@ -49,7 +49,7 @@ public class ApnPreference extends Preference
|
|||||||
private static CompoundButton sCurrentChecked = null;
|
private static CompoundButton sCurrentChecked = null;
|
||||||
private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||||
private boolean mProtectFromCheckedChange = false;
|
private boolean mProtectFromCheckedChange = false;
|
||||||
private boolean mSelectable = true;
|
private boolean mDefaultSelectable = true;
|
||||||
private boolean mHideDetails = false;
|
private boolean mHideDetails = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,6 +57,9 @@ public class ApnPreference extends Preference
|
|||||||
*/
|
*/
|
||||||
public ApnPreference(Context context, AttributeSet attrs, int defStyle) {
|
public ApnPreference(Context context, AttributeSet attrs, int defStyle) {
|
||||||
super(context, attrs, 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);
|
final RelativeLayout textArea = (RelativeLayout) view.findViewById(R.id.text_layout);
|
||||||
textArea.setOnClickListener(this);
|
textArea.setOnClickListener(this);
|
||||||
|
|
||||||
final View widget = view.findViewById(R.id.apn_radiobutton);
|
final RadioButton rb = view.itemView.requireViewById(R.id.apn_radiobutton);
|
||||||
if ((widget != null) && widget instanceof RadioButton) {
|
if (mDefaultSelectable) {
|
||||||
final RadioButton rb = (RadioButton) widget;
|
view.itemView.requireViewById(R.id.apn_radio_button_frame).setOnClickListener((v) -> {
|
||||||
if (mSelectable) {
|
rb.performClick();
|
||||||
rb.setOnCheckedChangeListener(this);
|
});
|
||||||
|
rb.setOnCheckedChangeListener(this);
|
||||||
|
|
||||||
final boolean isChecked = getKey().equals(sSelectedKey);
|
final boolean isChecked = getKey().equals(sSelectedKey);
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
sCurrentChecked = rb;
|
sCurrentChecked = rb;
|
||||||
sSelectedKey = getKey();
|
sSelectedKey = getKey();
|
||||||
}
|
|
||||||
|
|
||||||
mProtectFromCheckedChange = true;
|
|
||||||
rb.setChecked(isChecked);
|
|
||||||
mProtectFromCheckedChange = false;
|
|
||||||
rb.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
rb.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() {
|
public void setDefaultSelectable(boolean defaultSelectable) {
|
||||||
return mSelectable;
|
mDefaultSelectable = defaultSelectable;
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelectable(boolean selectable) {
|
|
||||||
mSelectable = selectable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSubId(int subId) {
|
public void setSubId(int subId) {
|
||||||
|
|||||||
6
src/com/android/settings/network/apn/ApnSettings.java
Executable file → Normal file
6
src/com/android/settings/network/apn/ApnSettings.java
Executable file → Normal file
@@ -369,10 +369,10 @@ public class ApnSettings extends RestrictedSettingsFragment
|
|||||||
pref.setSummary(apn);
|
pref.setSummary(apn);
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean selectable =
|
final boolean defaultSelectable =
|
||||||
((type == null) || type.contains(ApnSetting.TYPE_DEFAULT_STRING));
|
((type == null) || type.contains(ApnSetting.TYPE_DEFAULT_STRING));
|
||||||
pref.setSelectable(selectable);
|
pref.setDefaultSelectable(defaultSelectable);
|
||||||
if (selectable) {
|
if (defaultSelectable) {
|
||||||
if ((mSelectedKey != null) && mSelectedKey.equals(key)) {
|
if ((mSelectedKey != null) && mSelectedKey.equals(key)) {
|
||||||
pref.setChecked();
|
pref.setChecked();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user