Fix bug #16703191 APN settings shows back button even when you intent into it
- change a bit the way we recognize a SubSetting. Now we can pass the new ":settings:show_fragment_as_subsetting" Intent extra for forcing it. - convert ApnSettings to a SettingsPreferenceFragment Change-Id: I22167ad317530c0a58c4d522a72826f9d34ad2d3
This commit is contained in:
@@ -295,10 +295,11 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity-alias>
|
</activity-alias>
|
||||||
|
|
||||||
<activity android:name="ApnSettings"
|
<activity android:name="Settings$ApnSettingsActivity"
|
||||||
android:label="@string/apn_settings"
|
android:label="@string/apn_settings"
|
||||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
|
android:taskAffinity="com.android.settings"
|
||||||
|
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||||
android:parentActivityName="Settings$WirelessSettingsActivity">
|
android:parentActivityName="Settings$WirelessSettingsActivity">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
@@ -308,6 +309,8 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
||||||
android:value="true" />
|
android:value="true" />
|
||||||
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
|
android:value="com.android.settings.ApnSettings" />
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name="Settings$BluetoothSettingsActivity"
|
<activity android:name="Settings$BluetoothSettingsActivity"
|
||||||
|
@@ -1,39 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2014 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
-->
|
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/listContainer"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<ListView android:id="@android:id/list"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:drawSelectorOnTop="false"
|
|
||||||
android:scrollbarStyle="insideOverlay"
|
|
||||||
android:background="@android:color/white"
|
|
||||||
android:cacheColorHint="@android:color/white"
|
|
||||||
android:fadingEdgeLength="16dip" />
|
|
||||||
|
|
||||||
<TextView android:id="@android:id/empty"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="@string/apn_settings_not_available"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
|
||||||
</FrameLayout>
|
|
@@ -18,6 +18,8 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||||
|
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||||
android:gravity="center_vertical">
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
|
@@ -39,8 +39,12 @@ import android.preference.PreferenceGroup;
|
|||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
import android.provider.Telephony;
|
import android.provider.Telephony;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.android.internal.telephony.Phone;
|
import com.android.internal.telephony.Phone;
|
||||||
@@ -50,7 +54,7 @@ import com.android.internal.telephony.TelephonyProperties;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class ApnSettings extends PreferenceActivity implements
|
public class ApnSettings extends SettingsPreferenceFragment implements
|
||||||
Preference.OnPreferenceChangeListener {
|
Preference.OnPreferenceChangeListener {
|
||||||
static final String TAG = "ApnSettings";
|
static final String TAG = "ApnSettings";
|
||||||
|
|
||||||
@@ -121,33 +125,47 @@ public class ApnSettings extends PreferenceActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
|
|
||||||
mUm = (UserManager) getSystemService(Context.USER_SERVICE);
|
mUm = (UserManager) getSystemService(Context.USER_SERVICE);
|
||||||
|
|
||||||
|
mMobileStateFilter = new IntentFilter(
|
||||||
|
TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
|
||||||
|
|
||||||
|
setHasOptionsMenu(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
|
||||||
|
TextView empty = (TextView) getView().findViewById(android.R.id.empty);
|
||||||
|
if (empty != null) {
|
||||||
|
empty.setText(R.string.apn_settings_not_available);
|
||||||
|
getListView().setEmptyView(empty);
|
||||||
|
}
|
||||||
|
|
||||||
if (mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) {
|
if (mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) {
|
||||||
mUnavailable = true;
|
mUnavailable = true;
|
||||||
setContentView(R.layout.apn_disallowed_preference_screen);
|
setPreferenceScreen(new PreferenceScreen(getActivity(), null));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
addPreferencesFromResource(R.xml.apn_settings);
|
addPreferencesFromResource(R.xml.apn_settings);
|
||||||
getListView().setItemsCanFocus(true);
|
|
||||||
|
|
||||||
mMobileStateFilter = new IntentFilter(
|
getListView().setItemsCanFocus(true);
|
||||||
TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
if (mUnavailable) {
|
if (mUnavailable) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
registerReceiver(mMobileStateReceiver, mMobileStateFilter);
|
getActivity().registerReceiver(mMobileStateReceiver, mMobileStateFilter);
|
||||||
|
|
||||||
if (!mRestoreDefaultApnMode) {
|
if (!mRestoreDefaultApnMode) {
|
||||||
fillList();
|
fillList();
|
||||||
@@ -157,18 +175,18 @@ public class ApnSettings extends PreferenceActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
||||||
if (mUnavailable) {
|
if (mUnavailable) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
unregisterReceiver(mMobileStateReceiver);
|
getActivity().unregisterReceiver(mMobileStateReceiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
|
||||||
if (mRestoreDefaultApnThread != null) {
|
if (mRestoreDefaultApnThread != null) {
|
||||||
@@ -199,7 +217,7 @@ public class ApnSettings extends PreferenceActivity implements
|
|||||||
String key = cursor.getString(ID_INDEX);
|
String key = cursor.getString(ID_INDEX);
|
||||||
String type = cursor.getString(TYPES_INDEX);
|
String type = cursor.getString(TYPES_INDEX);
|
||||||
|
|
||||||
ApnPreference pref = new ApnPreference(this);
|
ApnPreference pref = new ApnPreference(getActivity());
|
||||||
|
|
||||||
pref.setKey(key);
|
pref.setKey(key);
|
||||||
pref.setTitle(name);
|
pref.setTitle(name);
|
||||||
@@ -228,16 +246,18 @@ public class ApnSettings extends PreferenceActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
super.onCreateOptionsMenu(menu);
|
if (!mUnavailable) {
|
||||||
menu.add(0, MENU_NEW, 0,
|
menu.add(0, MENU_NEW, 0,
|
||||||
getResources().getString(R.string.menu_new))
|
getResources().getString(R.string.menu_new))
|
||||||
.setIcon(android.R.drawable.ic_menu_add)
|
.setIcon(android.R.drawable.ic_menu_add)
|
||||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||||
menu.add(0, MENU_RESTORE, 0,
|
menu.add(0, MENU_RESTORE, 0,
|
||||||
getResources().getString(R.string.menu_restore))
|
getResources().getString(R.string.menu_restore))
|
||||||
.setIcon(android.R.drawable.ic_menu_upload);
|
.setIcon(android.R.drawable.ic_menu_upload);
|
||||||
return true;
|
}
|
||||||
|
|
||||||
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -329,9 +349,9 @@ public class ApnSettings extends PreferenceActivity implements
|
|||||||
fillList();
|
fillList();
|
||||||
getPreferenceScreen().setEnabled(true);
|
getPreferenceScreen().setEnabled(true);
|
||||||
mRestoreDefaultApnMode = false;
|
mRestoreDefaultApnMode = false;
|
||||||
dismissDialog(DIALOG_RESTORE_DEFAULTAPN);
|
removeDialog(DIALOG_RESTORE_DEFAULTAPN);
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
ApnSettings.this,
|
getActivity(),
|
||||||
getResources().getString(
|
getResources().getString(
|
||||||
R.string.restore_default_apn_completed),
|
R.string.restore_default_apn_completed),
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
@@ -362,20 +382,13 @@ public class ApnSettings extends PreferenceActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Dialog onCreateDialog(int id) {
|
public Dialog onCreateDialog(int id) {
|
||||||
if (id == DIALOG_RESTORE_DEFAULTAPN) {
|
if (id == DIALOG_RESTORE_DEFAULTAPN) {
|
||||||
ProgressDialog dialog = new ProgressDialog(this);
|
ProgressDialog dialog = new ProgressDialog(getActivity());
|
||||||
dialog.setMessage(getResources().getString(R.string.restore_default_apn));
|
dialog.setMessage(getResources().getString(R.string.restore_default_apn));
|
||||||
dialog.setCancelable(false);
|
dialog.setCancelable(false);
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPrepareDialog(int id, Dialog dialog) {
|
|
||||||
if (id == DIALOG_RESTORE_DEFAULTAPN) {
|
|
||||||
getPreferenceScreen().setEnabled(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -98,5 +98,6 @@ public class Settings extends SettingsActivity {
|
|||||||
public static class QuickLaunchSettingsActivity extends SettingsActivity { /* empty */ }
|
public static class QuickLaunchSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
|
|
||||||
public static class TopLevelSettings extends SettingsActivity { /* empty */ }
|
public static class TopLevelSettings extends SettingsActivity { /* empty */ }
|
||||||
|
public static class ApnSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -184,8 +184,13 @@ public class SettingsActivity extends Activity
|
|||||||
* that fragment.
|
* that fragment.
|
||||||
*/
|
*/
|
||||||
public static final String EXTRA_SHOW_FRAGMENT_TITLE = ":settings:show_fragment_title";
|
public static final String EXTRA_SHOW_FRAGMENT_TITLE = ":settings:show_fragment_title";
|
||||||
public static final String EXTRA_SHOW_FRAGMENT_TITLE_RESID = ":settings:show_fragment_title_resid";
|
public static final String EXTRA_SHOW_FRAGMENT_TITLE_RESID =
|
||||||
public static final String EXTRA_SHOW_FRAGMENT_AS_SHORTCUT = ":settings:show_fragment_as_shortcut";
|
":settings:show_fragment_title_resid";
|
||||||
|
public static final String EXTRA_SHOW_FRAGMENT_AS_SHORTCUT =
|
||||||
|
":settings:show_fragment_as_shortcut";
|
||||||
|
|
||||||
|
public static final String EXTRA_SHOW_FRAGMENT_AS_SUBSETTING =
|
||||||
|
":settings:show_fragment_as_subsetting";
|
||||||
|
|
||||||
private static final String META_DATA_KEY_FRAGMENT_CLASS =
|
private static final String META_DATA_KEY_FRAGMENT_CLASS =
|
||||||
"com.android.settings.FRAGMENT_CLASS";
|
"com.android.settings.FRAGMENT_CLASS";
|
||||||
@@ -290,7 +295,8 @@ public class SettingsActivity extends Activity
|
|||||||
NotificationAppList.class.getName(),
|
NotificationAppList.class.getName(),
|
||||||
AppNotificationSettings.class.getName(),
|
AppNotificationSettings.class.getName(),
|
||||||
OtherSoundSettings.class.getName(),
|
OtherSoundSettings.class.getName(),
|
||||||
QuickLaunchSettings.class.getName()
|
QuickLaunchSettings.class.getName(),
|
||||||
|
ApnSettings.class.getName()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -495,12 +501,15 @@ public class SettingsActivity extends Activity
|
|||||||
final String className = cn.getClassName();
|
final String className = cn.getClassName();
|
||||||
|
|
||||||
mIsShowingDashboard = className.equals(Settings.class.getName());
|
mIsShowingDashboard = className.equals(Settings.class.getName());
|
||||||
final boolean isSubSettings = className.equals(SubSettings.class.getName());
|
|
||||||
|
|
||||||
// If this is a sub settings or not the main Dashboard and not a Shortcut and an initial
|
// This is a "Sub Settings" when:
|
||||||
// Fragment then apply the SubSettings theme for the ActionBar content insets
|
// - this is a real SubSettings
|
||||||
if (isSubSettings ||
|
// - or :settings:show_fragment_as_subsetting is passed to the Intent
|
||||||
(!mIsShowingDashboard && !mIsShortcut && (initialFragmentName != null))) {
|
final boolean isSubSettings = className.equals(SubSettings.class.getName()) ||
|
||||||
|
intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, false);
|
||||||
|
|
||||||
|
// If this is a sub settings, then apply the SubSettings Theme for the ActionBar content insets
|
||||||
|
if (isSubSettings) {
|
||||||
// Check also that we are not a Theme Dialog as we don't want to override them
|
// Check also that we are not a Theme Dialog as we don't want to override them
|
||||||
final int themeResId = getThemeResId();
|
final int themeResId = getThemeResId();
|
||||||
if (themeResId != R.style.Theme_DialogWhenLarge &&
|
if (themeResId != R.style.Theme_DialogWhenLarge &&
|
||||||
@@ -550,6 +559,9 @@ public class SettingsActivity extends Activity
|
|||||||
} else if (isSubSettings) {
|
} else if (isSubSettings) {
|
||||||
mDisplayHomeAsUpEnabled = true;
|
mDisplayHomeAsUpEnabled = true;
|
||||||
mDisplaySearch = true;
|
mDisplaySearch = true;
|
||||||
|
} else {
|
||||||
|
mDisplayHomeAsUpEnabled = false;
|
||||||
|
mDisplaySearch = false;
|
||||||
}
|
}
|
||||||
setTitleFromIntent(intent);
|
setTitleFromIntent(intent);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user