Display a toast to notify user that Preset APN setting cannot be viewed
When KEY_HIDE_PRESET_APN_DETAILS_BOOL is set to true, Preset APN setting is hidden. When user taps Preset APN, a toast should be shown to inform that user cannot view the APN. Test: manual - check Preset APN setting details are hidden Bug: 115453290 Depends-On: I8a5c6f92f876d349b304acf89b4ffab86ff3f24b Change-Id: I0078b3492ae87a4297f24871b8bea1579e6a79af
This commit is contained in:
committed by
Youming Ye
parent
8f516adef7
commit
4d044ced6d
@@ -10041,6 +10041,9 @@
|
|||||||
<!-- Title for HFP(hands free profile) output switch button in settings. -->
|
<!-- Title for HFP(hands free profile) output switch button in settings. -->
|
||||||
<string name="take_call_on_title">Take call on</string>
|
<string name="take_call_on_title">Take call on</string>
|
||||||
|
|
||||||
|
<!-- Toast that appears when users tap an APN for which parameters cannot be viewed. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="cannot_change_apn_toast">This APN cannot be changed.</string>
|
||||||
|
|
||||||
<!-- Title for battery Suggestion. (tablet) [CHAR LIMIT=46] -->
|
<!-- Title for battery Suggestion. (tablet) [CHAR LIMIT=46] -->
|
||||||
<string name="battery_suggestion_title" product="tablet" >Improve tablet\'s battery life</string>
|
<string name="battery_suggestion_title" product="tablet" >Improve tablet\'s battery life</string>
|
||||||
<!-- Title for battery Suggestion. (device) [CHAR LIMIT=46] -->
|
<!-- Title for battery Suggestion. (device) [CHAR LIMIT=46] -->
|
||||||
|
@@ -29,6 +29,7 @@ import android.util.Log;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
|
||||||
@@ -53,6 +54,7 @@ public class ApnPreference extends Preference implements CompoundButton.OnChecke
|
|||||||
private static CompoundButton mCurrentChecked = null;
|
private static CompoundButton mCurrentChecked = null;
|
||||||
private boolean mProtectFromCheckedChange = false;
|
private boolean mProtectFromCheckedChange = false;
|
||||||
private boolean mSelectable = true;
|
private boolean mSelectable = true;
|
||||||
|
private boolean mHideDetails = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(PreferenceViewHolder view) {
|
public void onBindViewHolder(PreferenceViewHolder view) {
|
||||||
@@ -112,6 +114,11 @@ public class ApnPreference extends Preference implements CompoundButton.OnChecke
|
|||||||
super.onClick();
|
super.onClick();
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
|
if (mHideDetails) {
|
||||||
|
Toast.makeText(context, context.getString(
|
||||||
|
R.string.cannot_change_apn_toast), Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
int pos = Integer.parseInt(getKey());
|
int pos = Integer.parseInt(getKey());
|
||||||
Uri url = ContentUris.withAppendedId(Telephony.Carriers.CONTENT_URI, pos);
|
Uri url = ContentUris.withAppendedId(Telephony.Carriers.CONTENT_URI, pos);
|
||||||
Intent editIntent = new Intent(Intent.ACTION_EDIT, url);
|
Intent editIntent = new Intent(Intent.ACTION_EDIT, url);
|
||||||
@@ -131,4 +138,8 @@ public class ApnPreference extends Preference implements CompoundButton.OnChecke
|
|||||||
public void setSubId(int subId) {
|
public void setSubId(int subId) {
|
||||||
mSubId = subId;
|
mSubId = subId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setHideDetails() {
|
||||||
|
mHideDetails = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -77,12 +77,23 @@ public class ApnSettings extends RestrictedSettingsFragment {
|
|||||||
public static final String MVNO_TYPE = "mvno_type";
|
public static final String MVNO_TYPE = "mvno_type";
|
||||||
public static final String MVNO_MATCH_DATA = "mvno_match_data";
|
public static final String MVNO_MATCH_DATA = "mvno_match_data";
|
||||||
|
|
||||||
|
private static final String[] CARRIERS_PROJECTION = new String[] {
|
||||||
|
Telephony.Carriers._ID,
|
||||||
|
Telephony.Carriers.NAME,
|
||||||
|
Telephony.Carriers.APN,
|
||||||
|
Telephony.Carriers.TYPE,
|
||||||
|
Telephony.Carriers.MVNO_TYPE,
|
||||||
|
Telephony.Carriers.MVNO_MATCH_DATA,
|
||||||
|
Telephony.Carriers.EDITED,
|
||||||
|
};
|
||||||
|
|
||||||
private static final int ID_INDEX = 0;
|
private static final int ID_INDEX = 0;
|
||||||
private static final int NAME_INDEX = 1;
|
private static final int NAME_INDEX = 1;
|
||||||
private static final int APN_INDEX = 2;
|
private static final int APN_INDEX = 2;
|
||||||
private static final int TYPES_INDEX = 3;
|
private static final int TYPES_INDEX = 3;
|
||||||
private static final int MVNO_TYPE_INDEX = 4;
|
private static final int MVNO_TYPE_INDEX = 4;
|
||||||
private static final int MVNO_MATCH_DATA_INDEX = 5;
|
private static final int MVNO_MATCH_DATA_INDEX = 5;
|
||||||
|
private static final int EDITED_INDEX = 6;
|
||||||
|
|
||||||
private static final int MENU_NEW = Menu.FIRST;
|
private static final int MENU_NEW = Menu.FIRST;
|
||||||
private static final int MENU_RESTORE = Menu.FIRST + 1;
|
private static final int MENU_RESTORE = Menu.FIRST + 1;
|
||||||
@@ -115,6 +126,7 @@ public class ApnSettings extends RestrictedSettingsFragment {
|
|||||||
|
|
||||||
private boolean mHideImsApn;
|
private boolean mHideImsApn;
|
||||||
private boolean mAllowAddingApns;
|
private boolean mAllowAddingApns;
|
||||||
|
private boolean mHidePresetApnDetails;
|
||||||
|
|
||||||
public ApnSettings() {
|
public ApnSettings() {
|
||||||
super(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS);
|
super(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS);
|
||||||
@@ -195,6 +207,7 @@ public class ApnSettings extends RestrictedSettingsFragment {
|
|||||||
mAllowAddingApns = false;
|
mAllowAddingApns = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mHidePresetApnDetails = b.getBoolean(CarrierConfigManager.KEY_HIDE_PRESET_APN_DETAILS_BOOL);
|
||||||
mUserManager = UserManager.get(activity);
|
mUserManager = UserManager.get(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,9 +289,8 @@ public class ApnSettings extends RestrictedSettingsFragment {
|
|||||||
where.append(" AND NOT (type='ims')");
|
where.append(" AND NOT (type='ims')");
|
||||||
}
|
}
|
||||||
|
|
||||||
Cursor cursor = getContentResolver().query(Telephony.Carriers.CONTENT_URI, new String[] {
|
Cursor cursor = getContentResolver().query(Telephony.Carriers.CONTENT_URI,
|
||||||
"_id", "name", "apn", "type", "mvno_type", "mvno_match_data"}, where.toString(),
|
CARRIERS_PROJECTION, where.toString(), null, Telephony.Carriers.DEFAULT_SORT_ORDER);
|
||||||
null, Telephony.Carriers.DEFAULT_SORT_ORDER);
|
|
||||||
|
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
IccRecords r = null;
|
IccRecords r = null;
|
||||||
@@ -303,14 +315,19 @@ public class ApnSettings extends RestrictedSettingsFragment {
|
|||||||
String type = cursor.getString(TYPES_INDEX);
|
String type = cursor.getString(TYPES_INDEX);
|
||||||
String mvnoType = cursor.getString(MVNO_TYPE_INDEX);
|
String mvnoType = cursor.getString(MVNO_TYPE_INDEX);
|
||||||
String mvnoMatchData = cursor.getString(MVNO_MATCH_DATA_INDEX);
|
String mvnoMatchData = cursor.getString(MVNO_MATCH_DATA_INDEX);
|
||||||
|
int edited = cursor.getInt(EDITED_INDEX);
|
||||||
|
|
||||||
ApnPreference pref = new ApnPreference(getPrefContext());
|
ApnPreference pref = new ApnPreference(getPrefContext());
|
||||||
|
|
||||||
pref.setKey(key);
|
pref.setKey(key);
|
||||||
pref.setTitle(name);
|
pref.setTitle(name);
|
||||||
pref.setSummary(apn);
|
|
||||||
pref.setPersistent(false);
|
pref.setPersistent(false);
|
||||||
pref.setSubId(subId);
|
pref.setSubId(subId);
|
||||||
|
if (mHidePresetApnDetails && edited == Telephony.Carriers.UNEDITED) {
|
||||||
|
pref.setHideDetails();
|
||||||
|
} else {
|
||||||
|
pref.setSummary(apn);
|
||||||
|
}
|
||||||
|
|
||||||
boolean selectable = ((type == null) || !type.equals("mms"));
|
boolean selectable = ((type == null) || !type.equals("mms"));
|
||||||
pref.setSelectable(selectable);
|
pref.setSelectable(selectable);
|
||||||
|
Reference in New Issue
Block a user