summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabrice Di Meglio <fdimeglio@google.com>2014-01-17 19:17:58 -0800
committerFabrice Di Meglio <fdimeglio@google.com>2014-02-03 16:36:46 -0800
commit263bcc8b732dbb47d3ce63904e0e05191fabbad6 (patch)
treedc8fd51052ac94e418473d378c1244cb42594665
parentaf79ddb358ff6ed078708ce5995da9ff269f1679 (diff)
downloadpackages_apps_Settings-263bcc8b732dbb47d3ce63904e0e05191fabbad6.zip
packages_apps_Settings-263bcc8b732dbb47d3ce63904e0e05191fabbad6.tar.gz
packages_apps_Settings-263bcc8b732dbb47d3ce63904e0e05191fabbad6.tar.bz2
Use Drawer in Settings app
- get rid of PreferenceActivity as much as we can and use fragments instead - add Drawer widget - add Dashboard high level entry into the Drawer (but this is work in progress and would be done in another CL) - add bypass of fragment's Header validation when launched from the Drawer but *force* validation if external call thru an Intent Be aware that WifiPickerActivity should remain for now a PreferenceActivity. It is used by SetupWizard and should not trigger running the SettingsActivity's header building code. SetupWizard is a Home during the provisionnig process and then deactivate itself as a Home but would make the Home header to appear in the Drawer (because momentarily we would have two Home). Also, verified that: - the WiFi settings still work when called from SetupWizard - when you have multiple Launchers, the Home header will appear in the list of Headers in the Drawer Change-Id: I407a5e0fdd843ad7615d3d511c416a44e3d97c90
-rw-r--r--AndroidManifest.xml10
-rw-r--r--res/drawable-hdpi/ic_drawer_am.pngbin0 -> 2842 bytes
-rw-r--r--res/drawable-mdpi/ic_drawer_am.pngbin0 -> 2837 bytes
-rw-r--r--res/drawable-xhdpi/ic_drawer_am.pngbin0 -> 1056 bytes
-rw-r--r--res/drawable/ic_drawer.xml24
-rw-r--r--res/layout/dashboard.xml29
-rw-r--r--res/layout/settings_main.xml81
-rw-r--r--res/values-sw720dp/dimens.xml5
-rwxr-xr-xres/values/dimens.xml5
-rw-r--r--res/values/strings.xml11
-rw-r--r--res/values/styles.xml6
-rw-r--r--res/xml/device_info_settings.xml6
-rw-r--r--res/xml/settings_headers.xml7
-rw-r--r--src/com/android/settings/ApnEditor.java57
-rw-r--r--src/com/android/settings/ApnSettings.java39
-rw-r--r--src/com/android/settings/ButtonBarHandler.java2
-rw-r--r--src/com/android/settings/ChooseLockGeneric.java5
-rw-r--r--src/com/android/settings/ChooseLockPassword.java17
-rw-r--r--src/com/android/settings/ChooseLockPattern.java6
-rw-r--r--src/com/android/settings/ConfirmLockPassword.java14
-rw-r--r--src/com/android/settings/ConfirmLockPattern.java5
-rw-r--r--src/com/android/settings/CreateShortcut.java1
-rw-r--r--src/com/android/settings/CryptKeeperSettings.java3
-rw-r--r--src/com/android/settings/DataUsageSummary.java12
-rw-r--r--src/com/android/settings/DreamSettings.java1
-rw-r--r--src/com/android/settings/HomeSettings.java3
-rw-r--r--src/com/android/settings/IccLockSettings.java23
-rw-r--r--src/com/android/settings/MasterClear.java3
-rw-r--r--src/com/android/settings/Settings.java1088
-rw-r--r--src/com/android/settings/SettingsActivity.java1770
-rw-r--r--src/com/android/settings/SettingsPreferenceFragment.java11
-rw-r--r--src/com/android/settings/SubSettings.java2
-rw-r--r--src/com/android/settings/TestingSettings.java6
-rw-r--r--src/com/android/settings/UserDictionarySettings.java5
-rw-r--r--src/com/android/settings/Utils.java3
-rw-r--r--src/com/android/settings/WirelessSettings.java2
-rw-r--r--src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java6
-rw-r--r--src/com/android/settings/accounts/AccountPreferenceBase.java1
-rw-r--r--src/com/android/settings/accounts/AddAccountSettings.java3
-rw-r--r--src/com/android/settings/accounts/ChooseAccountFragment.java (renamed from src/com/android/settings/accounts/ChooseAccountActivity.java)26
-rw-r--r--src/com/android/settings/accounts/ManageAccountsSettings.java6
-rw-r--r--src/com/android/settings/accounts/SyncSettingsActivity.java12
-rw-r--r--src/com/android/settings/applications/AppOpsCategory.java6
-rw-r--r--src/com/android/settings/applications/AppOpsDetails.java6
-rw-r--r--src/com/android/settings/applications/InstalledAppDetails.java6
-rw-r--r--src/com/android/settings/applications/InstalledAppDetailsTop.java24
-rw-r--r--src/com/android/settings/applications/ManageApplications.java10
-rw-r--r--src/com/android/settings/applications/ProcessStatsDetail.java2
-rw-r--r--src/com/android/settings/applications/ProcessStatsUi.java4
-rw-r--r--src/com/android/settings/applications/RunningProcessesView.java8
-rwxr-xr-xsrc/com/android/settings/bluetooth/BluetoothSettings.java63
-rw-r--r--src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java2
-rw-r--r--src/com/android/settings/dashboard/DashboardSummary.java41
-rw-r--r--src/com/android/settings/deviceinfo/Memory.java6
-rw-r--r--src/com/android/settings/deviceinfo/Status.java89
-rw-r--r--src/com/android/settings/deviceinfo/StorageVolumePreferenceCategory.java4
-rw-r--r--src/com/android/settings/fuelgauge/PowerUsageDetail.java25
-rw-r--r--src/com/android/settings/fuelgauge/PowerUsageSummary.java8
-rw-r--r--src/com/android/settings/inputmethod/InputMethodAndSubtypeEnablerActivity.java6
-rw-r--r--src/com/android/settings/inputmethod/InputMethodPreference.java16
-rw-r--r--src/com/android/settings/inputmethod/KeyboardLayoutDialogFragment.java2
-rw-r--r--src/com/android/settings/inputmethod/UserDictionaryAddWordFragment.java6
-rw-r--r--src/com/android/settings/location/LocationSettings.java79
-rw-r--r--src/com/android/settings/location/RecentLocationApps.java6
-rw-r--r--src/com/android/settings/nfc/AndroidBeam.java6
-rw-r--r--src/com/android/settings/print/PrintServiceSettingsFragment.java11
-rw-r--r--src/com/android/settings/quicklaunch/QuickLaunchSettings.java53
-rw-r--r--src/com/android/settings/tts/TextToSpeechSettings.java20
-rw-r--r--src/com/android/settings/tts/TtsEnginePreference.java12
-rw-r--r--src/com/android/settings/users/UserSettings.java6
-rwxr-xr-xsrc/com/android/settings/wfd/WifiDisplaySettings.java6
-rw-r--r--src/com/android/settings/wifi/WifiInfo.java7
-rw-r--r--src/com/android/settings/wifi/WifiPickerActivity.java5
-rw-r--r--src/com/android/settings/wifi/WifiSettings.java74
-rw-r--r--src/com/android/settings/wifi/p2p/WifiP2pSettings.java9
-rw-r--r--tests/src/com/android/settings/SettingsHookTests.java7
76 files changed, 2466 insertions, 1485 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index eba2303..ec01534 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -79,8 +79,9 @@
<!-- Settings -->
<activity android:name="Settings"
- android:label="@string/settings_label_launcher"
+ android:uiOptions="splitActionBarWhenNarrow"
android:taskAffinity="com.android.settings"
+ android:label="@string/settings_label_launcher"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -1535,10 +1536,13 @@
</intent-filter>
</activity>
- <activity android:name="com.android.settings.accounts.ChooseAccountActivity"
+ <activity android:name="com.android.settings.Settings$ChooseAccountActivity"
android:label="@string/header_add_an_account"
android:configChanges="orientation|keyboardHidden|screenSize"
- android:theme="@android:style/Theme.Holo.DialogWhenLarge"/>
+ android:theme="@android:style/Theme.Holo.DialogWhenLarge">
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.accounts.ChooseAccountFragment" />
+ </activity>
<activity android:name=".CryptKeeper"
android:immersive="true"
diff --git a/res/drawable-hdpi/ic_drawer_am.png b/res/drawable-hdpi/ic_drawer_am.png
new file mode 100644
index 0000000..ff7b1de
--- /dev/null
+++ b/res/drawable-hdpi/ic_drawer_am.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_drawer_am.png b/res/drawable-mdpi/ic_drawer_am.png
new file mode 100644
index 0000000..fb681ba
--- /dev/null
+++ b/res/drawable-mdpi/ic_drawer_am.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_drawer_am.png b/res/drawable-xhdpi/ic_drawer_am.png
new file mode 100644
index 0000000..b9bc3d7
--- /dev/null
+++ b/res/drawable-xhdpi/ic_drawer_am.png
Binary files differ
diff --git a/res/drawable/ic_drawer.xml b/res/drawable/ic_drawer.xml
new file mode 100644
index 0000000..f228d47
--- /dev/null
+++ b/res/drawable/ic_drawer.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * Copyright 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.
+ */
+-->
+
+<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
+ android:src="@drawable/ic_drawer_am"
+ android:autoMirrored="true">
+</bitmap>
+
diff --git a/res/layout/dashboard.xml b/res/layout/dashboard.xml
new file mode 100644
index 0000000..547533a
--- /dev/null
+++ b/res/layout/dashboard.xml
@@ -0,0 +1,29 @@
+<?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/dashboard"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <TextView android:id="@+id/dash_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:text="@string/dashboard_wip"
+ />
+
+</FrameLayout>
diff --git a/res/layout/settings_main.xml b/res/layout/settings_main.xml
new file mode 100644
index 0000000..f34ece8
--- /dev/null
+++ b/res/layout/settings_main.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 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.
+*/
+-->
+
+<android.support.v4.widget.DrawerLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/drawer_layout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <LinearLayout
+ android:orientation="vertical"
+ android:layout_height="match_parent"
+ android:layout_width="match_parent">
+
+ <android.preference.PreferenceFrameLayout android:id="@+id/prefs"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ />
+
+ <RelativeLayout android:id="@+id/button_bar"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:layout_weight="0"
+ android:visibility="gone">
+
+ <Button android:id="@+id/back_button"
+ android:layout_width="150dip"
+ android:layout_height="wrap_content"
+ android:layout_margin="5dip"
+ android:layout_alignParentStart="true"
+ android:text="@*android:string/back_button_label"
+ />
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentEnd="true">
+
+ <Button android:id="@+id/skip_button"
+ android:layout_width="150dip"
+ android:layout_height="wrap_content"
+ android:layout_margin="5dip"
+ android:text="@*android:string/skip_button_label"
+ android:visibility="gone"
+ />
+
+ <Button android:id="@+id/next_button"
+ android:layout_width="150dip"
+ android:layout_height="wrap_content"
+ android:layout_margin="5dip"
+ android:text="@*android:string/next_button_label"
+ />
+ </LinearLayout>
+ </RelativeLayout>
+
+ </LinearLayout>
+
+ <ListView android:id="@+id/headers_drawer"
+ android:layout_width="300dp"
+ android:layout_height="match_parent"
+ android:layout_gravity="start"
+ android:background="#ff333333"/>
+
+</android.support.v4.widget.DrawerLayout>
diff --git a/res/values-sw720dp/dimens.xml b/res/values-sw720dp/dimens.xml
index 9c6cc25..06a7197 100644
--- a/res/values-sw720dp/dimens.xml
+++ b/res/values-sw720dp/dimens.xml
@@ -20,4 +20,9 @@
<integer name="keyguard_appwidget_picker_cols">2</integer>
<dimen name="keyguard_appwidget_picker_width">720dip</dimen>
<dimen name="settings_side_margin">32dp</dimen>
+
+ <!-- Weight of the left pane in a multi-pane preference layout. -->
+ <integer name="preferences_left_pane_weight">1</integer>
+ <!-- Weight of the right pane in a multi-pane preference layout. So the split is 1:2 -->
+ <integer name="preferences_right_pane_weight">2</integer>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 1294483..3581d6a 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -73,4 +73,9 @@
<dimen name="captioning_preview_height">200dp</dimen>
<dimen name="settings_side_margin">@*android:dimen/preference_fragment_padding_side</dimen>
+
+ <!-- Weight of the left pane in a multi-pane preference layout. -->
+ <integer name="preferences_left_pane_weight">4</integer>
+ <!-- Weight of the right pane in a multi-pane preference layout. So the split is 40:60 -->
+ <integer name="preferences_right_pane_weight">6</integer>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4fc708f..6366cc5 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4982,4 +4982,15 @@
<string name="enable_nfc">NFC is not enabled and is required for NFC Unlock. Please turn on NFC.</string>
<string name="ok">NFC Settings</string>
+ <!--Drawer strings-->
+ <!-- Text to describe the "open drawer" action for accessibility purpose [CHAR LIMIT=50] -->
+ <string name="drawer_open">Open navigation drawer</string>
+ <!-- Text to describe the "close drawer" action for accessibility purpose [CHAR LIMIT=50] -->
+ <string name="drawer_close">Close navigation drawer</string>
+
+ <!--Dashboard strings-->
+ <!-- Text to describe the dashboard entry into the Drawer [CHAR LIMIT=16] -->
+ <string name="dashboard_title">Overview</string>
+ <string name="dashboard_wip" translatable="false">Overview - work in progress\n\nUse the Drawer on the left to see the settings list</string>
+
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index eee2cd9..3416b2c 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -117,6 +117,12 @@
<item name="android:scrollbarStyle">outsideOverlay</item>
</style>
+ <style name="SettingsPreferenceHeaderPanel" parent="@*android:style/PreferenceHeaderPanel">
+ </style>
+
+ <style name="SettingsPreferenceHeaderList" parent="@*android:style/PreferenceHeaderList">
+ </style>
+
<style name="VertDivider">
<item name="android:layout_width">@dimen/vert_divider_width</item>
<item name="android:layout_height">fill_parent</item>
diff --git a/res/xml/device_info_settings.xml b/res/xml/device_info_settings.xml
index 07abe41..23d4abc 100644
--- a/res/xml/device_info_settings.xml
+++ b/res/xml/device_info_settings.xml
@@ -35,10 +35,8 @@
<!-- Device status - launches activity -->
<PreferenceScreen android:key="status_info"
android:title="@string/device_status"
- android:summary="@string/device_status_summary">
- <intent android:action="android.intent.action.MAIN"
- android:targetPackage="com.android.settings"
- android:targetClass="com.android.settings.deviceinfo.Status" />
+ android:summary="@string/device_status_summary"
+ android:fragment="com.android.settings.deviceinfo.Status">
</PreferenceScreen>
<!-- Legal Information -->
diff --git a/res/xml/settings_headers.xml b/res/xml/settings_headers.xml
index 8744328..8b512fc 100644
--- a/res/xml/settings_headers.xml
+++ b/res/xml/settings_headers.xml
@@ -22,6 +22,13 @@
<header android:id="@+id/wireless_section"
android:title="@string/header_category_wireless_networks" />
+ <!-- Dashboard -->
+ <!--TODO: android:icon="@drawable/ic_settings_dashboard"-->
+ <header
+ android:id="@+id/dashboard"
+ android:fragment="com.android.settings.dashboard.DashboardSummary"
+ android:title="@string/dashboard_title" />
+
<!-- Wifi -->
<header
android:id="@+id/wifi_settings"
diff --git a/src/com/android/settings/ApnEditor.java b/src/com/android/settings/ApnEditor.java
index 2da2d76..70f03ae 100644
--- a/src/com/android/settings/ApnEditor.java
+++ b/src/com/android/settings/ApnEditor.java
@@ -16,6 +16,7 @@
package com.android.settings;
+import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ContentUris;
@@ -31,21 +32,18 @@ import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
import android.provider.Telephony;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
+import android.view.MenuInflater;
import android.view.MenuItem;
-import com.android.internal.telephony.Phone;
-import com.android.internal.telephony.PhoneConstants;
-import com.android.internal.telephony.RILConstants;
import com.android.internal.telephony.TelephonyProperties;
-public class ApnEditor extends PreferenceActivity
+public class ApnEditor extends SettingsPreferenceFragment
implements SharedPreferences.OnSharedPreferenceChangeListener,
Preference.OnPreferenceChangeListener {
@@ -148,7 +146,7 @@ public class ApnEditor extends PreferenceActivity
@Override
- protected void onCreate(Bundle icicle) {
+ public void onCreate(Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.apn_editor);
@@ -188,7 +186,7 @@ public class ApnEditor extends PreferenceActivity
mRes = getResources();
- final Intent intent = getIntent();
+ final Intent intent = getActivity().getIntent();
final String action = intent.getAction();
mFirstTime = icicle == null;
@@ -208,24 +206,24 @@ public class ApnEditor extends PreferenceActivity
// original activity if they requested a result.
if (mUri == null) {
Log.w(TAG, "Failed to insert new telephony provider into "
- + getIntent().getData());
+ + getActivity().getIntent().getData());
finish();
return;
}
// The new entry was created, so assume all will end well and
// set the result to be returned.
- setResult(RESULT_OK, (new Intent()).setAction(mUri.toString()));
+ getActivity().setResult(Activity.RESULT_OK, (new Intent()).setAction(mUri.toString()));
} else {
finish();
return;
}
- mCursor = managedQuery(mUri, sProjection, null, null);
+ mCursor = getActivity().getContentResolver().query(mUri, sProjection, null, null, null);
mCursor.moveToFirst();
- mTelephonyManager = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
+ mTelephonyManager = (TelephonyManager) getSystemService(Activity.TELEPHONY_SERVICE);
fillUi();
}
@@ -441,8 +439,8 @@ public class ApnEditor extends PreferenceActivity
}
@Override
- public boolean onCreateOptionsMenu(Menu menu) {
- super.onCreateOptionsMenu(menu);
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ super.onCreateOptionsMenu(menu, inflater);
// If it's a new APN, then cancel will delete the new entry in onPause
if (!mNewApn) {
menu.add(0, MENU_DELETE, 0, R.string.menu_delete)
@@ -452,7 +450,6 @@ public class ApnEditor extends PreferenceActivity
.setIcon(android.R.drawable.ic_menu_save);
menu.add(0, MENU_CANCEL, 0, R.string.menu_cancel)
.setIcon(android.R.drawable.ic_menu_close_clear_cancel);
- return true;
}
@Override
@@ -477,20 +474,7 @@ public class ApnEditor extends PreferenceActivity
}
@Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- switch (keyCode) {
- case KeyEvent.KEYCODE_BACK: {
- if (validateAndSave(false)) {
- finish();
- }
- return true;
- }
- }
- return super.onKeyDown(keyCode, event);
- }
-
- @Override
- protected void onSaveInstanceState(Bundle icicle) {
+ public void onSaveInstanceState(Bundle icicle) {
super.onSaveInstanceState(icicle);
if (validateAndSave(true)) {
icicle.putInt(SAVED_POS, mCursor.getInt(ID_INDEX));
@@ -598,12 +582,12 @@ public class ApnEditor extends PreferenceActivity
}
@Override
- protected Dialog onCreateDialog(int id) {
+ public Dialog onCreateDialog(int id) {
if (id == ERROR_DIALOG_ID) {
String msg = getErrorMsg();
- return new AlertDialog.Builder(this)
+ return new AlertDialog.Builder(getActivity())
.setTitle(R.string.error_title)
.setPositiveButton(android.R.string.ok, null)
.setMessage(msg)
@@ -613,19 +597,6 @@ public class ApnEditor extends PreferenceActivity
return super.onCreateDialog(id);
}
- @Override
- protected void onPrepareDialog(int id, Dialog dialog) {
- super.onPrepareDialog(id, dialog);
-
- if (id == ERROR_DIALOG_ID) {
- String msg = getErrorMsg();
-
- if (msg != null) {
- ((AlertDialog)dialog).setMessage(msg);
- }
- }
- }
-
private void deleteApn() {
getContentResolver().delete(mUri, null, null);
finish();
diff --git a/src/com/android/settings/ApnSettings.java b/src/com/android/settings/ApnSettings.java
index 3fbb5e3..294d50f 100644
--- a/src/com/android/settings/ApnSettings.java
+++ b/src/com/android/settings/ApnSettings.java
@@ -33,12 +33,12 @@ import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.provider.Telephony;
import android.util.Log;
import android.view.Menu;
+import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.Toast;
@@ -49,7 +49,7 @@ import com.android.internal.telephony.TelephonyProperties;
import java.util.ArrayList;
-public class ApnSettings extends PreferenceActivity implements
+public class ApnSettings extends SettingsPreferenceFragment implements
Preference.OnPreferenceChangeListener {
static final String TAG = "ApnSettings";
@@ -116,7 +116,7 @@ public class ApnSettings extends PreferenceActivity implements
}
@Override
- protected void onCreate(Bundle icicle) {
+ public void onCreate(Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.apn_settings);
@@ -127,10 +127,10 @@ public class ApnSettings extends PreferenceActivity implements
}
@Override
- protected void onResume() {
+ public void onResume() {
super.onResume();
- registerReceiver(mMobileStateReceiver, mMobileStateFilter);
+ getActivity().registerReceiver(mMobileStateReceiver, mMobileStateFilter);
if (!mRestoreDefaultApnMode) {
fillList();
@@ -140,14 +140,14 @@ public class ApnSettings extends PreferenceActivity implements
}
@Override
- protected void onPause() {
+ public void onPause() {
super.onPause();
- unregisterReceiver(mMobileStateReceiver);
+ getActivity().unregisterReceiver(mMobileStateReceiver);
}
@Override
- protected void onDestroy() {
+ public void onDestroy() {
super.onDestroy();
if (mRestoreDefaultApnThread != null) {
@@ -178,7 +178,7 @@ public class ApnSettings extends PreferenceActivity implements
String key = cursor.getString(ID_INDEX);
String type = cursor.getString(TYPES_INDEX);
- ApnPreference pref = new ApnPreference(this);
+ ApnPreference pref = new ApnPreference(getActivity());
pref.setKey(key);
pref.setTitle(name);
@@ -207,8 +207,8 @@ public class ApnSettings extends PreferenceActivity implements
}
@Override
- public boolean onCreateOptionsMenu(Menu menu) {
- super.onCreateOptionsMenu(menu);
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ super.onCreateOptionsMenu(menu, inflater);
menu.add(0, MENU_NEW, 0,
getResources().getString(R.string.menu_new))
.setIcon(android.R.drawable.ic_menu_add)
@@ -216,7 +216,6 @@ public class ApnSettings extends PreferenceActivity implements
menu.add(0, MENU_RESTORE, 0,
getResources().getString(R.string.menu_restore))
.setIcon(android.R.drawable.ic_menu_upload);
- return true;
}
@Override
@@ -308,9 +307,9 @@ public class ApnSettings extends PreferenceActivity implements
fillList();
getPreferenceScreen().setEnabled(true);
mRestoreDefaultApnMode = false;
- dismissDialog(DIALOG_RESTORE_DEFAULTAPN);
+ removeDialog(DIALOG_RESTORE_DEFAULTAPN);
Toast.makeText(
- ApnSettings.this,
+ getActivity(),
getResources().getString(
R.string.restore_default_apn_completed),
Toast.LENGTH_LONG).show();
@@ -341,20 +340,14 @@ public class ApnSettings extends PreferenceActivity implements
}
@Override
- protected Dialog onCreateDialog(int id) {
+ public Dialog onCreateDialog(int id) {
if (id == DIALOG_RESTORE_DEFAULTAPN) {
- ProgressDialog dialog = new ProgressDialog(this);
+ getPreferenceScreen().setEnabled(false);
+ ProgressDialog dialog = new ProgressDialog(getActivity());
dialog.setMessage(getResources().getString(R.string.restore_default_apn));
dialog.setCancelable(false);
return dialog;
}
return null;
}
-
- @Override
- protected void onPrepareDialog(int id, Dialog dialog) {
- if (id == DIALOG_RESTORE_DEFAULTAPN) {
- getPreferenceScreen().setEnabled(false);
- }
- }
}
diff --git a/src/com/android/settings/ButtonBarHandler.java b/src/com/android/settings/ButtonBarHandler.java
index d61da13..85e39d1 100644
--- a/src/com/android/settings/ButtonBarHandler.java
+++ b/src/com/android/settings/ButtonBarHandler.java
@@ -19,7 +19,7 @@ import android.widget.Button;
/**
* Interface letting {@link SettingsPreferenceFragment} access to bottom bar inside
- * {@link android.preference.PreferenceActivity}.
+ * {@link SettingsActivity}.
*/
public interface ButtonBarHandler {
public boolean hasNextButton();
diff --git a/src/com/android/settings/ChooseLockGeneric.java b/src/com/android/settings/ChooseLockGeneric.java
index 49de366..a92f514 100644
--- a/src/com/android/settings/ChooseLockGeneric.java
+++ b/src/com/android/settings/ChooseLockGeneric.java
@@ -17,7 +17,6 @@
package com.android.settings;
import android.app.Activity;
-import android.app.Fragment;
import android.app.PendingIntent;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
@@ -28,7 +27,6 @@ import android.os.Process;
import android.os.UserHandle;
import android.os.UserManager;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen;
import android.security.KeyStore;
import android.util.EventLog;
@@ -38,13 +36,12 @@ import android.view.ViewGroup;
import android.widget.ListView;
import com.android.internal.widget.LockPatternUtils;
-import com.android.settings.ConfirmLockPattern.ConfirmLockPatternFragment;
import java.util.List;
import libcore.util.MutableBoolean;
-public class ChooseLockGeneric extends PreferenceActivity {
+public class ChooseLockGeneric extends SettingsActivity {
@Override
public Intent getIntent() {
diff --git a/src/com/android/settings/ChooseLockPassword.java b/src/com/android/settings/ChooseLockPassword.java
index f43738f..4d102a4 100644
--- a/src/com/android/settings/ChooseLockPassword.java
+++ b/src/com/android/settings/ChooseLockPassword.java
@@ -19,7 +19,6 @@ package com.android.settings;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.PasswordEntryKeyboardHelper;
import com.android.internal.widget.PasswordEntryKeyboardView;
-import com.android.settings.ChooseLockGeneric.ChooseLockGenericFragment;
import android.app.Activity;
import android.app.Fragment;
@@ -29,7 +28,6 @@ import android.inputmethodservice.KeyboardView;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
-import android.preference.PreferenceActivity;
import android.text.Editable;
import android.text.InputType;
import android.text.Selection;
@@ -41,13 +39,12 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
-import android.view.accessibility.AccessibilityEvent;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
-public class ChooseLockPassword extends PreferenceActivity {
+public class ChooseLockPassword extends SettingsActivity {
public static final String PASSWORD_MIN_KEY = "lockscreen.password_min";
public static final String PASSWORD_MAX_KEY = "lockscreen.password_max";
public static final String PASSWORD_MIN_LETTERS_KEY = "lockscreen.password_min_letters";
@@ -79,7 +76,7 @@ public class ChooseLockPassword extends PreferenceActivity {
//WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
super.onCreate(savedInstanceState);
CharSequence msg = getText(R.string.lockpassword_choose_your_password_header);
- showBreadCrumbs(msg, msg);
+ setTitle(msg);
}
public static class ChooseLockPasswordFragment extends Fragment
@@ -137,9 +134,6 @@ public class ChooseLockPassword extends PreferenceActivity {
R.string.lockpassword_confirm_pins_dont_match,
R.string.lockpassword_continue_label);
- /**
- * @param headerMessage The message displayed at the top.
- */
Stage(int hintInAlpha, int hintInNumeric, int nextButtonText) {
this.alphaHint = hintInAlpha;
this.numericHint = hintInNumeric;
@@ -235,13 +229,12 @@ public class ChooseLockPassword extends PreferenceActivity {
updateStage(mUiStage);
}
}
- // Update the breadcrumb (title) if this is embedded in a PreferenceActivity
- if (activity instanceof PreferenceActivity) {
- final PreferenceActivity preferenceActivity = (PreferenceActivity) activity;
+ if (activity instanceof SettingsActivity) {
+ final SettingsActivity sa = (SettingsActivity) activity;
int id = mIsAlphaMode ? R.string.lockpassword_choose_your_password_header
: R.string.lockpassword_choose_your_pin_header;
CharSequence title = getText(id);
- preferenceActivity.showBreadCrumbs(title, title);
+ sa.setTitle(title);
}
return view;
diff --git a/src/com/android/settings/ChooseLockPattern.java b/src/com/android/settings/ChooseLockPattern.java
index 328312c..5a939aa 100644
--- a/src/com/android/settings/ChooseLockPattern.java
+++ b/src/com/android/settings/ChooseLockPattern.java
@@ -22,7 +22,6 @@ import com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockPatternView;
import com.android.internal.widget.LockPatternView.Cell;
-import com.android.settings.ChooseLockGeneric.ChooseLockGenericFragment;
import static com.android.internal.widget.LockPatternView.DisplayMode;
@@ -30,7 +29,6 @@ import android.app.Activity;
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
-import android.preference.PreferenceActivity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
@@ -49,7 +47,7 @@ import java.util.List;
* - asks for confirmation / restart
* - saves chosen password when confirmed
*/
-public class ChooseLockPattern extends PreferenceActivity {
+public class ChooseLockPattern extends SettingsActivity {
/**
* Used by the choose lock pattern wizard to indicate the wizard is
* finished, and each activity in the wizard should finish.
@@ -80,7 +78,7 @@ public class ChooseLockPattern extends PreferenceActivity {
// requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
CharSequence msg = getText(R.string.lockpassword_choose_your_pattern_header);
- showBreadCrumbs(msg, msg);
+ setTitle(msg);
}
@Override
diff --git a/src/com/android/settings/ConfirmLockPassword.java b/src/com/android/settings/ConfirmLockPassword.java
index d7402da..72da156 100644
--- a/src/com/android/settings/ConfirmLockPassword.java
+++ b/src/com/android/settings/ConfirmLockPassword.java
@@ -19,7 +19,6 @@ package com.android.settings;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.PasswordEntryKeyboardHelper;
import com.android.internal.widget.PasswordEntryKeyboardView;
-import com.android.settings.ChooseLockGeneric.ChooseLockGenericFragment;
import android.app.Activity;
import android.app.Fragment;
@@ -27,7 +26,6 @@ import android.app.admin.DevicePolicyManager;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
-import android.preference.PreferenceActivity;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
@@ -36,13 +34,12 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
-import android.view.accessibility.AccessibilityEvent;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
-public class ConfirmLockPassword extends PreferenceActivity {
+public class ConfirmLockPassword extends SettingsActivity {
@Override
public Intent getIntent() {
@@ -65,7 +62,7 @@ public class ConfirmLockPassword extends PreferenceActivity {
//WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
super.onCreate(savedInstanceState);
CharSequence msg = getText(R.string.lockpassword_confirm_your_password_header);
- showBreadCrumbs(msg, msg);
+ setTitle(msg);
}
public static class ConfirmLockPasswordFragment extends Fragment implements OnClickListener,
@@ -127,13 +124,12 @@ public class ConfirmLockPassword extends PreferenceActivity {
mPasswordEntry.setInputType(isAlpha ? currentType
: (InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD));
- // Update the breadcrumb (title) if this is embedded in a PreferenceActivity
- if (activity instanceof PreferenceActivity) {
- final PreferenceActivity preferenceActivity = (PreferenceActivity) activity;
+ if (activity instanceof SettingsActivity) {
+ final SettingsActivity sa = (SettingsActivity) activity;
int id = isAlpha ? R.string.lockpassword_confirm_your_password_header
: R.string.lockpassword_confirm_your_pin_header;
CharSequence title = getText(id);
- preferenceActivity.showBreadCrumbs(title, title);
+ sa.setTitle(title);
}
return view;
diff --git a/src/com/android/settings/ConfirmLockPattern.java b/src/com/android/settings/ConfirmLockPattern.java
index 3a1f06c..81b325b 100644
--- a/src/com/android/settings/ConfirmLockPattern.java
+++ b/src/com/android/settings/ConfirmLockPattern.java
@@ -27,7 +27,6 @@ import android.content.Intent;
import android.os.CountDownTimer;
import android.os.SystemClock;
import android.os.Bundle;
-import android.preference.PreferenceActivity;
import android.widget.TextView;
import android.view.LayoutInflater;
import android.view.View;
@@ -41,7 +40,7 @@ import java.util.List;
* Sets an activity result of {@link Activity#RESULT_OK} when the user
* successfully confirmed their pattern.
*/
-public class ConfirmLockPattern extends PreferenceActivity {
+public class ConfirmLockPattern extends SettingsActivity {
/**
* Names of {@link CharSequence} fields within the originating {@link Intent}
@@ -65,7 +64,7 @@ public class ConfirmLockPattern extends PreferenceActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
CharSequence msg = getText(R.string.lockpassword_confirm_your_pattern_header);
- showBreadCrumbs(msg, msg);
+ setTitle(msg);
}
@Override
diff --git a/src/com/android/settings/CreateShortcut.java b/src/com/android/settings/CreateShortcut.java
index f71df1d..0bf265f 100644
--- a/src/com/android/settings/CreateShortcut.java
+++ b/src/com/android/settings/CreateShortcut.java
@@ -19,7 +19,6 @@ package com.android.settings;
import android.app.LauncherActivity;
import android.content.Intent;
import android.content.pm.ResolveInfo;
-import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
diff --git a/src/com/android/settings/CryptKeeperSettings.java b/src/com/android/settings/CryptKeeperSettings.java
index 58d97a8..cedf530 100644
--- a/src/com/android/settings/CryptKeeperSettings.java
+++ b/src/com/android/settings/CryptKeeperSettings.java
@@ -30,7 +30,6 @@ import android.content.res.Resources;
import android.os.BatteryManager;
import android.os.Bundle;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
@@ -201,6 +200,6 @@ public class CryptKeeperSettings extends Fragment {
preference.setFragment(CryptKeeperConfirm.class.getName());
preference.setTitle(R.string.crypt_keeper_confirm_title);
preference.getExtras().putString("password", password);
- ((PreferenceActivity) getActivity()).onPreferenceStartFragment(null, preference);
+ ((SettingsActivity) getActivity()).onPreferenceStartFragment(null, preference);
}
}
diff --git a/src/com/android/settings/DataUsageSummary.java b/src/com/android/settings/DataUsageSummary.java
index db1ae29..90443bd 100644
--- a/src/com/android/settings/DataUsageSummary.java
+++ b/src/com/android/settings/DataUsageSummary.java
@@ -87,8 +87,6 @@ import android.os.ServiceManager;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
-import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.text.format.DateUtils;
@@ -548,8 +546,8 @@ public class DataUsageSummary extends Fragment {
return true;
}
case R.id.data_usage_menu_metered: {
- final PreferenceActivity activity = (PreferenceActivity) getActivity();
- activity.startPreferencePanel(DataUsageMeteredSettings.class.getCanonicalName(), null,
+ final SettingsActivity sa = (SettingsActivity) getActivity();
+ sa.startPreferencePanel(DataUsageMeteredSettings.class.getCanonicalName(), null,
R.string.data_usage_metered_title, null, this, 0);
return true;
}
@@ -886,14 +884,16 @@ public class DataUsageSummary extends Fragment {
private boolean getDataRoaming() {
final ContentResolver resolver = getActivity().getContentResolver();
- return Settings.Global.getInt(resolver, Settings.Global.DATA_ROAMING, 0) != 0;
+ return android.provider.Settings.Global.getInt(resolver,
+ android.provider.Settings.Global.DATA_ROAMING, 0) != 0;
}
private void setDataRoaming(boolean enabled) {
// TODO: teach telephony DataConnectionTracker to watch and apply
// updates when changed.
final ContentResolver resolver = getActivity().getContentResolver();
- Settings.Global.putInt(resolver, Settings.Global.DATA_ROAMING, enabled ? 1 : 0);
+ android.provider.Settings.Global.putInt(resolver,
+ android.provider.Settings.Global.DATA_ROAMING, enabled ? 1 : 0);
mMenuDataRoaming.setChecked(enabled);
}
diff --git a/src/com/android/settings/DreamSettings.java b/src/com/android/settings/DreamSettings.java
index cb91f39..f4e251e 100644
--- a/src/com/android/settings/DreamSettings.java
+++ b/src/com/android/settings/DreamSettings.java
@@ -26,7 +26,6 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
-import android.preference.PreferenceActivity;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
diff --git a/src/com/android/settings/HomeSettings.java b/src/com/android/settings/HomeSettings.java
index eb659e2..8697062 100644
--- a/src/com/android/settings/HomeSettings.java
+++ b/src/com/android/settings/HomeSettings.java
@@ -23,7 +23,6 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
-import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
@@ -138,7 +137,7 @@ public class HomeSettings extends SettingsPreferenceFragment {
if (mPrefs.size() < 2) {
if (mShowNotice) {
mShowNotice = false;
- Settings.requestHomeNotice();
+ SettingsActivity.requestHomeNotice();
}
finishFragment();
}
diff --git a/src/com/android/settings/IccLockSettings.java b/src/com/android/settings/IccLockSettings.java
index b988572..cb39020 100644
--- a/src/com/android/settings/IccLockSettings.java
+++ b/src/com/android/settings/IccLockSettings.java
@@ -27,7 +27,6 @@ import android.os.Handler;
import android.os.Message;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen;
import android.util.Log;
import android.widget.Toast;
@@ -45,7 +44,7 @@ import com.android.internal.telephony.TelephonyIntents;
* these operations.
*
*/
-public class IccLockSettings extends PreferenceActivity
+public class IccLockSettings extends SettingsPreferenceFragment
implements EditPinPreference.OnPinEnteredListener {
private static final String TAG = "IccLockSettings";
private static final boolean DBG = true;
@@ -141,7 +140,7 @@ public class IccLockSettings extends PreferenceActivity
}
@Override
- protected void onCreate(Bundle savedInstanceState) {
+ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Utils.isMonkeyRunning()) {
@@ -192,13 +191,13 @@ public class IccLockSettings extends PreferenceActivity
}
@Override
- protected void onResume() {
+ public void onResume() {
super.onResume();
// ACTION_SIM_STATE_CHANGED is sticky, so we'll receive current state after this call,
// which will call updatePreferences().
final IntentFilter filter = new IntentFilter(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
- registerReceiver(mSimStateReceiver, filter);
+ getActivity().registerReceiver(mSimStateReceiver, filter);
if (mDialogState != OFF_MODE) {
showPinDialog();
@@ -209,13 +208,13 @@ public class IccLockSettings extends PreferenceActivity
}
@Override
- protected void onPause() {
+ public void onPause() {
super.onPause();
- unregisterReceiver(mSimStateReceiver);
+ getActivity().unregisterReceiver(mSimStateReceiver);
}
@Override
- protected void onSaveInstanceState(Bundle out) {
+ public void onSaveInstanceState(Bundle out) {
// Need to store this state for slider open/close
// There is one case where the dialog is popped up by the preference
// framework. In that case, let the preference framework store the
@@ -359,8 +358,8 @@ public class IccLockSettings extends PreferenceActivity
if (success) {
mPinToggle.setChecked(mToState);
} else {
- Toast.makeText(this, getPinPasswordErrorMessage(attemptsRemaining), Toast.LENGTH_LONG)
- .show();
+ Toast.makeText(getActivity(),
+ getPinPasswordErrorMessage(attemptsRemaining), Toast.LENGTH_LONG).show();
}
mPinToggle.setEnabled(true);
resetDialogState();
@@ -368,11 +367,11 @@ public class IccLockSettings extends PreferenceActivity
private void iccPinChanged(boolean success, int attemptsRemaining) {
if (!success) {
- Toast.makeText(this, getPinPasswordErrorMessage(attemptsRemaining),
+ Toast.makeText(getActivity(), getPinPasswordErrorMessage(attemptsRemaining),
Toast.LENGTH_LONG)
.show();
} else {
- Toast.makeText(this, mRes.getString(R.string.sim_change_succeeded),
+ Toast.makeText(getActivity(), mRes.getString(R.string.sim_change_succeeded),
Toast.LENGTH_SHORT)
.show();
diff --git a/src/com/android/settings/MasterClear.java b/src/com/android/settings/MasterClear.java
index 262aca3..eaf29c6 100644
--- a/src/com/android/settings/MasterClear.java
+++ b/src/com/android/settings/MasterClear.java
@@ -31,7 +31,6 @@ import android.os.Environment;
import android.os.SystemProperties;
import android.os.UserManager;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -115,7 +114,7 @@ public class MasterClear extends Fragment {
preference.setFragment(MasterClearConfirm.class.getName());
preference.setTitle(R.string.master_clear_confirm_title);
preference.getExtras().putBoolean(ERASE_EXTERNAL_EXTRA, mExternalStorage.isChecked());
- ((PreferenceActivity) getActivity()).onPreferenceStartFragment(null, preference);
+ ((SettingsActivity) getActivity()).onPreferenceStartFragment(null, preference);
}
/**
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 91f7fbc..6bcfbee 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -16,1045 +16,77 @@
package com.android.settings;
-import android.accounts.Account;
-import android.accounts.AccountManager;
-import android.accounts.OnAccountsUpdateListener;
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.app.DialogFragment;
-import android.app.admin.DevicePolicyManager;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.SharedPreferences;
-import android.content.pm.ActivityInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.pm.ResolveInfo;
-import android.graphics.drawable.Drawable;
-import android.nfc.NfcAdapter;
-import android.os.Bundle;
-import android.os.INetworkManagementService;
-import android.os.RemoteException;
-import android.os.ServiceManager;
-import android.os.UserHandle;
-import android.os.UserManager;
-import android.preference.Preference;
-import android.preference.PreferenceActivity;
-import android.preference.PreferenceFragment;
-import android.text.TextUtils;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.ViewGroup;
-import android.widget.ArrayAdapter;
-import android.widget.Button;
-import android.widget.ImageButton;
-import android.widget.ImageView;
-import android.widget.ListAdapter;
-import android.widget.Switch;
-import android.widget.TextView;
-
-import com.android.internal.util.ArrayUtils;
-import com.android.settings.accessibility.AccessibilitySettings;
-import com.android.settings.accessibility.CaptionPropertiesFragment;
-import com.android.settings.accessibility.ToggleAccessibilityServicePreferenceFragment;
-import com.android.settings.accounts.AccountSyncSettings;
-import com.android.settings.accounts.AuthenticatorHelper;
-import com.android.settings.accounts.ManageAccountsSettings;
import com.android.settings.applications.AppOpsSummary;
-import com.android.settings.applications.ManageApplications;
-import com.android.settings.applications.ProcessStatsUi;
-import com.android.settings.bluetooth.BluetoothEnabler;
-import com.android.settings.bluetooth.BluetoothSettings;
-import com.android.settings.deviceinfo.Memory;
-import com.android.settings.deviceinfo.UsbSettings;
-import com.android.settings.fuelgauge.PowerUsageSummary;
-import com.android.settings.inputmethod.InputMethodAndLanguageSettings;
-import com.android.settings.inputmethod.KeyboardLayoutPickerFragment;
-import com.android.settings.inputmethod.SpellCheckersSettings;
-import com.android.settings.inputmethod.UserDictionaryList;
-import com.android.settings.location.LocationSettings;
-import com.android.settings.nfc.AndroidBeam;
-import com.android.settings.nfc.PaymentSettings;
-import com.android.settings.print.PrintJobSettingsFragment;
-import com.android.settings.print.PrintServiceSettingsFragment;
-import com.android.settings.print.PrintSettingsFragment;
-import com.android.settings.tts.TextToSpeechSettings;
-import com.android.settings.users.UserSettings;
-import com.android.settings.vpn2.VpnSettings;
-import com.android.settings.wfd.WifiDisplaySettings;
-import com.android.settings.wifi.AdvancedWifiSettings;
-import com.android.settings.wifi.WifiEnabler;
-import com.android.settings.wifi.WifiSettings;
-import com.android.settings.wifi.p2p.WifiP2pSettings;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
/**
- * Top-level settings activity to handle single pane and double pane UI layout.
+ * Top-level Settings activity
*/
-public class Settings extends PreferenceActivity
- implements ButtonBarHandler, OnAccountsUpdateListener {
-
- private static final String LOG_TAG = "Settings";
-
- private static final String META_DATA_KEY_HEADER_ID =
- "com.android.settings.TOP_LEVEL_HEADER_ID";
- private static final String META_DATA_KEY_FRAGMENT_CLASS =
- "com.android.settings.FRAGMENT_CLASS";
- private static final String EXTRA_UI_OPTIONS = "settings:ui_options";
- private static final String SAVE_KEY_CURRENT_HEADER = "com.android.settings.CURRENT_HEADER";
-
- private static boolean sShowNoHomeNotice = false;
-
- private String mFragmentClass;
- private int mTopLevelHeaderId;
- private Header mFirstHeader;
- private Header mCurrentHeader;
- private boolean mInLocalHeaderSwitch;
-
- // Show only these settings for restricted users
- private int[] SETTINGS_FOR_RESTRICTED = {
- R.id.wireless_section,
- R.id.wifi_settings,
- R.id.bluetooth_settings,
- R.id.data_usage_settings,
- R.id.wireless_settings,
- R.id.device_section,
- R.id.sound_settings,
- R.id.display_settings,
- R.id.storage_settings,
- R.id.application_settings,
- R.id.battery_settings,
- R.id.personal_section,
- R.id.location_settings,
- R.id.security_settings,
- R.id.language_settings,
- R.id.user_settings,
- R.id.account_settings,
- R.id.account_add,
- R.id.system_section,
- R.id.date_time_settings,
- R.id.about_settings,
- R.id.accessibility_settings,
- R.id.print_settings,
- R.id.nfc_payment_settings,
- R.id.home_settings
- };
-
- private SharedPreferences mDevelopmentPreferences;
- private SharedPreferences.OnSharedPreferenceChangeListener mDevelopmentPreferencesListener;
-
- // TODO: Update Call Settings based on airplane mode state.
-
- protected HashMap<Integer, Integer> mHeaderIndexMap = new HashMap<Integer, Integer>();
-
- private AuthenticatorHelper mAuthenticatorHelper;
- private Header mLastHeader;
- private boolean mListeningToAccountUpdates;
-
- private boolean mBatteryPresent = true;
- private BroadcastReceiver mBatteryInfoReceiver = new BroadcastReceiver() {
-
- @Override
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
- boolean batteryPresent = Utils.isBatteryPresent(intent);
-
- if (mBatteryPresent != batteryPresent) {
- mBatteryPresent = batteryPresent;
- invalidateHeaders();
- }
- }
- }
- };
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- if (getIntent().hasExtra(EXTRA_UI_OPTIONS)) {
- getWindow().setUiOptions(getIntent().getIntExtra(EXTRA_UI_OPTIONS, 0));
- }
-
- mAuthenticatorHelper = new AuthenticatorHelper();
- mAuthenticatorHelper.updateAuthDescriptions(this);
- mAuthenticatorHelper.onAccountsUpdated(this, null);
-
- mDevelopmentPreferences = getSharedPreferences(DevelopmentSettings.PREF_FILE,
- Context.MODE_PRIVATE);
-
- getMetaData();
- mInLocalHeaderSwitch = true;
- super.onCreate(savedInstanceState);
- mInLocalHeaderSwitch = false;
-
- if (!onIsHidingHeaders() && onIsMultiPane()) {
- highlightHeader(mTopLevelHeaderId);
- // Force the title so that it doesn't get overridden by a direct launch of
- // a specific settings screen.
- setTitle(R.string.settings_label);
- }
-
- // Retrieve any saved state
- if (savedInstanceState != null) {
- mCurrentHeader = savedInstanceState.getParcelable(SAVE_KEY_CURRENT_HEADER);
- }
-
- // If the current header was saved, switch to it
- if (savedInstanceState != null && mCurrentHeader != null) {
- //switchToHeaderLocal(mCurrentHeader);
- showBreadCrumbs(mCurrentHeader.title, null);
- }
-
- // Override up navigation for multi-pane, since we handle it in the fragment breadcrumbs
- if (onIsMultiPane()) {
- getActionBar().setDisplayHomeAsUpEnabled(false);
- getActionBar().setHomeButtonEnabled(false);
- }
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
-
- // Save the current fragment, if it is the same as originally launched
- if (mCurrentHeader != null) {
- outState.putParcelable(SAVE_KEY_CURRENT_HEADER, mCurrentHeader);
- }
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
- mDevelopmentPreferencesListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
- @Override
- public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
- invalidateHeaders();
- }
- };
- mDevelopmentPreferences.registerOnSharedPreferenceChangeListener(
- mDevelopmentPreferencesListener);
-
- ListAdapter listAdapter = getListAdapter();
- if (listAdapter instanceof HeaderAdapter) {
- ((HeaderAdapter) listAdapter).resume();
- }
- invalidateHeaders();
-
- registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
- }
-
- @Override
- public void onPause() {
- super.onPause();
-
- unregisterReceiver(mBatteryInfoReceiver);
-
- ListAdapter listAdapter = getListAdapter();
- if (listAdapter instanceof HeaderAdapter) {
- ((HeaderAdapter) listAdapter).pause();
- }
-
- mDevelopmentPreferences.unregisterOnSharedPreferenceChangeListener(
- mDevelopmentPreferencesListener);
- mDevelopmentPreferencesListener = null;
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- if (mListeningToAccountUpdates) {
- AccountManager.get(this).removeOnAccountsUpdatedListener(this);
- }
- }
-
- @Override
- public boolean onIsMultiPane() {
- return false;
- }
-
- private static final String[] ENTRY_FRAGMENTS = {
- WirelessSettings.class.getName(),
- WifiSettings.class.getName(),
- AdvancedWifiSettings.class.getName(),
- BluetoothSettings.class.getName(),
- TetherSettings.class.getName(),
- WifiP2pSettings.class.getName(),
- VpnSettings.class.getName(),
- DateTimeSettings.class.getName(),
- LocalePicker.class.getName(),
- InputMethodAndLanguageSettings.class.getName(),
- SpellCheckersSettings.class.getName(),
- UserDictionaryList.class.getName(),
- UserDictionarySettings.class.getName(),
- SoundSettings.class.getName(),
- DisplaySettings.class.getName(),
- DeviceInfoSettings.class.getName(),
- ManageApplications.class.getName(),
- ProcessStatsUi.class.getName(),
- NotificationStation.class.getName(),
- LocationSettings.class.getName(),
- SecuritySettings.class.getName(),
- PrivacySettings.class.getName(),
- DeviceAdminSettings.class.getName(),
- AccessibilitySettings.class.getName(),
- CaptionPropertiesFragment.class.getName(),
- com.android.settings.accessibility.ToggleInversionPreferenceFragment.class.getName(),
- com.android.settings.accessibility.ToggleContrastPreferenceFragment.class.getName(),
- com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment.class.getName(),
- TextToSpeechSettings.class.getName(),
- Memory.class.getName(),
- DevelopmentSettings.class.getName(),
- UsbSettings.class.getName(),
- AndroidBeam.class.getName(),
- WifiDisplaySettings.class.getName(),
- PowerUsageSummary.class.getName(),
- AccountSyncSettings.class.getName(),
- CryptKeeperSettings.class.getName(),
- DataUsageSummary.class.getName(),
- DreamSettings.class.getName(),
- UserSettings.class.getName(),
- NotificationAccessSettings.class.getName(),
- ManageAccountsSettings.class.getName(),
- PrintSettingsFragment.class.getName(),
- PrintJobSettingsFragment.class.getName(),
- TrustedCredentialsSettings.class.getName(),
- PaymentSettings.class.getName(),
- KeyboardLayoutPickerFragment.class.getName()
- };
-
- @Override
- protected boolean isValidFragment(String fragmentName) {
- // Almost all fragments are wrapped in this,
- // except for a few that have their own activities.
- for (int i = 0; i < ENTRY_FRAGMENTS.length; i++) {
- if (ENTRY_FRAGMENTS[i].equals(fragmentName)) return true;
- }
- return false;
- }
-
- private void switchToHeaderLocal(Header header) {
- mInLocalHeaderSwitch = true;
- switchToHeader(header);
- mInLocalHeaderSwitch = false;
- }
-
- @Override
- public void switchToHeader(Header header) {
- if (!mInLocalHeaderSwitch) {
- mCurrentHeader = null;
- }
- super.switchToHeader(header);
- }
-
- @Override
- public void onNewIntent(Intent intent) {
- super.onNewIntent(intent);
-
- // If it is not launched from history, then reset to top-level
- if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) {
- if (mFirstHeader != null && !onIsHidingHeaders() && onIsMultiPane()) {
- switchToHeaderLocal(mFirstHeader);
- }
- getListView().setSelectionFromTop(0, 0);
- }
- }
-
- private void highlightHeader(int id) {
- if (id != 0) {
- Integer index = mHeaderIndexMap.get(id);
- if (index != null) {
- getListView().setItemChecked(index, true);
- if (isMultiPane()) {
- getListView().smoothScrollToPosition(index);
- }
- }
- }
- }
-
- @Override
- public Intent getIntent() {
- Intent superIntent = super.getIntent();
- String startingFragment = getStartingFragmentClass(superIntent);
- // This is called from super.onCreate, isMultiPane() is not yet reliable
- // Do not use onIsHidingHeaders either, which relies itself on this method
- if (startingFragment != null && !onIsMultiPane()) {
- Intent modIntent = new Intent(superIntent);
- modIntent.putExtra(EXTRA_SHOW_FRAGMENT, startingFragment);
- Bundle args = superIntent.getExtras();
- if (args != null) {
- args = new Bundle(args);
- } else {
- args = new Bundle();
- }
- args.putParcelable("intent", superIntent);
- modIntent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, superIntent.getExtras());
- return modIntent;
- }
- return superIntent;
- }
-
- /**
- * Checks if the component name in the intent is different from the Settings class and
- * returns the class name to load as a fragment.
- */
- protected String getStartingFragmentClass(Intent intent) {
- if (mFragmentClass != null) return mFragmentClass;
-
- String intentClass = intent.getComponent().getClassName();
- if (intentClass.equals(getClass().getName())) return null;
-
- if ("com.android.settings.ManageApplications".equals(intentClass)
- || "com.android.settings.RunningServices".equals(intentClass)
- || "com.android.settings.applications.StorageUse".equals(intentClass)) {
- // Old names of manage apps.
- intentClass = com.android.settings.applications.ManageApplications.class.getName();
- }
-
- return intentClass;
- }
-
- /**
- * Override initial header when an activity-alias is causing Settings to be launched
- * for a specific fragment encoded in the android:name parameter.
- */
- @Override
- public Header onGetInitialHeader() {
- String fragmentClass = getStartingFragmentClass(super.getIntent());
- if (fragmentClass != null) {
- Header header = new Header();
- header.fragment = fragmentClass;
- header.title = getTitle();
- header.fragmentArguments = getIntent().getExtras();
- mCurrentHeader = header;
- return header;
- }
-
- return mFirstHeader;
- }
-
- @Override
- public Intent onBuildStartFragmentIntent(String fragmentName, Bundle args,
- int titleRes, int shortTitleRes) {
- Intent intent = super.onBuildStartFragmentIntent(fragmentName, args,
- titleRes, shortTitleRes);
-
- // Some fragments want split ActionBar; these should stay in sync with
- // uiOptions for fragments also defined as activities in manifest.
- if (WifiSettings.class.getName().equals(fragmentName) ||
- WifiP2pSettings.class.getName().equals(fragmentName) ||
- BluetoothSettings.class.getName().equals(fragmentName) ||
- DreamSettings.class.getName().equals(fragmentName) ||
- LocationSettings.class.getName().equals(fragmentName) ||
- ToggleAccessibilityServicePreferenceFragment.class.getName().equals(fragmentName) ||
- PrintSettingsFragment.class.getName().equals(fragmentName) ||
- PrintServiceSettingsFragment.class.getName().equals(fragmentName)) {
- intent.putExtra(EXTRA_UI_OPTIONS, ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW);
- }
-
- intent.setClass(this, SubSettings.class);
- return intent;
- }
-
- /**
- * Populate the activity with the top-level headers.
- */
- @Override
- public void onBuildHeaders(List<Header> headers) {
- if (!onIsHidingHeaders()) {
- loadHeadersFromResource(R.xml.settings_headers, headers);
- updateHeaderList(headers);
- }
- }
-
- private void updateHeaderList(List<Header> target) {
- final boolean showDev = mDevelopmentPreferences.getBoolean(
- DevelopmentSettings.PREF_SHOW,
- android.os.Build.TYPE.equals("eng"));
- int i = 0;
-
- final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
- mHeaderIndexMap.clear();
- while (i < target.size()) {
- Header header = target.get(i);
- // Ids are integers, so downcasting
- int id = (int) header.id;
- if (id == R.id.operator_settings || id == R.id.manufacturer_settings) {
- Utils.updateHeaderToSpecificActivityFromMetaDataOrRemove(this, target, header);
- } else if (id == R.id.wifi_settings) {
- // Remove WiFi Settings if WiFi service is not available.
- if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI)) {
- target.remove(i);
- }
- } else if (id == R.id.bluetooth_settings) {
- // Remove Bluetooth Settings if Bluetooth service is not available.
- if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) {
- target.remove(i);
- }
- } else if (id == R.id.data_usage_settings) {
- // Remove data usage when kernel module not enabled
- final INetworkManagementService netManager = INetworkManagementService.Stub
- .asInterface(ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE));
- try {
- if (!netManager.isBandwidthControlEnabled()) {
- target.remove(i);
- }
- } catch (RemoteException e) {
- // ignored
- }
- } else if (id == R.id.battery_settings) {
- // Remove battery settings when battery is not available. (e.g. TV)
-
- if (!mBatteryPresent) {
- target.remove(i);
- }
- } else if (id == R.id.account_settings) {
- int headerIndex = i + 1;
- i = insertAccountsHeaders(target, headerIndex);
- } else if (id == R.id.home_settings) {
- if (!updateHomeSettingHeaders(header)) {
- target.remove(i);
- }
- } else if (id == R.id.user_settings) {
- if (!UserHandle.MU_ENABLED
- || !UserManager.supportsMultipleUsers()
- || Utils.isMonkeyRunning()) {
- target.remove(i);
- }
- } else if (id == R.id.nfc_payment_settings) {
- if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC)) {
- target.remove(i);
- } else {
- // Only show if NFC is on and we have the HCE feature
- NfcAdapter adapter = NfcAdapter.getDefaultAdapter(this);
- if (!adapter.isEnabled() || !getPackageManager().hasSystemFeature(
- PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)) {
- target.remove(i);
- }
- }
- } else if (id == R.id.development_settings) {
- if (!showDev) {
- target.remove(i);
- }
- } else if (id == R.id.account_add) {
- if (um.hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS)) {
- target.remove(i);
- }
- }
-
- if (i < target.size() && target.get(i) == header
- && UserHandle.MU_ENABLED && UserHandle.myUserId() != 0
- && !ArrayUtils.contains(SETTINGS_FOR_RESTRICTED, id)) {
- target.remove(i);
- }
-
- // Increment if the current one wasn't removed by the Utils code.
- if (i < target.size() && target.get(i) == header) {
- // Hold on to the first header, when we need to reset to the top-level
- if (mFirstHeader == null &&
- HeaderAdapter.getHeaderType(header) != HeaderAdapter.HEADER_TYPE_CATEGORY) {
- mFirstHeader = header;
- }
- mHeaderIndexMap.put(id, i);
- i++;
- }
- }
- }
-
- private int insertAccountsHeaders(List<Header> target, int headerIndex) {
- String[] accountTypes = mAuthenticatorHelper.getEnabledAccountTypes();
- List<Header> accountHeaders = new ArrayList<Header>(accountTypes.length);
- for (String accountType : accountTypes) {
- CharSequence label = mAuthenticatorHelper.getLabelForType(this, accountType);
- if (label == null) {
- continue;
- }
-
- Account[] accounts = AccountManager.get(this).getAccountsByType(accountType);
- boolean skipToAccount = accounts.length == 1
- && !mAuthenticatorHelper.hasAccountPreferences(accountType);
- Header accHeader = new Header();
- accHeader.title = label;
- if (accHeader.extras == null) {
- accHeader.extras = new Bundle();
- }
- if (skipToAccount) {
- accHeader.breadCrumbTitleRes = R.string.account_sync_settings_title;
- accHeader.breadCrumbShortTitleRes = R.string.account_sync_settings_title;
- accHeader.fragment = AccountSyncSettings.class.getName();
- accHeader.fragmentArguments = new Bundle();
- // Need this for the icon
- accHeader.extras.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE, accountType);
- accHeader.extras.putParcelable(AccountSyncSettings.ACCOUNT_KEY, accounts[0]);
- accHeader.fragmentArguments.putParcelable(AccountSyncSettings.ACCOUNT_KEY,
- accounts[0]);
- } else {
- accHeader.breadCrumbTitle = label;
- accHeader.breadCrumbShortTitle = label;
- accHeader.fragment = ManageAccountsSettings.class.getName();
- accHeader.fragmentArguments = new Bundle();
- accHeader.extras.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE, accountType);
- accHeader.fragmentArguments.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE,
- accountType);
- if (!isMultiPane()) {
- accHeader.fragmentArguments.putString(ManageAccountsSettings.KEY_ACCOUNT_LABEL,
- label.toString());
- }
- }
- accountHeaders.add(accHeader);
- mAuthenticatorHelper.preloadDrawableForType(this, accountType);
- }
-
- // Sort by label
- Collections.sort(accountHeaders, new Comparator<Header>() {
- @Override
- public int compare(Header h1, Header h2) {
- return h1.title.toString().compareTo(h2.title.toString());
- }
- });
-
- for (Header header : accountHeaders) {
- target.add(headerIndex++, header);
- }
- if (!mListeningToAccountUpdates) {
- AccountManager.get(this).addOnAccountsUpdatedListener(this, null, true);
- mListeningToAccountUpdates = true;
- }
- return headerIndex;
- }
-
- private boolean updateHomeSettingHeaders(Header header) {
- // Once we decide to show Home settings, keep showing it forever
- SharedPreferences sp = getSharedPreferences(HomeSettings.HOME_PREFS, Context.MODE_PRIVATE);
- if (sp.getBoolean(HomeSettings.HOME_PREFS_DO_SHOW, false)) {
- return true;
- }
-
- try {
- final ArrayList<ResolveInfo> homeApps = new ArrayList<ResolveInfo>();
- getPackageManager().getHomeActivities(homeApps);
- if (homeApps.size() < 2) {
- // When there's only one available home app, omit this settings
- // category entirely at the top level UI. If the user just
- // uninstalled the penultimate home app candidiate, we also
- // now tell them about why they aren't seeing 'Home' in the list.
- if (sShowNoHomeNotice) {
- sShowNoHomeNotice = false;
- NoHomeDialogFragment.show(this);
- }
- return false;
- } else {
- // Okay, we're allowing the Home settings category. Tell it, when
- // invoked via this front door, that we'll need to be told about the
- // case when the user uninstalls all but one home app.
- if (header.fragmentArguments == null) {
- header.fragmentArguments = new Bundle();
- }
- header.fragmentArguments.putBoolean(HomeSettings.HOME_SHOW_NOTICE, true);
- }
- } catch (Exception e) {
- // Can't look up the home activity; bail on configuring the icon
- Log.w(LOG_TAG, "Problem looking up home activity!", e);
- }
-
- sp.edit().putBoolean(HomeSettings.HOME_PREFS_DO_SHOW, true).apply();
- return true;
- }
-
- private void getMetaData() {
- try {
- ActivityInfo ai = getPackageManager().getActivityInfo(getComponentName(),
- PackageManager.GET_META_DATA);
- if (ai == null || ai.metaData == null) return;
- mTopLevelHeaderId = ai.metaData.getInt(META_DATA_KEY_HEADER_ID);
- mFragmentClass = ai.metaData.getString(META_DATA_KEY_FRAGMENT_CLASS);
- } catch (NameNotFoundException nnfe) {
- // No recovery
- Log.d(LOG_TAG, "Cannot get Metadata for: " + getComponentName().toString());
- }
- }
-
- @Override
- public boolean hasNextButton() {
- return super.hasNextButton();
- }
-
- @Override
- public Button getNextButton() {
- return super.getNextButton();
- }
-
- public static class NoHomeDialogFragment extends DialogFragment {
- public static void show(Activity parent) {
- final NoHomeDialogFragment dialog = new NoHomeDialogFragment();
- dialog.show(parent.getFragmentManager(), null);
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- return new AlertDialog.Builder(getActivity())
- .setMessage(R.string.only_one_home_message)
- .setPositiveButton(android.R.string.ok, null)
- .create();
- }
- }
-
- private static class HeaderAdapter extends ArrayAdapter<Header> {
- static final int HEADER_TYPE_CATEGORY = 0;
- static final int HEADER_TYPE_NORMAL = 1;
- static final int HEADER_TYPE_SWITCH = 2;
- static final int HEADER_TYPE_BUTTON = 3;
- private static final int HEADER_TYPE_COUNT = HEADER_TYPE_BUTTON + 1;
-
- private final WifiEnabler mWifiEnabler;
- private final BluetoothEnabler mBluetoothEnabler;
- private AuthenticatorHelper mAuthHelper;
- private DevicePolicyManager mDevicePolicyManager;
-
- private static class HeaderViewHolder {
- ImageView mIcon;
- TextView mTitle;
- TextView mSummary;
- Switch mSwitch;
- ImageButton mButton;
- View mDivider;
- }
-
- private LayoutInflater mInflater;
-
- static int getHeaderType(Header header) {
- if (header.fragment == null && header.intent == null) {
- return HEADER_TYPE_CATEGORY;
- } else if (header.id == R.id.wifi_settings || header.id == R.id.bluetooth_settings) {
- return HEADER_TYPE_SWITCH;
- } else if (header.id == R.id.security_settings) {
- return HEADER_TYPE_BUTTON;
- } else {
- return HEADER_TYPE_NORMAL;
- }
- }
-
- @Override
- public int getItemViewType(int position) {
- Header header = getItem(position);
- return getHeaderType(header);
- }
-
- @Override
- public boolean areAllItemsEnabled() {
- return false; // because of categories
- }
-
- @Override
- public boolean isEnabled(int position) {
- return getItemViewType(position) != HEADER_TYPE_CATEGORY;
- }
-
- @Override
- public int getViewTypeCount() {
- return HEADER_TYPE_COUNT;
- }
-
- @Override
- public boolean hasStableIds() {
- return true;
- }
-
- public HeaderAdapter(Context context, List<Header> objects,
- AuthenticatorHelper authenticatorHelper, DevicePolicyManager dpm) {
- super(context, 0, objects);
-
- mAuthHelper = authenticatorHelper;
- mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-
- // Temp Switches provided as placeholder until the adapter replaces these with actual
- // Switches inflated from their layouts. Must be done before adapter is set in super
- mWifiEnabler = new WifiEnabler(context, new Switch(context));
- mBluetoothEnabler = new BluetoothEnabler(context, new Switch(context));
- mDevicePolicyManager = dpm;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- HeaderViewHolder holder;
- Header header = getItem(position);
- int headerType = getHeaderType(header);
- View view = null;
-
- if (convertView == null) {
- holder = new HeaderViewHolder();
- switch (headerType) {
- case HEADER_TYPE_CATEGORY:
- view = new TextView(getContext(), null,
- android.R.attr.listSeparatorTextViewStyle);
- holder.mTitle = (TextView) view;
- break;
-
- case HEADER_TYPE_SWITCH:
- view = mInflater.inflate(R.layout.preference_header_switch_item, parent,
- false);
- holder.mIcon = (ImageView) view.findViewById(R.id.icon);
- holder.mTitle = (TextView)
- view.findViewById(com.android.internal.R.id.title);
- holder.mSummary = (TextView)
- view.findViewById(com.android.internal.R.id.summary);
- holder.mSwitch = (Switch) view.findViewById(R.id.switchWidget);
- break;
-
- case HEADER_TYPE_BUTTON:
- view = mInflater.inflate(R.layout.preference_header_button_item, parent,
- false);
- holder.mIcon = (ImageView) view.findViewById(R.id.icon);
- holder.mTitle = (TextView)
- view.findViewById(com.android.internal.R.id.title);
- holder.mSummary = (TextView)
- view.findViewById(com.android.internal.R.id.summary);
- holder.mButton = (ImageButton) view.findViewById(R.id.buttonWidget);
- holder.mDivider = view.findViewById(R.id.divider);
- break;
-
- case HEADER_TYPE_NORMAL:
- view = mInflater.inflate(
- R.layout.preference_header_item, parent,
- false);
- holder.mIcon = (ImageView) view.findViewById(R.id.icon);
- holder.mTitle = (TextView)
- view.findViewById(com.android.internal.R.id.title);
- holder.mSummary = (TextView)
- view.findViewById(com.android.internal.R.id.summary);
- break;
- }
- view.setTag(holder);
- } else {
- view = convertView;
- holder = (HeaderViewHolder) view.getTag();
- }
-
- // All view fields must be updated every time, because the view may be recycled
- switch (headerType) {
- case HEADER_TYPE_CATEGORY:
- holder.mTitle.setText(header.getTitle(getContext().getResources()));
- break;
-
- case HEADER_TYPE_SWITCH:
- // Would need a different treatment if the main menu had more switches
- if (header.id == R.id.wifi_settings) {
- mWifiEnabler.setSwitch(holder.mSwitch);
- } else {
- mBluetoothEnabler.setSwitch(holder.mSwitch);
- }
- updateCommonHeaderView(header, holder);
- break;
-
- case HEADER_TYPE_BUTTON:
- if (header.id == R.id.security_settings) {
- boolean hasCert = DevicePolicyManager.hasAnyCaCertsInstalled();
- if (hasCert) {
- holder.mButton.setVisibility(View.VISIBLE);
- holder.mDivider.setVisibility(View.VISIBLE);
- boolean isManaged = mDevicePolicyManager.getDeviceOwner() != null;
- if (isManaged) {
- holder.mButton.setImageResource(R.drawable.ic_settings_about);
- } else {
- holder.mButton.setImageResource(
- android.R.drawable.stat_notify_error);
- }
- holder.mButton.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent intent = new Intent(
- android.provider.Settings.ACTION_MONITORING_CERT_INFO);
- getContext().startActivity(intent);
- }
- });
- } else {
- holder.mButton.setVisibility(View.GONE);
- holder.mDivider.setVisibility(View.GONE);
- }
- }
- updateCommonHeaderView(header, holder);
- break;
-
- case HEADER_TYPE_NORMAL:
- updateCommonHeaderView(header, holder);
- break;
- }
-
- return view;
- }
-
- private void updateCommonHeaderView(Header header, HeaderViewHolder holder) {
- if (header.extras != null
- && header.extras.containsKey(ManageAccountsSettings.KEY_ACCOUNT_TYPE)) {
- String accType = header.extras.getString(
- ManageAccountsSettings.KEY_ACCOUNT_TYPE);
- Drawable icon = mAuthHelper.getDrawableForType(getContext(), accType);
- setHeaderIcon(holder, icon);
- } else {
- holder.mIcon.setImageResource(header.iconRes);
- }
- holder.mTitle.setText(header.getTitle(getContext().getResources()));
- CharSequence summary = header.getSummary(getContext().getResources());
- if (!TextUtils.isEmpty(summary)) {
- holder.mSummary.setVisibility(View.VISIBLE);
- holder.mSummary.setText(summary);
- } else {
- holder.mSummary.setVisibility(View.GONE);
- }
- }
-
- private void setHeaderIcon(HeaderViewHolder holder, Drawable icon) {
- ViewGroup.LayoutParams lp = holder.mIcon.getLayoutParams();
- lp.width = getContext().getResources().getDimensionPixelSize(
- R.dimen.header_icon_width);
- lp.height = lp.width;
- holder.mIcon.setLayoutParams(lp);
- holder.mIcon.setImageDrawable(icon);
- }
-
- public void resume() {
- mWifiEnabler.resume();
- mBluetoothEnabler.resume();
- }
-
- public void pause() {
- mWifiEnabler.pause();
- mBluetoothEnabler.pause();
- }
- }
-
- @Override
- public void onHeaderClick(Header header, int position) {
- boolean revert = false;
- if (header.id == R.id.account_add) {
- revert = true;
- }
-
- super.onHeaderClick(header, position);
-
- if (revert && mLastHeader != null) {
- highlightHeader((int) mLastHeader.id);
- } else {
- mLastHeader = header;
- }
- }
-
- @Override
- public boolean onPreferenceStartFragment(PreferenceFragment caller, Preference pref) {
- // Override the fragment title for Wallpaper settings
- int titleRes = pref.getTitleRes();
- if (pref.getFragment().equals(WallpaperTypeSettings.class.getName())) {
- titleRes = R.string.wallpaper_settings_fragment_title;
- } else if (pref.getFragment().equals(OwnerInfoSettings.class.getName())
- && UserHandle.myUserId() != UserHandle.USER_OWNER) {
- if (UserManager.get(this).isLinkedUser()) {
- titleRes = R.string.profile_info_settings_title;
- } else {
- titleRes = R.string.user_info_settings_title;
- }
- }
- startPreferencePanel(pref.getFragment(), pref.getExtras(), titleRes, pref.getTitle(),
- null, 0);
- return true;
- }
-
- @Override
- public boolean shouldUpRecreateTask(Intent targetIntent) {
- return super.shouldUpRecreateTask(new Intent(this, Settings.class));
- }
-
- @Override
- public void setListAdapter(ListAdapter adapter) {
- if (adapter == null) {
- super.setListAdapter(null);
- } else {
- DevicePolicyManager dpm =
- (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
- super.setListAdapter(new HeaderAdapter(this, getHeaders(), mAuthenticatorHelper, dpm));
- }
- }
-
- @Override
- public void onAccountsUpdated(Account[] accounts) {
- // TODO: watch for package upgrades to invalidate cache; see 7206643
- mAuthenticatorHelper.updateAuthDescriptions(this);
- mAuthenticatorHelper.onAccountsUpdated(this, accounts);
- invalidateHeaders();
- }
-
- public static void requestHomeNotice() {
- sShowNoHomeNotice = true;
- }
+public class Settings extends SettingsActivity {
/*
- * Settings subclasses for launching independently.
- */
- public static class BluetoothSettingsActivity extends Settings { /* empty */ }
- public static class WirelessSettingsActivity extends Settings { /* empty */ }
- public static class TetherSettingsActivity extends Settings { /* empty */ }
- public static class VpnSettingsActivity extends Settings { /* empty */ }
- public static class DateTimeSettingsActivity extends Settings { /* empty */ }
- public static class StorageSettingsActivity extends Settings { /* empty */ }
- public static class WifiSettingsActivity extends Settings { /* empty */ }
- public static class WifiP2pSettingsActivity extends Settings { /* empty */ }
- public static class InputMethodAndLanguageSettingsActivity extends Settings { /* empty */ }
- public static class KeyboardLayoutPickerActivity extends Settings { /* empty */ }
- public static class InputMethodAndSubtypeEnablerActivity extends Settings { /* empty */ }
- public static class SpellCheckersSettingsActivity extends Settings { /* empty */ }
- public static class LocalePickerActivity extends Settings { /* empty */ }
- public static class UserDictionarySettingsActivity extends Settings { /* empty */ }
- public static class SoundSettingsActivity extends Settings { /* empty */ }
- public static class DisplaySettingsActivity extends Settings { /* empty */ }
- public static class DeviceInfoSettingsActivity extends Settings { /* empty */ }
- public static class ApplicationSettingsActivity extends Settings { /* empty */ }
- public static class ManageApplicationsActivity extends Settings { /* empty */ }
- public static class AppOpsSummaryActivity extends Settings {
+ * Settings subclasses for launching independently.
+ */
+ public static class BluetoothSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class WirelessSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class TetherSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class VpnSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class DateTimeSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class StorageSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class WifiSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class WifiP2pSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class InputMethodAndLanguageSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class KeyboardLayoutPickerActivity extends SettingsActivity { /* empty */ }
+ public static class InputMethodAndSubtypeEnablerActivity extends SettingsActivity { /* empty */ }
+ public static class SpellCheckersSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class LocalePickerActivity extends SettingsActivity { /* empty */ }
+ public static class UserDictionarySettingsActivity extends SettingsActivity { /* empty */ }
+ public static class SoundSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class DisplaySettingsActivity extends SettingsActivity { /* empty */ }
+ public static class DeviceInfoSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class ApplicationSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class ManageApplicationsActivity extends SettingsActivity { /* empty */ }
+ public static class AppOpsSummaryActivity extends SettingsActivity {
@Override
public boolean isValidFragment(String className) {
if (AppOpsSummary.class.getName().equals(className)) {
return true;
}
return super.isValidFragment(className);
- }
+ }
}
- public static class StorageUseActivity extends Settings { /* empty */ }
- public static class DevelopmentSettingsActivity extends Settings { /* empty */ }
- public static class AccessibilitySettingsActivity extends Settings { /* empty */ }
- public static class CaptioningSettingsActivity extends Settings { /* empty */ }
- public static class AccessibilityInversionSettingsActivity extends Settings { /* empty */ }
- public static class AccessibilityContrastSettingsActivity extends Settings { /* empty */ }
- public static class AccessibilityDaltonizerSettingsActivity extends Settings { /* empty */ }
- public static class SecuritySettingsActivity extends Settings { /* empty */ }
- public static class LocationSettingsActivity extends Settings { /* empty */ }
- public static class PrivacySettingsActivity extends Settings { /* empty */ }
- public static class RunningServicesActivity extends Settings { /* empty */ }
- public static class ManageAccountsSettingsActivity extends Settings { /* empty */ }
- public static class PowerUsageSummaryActivity extends Settings { /* empty */ }
- public static class AccountSyncSettingsActivity extends Settings { /* empty */ }
- public static class AccountSyncSettingsInAddAccountActivity extends Settings { /* empty */ }
- public static class CryptKeeperSettingsActivity extends Settings { /* empty */ }
- public static class DeviceAdminSettingsActivity extends Settings { /* empty */ }
- public static class DataUsageSummaryActivity extends Settings { /* empty */ }
- public static class AdvancedWifiSettingsActivity extends Settings { /* empty */ }
- public static class TextToSpeechSettingsActivity extends Settings { /* empty */ }
- public static class AndroidBeamSettingsActivity extends Settings { /* empty */ }
- public static class WifiDisplaySettingsActivity extends Settings { /* empty */ }
- public static class DreamSettingsActivity extends Settings { /* empty */ }
- public static class NotificationStationActivity extends Settings { /* empty */ }
- public static class UserSettingsActivity extends Settings { /* empty */ }
- public static class NotificationAccessSettingsActivity extends Settings { /* empty */ }
- public static class UsbSettingsActivity extends Settings { /* empty */ }
- public static class TrustedCredentialsSettingsActivity extends Settings { /* empty */ }
- public static class PaymentSettingsActivity extends Settings { /* empty */ }
- public static class PrintSettingsActivity extends Settings { /* empty */ }
- public static class PrintJobSettingsActivity extends Settings { /* empty */ }
+ public static class StorageUseActivity extends SettingsActivity { /* empty */ }
+ public static class DevelopmentSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class AccessibilitySettingsActivity extends SettingsActivity { /* empty */ }
+ public static class CaptioningSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class AccessibilityInversionSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class AccessibilityContrastSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class AccessibilityDaltonizerSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class SecuritySettingsActivity extends SettingsActivity { /* empty */ }
+ public static class LocationSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class PrivacySettingsActivity extends SettingsActivity { /* empty */ }
+ public static class RunningServicesActivity extends SettingsActivity { /* empty */ }
+ public static class ManageAccountsSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class PowerUsageSummaryActivity extends SettingsActivity { /* empty */ }
+ public static class ChooseAccountActivity extends SettingsActivity { /* empty */ }
+ public static class AccountSyncSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class AccountSyncSettingsInAddAccountActivity extends SettingsActivity { /* empty */ }
+ public static class CryptKeeperSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class DeviceAdminSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class DataUsageSummaryActivity extends SettingsActivity { /* empty */ }
+ public static class AdvancedWifiSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class TextToSpeechSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class AndroidBeamSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class WifiDisplaySettingsActivity extends SettingsActivity { /* empty */ }
+ public static class DreamSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class NotificationStationActivity extends SettingsActivity { /* empty */ }
+ public static class UserSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class NotificationAccessSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class UsbSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class TrustedCredentialsSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class PaymentSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class PrintSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class PrintJobSettingsActivity extends SettingsActivity { /* empty */ }
+
+ public static class TopLevelSettings extends SettingsActivity { /* empty */ }
}
+
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
new file mode 100644
index 0000000..c3d067f
--- /dev/null
+++ b/src/com/android/settings/SettingsActivity.java
@@ -0,0 +1,1770 @@
+/*
+ * 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.
+ */
+
+package com.android.settings;
+
+import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.accounts.OnAccountsUpdateListener;
+import android.app.ActionBar;
+import android.app.Activity;
+import android.app.Fragment;
+import android.app.FragmentManager;
+import android.app.FragmentTransaction;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.DialogFragment;
+import android.app.admin.DevicePolicyManager;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.SharedPreferences;
+import android.content.pm.ActivityInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.pm.ResolveInfo;
+import android.content.res.Configuration;
+import android.content.res.Resources;
+import android.content.res.TypedArray;
+import android.content.res.XmlResourceParser;
+import android.graphics.drawable.Drawable;
+import android.nfc.NfcAdapter;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.INetworkManagementService;
+import android.os.Message;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.preference.Preference;
+import android.preference.PreferenceFragment;
+import android.preference.PreferenceManager;
+import android.preference.PreferenceScreen;
+import android.support.v4.app.ActionBarDrawerToggle;
+import android.support.v4.widget.DrawerLayout;
+import android.text.TextUtils;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.util.Pair;
+import android.util.TypedValue;
+import android.util.Xml;
+import android.view.LayoutInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.AbsListView;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.ImageButton;
+import android.widget.ImageView;
+import android.widget.ListView;
+import android.widget.Switch;
+import android.widget.TextView;
+
+import com.android.internal.util.ArrayUtils;
+import com.android.internal.util.XmlUtils;
+import com.android.settings.accessibility.AccessibilitySettings;
+import com.android.settings.accessibility.CaptionPropertiesFragment;
+import com.android.settings.accounts.AccountSyncSettings;
+import com.android.settings.accounts.AuthenticatorHelper;
+import com.android.settings.accounts.ChooseAccountFragment;
+import com.android.settings.accounts.ManageAccountsSettings;
+import com.android.settings.applications.ManageApplications;
+import com.android.settings.applications.ProcessStatsUi;
+import com.android.settings.bluetooth.BluetoothEnabler;
+import com.android.settings.bluetooth.BluetoothSettings;
+import com.android.settings.dashboard.DashboardSummary;
+import com.android.settings.deviceinfo.Memory;
+import com.android.settings.deviceinfo.UsbSettings;
+import com.android.settings.fuelgauge.PowerUsageSummary;
+import com.android.settings.inputmethod.InputMethodAndLanguageSettings;
+import com.android.settings.inputmethod.KeyboardLayoutPickerFragment;
+import com.android.settings.inputmethod.SpellCheckersSettings;
+import com.android.settings.inputmethod.UserDictionaryList;
+import com.android.settings.location.LocationSettings;
+import com.android.settings.nfc.AndroidBeam;
+import com.android.settings.nfc.PaymentSettings;
+import com.android.settings.print.PrintJobSettingsFragment;
+import com.android.settings.print.PrintSettingsFragment;
+import com.android.settings.tts.TextToSpeechSettings;
+import com.android.settings.users.UserSettings;
+import com.android.settings.vpn2.VpnSettings;
+import com.android.settings.wfd.WifiDisplaySettings;
+import com.android.settings.wifi.AdvancedWifiSettings;
+import com.android.settings.wifi.WifiEnabler;
+import com.android.settings.wifi.WifiSettings;
+import com.android.settings.wifi.p2p.WifiP2pSettings;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+
+public class SettingsActivity extends Activity
+ implements PreferenceManager.OnPreferenceTreeClickListener,
+ PreferenceFragment.OnPreferenceStartFragmentCallback,
+ ButtonBarHandler, OnAccountsUpdateListener, FragmentManager.OnBackStackChangedListener {
+
+ private static final String LOG_TAG = "Settings";
+
+ // Constants for state save/restore
+ private static final String HEADERS_TAG = ":settings:headers";
+ private static final String CUR_HEADER_TAG = ":settings:cur_header";
+
+ /**
+ * When starting this activity, the invoking Intent can contain this extra
+ * string to specify which fragment should be initially displayed.
+ * <p/>Starting from Key Lime Pie, when this argument is passed in, the activity
+ * will call isValidFragment() to confirm that the fragment class name is valid for this
+ * activity.
+ */
+ public static final String EXTRA_SHOW_FRAGMENT = ":settings:show_fragment";
+
+ /**
+ * When starting this activity and using {@link #EXTRA_SHOW_FRAGMENT},
+ * this extra can also be specified to supply a Bundle of arguments to pass
+ * to that fragment when it is instantiated during the initial creation
+ * of the activity.
+ */
+ public static final String EXTRA_SHOW_FRAGMENT_ARGUMENTS = ":settings:show_fragment_args";
+
+ /**
+ * When starting this activity, the invoking Intent can contain this extra
+ * boolean that the header list should not be displayed. This is most often
+ * used in conjunction with {@link #EXTRA_SHOW_FRAGMENT} to launch
+ * the activity to display a specific fragment that the user has navigated
+ * to.
+ */
+ public static final String EXTRA_NO_HEADERS = ":settings:no_headers";
+
+ // extras that allow any preference activity to be launched as part of a wizard
+
+ // show Back and Next buttons? takes boolean parameter
+ // Back will then return RESULT_CANCELED and Next RESULT_OK
+ protected static final String EXTRA_PREFS_SHOW_BUTTON_BAR = "extra_prefs_show_button_bar";
+
+ // add a Skip button?
+ private static final String EXTRA_PREFS_SHOW_SKIP = "extra_prefs_show_skip";
+
+ // specify custom text for the Back or Next buttons, or cause a button to not appear
+ // at all by setting it to null
+ protected static final String EXTRA_PREFS_SET_NEXT_TEXT = "extra_prefs_set_next_text";
+ protected static final String EXTRA_PREFS_SET_BACK_TEXT = "extra_prefs_set_back_text";
+
+ /**
+ * When starting this activity and using {@link #EXTRA_SHOW_FRAGMENT},
+ * this extra can also be specify to supply the title to be shown for
+ * that fragment.
+ */
+ protected static final String EXTRA_SHOW_FRAGMENT_TITLE = ":settings:show_fragment_title";
+
+ private static final String BACK_STACK_PREFS = ":settings:prefs";
+
+ private static final String META_DATA_KEY_HEADER_ID =
+ "com.android.settings.TOP_LEVEL_HEADER_ID";
+
+ private static final String META_DATA_KEY_FRAGMENT_CLASS =
+ "com.android.settings.FRAGMENT_CLASS";
+
+ private static final String EXTRA_UI_OPTIONS = "settings:ui_options";
+
+ private static final String SAVE_KEY_CURRENT_HEADER = "com.android.settings.CURRENT_HEADER";
+
+ private static boolean sShowNoHomeNotice = false;
+
+ private String mFragmentClass;
+ private int mTopLevelHeaderId;
+ private Header mFirstHeader;
+ private Header mCurrentHeader;
+
+ // Show only these settings for restricted users
+ private int[] SETTINGS_FOR_RESTRICTED = {
+ R.id.wireless_section,
+ R.id.wifi_settings,
+ R.id.bluetooth_settings,
+ R.id.data_usage_settings,
+ R.id.wireless_settings,
+ R.id.device_section,
+ R.id.sound_settings,
+ R.id.display_settings,
+ R.id.storage_settings,
+ R.id.application_settings,
+ R.id.battery_settings,
+ R.id.personal_section,
+ R.id.location_settings,
+ R.id.security_settings,
+ R.id.language_settings,
+ R.id.user_settings,
+ R.id.account_settings,
+ R.id.account_add,
+ R.id.system_section,
+ R.id.date_time_settings,
+ R.id.about_settings,
+ R.id.accessibility_settings,
+ R.id.print_settings,
+ R.id.nfc_payment_settings,
+ R.id.home_settings
+ };
+
+ private static final String[] ENTRY_FRAGMENTS = {
+ WirelessSettings.class.getName(),
+ WifiSettings.class.getName(),
+ AdvancedWifiSettings.class.getName(),
+ BluetoothSettings.class.getName(),
+ TetherSettings.class.getName(),
+ WifiP2pSettings.class.getName(),
+ VpnSettings.class.getName(),
+ DateTimeSettings.class.getName(),
+ LocalePicker.class.getName(),
+ InputMethodAndLanguageSettings.class.getName(),
+ SpellCheckersSettings.class.getName(),
+ UserDictionaryList.class.getName(),
+ UserDictionarySettings.class.getName(),
+ SoundSettings.class.getName(),
+ DisplaySettings.class.getName(),
+ DeviceInfoSettings.class.getName(),
+ ManageApplications.class.getName(),
+ ProcessStatsUi.class.getName(),
+ NotificationStation.class.getName(),
+ LocationSettings.class.getName(),
+ SecuritySettings.class.getName(),
+ PrivacySettings.class.getName(),
+ DeviceAdminSettings.class.getName(),
+ AccessibilitySettings.class.getName(),
+ CaptionPropertiesFragment.class.getName(),
+ com.android.settings.accessibility.ToggleInversionPreferenceFragment.class.getName(),
+ com.android.settings.accessibility.ToggleContrastPreferenceFragment.class.getName(),
+ com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment.class.getName(),
+ TextToSpeechSettings.class.getName(),
+ Memory.class.getName(),
+ DevelopmentSettings.class.getName(),
+ UsbSettings.class.getName(),
+ AndroidBeam.class.getName(),
+ WifiDisplaySettings.class.getName(),
+ PowerUsageSummary.class.getName(),
+ AccountSyncSettings.class.getName(),
+ CryptKeeperSettings.class.getName(),
+ DataUsageSummary.class.getName(),
+ DreamSettings.class.getName(),
+ UserSettings.class.getName(),
+ NotificationAccessSettings.class.getName(),
+ ManageAccountsSettings.class.getName(),
+ PrintSettingsFragment.class.getName(),
+ PrintJobSettingsFragment.class.getName(),
+ TrustedCredentialsSettings.class.getName(),
+ PaymentSettings.class.getName(),
+ KeyboardLayoutPickerFragment.class.getName(),
+ ChooseAccountFragment.class.getName(),
+ DashboardSummary.class.getName()
+ };
+
+ private SharedPreferences mDevelopmentPreferences;
+ private SharedPreferences.OnSharedPreferenceChangeListener mDevelopmentPreferencesListener;
+
+ // TODO: Update Call Settings based on airplane mode state.
+
+ protected HashMap<Integer, Integer> mHeaderIndexMap = new HashMap<Integer, Integer>();
+
+ private AuthenticatorHelper mAuthenticatorHelper;
+ private boolean mListeningToAccountUpdates;
+
+ private Button mNextButton;
+
+ private boolean mBatteryPresent = true;
+ private BroadcastReceiver mBatteryInfoReceiver = new BroadcastReceiver() {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
+ boolean batteryPresent = Utils.isBatteryPresent(intent);
+
+ if (mBatteryPresent != batteryPresent) {
+ mBatteryPresent = batteryPresent;
+ invalidateHeaders();
+ }
+ }
+ }
+ };
+
+ private final ArrayList<Header> mHeaders = new ArrayList<Header>();
+ private Header mCurHeader;
+ private HeaderAdapter mHeaderAdapter;
+
+ private class TitlePair extends Pair<Integer, CharSequence> {
+
+ public TitlePair(Integer first, CharSequence second) {
+ super(first, second);
+ }
+ }
+
+ private final ArrayList<TitlePair> mTitleStack = new ArrayList<TitlePair>();
+
+ private DrawerLayout mDrawerLayout;
+ private ListView mDrawer;
+ private ActionBarDrawerToggle mDrawerToggle;
+ private ActionBar mActionBar;
+
+ private static final int MSG_BUILD_HEADERS = 1;
+ private Handler mHandler = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case MSG_BUILD_HEADERS: {
+ mHeaders.clear();
+ onBuildHeaders(mHeaders);
+ mHeaderAdapter.notifyDataSetChanged();
+ if (mCurHeader != null) {
+ Header mappedHeader = findBestMatchingHeader(mCurHeader, mHeaders);
+ if (mappedHeader != null) {
+ setSelectedHeader(mappedHeader);
+ }
+ }
+ } break;
+ }
+ }
+ };
+
+ @Override
+ public boolean onPreferenceStartFragment(PreferenceFragment caller, Preference pref) {
+ // Override the fragment title for Wallpaper settings
+ int titleRes = pref.getTitleRes();
+ if (pref.getFragment().equals(WallpaperTypeSettings.class.getName())) {
+ titleRes = R.string.wallpaper_settings_fragment_title;
+ } else if (pref.getFragment().equals(OwnerInfoSettings.class.getName())
+ && UserHandle.myUserId() != UserHandle.USER_OWNER) {
+ if (UserManager.get(this).isLinkedUser()) {
+ titleRes = R.string.profile_info_settings_title;
+ } else {
+ titleRes = R.string.user_info_settings_title;
+ }
+ }
+ startPreferencePanel(pref.getFragment(), pref.getExtras(), titleRes, pref.getTitle(),
+ null, 0);
+ return true;
+ }
+
+ @Override
+ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
+ return false;
+ }
+
+ private class DrawerListener implements DrawerLayout.DrawerListener {
+ @Override
+ public void onDrawerOpened(View drawerView) {
+ mDrawerToggle.onDrawerOpened(drawerView);
+ }
+
+ @Override
+ public void onDrawerClosed(View drawerView) {
+ mDrawerToggle.onDrawerClosed(drawerView);
+ onHeaderClick(mCurrentHeader);
+ }
+
+ @Override
+ public void onDrawerSlide(View drawerView, float slideOffset) {
+ mDrawerToggle.onDrawerSlide(drawerView, slideOffset);
+ }
+
+ @Override
+ public void onDrawerStateChanged(int newState) {
+ mDrawerToggle.onDrawerStateChanged(newState);
+ }
+ }
+
+ private class DrawerItemClickListener implements ListView.OnItemClickListener {
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ mDrawerLayout.closeDrawer(mDrawer);
+ onListItemClick((ListView)parent, view, position, id);
+ }
+ }
+
+ private Header findBestMatchingHeader(Header cur, ArrayList<Header> from) {
+ ArrayList<Header> matches = new ArrayList<Header>();
+ for (int j=0; j<from.size(); j++) {
+ Header oh = from.get(j);
+ if (cur == oh || (cur.id != HEADER_ID_UNDEFINED && cur.id == oh.id)) {
+ // Must be this one.
+ matches.clear();
+ matches.add(oh);
+ break;
+ }
+ if (cur.fragment != null) {
+ if (cur.fragment.equals(oh.fragment)) {
+ matches.add(oh);
+ }
+ } else if (cur.intent != null) {
+ if (cur.intent.equals(oh.intent)) {
+ matches.add(oh);
+ }
+ } else if (cur.title != null) {
+ if (cur.title.equals(oh.title)) {
+ matches.add(oh);
+ }
+ }
+ }
+ final int NM = matches.size();
+ if (NM == 1) {
+ return matches.get(0);
+ } else if (NM > 1) {
+ for (int j=0; j<NM; j++) {
+ Header oh = matches.get(j);
+ if (cur.fragmentArguments != null &&
+ cur.fragmentArguments.equals(oh.fragmentArguments)) {
+ return oh;
+ }
+ if (cur.extras != null && cur.extras.equals(oh.extras)) {
+ return oh;
+ }
+ if (cur.title != null && cur.title.equals(oh.title)) {
+ return oh;
+ }
+ }
+ }
+ return null;
+ }
+
+ private void invalidateHeaders() {
+ if (!mHandler.hasMessages(MSG_BUILD_HEADERS)) {
+ mHandler.sendEmptyMessage(MSG_BUILD_HEADERS);
+ }
+ }
+
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+
+ // Sync the toggle state after onRestoreInstanceState has occurred.
+ if (mDrawerToggle != null) {
+ mDrawerToggle.syncState();
+ }
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ if (mDrawerToggle != null) {
+ mDrawerToggle.onConfigurationChanged(newConfig);
+ }
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (mDrawerToggle != null && mDrawerToggle.onOptionsItemSelected(item)) {
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ if (getIntent().hasExtra(EXTRA_UI_OPTIONS)) {
+ getWindow().setUiOptions(getIntent().getIntExtra(EXTRA_UI_OPTIONS, 0));
+ }
+
+ mAuthenticatorHelper = new AuthenticatorHelper();
+ mAuthenticatorHelper.updateAuthDescriptions(this);
+ mAuthenticatorHelper.onAccountsUpdated(this, null);
+
+ DevicePolicyManager dpm =
+ (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
+ mHeaderAdapter= new HeaderAdapter(this, getHeaders(), mAuthenticatorHelper, dpm);
+
+ mDevelopmentPreferences = getSharedPreferences(DevelopmentSettings.PREF_FILE,
+ Context.MODE_PRIVATE);
+
+ getMetaData();
+
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.settings_main);
+
+ getFragmentManager().addOnBackStackChangedListener(this);
+
+ mActionBar = getActionBar();
+ if (mActionBar != null) {
+ mActionBar.setDisplayHomeAsUpEnabled(true);
+ mActionBar.setHomeButtonEnabled(true);
+
+ mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
+ mDrawerLayout.setDrawerListener(new DrawerListener());
+
+ mDrawer = (ListView) findViewById(R.id.headers_drawer);
+ mDrawer.setAdapter(mHeaderAdapter);
+ mDrawer.setOnItemClickListener(new DrawerItemClickListener());
+ mDrawer.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
+
+ mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
+ R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close);
+ }
+
+ String initialFragment = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT);
+ Bundle initialArguments = getIntent().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS);
+
+ if (savedInstanceState != null) {
+ // We are restarting from a previous saved state; used that to
+ // initialize, instead of starting fresh.
+ ArrayList<Header> headers = savedInstanceState.getParcelableArrayList(HEADERS_TAG);
+ if (headers != null) {
+ mHeaders.addAll(headers);
+ int curHeader = savedInstanceState.getInt(CUR_HEADER_TAG,
+ (int) HEADER_ID_UNDEFINED);
+ if (curHeader >= 0 && curHeader < mHeaders.size()) {
+ setSelectedHeader(mHeaders.get(curHeader));
+ }
+ }
+
+ } else {
+ if (initialFragment != null) {
+ // If we are just showing a fragment, we want to run in
+ // new fragment mode, but don't need to compute and show
+ // the headers.
+ switchToHeader(initialFragment, initialArguments, true);
+
+ final int initialTitle = getIntent().getIntExtra(EXTRA_SHOW_FRAGMENT_TITLE, 0);
+ if (initialTitle != 0) {
+ setTitle(getText(initialTitle));
+ }
+ } else {
+ // We need to try to build the headers.
+ onBuildHeaders(mHeaders);
+
+ // If there are headers, then at this point we need to show
+ // them and, depending on the screen, we may also show in-line
+ // the currently selected preference fragment.
+ if (mHeaders.size() > 0) {
+ if (initialFragment == null) {
+ Header h = onGetInitialHeader();
+ switchToHeader(h, false);
+ } else {
+ switchToHeader(initialFragment, initialArguments, false);
+ }
+ }
+ }
+ }
+
+ // see if we should show Back/Next buttons
+ Intent intent = getIntent();
+ if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false)) {
+
+ View buttonBar = findViewById(com.android.internal.R.id.button_bar);
+ if (buttonBar != null) {
+ buttonBar.setVisibility(View.VISIBLE);
+
+ Button backButton = (Button)findViewById(com.android.internal.R.id.back_button);
+ backButton.setOnClickListener(new OnClickListener() {
+ public void onClick(View v) {
+ setResult(RESULT_CANCELED);
+ finish();
+ }
+ });
+ Button skipButton = (Button)findViewById(com.android.internal.R.id.skip_button);
+ skipButton.setOnClickListener(new OnClickListener() {
+ public void onClick(View v) {
+ setResult(RESULT_OK);
+ finish();
+ }
+ });
+ mNextButton = (Button)findViewById(com.android.internal.R.id.next_button);
+ mNextButton.setOnClickListener(new OnClickListener() {
+ public void onClick(View v) {
+ setResult(RESULT_OK);
+ finish();
+ }
+ });
+
+ // set our various button parameters
+ if (intent.hasExtra(EXTRA_PREFS_SET_NEXT_TEXT)) {
+ String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_NEXT_TEXT);
+ if (TextUtils.isEmpty(buttonText)) {
+ mNextButton.setVisibility(View.GONE);
+ }
+ else {
+ mNextButton.setText(buttonText);
+ }
+ }
+ if (intent.hasExtra(EXTRA_PREFS_SET_BACK_TEXT)) {
+ String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_BACK_TEXT);
+ if (TextUtils.isEmpty(buttonText)) {
+ backButton.setVisibility(View.GONE);
+ }
+ else {
+ backButton.setText(buttonText);
+ }
+ }
+ if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_SKIP, false)) {
+ skipButton.setVisibility(View.VISIBLE);
+ }
+ }
+ }
+
+ if (!onIsHidingHeaders()) {
+ highlightHeader(mTopLevelHeaderId);
+ }
+
+ // Retrieve any saved state
+ if (savedInstanceState != null) {
+ mCurrentHeader = savedInstanceState.getParcelable(SAVE_KEY_CURRENT_HEADER);
+ }
+ }
+
+ @Override
+ public void onBackStackChanged() {
+ final int count = getFragmentManager().getBackStackEntryCount() + 1;
+ TitlePair pair = null;
+ int last;
+ while (mTitleStack.size() > count) {
+ last = mTitleStack.size() - 1;
+ pair = mTitleStack.remove(last);
+ }
+ // Check if we go back
+ if (pair != null) {
+ int size = mTitleStack.size();
+ if (size > 0) {
+ last = mTitleStack.size() - 1;
+ pair = mTitleStack.get(last);
+ if (pair != null) {
+ final CharSequence title;
+ if (pair.first > 0) {
+ title = getText(pair.first);
+ } else {
+ title = pair.second;
+ }
+ setTitle(title);
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns the Header list
+ */
+ private List<Header> getHeaders() {
+ return mHeaders;
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+
+ if (mHeaders.size() > 0) {
+ outState.putParcelableArrayList(HEADERS_TAG, mHeaders);
+ if (mCurHeader != null) {
+ int index = mHeaders.indexOf(mCurHeader);
+ if (index >= 0) {
+ outState.putInt(CUR_HEADER_TAG, index);
+ }
+ }
+ }
+
+ // Save the current fragment, if it is the same as originally launched
+ if (mCurrentHeader != null) {
+ outState.putParcelable(SAVE_KEY_CURRENT_HEADER, mCurrentHeader);
+ }
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+
+ mDevelopmentPreferencesListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+ invalidateHeaders();
+ }
+ };
+ mDevelopmentPreferences.registerOnSharedPreferenceChangeListener(
+ mDevelopmentPreferencesListener);
+
+ mHeaderAdapter.resume();
+ invalidateHeaders();
+
+ registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+
+ unregisterReceiver(mBatteryInfoReceiver);
+
+ mHeaderAdapter.pause();
+
+ mDevelopmentPreferences.unregisterOnSharedPreferenceChangeListener(
+ mDevelopmentPreferencesListener);
+
+ mDevelopmentPreferencesListener = null;
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ if (mListeningToAccountUpdates) {
+ AccountManager.get(this).removeOnAccountsUpdatedListener(this);
+ }
+ }
+
+ /**
+ * @hide
+ */
+ protected boolean isValidFragment(String fragmentName) {
+ // Almost all fragments are wrapped in this,
+ // except for a few that have their own activities.
+ for (int i = 0; i < ENTRY_FRAGMENTS.length; i++) {
+ if (ENTRY_FRAGMENTS[i].equals(fragmentName)) return true;
+ }
+ return false;
+ }
+
+ /**
+ * When in two-pane mode, switch to the fragment pane to show the given
+ * preference fragment.
+ *
+ * @param header The new header to display.
+ * @param validate true means that the fragment's Header needs to be validated
+ */
+ private void switchToHeader(Header header, boolean validate) {
+ if (mCurHeader == header) {
+ // This is the header we are currently displaying. Just make sure
+ // to pop the stack up to its root state.
+ getFragmentManager().popBackStack(BACK_STACK_PREFS,
+ FragmentManager.POP_BACK_STACK_INCLUSIVE);
+ } else {
+ mTitleStack.clear();
+ if (header.fragment == null) {
+ throw new IllegalStateException("can't switch to header that has no fragment");
+ }
+ switchToHeaderInner(header.fragment, header.fragmentArguments, validate);
+ setSelectedHeader(header);
+ final CharSequence title;
+ if (header.fragment.equals("com.android.settings.dashboard.DashboardSummary")) {
+ title = getResources().getString(R.string.settings_label);
+ } else {
+ title = header.getTitle(getResources());
+ }
+ final TitlePair pair = new TitlePair(0, title);
+ mTitleStack.add(pair);
+ setTitle(title);
+ }
+ }
+
+ private void setSelectedHeader(Header header) {
+ mCurHeader = header;
+ int index = mHeaders.indexOf(header);
+ if (mDrawer != null) {
+ if (index >= 0) {
+ mDrawer.setItemChecked(index, true);
+ } else {
+ mDrawer.clearChoices();
+ }
+ }
+ }
+
+ public Header onGetInitialHeader() {
+ String fragmentClass = getStartingFragmentClass(super.getIntent());
+ if (fragmentClass != null) {
+ Header header = new Header();
+ header.fragment = fragmentClass;
+ header.title = getTitle();
+ header.fragmentArguments = getIntent().getExtras();
+ mCurrentHeader = header;
+ return header;
+ }
+
+ return mFirstHeader;
+ }
+
+ /**
+ * When in two-pane mode, switch the fragment pane to show the given
+ * preference fragment.
+ *
+ * @param fragmentName The name of the fragment to display.
+ * @param args Optional arguments to supply to the fragment.
+ * @param validate true means that the fragment's Header needs to be validated
+ */
+ private void switchToHeader(String fragmentName, Bundle args, boolean validate) {
+ setSelectedHeader(null);
+ switchToHeaderInner(fragmentName, args, validate);
+ }
+
+ private void switchToHeaderInner(String fragmentName, Bundle args, boolean validate) {
+ getFragmentManager().popBackStack(BACK_STACK_PREFS,
+ FragmentManager.POP_BACK_STACK_INCLUSIVE);
+ if (validate && !isValidFragment(fragmentName)) {
+ throw new IllegalArgumentException("Invalid fragment for this activity: "
+ + fragmentName);
+ }
+ Fragment f = Fragment.instantiate(this, fragmentName, args);
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
+ transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
+ transaction.replace(R.id.prefs, f);
+ transaction.commitAllowingStateLoss();
+ }
+
+ @Override
+ public void onNewIntent(Intent intent) {
+ super.onNewIntent(intent);
+
+ // If it is not launched from history, then reset to top-level
+ if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) {
+ if (mDrawer != null) {
+ mDrawer.setSelectionFromTop(0, 0);
+ }
+ }
+ }
+
+ /**
+ * Called to determine whether the header list should be hidden.
+ * The default implementation returns the
+ * value given in {@link #EXTRA_NO_HEADERS} or false if it is not supplied.
+ * This is set to false, for example, when the activity is being re-launched
+ * to show a particular preference activity.
+ */
+ public boolean onIsHidingHeaders() {
+ return getIntent().getBooleanExtra(EXTRA_NO_HEADERS, false);
+ }
+
+ private void highlightHeader(int id) {
+ if (id != 0) {
+ Integer index = mHeaderIndexMap.get(id);
+ if (index != null && mDrawer != null) {
+ mDrawer.setItemChecked(index, true);
+ if (mDrawer.getVisibility() == View.VISIBLE) {
+ mDrawer.smoothScrollToPosition(index);
+ }
+ }
+ }
+ }
+
+ @Override
+ public Intent getIntent() {
+ Intent superIntent = super.getIntent();
+ String startingFragment = getStartingFragmentClass(superIntent);
+ // This is called from super.onCreate, isMultiPane() is not yet reliable
+ // Do not use onIsHidingHeaders either, which relies itself on this method
+ if (startingFragment != null) {
+ Intent modIntent = new Intent(superIntent);
+ modIntent.putExtra(EXTRA_SHOW_FRAGMENT, startingFragment);
+ Bundle args = superIntent.getExtras();
+ if (args != null) {
+ args = new Bundle(args);
+ } else {
+ args = new Bundle();
+ }
+ args.putParcelable("intent", superIntent);
+ modIntent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, superIntent.getExtras());
+ return modIntent;
+ }
+ return superIntent;
+ }
+
+ /**
+ * Checks if the component name in the intent is different from the Settings class and
+ * returns the class name to load as a fragment.
+ */
+ private String getStartingFragmentClass(Intent intent) {
+ if (mFragmentClass != null) return mFragmentClass;
+
+ String intentClass = intent.getComponent().getClassName();
+ if (intentClass.equals(getClass().getName())) return null;
+
+ if ("com.android.settings.ManageApplications".equals(intentClass)
+ || "com.android.settings.RunningServices".equals(intentClass)
+ || "com.android.settings.applications.StorageUse".equals(intentClass)) {
+ // Old names of manage apps.
+ intentClass = com.android.settings.applications.ManageApplications.class.getName();
+ }
+
+ return intentClass;
+ }
+
+ /**
+ * Start a new fragment containing a preference panel. If the preferences
+ * are being displayed in multi-pane mode, the given fragment class will
+ * be instantiated and placed in the appropriate pane. If running in
+ * single-pane mode, a new activity will be launched in which to show the
+ * fragment.
+ *
+ * @param fragmentClass Full name of the class implementing the fragment.
+ * @param args Any desired arguments to supply to the fragment.
+ * @param titleRes Optional resource identifier of the title of this
+ * fragment.
+ * @param titleText Optional text of the title of this fragment.
+ * @param resultTo Optional fragment that result data should be sent to.
+ * If non-null, resultTo.onActivityResult() will be called when this
+ * preference panel is done. The launched panel must use
+ * {@link #finishPreferencePanel(Fragment, int, Intent)} when done.
+ * @param resultRequestCode If resultTo is non-null, this is the caller's
+ * request code to be received with the resut.
+ */
+ public void startPreferencePanel(String fragmentClass, Bundle args, int titleRes,
+ CharSequence titleText, Fragment resultTo,
+ int resultRequestCode) {
+ startWithFragment(fragmentClass, args, resultTo, resultRequestCode, titleRes, 0);
+ }
+
+ /**
+ * Called by a preference panel fragment to finish itself.
+ *
+ * @param caller The fragment that is asking to be finished.
+ * @param resultCode Optional result code to send back to the original
+ * launching fragment.
+ * @param resultData Optional result data to send back to the original
+ * launching fragment.
+ */
+ public void finishPreferencePanel(Fragment caller, int resultCode, Intent resultData) {
+ setResult(resultCode, resultData);
+ }
+
+ /**
+ * Start a new fragment.
+ *
+ * @param fragment The fragment to start
+ * @param push If true, the current fragment will be pushed onto the back stack. If false,
+ * the current fragment will be replaced.
+ */
+ public void startPreferenceFragment(Fragment fragment, boolean push) {
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
+ transaction.replace(R.id.prefs, fragment);
+ if (push) {
+ transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
+ transaction.addToBackStack(BACK_STACK_PREFS);
+ } else {
+ transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
+ }
+ transaction.commitAllowingStateLoss();
+ }
+
+ /**
+ * Start a new fragment.
+ *
+ * @param fragmentName The name of the fragment to display.
+ * @param args Optional arguments to supply to the fragment.
+ * @param resultTo Option fragment that should receive the result of
+ * the activity launch.
+ * @param resultRequestCode If resultTo is non-null, this is the request
+ * code in which to report the result.
+ * @param titleRes Resource ID of string to display for the title of
+ * this set of preferences.
+ * @param shortTitleRes Resource ID of string to display for the short title of
+ * this set of preferences.
+ */
+ private void startWithFragment(String fragmentName, Bundle args, Fragment resultTo,
+ int resultRequestCode, int titleRes, int shortTitleRes) {
+ Fragment f = Fragment.instantiate(this, fragmentName, args);
+ if (resultTo != null) {
+ f.setTargetFragment(resultTo, resultRequestCode);
+ }
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
+ transaction.replace(R.id.prefs, f);
+ transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
+ transaction.addToBackStack(BACK_STACK_PREFS);
+ transaction.commitAllowingStateLoss();
+
+ final CharSequence title = getText(titleRes);
+ final TitlePair pair = new TitlePair(titleRes, null);
+ mTitleStack.add(pair);
+ setTitle(title);
+ }
+
+ /**
+ * Called when the activity needs its list of headers build. By
+ * implementing this and adding at least one item to the list, you
+ * will cause the activity to run in its modern fragment mode. Note
+ * that this function may not always be called; for example, if the
+ * activity has been asked to display a particular fragment without
+ * the header list, there is no need to build the headers.
+ *
+ * <p>Typical implementations will use {@link #loadHeadersFromResource}
+ * to fill in the list from a resource.
+ *
+ * @param headers The list in which to place the headers.
+ */
+ private void onBuildHeaders(List<Header> headers) {
+ loadHeadersFromResource(R.xml.settings_headers, headers);
+ updateHeaderList(headers);
+ }
+
+ /**
+ * Parse the given XML file as a header description, adding each
+ * parsed Header into the target list.
+ *
+ * @param resid The XML resource to load and parse.
+ * @param target The list in which the parsed headers should be placed.
+ */
+ private void loadHeadersFromResource(int resid, List<Header> target) {
+ XmlResourceParser parser = null;
+ try {
+ parser = getResources().getXml(resid);
+ AttributeSet attrs = Xml.asAttributeSet(parser);
+
+ int type;
+ while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
+ && type != XmlPullParser.START_TAG) {
+ // Parse next until start tag is found
+ }
+
+ String nodeName = parser.getName();
+ if (!"preference-headers".equals(nodeName)) {
+ throw new RuntimeException(
+ "XML document must start with <preference-headers> tag; found"
+ + nodeName + " at " + parser.getPositionDescription());
+ }
+
+ Bundle curBundle = null;
+
+ final int outerDepth = parser.getDepth();
+ while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
+ && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
+ if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
+ continue;
+ }
+
+ nodeName = parser.getName();
+ if ("header".equals(nodeName)) {
+ Header header = new Header();
+
+ TypedArray sa = obtainStyledAttributes(
+ attrs, com.android.internal.R.styleable.PreferenceHeader);
+ header.id = sa.getResourceId(
+ com.android.internal.R.styleable.PreferenceHeader_id,
+ (int)HEADER_ID_UNDEFINED);
+ TypedValue tv = sa.peekValue(
+ com.android.internal.R.styleable.PreferenceHeader_title);
+ if (tv != null && tv.type == TypedValue.TYPE_STRING) {
+ if (tv.resourceId != 0) {
+ header.titleRes = tv.resourceId;
+ } else {
+ header.title = tv.string;
+ }
+ }
+ tv = sa.peekValue(
+ com.android.internal.R.styleable.PreferenceHeader_summary);
+ if (tv != null && tv.type == TypedValue.TYPE_STRING) {
+ if (tv.resourceId != 0) {
+ header.summaryRes = tv.resourceId;
+ } else {
+ header.summary = tv.string;
+ }
+ }
+ header.iconRes = sa.getResourceId(
+ com.android.internal.R.styleable.PreferenceHeader_icon, 0);
+ header.fragment = sa.getString(
+ com.android.internal.R.styleable.PreferenceHeader_fragment);
+ sa.recycle();
+
+ if (curBundle == null) {
+ curBundle = new Bundle();
+ }
+
+ final int innerDepth = parser.getDepth();
+ while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
+ && (type != XmlPullParser.END_TAG || parser.getDepth() > innerDepth)) {
+ if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
+ continue;
+ }
+
+ String innerNodeName = parser.getName();
+ if (innerNodeName.equals("extra")) {
+ getResources().parseBundleExtra("extra", attrs, curBundle);
+ XmlUtils.skipCurrentTag(parser);
+
+ } else if (innerNodeName.equals("intent")) {
+ header.intent = Intent.parseIntent(getResources(), parser, attrs);
+
+ } else {
+ XmlUtils.skipCurrentTag(parser);
+ }
+ }
+
+ if (curBundle.size() > 0) {
+ header.fragmentArguments = curBundle;
+ curBundle = null;
+ }
+
+ target.add(header);
+ } else {
+ XmlUtils.skipCurrentTag(parser);
+ }
+ }
+
+ } catch (XmlPullParserException e) {
+ throw new RuntimeException("Error parsing headers", e);
+ } catch (IOException e) {
+ throw new RuntimeException("Error parsing headers", e);
+ } finally {
+ if (parser != null) parser.close();
+ }
+ }
+
+ private void updateHeaderList(List<Header> target) {
+ final boolean showDev = mDevelopmentPreferences.getBoolean(
+ DevelopmentSettings.PREF_SHOW,
+ android.os.Build.TYPE.equals("eng"));
+ int i = 0;
+
+ final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
+ mHeaderIndexMap.clear();
+ while (i < target.size()) {
+ Header header = target.get(i);
+ // Ids are integers, so downcasting
+ int id = (int) header.id;
+ if (id == R.id.operator_settings || id == R.id.manufacturer_settings) {
+ Utils.updateHeaderToSpecificActivityFromMetaDataOrRemove(this, target, header);
+ } else if (id == R.id.wifi_settings) {
+ // Remove WiFi Settings if WiFi service is not available.
+ if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI)) {
+ target.remove(i);
+ }
+ } else if (id == R.id.bluetooth_settings) {
+ // Remove Bluetooth Settings if Bluetooth service is not available.
+ if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) {
+ target.remove(i);
+ }
+ } else if (id == R.id.data_usage_settings) {
+ // Remove data usage when kernel module not enabled
+ final INetworkManagementService netManager = INetworkManagementService.Stub
+ .asInterface(ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE));
+ try {
+ if (!netManager.isBandwidthControlEnabled()) {
+ target.remove(i);
+ }
+ } catch (RemoteException e) {
+ // ignored
+ }
+ } else if (id == R.id.battery_settings) {
+ // Remove battery settings when battery is not available. (e.g. TV)
+
+ if (!mBatteryPresent) {
+ target.remove(i);
+ }
+ } else if (id == R.id.account_settings) {
+ int headerIndex = i + 1;
+ i = insertAccountsHeaders(target, headerIndex);
+ } else if (id == R.id.home_settings) {
+ if (!updateHomeSettingHeaders(header)) {
+ target.remove(i);
+ }
+ } else if (id == R.id.user_settings) {
+ if (!UserHandle.MU_ENABLED
+ || !UserManager.supportsMultipleUsers()
+ || Utils.isMonkeyRunning()) {
+ target.remove(i);
+ }
+ } else if (id == R.id.nfc_payment_settings) {
+ if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC)) {
+ target.remove(i);
+ } else {
+ // Only show if NFC is on and we have the HCE feature
+ NfcAdapter adapter = NfcAdapter.getDefaultAdapter(this);
+ if (!adapter.isEnabled() || !getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)) {
+ target.remove(i);
+ }
+ }
+ } else if (id == R.id.development_settings) {
+ if (!showDev) {
+ target.remove(i);
+ }
+ } else if (id == R.id.account_add) {
+ if (um.hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS)) {
+ target.remove(i);
+ }
+ }
+
+ if (i < target.size() && target.get(i) == header
+ && UserHandle.MU_ENABLED && UserHandle.myUserId() != 0
+ && !ArrayUtils.contains(SETTINGS_FOR_RESTRICTED, id)) {
+ target.remove(i);
+ }
+
+ // Increment if the current one wasn't removed by the Utils code.
+ if (i < target.size() && target.get(i) == header) {
+ // Hold on to the first header, when we need to reset to the top-level
+ if (mFirstHeader == null &&
+ HeaderAdapter.getHeaderType(header) != HeaderAdapter.HEADER_TYPE_CATEGORY) {
+ mFirstHeader = header;
+ }
+ mHeaderIndexMap.put(id, i);
+ i++;
+ }
+ }
+ }
+
+ private int insertAccountsHeaders(List<Header> target, int headerIndex) {
+ String[] accountTypes = mAuthenticatorHelper.getEnabledAccountTypes();
+ List<Header> accountHeaders = new ArrayList<Header>(accountTypes.length);
+ for (String accountType : accountTypes) {
+ CharSequence label = mAuthenticatorHelper.getLabelForType(this, accountType);
+ if (label == null) {
+ continue;
+ }
+
+ Account[] accounts = AccountManager.get(this).getAccountsByType(accountType);
+ boolean skipToAccount = accounts.length == 1
+ && !mAuthenticatorHelper.hasAccountPreferences(accountType);
+ Header accHeader = new Header();
+ accHeader.title = label;
+ if (accHeader.extras == null) {
+ accHeader.extras = new Bundle();
+ }
+ if (skipToAccount) {
+ accHeader.fragment = AccountSyncSettings.class.getName();
+ accHeader.fragmentArguments = new Bundle();
+ // Need this for the icon
+ accHeader.extras.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE, accountType);
+ accHeader.extras.putParcelable(AccountSyncSettings.ACCOUNT_KEY, accounts[0]);
+ accHeader.fragmentArguments.putParcelable(AccountSyncSettings.ACCOUNT_KEY,
+ accounts[0]);
+ } else {
+ accHeader.fragment = ManageAccountsSettings.class.getName();
+ accHeader.fragmentArguments = new Bundle();
+ accHeader.extras.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE, accountType);
+ accHeader.fragmentArguments.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE,
+ accountType);
+ accHeader.fragmentArguments.putString(ManageAccountsSettings.KEY_ACCOUNT_LABEL,
+ label.toString());
+ }
+ accountHeaders.add(accHeader);
+ mAuthenticatorHelper.preloadDrawableForType(this, accountType);
+ }
+
+ // Sort by label
+ Collections.sort(accountHeaders, new Comparator<Header>() {
+ @Override
+ public int compare(Header h1, Header h2) {
+ return h1.title.toString().compareTo(h2.title.toString());
+ }
+ });
+
+ for (Header header : accountHeaders) {
+ target.add(headerIndex++, header);
+ }
+ if (!mListeningToAccountUpdates) {
+ AccountManager.get(this).addOnAccountsUpdatedListener(this, null, true);
+ mListeningToAccountUpdates = true;
+ }
+ return headerIndex;
+ }
+
+ private boolean updateHomeSettingHeaders(Header header) {
+ // Once we decide to show Home settings, keep showing it forever
+ SharedPreferences sp = getSharedPreferences(HomeSettings.HOME_PREFS, Context.MODE_PRIVATE);
+ if (sp.getBoolean(HomeSettings.HOME_PREFS_DO_SHOW, false)) {
+ return true;
+ }
+
+ try {
+ final ArrayList<ResolveInfo> homeApps = new ArrayList<ResolveInfo>();
+ getPackageManager().getHomeActivities(homeApps);
+ if (homeApps.size() < 2) {
+ // When there's only one available home app, omit this settings
+ // category entirely at the top level UI. If the user just
+ // uninstalled the penultimate home app candidiate, we also
+ // now tell them about why they aren't seeing 'Home' in the list.
+ if (sShowNoHomeNotice) {
+ sShowNoHomeNotice = false;
+ NoHomeDialogFragment.show(this);
+ }
+ return false;
+ } else {
+ // Okay, we're allowing the Home settings category. Tell it, when
+ // invoked via this front door, that we'll need to be told about the
+ // case when the user uninstalls all but one home app.
+ if (header.fragmentArguments == null) {
+ header.fragmentArguments = new Bundle();
+ }
+ header.fragmentArguments.putBoolean(HomeSettings.HOME_SHOW_NOTICE, true);
+ }
+ } catch (Exception e) {
+ // Can't look up the home activity; bail on configuring the icon
+ Log.w(LOG_TAG, "Problem looking up home activity!", e);
+ }
+
+ sp.edit().putBoolean(HomeSettings.HOME_PREFS_DO_SHOW, true).apply();
+ return true;
+ }
+
+ private void getMetaData() {
+ try {
+ ActivityInfo ai = getPackageManager().getActivityInfo(getComponentName(),
+ PackageManager.GET_META_DATA);
+ if (ai == null || ai.metaData == null) return;
+ mTopLevelHeaderId = ai.metaData.getInt(META_DATA_KEY_HEADER_ID);
+ mFragmentClass = ai.metaData.getString(META_DATA_KEY_FRAGMENT_CLASS);
+ } catch (NameNotFoundException nnfe) {
+ // No recovery
+ Log.d(LOG_TAG, "Cannot get Metadata for: " + getComponentName().toString());
+ }
+ }
+
+ // give subclasses access to the Next button
+ public boolean hasNextButton() {
+ return mNextButton != null;
+ }
+
+ public Button getNextButton() {
+ return mNextButton;
+ }
+
+ public static class NoHomeDialogFragment extends DialogFragment {
+ public static void show(Activity parent) {
+ final NoHomeDialogFragment dialog = new NoHomeDialogFragment();
+ dialog.show(parent.getFragmentManager(), null);
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ return new AlertDialog.Builder(getActivity())
+ .setMessage(R.string.only_one_home_message)
+ .setPositiveButton(android.R.string.ok, null)
+ .create();
+ }
+ }
+
+ private static class HeaderAdapter extends ArrayAdapter<Header> {
+ static final int HEADER_TYPE_CATEGORY = 0;
+ static final int HEADER_TYPE_NORMAL = 1;
+ static final int HEADER_TYPE_SWITCH = 2;
+ static final int HEADER_TYPE_BUTTON = 3;
+ private static final int HEADER_TYPE_COUNT = HEADER_TYPE_BUTTON + 1;
+
+ private final WifiEnabler mWifiEnabler;
+ private final BluetoothEnabler mBluetoothEnabler;
+ private AuthenticatorHelper mAuthHelper;
+ private DevicePolicyManager mDevicePolicyManager;
+
+ private static class HeaderViewHolder {
+ ImageView mIcon;
+ TextView mTitle;
+ TextView mSummary;
+ Switch mSwitch;
+ ImageButton mButton;
+ View mDivider;
+ }
+
+ private LayoutInflater mInflater;
+
+ static int getHeaderType(Header header) {
+ if (header.fragment == null && header.intent == null) {
+ return HEADER_TYPE_CATEGORY;
+ } else if (header.id == R.id.wifi_settings || header.id == R.id.bluetooth_settings) {
+ return HEADER_TYPE_SWITCH;
+ } else if (header.id == R.id.security_settings) {
+ return HEADER_TYPE_BUTTON;
+ } else {
+ return HEADER_TYPE_NORMAL;
+ }
+ }
+
+ @Override
+ public int getItemViewType(int position) {
+ Header header = getItem(position);
+ return getHeaderType(header);
+ }
+
+ @Override
+ public boolean areAllItemsEnabled() {
+ return false; // because of categories
+ }
+
+ @Override
+ public boolean isEnabled(int position) {
+ return getItemViewType(position) != HEADER_TYPE_CATEGORY;
+ }
+
+ @Override
+ public int getViewTypeCount() {
+ return HEADER_TYPE_COUNT;
+ }
+
+ @Override
+ public boolean hasStableIds() {
+ return true;
+ }
+
+ public HeaderAdapter(Context context, List<Header> objects,
+ AuthenticatorHelper authenticatorHelper, DevicePolicyManager dpm) {
+ super(context, 0, objects);
+
+ mAuthHelper = authenticatorHelper;
+ mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+
+ // Temp Switches provided as placeholder until the adapter replaces these with actual
+ // Switches inflated from their layouts. Must be done before adapter is set in super
+ mWifiEnabler = new WifiEnabler(context, new Switch(context));
+ mBluetoothEnabler = new BluetoothEnabler(context, new Switch(context));
+ mDevicePolicyManager = dpm;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ HeaderViewHolder holder;
+ Header header = getItem(position);
+ int headerType = getHeaderType(header);
+ View view = null;
+
+ if (convertView == null) {
+ holder = new HeaderViewHolder();
+ switch (headerType) {
+ case HEADER_TYPE_CATEGORY:
+ view = new TextView(getContext(), null,
+ android.R.attr.listSeparatorTextViewStyle);
+ holder.mTitle = (TextView) view;
+ break;
+
+ case HEADER_TYPE_SWITCH:
+ view = mInflater.inflate(R.layout.preference_header_switch_item, parent,
+ false);
+ holder.mIcon = (ImageView) view.findViewById(R.id.icon);
+ holder.mTitle = (TextView)
+ view.findViewById(com.android.internal.R.id.title);
+ holder.mSummary = (TextView)
+ view.findViewById(com.android.internal.R.id.summary);
+ holder.mSwitch = (Switch) view.findViewById(R.id.switchWidget);
+ break;
+
+ case HEADER_TYPE_BUTTON:
+ view = mInflater.inflate(R.layout.preference_header_button_item, parent,
+ false);
+ holder.mIcon = (ImageView) view.findViewById(R.id.icon);
+ holder.mTitle = (TextView)
+ view.findViewById(com.android.internal.R.id.title);
+ holder.mSummary = (TextView)
+ view.findViewById(com.android.internal.R.id.summary);
+ holder.mButton = (ImageButton) view.findViewById(R.id.buttonWidget);
+ holder.mDivider = view.findViewById(R.id.divider);
+ break;
+
+ case HEADER_TYPE_NORMAL:
+ view = mInflater.inflate(
+ R.layout.preference_header_item, parent,
+ false);
+ holder.mIcon = (ImageView) view.findViewById(R.id.icon);
+ holder.mTitle = (TextView)
+ view.findViewById(com.android.internal.R.id.title);
+ holder.mSummary = (TextView)
+ view.findViewById(com.android.internal.R.id.summary);
+ break;
+ }
+ view.setTag(holder);
+ } else {
+ view = convertView;
+ holder = (HeaderViewHolder) view.getTag();
+ }
+
+ // All view fields must be updated every time, because the view may be recycled
+ switch (headerType) {
+ case HEADER_TYPE_CATEGORY:
+ holder.mTitle.setText(header.getTitle(getContext().getResources()));
+ break;
+
+ case HEADER_TYPE_SWITCH:
+ // Would need a different treatment if the main menu had more switches
+ if (header.id == R.id.wifi_settings) {
+ mWifiEnabler.setSwitch(holder.mSwitch);
+ } else {
+ mBluetoothEnabler.setSwitch(holder.mSwitch);
+ }
+ updateCommonHeaderView(header, holder);
+ break;
+
+ case HEADER_TYPE_BUTTON:
+ if (header.id == R.id.security_settings) {
+ boolean hasCert = DevicePolicyManager.hasAnyCaCertsInstalled();
+ if (hasCert) {
+ holder.mButton.setVisibility(View.VISIBLE);
+ holder.mDivider.setVisibility(View.VISIBLE);
+ boolean isManaged = mDevicePolicyManager.getDeviceOwner() != null;
+ if (isManaged) {
+ holder.mButton.setImageResource(R.drawable.ic_settings_about);
+ } else {
+ holder.mButton.setImageResource(
+ android.R.drawable.stat_notify_error);
+ }
+ holder.mButton.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(
+ android.provider.Settings.ACTION_MONITORING_CERT_INFO);
+ getContext().startActivity(intent);
+ }
+ });
+ } else {
+ holder.mButton.setVisibility(View.GONE);
+ holder.mDivider.setVisibility(View.GONE);
+ }
+ }
+ updateCommonHeaderView(header, holder);
+ break;
+
+ case HEADER_TYPE_NORMAL:
+ updateCommonHeaderView(header, holder);
+ break;
+ }
+
+ return view;
+ }
+
+ private void updateCommonHeaderView(Header header, HeaderViewHolder holder) {
+ if (header.extras != null
+ && header.extras.containsKey(ManageAccountsSettings.KEY_ACCOUNT_TYPE)) {
+ String accType = header.extras.getString(
+ ManageAccountsSettings.KEY_ACCOUNT_TYPE);
+ Drawable icon = mAuthHelper.getDrawableForType(getContext(), accType);
+ setHeaderIcon(holder, icon);
+ } else {
+ holder.mIcon.setImageResource(header.iconRes);
+ }
+ holder.mTitle.setText(header.getTitle(getContext().getResources()));
+ CharSequence summary = header.getSummary(getContext().getResources());
+ if (!TextUtils.isEmpty(summary)) {
+ holder.mSummary.setVisibility(View.VISIBLE);
+ holder.mSummary.setText(summary);
+ } else {
+ holder.mSummary.setVisibility(View.GONE);
+ }
+ }
+
+ private void setHeaderIcon(HeaderViewHolder holder, Drawable icon) {
+ ViewGroup.LayoutParams lp = holder.mIcon.getLayoutParams();
+ lp.width = getContext().getResources().getDimensionPixelSize(
+ R.dimen.header_icon_width);
+ lp.height = lp.width;
+ holder.mIcon.setLayoutParams(lp);
+ holder.mIcon.setImageDrawable(icon);
+ }
+
+ public void resume() {
+ mWifiEnabler.resume();
+ mBluetoothEnabler.resume();
+ }
+
+ public void pause() {
+ mWifiEnabler.pause();
+ mBluetoothEnabler.pause();
+ }
+ }
+
+ private void onListItemClick(ListView l, View v, int position, long id) {
+ if (!isResumed()) {
+ return;
+ }
+ Object item = mHeaderAdapter.getItem(position);
+ if (item instanceof Header) {
+ mCurrentHeader = (Header) item;
+ }
+ }
+
+ /**
+ * Called when the user selects an item in the header list. The default
+ * implementation will call either
+ * {@link #startWithFragment(String, Bundle, Fragment, int, int, int)}
+ * or {@link #switchToHeader(com.android.settings.SettingsActivity.Header, boolean)}
+ * as appropriate.
+ *
+ * @param header The header that was selected.
+ */
+ private void onHeaderClick(Header header) {
+ if (header == null) return;
+ if (header.fragment != null) {
+ switchToHeader(header, false);
+ } else if (header.intent != null) {
+ startActivity(header.intent);
+ }
+ }
+
+ @Override
+ public boolean shouldUpRecreateTask(Intent targetIntent) {
+ return super.shouldUpRecreateTask(new Intent(this, SettingsActivity.class));
+ }
+
+ @Override
+ public void onAccountsUpdated(Account[] accounts) {
+ // TODO: watch for package upgrades to invalidate cache; see 7206643
+ mAuthenticatorHelper.updateAuthDescriptions(this);
+ mAuthenticatorHelper.onAccountsUpdated(this, accounts);
+ invalidateHeaders();
+ }
+
+ public static void requestHomeNotice() {
+ sShowNoHomeNotice = true;
+ }
+
+ /**
+ * Default value for {@link Header#id Header.id} indicating that no
+ * identifier value is set. All other values (including those below -1)
+ * are valid.
+ */
+ private static final long HEADER_ID_UNDEFINED = -1;
+
+ /**
+ * Description of a single Header item that the user can select.
+ */
+ static final class Header implements Parcelable {
+ /**
+ * Identifier for this header, to correlate with a new list when
+ * it is updated. The default value is
+ * {@link SettingsActivity#HEADER_ID_UNDEFINED}, meaning no id.
+ * @attr ref android.R.styleable#PreferenceHeader_id
+ */
+ public long id = HEADER_ID_UNDEFINED;
+
+ /**
+ * Resource ID of title of the header that is shown to the user.
+ * @attr ref android.R.styleable#PreferenceHeader_title
+ */
+ public int titleRes;
+
+ /**
+ * Title of the header that is shown to the user.
+ * @attr ref android.R.styleable#PreferenceHeader_title
+ */
+ public CharSequence title;
+
+ /**
+ * Resource ID of optional summary describing what this header controls.
+ * @attr ref android.R.styleable#PreferenceHeader_summary
+ */
+ public int summaryRes;
+
+ /**
+ * Optional summary describing what this header controls.
+ * @attr ref android.R.styleable#PreferenceHeader_summary
+ */
+ public CharSequence summary;
+
+ /**
+ * Optional icon resource to show for this header.
+ * @attr ref android.R.styleable#PreferenceHeader_icon
+ */
+ public int iconRes;
+
+ /**
+ * Full class name of the fragment to display when this header is
+ * selected.
+ * @attr ref android.R.styleable#PreferenceHeader_fragment
+ */
+ public String fragment;
+
+ /**
+ * Optional arguments to supply to the fragment when it is
+ * instantiated.
+ */
+ public Bundle fragmentArguments;
+
+ /**
+ * Intent to launch when the preference is selected.
+ */
+ public Intent intent;
+
+ /**
+ * Optional additional data for use by subclasses of the activity
+ */
+ public Bundle extras;
+
+ public Header() {
+ // Empty
+ }
+
+ /**
+ * Return the currently set title. If {@link #titleRes} is set,
+ * this resource is loaded from <var>res</var> and returned. Otherwise
+ * {@link #title} is returned.
+ */
+ public CharSequence getTitle(Resources res) {
+ if (titleRes != 0) {
+ return res.getText(titleRes);
+ }
+ return title;
+ }
+
+ /**
+ * Return the currently set summary. If {@link #summaryRes} is set,
+ * this resource is loaded from <var>res</var> and returned. Otherwise
+ * {@link #summary} is returned.
+ */
+ public CharSequence getSummary(Resources res) {
+ if (summaryRes != 0) {
+ return res.getText(summaryRes);
+ }
+ return summary;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeLong(id);
+ dest.writeInt(titleRes);
+ TextUtils.writeToParcel(title, dest, flags);
+ dest.writeInt(summaryRes);
+ TextUtils.writeToParcel(summary, dest, flags);
+ dest.writeInt(iconRes);
+ dest.writeString(fragment);
+ dest.writeBundle(fragmentArguments);
+ if (intent != null) {
+ dest.writeInt(1);
+ intent.writeToParcel(dest, flags);
+ } else {
+ dest.writeInt(0);
+ }
+ dest.writeBundle(extras);
+ }
+
+ public void readFromParcel(Parcel in) {
+ id = in.readLong();
+ titleRes = in.readInt();
+ title = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
+ summaryRes = in.readInt();
+ summary = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
+ iconRes = in.readInt();
+ fragment = in.readString();
+ fragmentArguments = in.readBundle();
+ if (in.readInt() != 0) {
+ intent = Intent.CREATOR.createFromParcel(in);
+ }
+ extras = in.readBundle();
+ }
+
+ Header(Parcel in) {
+ readFromParcel(in);
+ }
+
+ public static final Creator<Header> CREATOR = new Creator<Header>() {
+ public Header createFromParcel(Parcel source) {
+ return new Header(source);
+ }
+ public Header[] newArray(int size) {
+ return new Header[size];
+ }
+ };
+ }
+}
diff --git a/src/com/android/settings/SettingsPreferenceFragment.java b/src/com/android/settings/SettingsPreferenceFragment.java
index 0a382b5..d91c11b 100644
--- a/src/com/android/settings/SettingsPreferenceFragment.java
+++ b/src/com/android/settings/SettingsPreferenceFragment.java
@@ -22,12 +22,9 @@ import android.app.Fragment;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
-import android.content.Intent;
import android.content.pm.PackageManager;
-import android.net.Uri;
import android.os.Bundle;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
import android.preference.PreferenceFragment;
import android.text.TextUtils;
import android.util.Log;
@@ -305,13 +302,13 @@ public class SettingsPreferenceFragment extends PreferenceFragment implements Di
public boolean startFragment(
Fragment caller, String fragmentClass, int requestCode, Bundle extras) {
- if (getActivity() instanceof PreferenceActivity) {
- PreferenceActivity preferenceActivity = (PreferenceActivity)getActivity();
- preferenceActivity.startPreferencePanel(fragmentClass, extras,
+ if (getActivity() instanceof SettingsActivity) {
+ SettingsActivity sa = (SettingsActivity) getActivity();
+ sa.startPreferencePanel(fragmentClass, extras,
R.string.lock_settings_picker_title, null, caller, requestCode);
return true;
} else {
- Log.w(TAG, "Parent isn't PreferenceActivity, thus there's no way to launch the "
+ Log.w(TAG, "Parent isn't Settings activity, thus there's no way to launch the "
+ "given Fragment (name: " + fragmentClass + ", requestCode: " + requestCode
+ ")");
return false;
diff --git a/src/com/android/settings/SubSettings.java b/src/com/android/settings/SubSettings.java
index bcc56e1..04955b2 100644
--- a/src/com/android/settings/SubSettings.java
+++ b/src/com/android/settings/SubSettings.java
@@ -22,7 +22,7 @@ import android.util.Log;
* Stub class for showing sub-settings; we can't use the main Settings class
* since for our app it is a special singleTask class.
*/
-public class SubSettings extends Settings {
+public class SubSettings extends SettingsActivity {
@Override
public boolean onNavigateUp() {
diff --git a/src/com/android/settings/TestingSettings.java b/src/com/android/settings/TestingSettings.java
index 3994560..2eadd84 100644
--- a/src/com/android/settings/TestingSettings.java
+++ b/src/com/android/settings/TestingSettings.java
@@ -17,15 +17,13 @@
package com.android.settings;
import android.os.Bundle;
-import android.preference.PreferenceActivity;
-public class TestingSettings extends PreferenceActivity {
+public class TestingSettings extends SettingsPreferenceFragment {
@Override
- protected void onCreate(Bundle savedInstanceState) {
+ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.testing_settings);
}
-
}
diff --git a/src/com/android/settings/UserDictionarySettings.java b/src/com/android/settings/UserDictionarySettings.java
index da12004..1e9fd0a 100644
--- a/src/com/android/settings/UserDictionarySettings.java
+++ b/src/com/android/settings/UserDictionarySettings.java
@@ -192,9 +192,8 @@ public class UserDictionarySettings extends ListFragment {
args.putString(UserDictionaryAddWordContents.EXTRA_WORD, editingWord);
args.putString(UserDictionaryAddWordContents.EXTRA_SHORTCUT, editingShortcut);
args.putString(UserDictionaryAddWordContents.EXTRA_LOCALE, mLocale);
- android.preference.PreferenceActivity pa =
- (android.preference.PreferenceActivity)getActivity();
- pa.startPreferencePanel(
+ SettingsActivity sa = (SettingsActivity) getActivity();
+ sa.startPreferencePanel(
com.android.settings.inputmethod.UserDictionaryAddWordFragment.class.getName(),
args, R.string.user_dict_settings_add_dialog_title, null, null, 0);
}
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index c676ee8..bf44835 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -42,7 +42,6 @@ import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
import android.preference.Preference;
-import android.preference.PreferenceActivity.Header;
import android.preference.PreferenceFrameLayout;
import android.preference.PreferenceGroup;
import android.provider.ContactsContract.CommonDataKinds;
@@ -238,7 +237,7 @@ public class Utils {
}
public static boolean updateHeaderToSpecificActivityFromMetaDataOrRemove(Context context,
- List<Header> target, Header header) {
+ List<SettingsActivity.Header> target, SettingsActivity.Header header) {
Intent intent = header.intent;
if (intent != null) {
diff --git a/src/com/android/settings/WirelessSettings.java b/src/com/android/settings/WirelessSettings.java
index ae8fdcf..59074e5 100644
--- a/src/com/android/settings/WirelessSettings.java
+++ b/src/com/android/settings/WirelessSettings.java
@@ -92,7 +92,7 @@ public class WirelessSettings extends RestrictedSettingsFragment
}
/**
* Invoked on each preference click in this hierarchy, overrides
- * PreferenceActivity's implementation. Used to make sure we track the
+ * PreferenceFragment's implementation. Used to make sure we track the
* preference click events.
*/
@Override
diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
index 482ea70..d56e37c 100644
--- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
@@ -23,7 +23,6 @@ import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen;
import android.view.Gravity;
import android.view.Menu;
@@ -35,6 +34,7 @@ import android.view.accessibility.AccessibilityManager;
import android.widget.TextView;
import com.android.settings.R;
+import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
public abstract class ToggleFeaturePreferenceFragment
@@ -126,8 +126,8 @@ public abstract class ToggleFeaturePreferenceFragment
}
public void setTitle(String title) {
- final PreferenceActivity activity = (PreferenceActivity) getActivity();
- if (!activity.onIsMultiPane() || activity.onIsHidingHeaders()) {
+ final SettingsActivity activity = (SettingsActivity) getActivity();
+ if (!activity.onIsHidingHeaders()) {
getActivity().setTitle(title);
}
}
diff --git a/src/com/android/settings/accounts/AccountPreferenceBase.java b/src/com/android/settings/accounts/AccountPreferenceBase.java
index 2759a8f..f533263 100644
--- a/src/com/android/settings/accounts/AccountPreferenceBase.java
+++ b/src/com/android/settings/accounts/AccountPreferenceBase.java
@@ -38,7 +38,6 @@ import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
-import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen;
import android.text.format.DateFormat;
import android.util.Log;
diff --git a/src/com/android/settings/accounts/AddAccountSettings.java b/src/com/android/settings/accounts/AddAccountSettings.java
index 39906eb..3f98e59 100644
--- a/src/com/android/settings/accounts/AddAccountSettings.java
+++ b/src/com/android/settings/accounts/AddAccountSettings.java
@@ -31,6 +31,7 @@ import android.util.Log;
import android.widget.Toast;
import com.android.settings.R;
+import com.android.settings.Settings;
import com.android.settings.Utils;
import java.io.IOException;
@@ -142,7 +143,7 @@ public class AddAccountSettings extends Activity {
getIntent().getStringArrayExtra(AccountPreferenceBase.AUTHORITIES_FILTER_KEY);
final String[] accountTypes =
getIntent().getStringArrayExtra(AccountPreferenceBase.ACCOUNT_TYPES_FILTER_KEY);
- final Intent intent = new Intent(this, ChooseAccountActivity.class);
+ final Intent intent = new Intent(this, Settings.ChooseAccountActivity.class);
if (authorities != null) {
intent.putExtra(AccountPreferenceBase.AUTHORITIES_FILTER_KEY, authorities);
}
diff --git a/src/com/android/settings/accounts/ChooseAccountActivity.java b/src/com/android/settings/accounts/ChooseAccountFragment.java
index 631fe47..292c3dd 100644
--- a/src/com/android/settings/accounts/ChooseAccountActivity.java
+++ b/src/com/android/settings/accounts/ChooseAccountFragment.java
@@ -18,6 +18,7 @@ package com.android.settings.accounts;
import android.accounts.AccountManager;
import android.accounts.AuthenticatorDescription;
+import android.app.Activity;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
@@ -27,12 +28,12 @@ import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.util.Log;
import com.android.internal.util.CharSequences;
import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
import com.google.android.collect.Maps;
import java.util.ArrayList;
@@ -44,9 +45,9 @@ import java.util.Map;
/**
* Activity asking a user to select an account to be set up.
*/
-public class ChooseAccountActivity extends PreferenceActivity {
+public class ChooseAccountFragment extends SettingsPreferenceFragment {
- private static final String TAG = "ChooseAccountActivity";
+ private static final String TAG = "ChooseAccountFragment";
private String[] mAuthorities;
private PreferenceGroup mAddAccountGroup;
private final ArrayList<ProviderEntry> mProviderList = new ArrayList<ProviderEntry>();
@@ -76,14 +77,13 @@ public class ChooseAccountActivity extends PreferenceActivity {
}
@Override
- protected void onCreate(Bundle icicle) {
+ public void onCreate(Bundle icicle) {
super.onCreate(icicle);
- setContentView(R.layout.add_account_screen);
addPreferencesFromResource(R.xml.add_account_settings);
- mAuthorities = getIntent().getStringArrayExtra(
+ mAuthorities = getActivity().getIntent().getStringArrayExtra(
AccountPreferenceBase.AUTHORITIES_FILTER_KEY);
- String[] accountTypesFilter = getIntent().getStringArrayExtra(
+ String[] accountTypesFilter = getActivity().getIntent().getStringArrayExtra(
AccountPreferenceBase.ACCOUNT_TYPES_FILTER_KEY);
if (accountTypesFilter != null) {
mAccountTypesFilter = new HashSet<String>();
@@ -100,7 +100,7 @@ public class ChooseAccountActivity extends PreferenceActivity {
* and update any UI that depends on AuthenticatorDescriptions in onAuthDescriptionsUpdated().
*/
private void updateAuthDescriptions() {
- mAuthDescs = AccountManager.get(this).getAuthenticatorTypes();
+ mAuthDescs = AccountManager.get(getActivity()).getAuthenticatorTypes();
for (int i = 0; i < mAuthDescs.length; i++) {
mTypeToAuthDescription.put(mAuthDescs[i].type, mAuthDescs[i]);
}
@@ -148,7 +148,7 @@ public class ChooseAccountActivity extends PreferenceActivity {
for (ProviderEntry pref : mProviderList) {
Drawable drawable = getDrawableForType(pref.type);
ProviderPreference p =
- new ProviderPreference(this, pref.type, drawable, pref.name);
+ new ProviderPreference(getActivity(), pref.type, drawable, pref.name);
mAddAccountGroup.addPreference(p);
}
} else {
@@ -160,7 +160,7 @@ public class ChooseAccountActivity extends PreferenceActivity {
}
Log.v(TAG, "No providers found for authorities: " + auths);
}
- setResult(RESULT_CANCELED);
+ getActivity().setResult(Activity.RESULT_CANCELED);
finish();
}
}
@@ -196,7 +196,7 @@ public class ChooseAccountActivity extends PreferenceActivity {
if (mTypeToAuthDescription.containsKey(accountType)) {
try {
AuthenticatorDescription desc = mTypeToAuthDescription.get(accountType);
- Context authContext = createPackageContext(desc.packageName, 0);
+ Context authContext = getActivity().createPackageContext(desc.packageName, 0);
icon = authContext.getResources().getDrawable(desc.iconId);
} catch (PackageManager.NameNotFoundException e) {
// TODO: place holder icon for missing account icons?
@@ -219,7 +219,7 @@ public class ChooseAccountActivity extends PreferenceActivity {
if (mTypeToAuthDescription.containsKey(accountType)) {
try {
AuthenticatorDescription desc = mTypeToAuthDescription.get(accountType);
- Context authContext = createPackageContext(desc.packageName, 0);
+ Context authContext = getActivity().createPackageContext(desc.packageName, 0);
label = authContext.getResources().getText(desc.labelId);
} catch (PackageManager.NameNotFoundException e) {
Log.w(TAG, "No label name for account type " + accountType);
@@ -245,7 +245,7 @@ public class ChooseAccountActivity extends PreferenceActivity {
private void finishWithAccountType(String accountType) {
Intent intent = new Intent();
intent.putExtra(AddAccountSettings.EXTRA_SELECTED_ACCOUNT, accountType);
- setResult(RESULT_OK, intent);
+ getActivity().setResult(Activity.RESULT_OK, intent);
finish();
}
}
diff --git a/src/com/android/settings/accounts/ManageAccountsSettings.java b/src/com/android/settings/accounts/ManageAccountsSettings.java
index 184f680..b5a6579 100644
--- a/src/com/android/settings/accounts/ManageAccountsSettings.java
+++ b/src/com/android/settings/accounts/ManageAccountsSettings.java
@@ -31,7 +31,6 @@ import android.content.pm.ResolveInfo;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen;
import android.util.Log;
import android.view.LayoutInflater;
@@ -45,6 +44,7 @@ import android.widget.TextView;
import com.android.settings.AccountPreference;
import com.android.settings.R;
+import com.android.settings.SettingsActivity;
import com.android.settings.Utils;
import com.android.settings.location.LocationSettings;
@@ -146,7 +146,7 @@ public class ManageAccountsSettings extends AccountPreferenceBase
private void startAccountSettings(AccountPreference acctPref) {
Bundle args = new Bundle();
args.putParcelable(AccountSyncSettings.ACCOUNT_KEY, acctPref.getAccount());
- ((PreferenceActivity) getActivity()).startPreferencePanel(
+ ((SettingsActivity) getActivity()).startPreferencePanel(
AccountSyncSettings.class.getCanonicalName(), args,
R.string.account_sync_settings_title, acctPref.getAccount().name,
this, REQUEST_SHOW_SYNC_SETTINGS);
@@ -368,7 +368,7 @@ public class ManageAccountsSettings extends AccountPreferenceBase
@Override
public boolean onPreferenceClick(Preference preference) {
- ((PreferenceActivity) getActivity()).startPreferencePanel(
+ ((SettingsActivity) getActivity()).startPreferencePanel(
mClass, null, mTitleRes, null, null, 0);
// Hack: announce that the Google account preferences page is launching the location
// settings
diff --git a/src/com/android/settings/accounts/SyncSettingsActivity.java b/src/com/android/settings/accounts/SyncSettingsActivity.java
index 96f16d6..bbd9f91 100644
--- a/src/com/android/settings/accounts/SyncSettingsActivity.java
+++ b/src/com/android/settings/accounts/SyncSettingsActivity.java
@@ -16,22 +16,20 @@
package com.android.settings.accounts;
-import android.app.Fragment;
import android.content.Intent;
-import android.preference.PreferenceActivity;
-import com.android.settings.ChooseLockGeneric.ChooseLockGenericFragment;
+import com.android.settings.SettingsActivity;
/**
* Launcher activity for the SyncSettings fragment.
*
*/
-public class SyncSettingsActivity extends PreferenceActivity {
+public class SyncSettingsActivity extends SettingsActivity {
@Override
public Intent getIntent() {
- Intent modIntent = new Intent(super.getIntent());
- modIntent.putExtra(EXTRA_SHOW_FRAGMENT, SyncSettings.class.getName());
- modIntent.putExtra(EXTRA_NO_HEADERS, true);
+ Intent modIntent = new Intent(getIntent());
+ modIntent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT, SyncSettings.class.getName());
+ modIntent.putExtra(SettingsActivity.EXTRA_NO_HEADERS, true);
return modIntent;
}
diff --git a/src/com/android/settings/applications/AppOpsCategory.java b/src/com/android/settings/applications/AppOpsCategory.java
index 125a43b..03ebb9e 100644
--- a/src/com/android/settings/applications/AppOpsCategory.java
+++ b/src/com/android/settings/applications/AppOpsCategory.java
@@ -28,7 +28,6 @@ import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;
-import android.preference.PreferenceActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -40,6 +39,7 @@ import android.widget.TextView;
import java.util.List;
import com.android.settings.R;
+import com.android.settings.SettingsActivity;
import com.android.settings.applications.AppOpsState.AppOpEntry;
public class AppOpsCategory extends ListFragment implements
@@ -333,8 +333,8 @@ public class AppOpsCategory extends ListFragment implements
Bundle args = new Bundle();
args.putString(AppOpsDetails.ARG_PACKAGE_NAME, mCurrentPkgName);
- PreferenceActivity pa = (PreferenceActivity)getActivity();
- pa.startPreferencePanel(AppOpsDetails.class.getName(), args,
+ SettingsActivity sa = (SettingsActivity) getActivity();
+ sa.startPreferencePanel(AppOpsDetails.class.getName(), args,
R.string.app_ops_settings, null, this, RESULT_APP_DETAILS);
}
diff --git a/src/com/android/settings/applications/AppOpsDetails.java b/src/com/android/settings/applications/AppOpsDetails.java
index 1e2ac7d..d9dec19 100644
--- a/src/com/android/settings/applications/AppOpsDetails.java
+++ b/src/com/android/settings/applications/AppOpsDetails.java
@@ -28,7 +28,6 @@ import android.content.pm.PermissionGroupInfo;
import android.content.pm.PermissionInfo;
import android.content.res.Resources;
import android.os.Bundle;
-import android.preference.PreferenceActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -40,6 +39,7 @@ import android.widget.Switch;
import android.widget.TextView;
import com.android.settings.R;
+import com.android.settings.SettingsActivity;
import com.android.settings.Utils;
import java.util.List;
@@ -161,8 +161,8 @@ public class AppOpsDetails extends Fragment {
private void setIntentAndFinish(boolean finish, boolean appChanged) {
Intent intent = new Intent();
intent.putExtra(ManageApplications.APP_CHG, appChanged);
- PreferenceActivity pa = (PreferenceActivity)getActivity();
- pa.finishPreferencePanel(this, Activity.RESULT_OK, intent);
+ SettingsActivity sa = (SettingsActivity)getActivity();
+ sa.finishPreferencePanel(this, Activity.RESULT_OK, intent);
}
/** Called when the activity is first created. */
diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java
index 1b3938c..722f569 100644
--- a/src/com/android/settings/applications/InstalledAppDetails.java
+++ b/src/com/android/settings/applications/InstalledAppDetails.java
@@ -19,6 +19,7 @@ package com.android.settings.applications;
import com.android.internal.telephony.ISms;
import com.android.internal.telephony.SmsUsageMonitor;
import com.android.settings.R;
+import com.android.settings.SettingsActivity;
import com.android.settings.Utils;
import com.android.settings.applications.ApplicationsState.AppEntry;
@@ -57,7 +58,6 @@ import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.os.UserManager;
-import android.preference.PreferenceActivity;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.format.Formatter;
@@ -920,8 +920,8 @@ public class InstalledAppDetails extends Fragment
if(localLOGV) Log.i(TAG, "appChanged="+appChanged);
Intent intent = new Intent();
intent.putExtra(ManageApplications.APP_CHG, appChanged);
- PreferenceActivity pa = (PreferenceActivity)getActivity();
- pa.finishPreferencePanel(this, Activity.RESULT_OK, intent);
+ SettingsActivity sa = (SettingsActivity)getActivity();
+ sa.finishPreferencePanel(this, Activity.RESULT_OK, intent);
}
private void refreshSizeInfo() {
diff --git a/src/com/android/settings/applications/InstalledAppDetailsTop.java b/src/com/android/settings/applications/InstalledAppDetailsTop.java
index 44a88fb..e731c1c 100644
--- a/src/com/android/settings/applications/InstalledAppDetailsTop.java
+++ b/src/com/android/settings/applications/InstalledAppDetailsTop.java
@@ -1,12 +1,25 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
package com.android.settings.applications;
-import android.app.Fragment;
import android.content.Intent;
-import android.preference.PreferenceActivity;
-
-import com.android.settings.ChooseLockGeneric.ChooseLockGenericFragment;
+import com.android.settings.SettingsActivity;
-public class InstalledAppDetailsTop extends PreferenceActivity {
+public class InstalledAppDetailsTop extends SettingsActivity {
@Override
public Intent getIntent() {
@@ -21,5 +34,4 @@ public class InstalledAppDetailsTop extends PreferenceActivity {
if (InstalledAppDetails.class.getName().equals(fragmentName)) return true;
return false;
}
-
}
diff --git a/src/com/android/settings/applications/ManageApplications.java b/src/com/android/settings/applications/ManageApplications.java
index 0a1dcb1..5a11e6e 100644
--- a/src/com/android/settings/applications/ManageApplications.java
+++ b/src/com/android/settings/applications/ManageApplications.java
@@ -29,7 +29,6 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
-import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
@@ -44,9 +43,7 @@ import android.os.IBinder;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
-import android.preference.PreferenceActivity;
import android.preference.PreferenceFrameLayout;
-import android.provider.Settings;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.PagerTabStrip;
import android.support.v4.view.ViewPager;
@@ -72,6 +69,7 @@ import android.widget.TextView;
import com.android.internal.app.IMediaContainerService;
import com.android.internal.content.PackageHelper;
import com.android.settings.R;
+import com.android.settings.SettingsActivity;
import com.android.settings.Settings.RunningServicesActivity;
import com.android.settings.Settings.StorageUseActivity;
import com.android.settings.applications.ApplicationsState.AppEntry;
@@ -844,7 +842,7 @@ public class ManageApplications extends Fragment implements
|| className.endsWith(".StorageUse")) {
mSortOrder = SORT_ORDER_SIZE;
defaultListType = LIST_TYPE_ALL;
- } else if (Settings.ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS.equals(action)) {
+ } else if (android.provider.Settings.ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS.equals(action)) {
// Select the all-apps list, with the default sorting
defaultListType = LIST_TYPE_ALL;
}
@@ -1026,8 +1024,8 @@ public class ManageApplications extends Fragment implements
Bundle args = new Bundle();
args.putString(InstalledAppDetails.ARG_PACKAGE_NAME, mCurrentPkgName);
- PreferenceActivity pa = (PreferenceActivity)getActivity();
- pa.startPreferencePanel(InstalledAppDetails.class.getName(), args,
+ SettingsActivity sa = (SettingsActivity) getActivity();
+ sa.startPreferencePanel(InstalledAppDetails.class.getName(), args,
R.string.application_info_label, null, this, INSTALLED_APP_DETAILS);
}
diff --git a/src/com/android/settings/applications/ProcessStatsDetail.java b/src/com/android/settings/applications/ProcessStatsDetail.java
index 326ca7b..5d0660a 100644
--- a/src/com/android/settings/applications/ProcessStatsDetail.java
+++ b/src/com/android/settings/applications/ProcessStatsDetail.java
@@ -30,7 +30,6 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.Process;
import android.os.UserHandle;
-import android.preference.PreferenceActivity;
import android.text.format.Formatter;
import android.view.LayoutInflater;
import android.view.View;
@@ -161,7 +160,6 @@ public class ProcessStatsDetail extends Fragment implements Button.OnClickListen
}
private void doAction(int action) {
- PreferenceActivity pa = (PreferenceActivity)getActivity();
switch (action) {
case ACTION_FORCE_STOP:
killProcesses();
diff --git a/src/com/android/settings/applications/ProcessStatsUi.java b/src/com/android/settings/applications/ProcessStatsUi.java
index 3180221..9deb22d 100644
--- a/src/com/android/settings/applications/ProcessStatsUi.java
+++ b/src/com/android/settings/applications/ProcessStatsUi.java
@@ -25,7 +25,6 @@ import android.os.ServiceManager;
import android.os.SystemClock;
import android.os.UserManager;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
import android.preference.PreferenceFragment;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
@@ -40,6 +39,7 @@ import com.android.internal.app.IProcessStats;
import com.android.internal.app.ProcessMap;
import com.android.internal.app.ProcessStats;
import com.android.settings.R;
+import com.android.settings.SettingsActivity;
import com.android.settings.fuelgauge.Utils;
import java.io.IOException;
@@ -192,7 +192,7 @@ public class ProcessStatsUi extends PreferenceFragment
args.putBoolean(ProcessStatsDetail.EXTRA_USE_USS, mUseUss);
args.putLong(ProcessStatsDetail.EXTRA_MAX_WEIGHT, mMaxWeight);
args.putLong(ProcessStatsDetail.EXTRA_TOTAL_TIME, mTotalTime);
- ((PreferenceActivity) getActivity()).startPreferencePanel(
+ ((SettingsActivity) getActivity()).startPreferencePanel(
ProcessStatsDetail.class.getName(), args, R.string.details_title, null, null, 0);
return super.onPreferenceTreeClick(preferenceScreen, preference);
diff --git a/src/com/android/settings/applications/RunningProcessesView.java b/src/com/android/settings/applications/RunningProcessesView.java
index 8eb0496..caa5450 100644
--- a/src/com/android/settings/applications/RunningProcessesView.java
+++ b/src/com/android/settings/applications/RunningProcessesView.java
@@ -28,7 +28,6 @@ import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.SystemClock;
import android.os.UserHandle;
-import android.preference.PreferenceActivity;
import android.text.format.DateUtils;
import android.text.format.Formatter;
import android.util.AttributeSet;
@@ -42,6 +41,7 @@ import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AbsListView.RecyclerListener;
+import com.android.settings.SettingsActivity;
import java.util.ArrayList;
import java.util.Collections;
@@ -397,9 +397,9 @@ public class RunningProcessesView extends FrameLayout
}
args.putInt(RunningServiceDetails.KEY_USER_ID, mi.mUserId);
args.putBoolean(RunningServiceDetails.KEY_BACKGROUND, mAdapter.mShowBackground);
-
- PreferenceActivity pa = (PreferenceActivity)mOwner.getActivity();
- pa.startPreferencePanel(RunningServiceDetails.class.getName(), args,
+
+ SettingsActivity sa = (SettingsActivity) mOwner.getActivity();
+ sa.startPreferencePanel(RunningServiceDetails.class.getName(), args,
R.string.runningservicedetails_settings_title, null, null, 0);
}
}
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index 4cb36c8..14c6054 100755
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -28,7 +28,6 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
@@ -42,6 +41,7 @@ import android.widget.Switch;
import android.widget.TextView;
import com.android.settings.R;
+import com.android.settings.SettingsActivity;
/**
* BluetoothSettings is the Settings screen for Bluetooth configuration and
@@ -58,16 +58,16 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment {
"android.btopp.intent.action.OPEN_RECEIVED_FILES";
private BluetoothEnabler mBluetoothEnabler;
-
private BluetoothDiscoverableEnabler mDiscoverableEnabler;
private PreferenceGroup mPairedDevicesCategory;
-
private PreferenceGroup mAvailableDevicesCategory;
private boolean mAvailableDevicesCategoryIsPresent;
+
private boolean mActivityStarted;
private TextView mEmptyView;
+ private Switch mSwitch;
private final IntentFilter mIntentFilter;
@@ -103,32 +103,45 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment {
mEmptyView = (TextView) getView().findViewById(android.R.id.empty);
getListView().setEmptyView(mEmptyView);
+
+ final Activity activity = getActivity();
+ final int padding = activity.getResources().getDimensionPixelSize(
+ R.dimen.action_bar_switch_padding);
+ mSwitch = new Switch(activity);
+ mSwitch.setPaddingRelative(0, 0, padding, 0);
+
+ mBluetoothEnabler = new BluetoothEnabler(activity, mSwitch);
}
@Override
- void addPreferencesForActivity() {
- addPreferencesFromResource(R.xml.bluetooth_settings);
+ public void onStart() {
+ super.onStart();
+
+ final SettingsActivity activity = (SettingsActivity) getActivity();
+
+ if (!activity.onIsHidingHeaders()) {
+ activity.getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
+ ActionBar.DISPLAY_SHOW_CUSTOM);
+ activity.getActionBar().setCustomView(mSwitch, new ActionBar.LayoutParams(
+ ActionBar.LayoutParams.WRAP_CONTENT,
+ ActionBar.LayoutParams.WRAP_CONTENT,
+ Gravity.CENTER_VERTICAL | Gravity.END));
+ }
+ }
- Activity activity = getActivity();
-
- Switch actionBarSwitch = new Switch(activity);
-
- if (activity instanceof PreferenceActivity) {
- PreferenceActivity preferenceActivity = (PreferenceActivity) activity;
- if (preferenceActivity.onIsHidingHeaders() || !preferenceActivity.onIsMultiPane()) {
- final int padding = activity.getResources().getDimensionPixelSize(
- R.dimen.action_bar_switch_padding);
- actionBarSwitch.setPaddingRelative(0, 0, padding, 0);
- activity.getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
- ActionBar.DISPLAY_SHOW_CUSTOM);
- activity.getActionBar().setCustomView(actionBarSwitch, new ActionBar.LayoutParams(
- ActionBar.LayoutParams.WRAP_CONTENT,
- ActionBar.LayoutParams.WRAP_CONTENT,
- Gravity.CENTER_VERTICAL | Gravity.END));
- }
+ @Override
+ public void onStop() {
+ super.onStop();
+ final SettingsActivity activity = (SettingsActivity) getActivity();
+ if (!activity.onIsHidingHeaders()) {
+ activity.getActionBar().setDisplayOptions(0, ActionBar.DISPLAY_SHOW_CUSTOM);
+ activity.getActionBar().setCustomView(null);
}
+ }
- mBluetoothEnabler = new BluetoothEnabler(activity, actionBarSwitch);
+ @Override
+ void addPreferencesForActivity() {
+ addPreferencesFromResource(R.xml.bluetooth_settings);
setHasOptionsMenu(true);
}
@@ -348,7 +361,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment {
public void onClick(View v) {
if (isRestrictedAndNotPinProtected()) return;
- ((PreferenceActivity) getActivity()).startPreferencePanel(
+ ((SettingsActivity) getActivity()).startPreferencePanel(
LocalDeviceProfilesSettings.class.getName(), null,
0, mLocalAdapter.getName(), null, 0);
}
@@ -366,7 +379,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment {
Bundle args = new Bundle(1);
args.putParcelable(DeviceProfilesSettings.EXTRA_DEVICE, device.getDevice());
- ((PreferenceActivity) getActivity()).startPreferencePanel(
+ ((SettingsActivity) getActivity()).startPreferencePanel(
DeviceProfilesSettings.class.getName(), args,
R.string.bluetooth_device_advanced_title, null, null, 0);
} else {
diff --git a/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java b/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java
index e2faf7f..9ced992 100644
--- a/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java
+++ b/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java
@@ -25,9 +25,7 @@ import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.util.Log;
-import com.android.settings.ProgressCategory;
import com.android.settings.RestrictedSettingsFragment;
-import com.android.settings.SettingsPreferenceFragment;
import java.util.Collection;
import java.util.WeakHashMap;
diff --git a/src/com/android/settings/dashboard/DashboardSummary.java b/src/com/android/settings/dashboard/DashboardSummary.java
new file mode 100644
index 0000000..f5b47ae
--- /dev/null
+++ b/src/com/android/settings/dashboard/DashboardSummary.java
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+package com.android.settings.dashboard;
+
+import android.app.Fragment;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import com.android.settings.R;
+
+public class DashboardSummary extends Fragment {
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+
+ final View view = inflater.inflate(R.layout.dashboard, container, false);
+
+ return view;
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/Memory.java b/src/com/android/settings/deviceinfo/Memory.java
index 999611d..4923070 100644
--- a/src/com/android/settings/deviceinfo/Memory.java
+++ b/src/com/android/settings/deviceinfo/Memory.java
@@ -40,7 +40,6 @@ import android.os.storage.StorageEventListener;
import android.os.storage.StorageManager;
import android.os.storage.StorageVolume;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen;
import android.util.Log;
import android.view.Menu;
@@ -49,6 +48,7 @@ import android.view.MenuItem;
import android.widget.Toast;
import com.android.settings.R;
+import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;
import com.google.android.collect.Lists;
@@ -186,8 +186,8 @@ public class Memory extends SettingsPreferenceFragment {
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.storage_usb:
- if (getActivity() instanceof PreferenceActivity) {
- ((PreferenceActivity) getActivity()).startPreferencePanel(
+ if (getActivity() instanceof SettingsActivity) {
+ ((SettingsActivity) getActivity()).startPreferencePanel(
UsbSettings.class.getCanonicalName(),
null,
R.string.storage_title_usb, null,
diff --git a/src/com/android/settings/deviceinfo/Status.java b/src/com/android/settings/deviceinfo/Status.java
index a448dae..f9f0416 100644
--- a/src/com/android/settings/deviceinfo/Status.java
+++ b/src/com/android/settings/deviceinfo/Status.java
@@ -16,6 +16,7 @@
package com.android.settings.deviceinfo;
+import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.content.BroadcastReceiver;
import android.content.ClipboardManager;
@@ -24,7 +25,6 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
@@ -35,19 +35,15 @@ import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
-import android.preference.PreferenceScreen;
import android.telephony.CellBroadcastMessage;
import android.telephony.PhoneNumberUtils;
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
-import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListAdapter;
-import android.widget.ListView;
import android.widget.Toast;
import com.android.internal.telephony.Phone;
@@ -56,6 +52,7 @@ import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.PhoneStateIntentReceiver;
import com.android.internal.util.ArrayUtils;
import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;
import java.lang.ref.WeakReference;
@@ -75,7 +72,7 @@ import java.lang.ref.WeakReference;
* # XMPP/buzz/tickle status : TODO
*
*/
-public class Status extends PreferenceActivity {
+public class Status extends SettingsPreferenceFragment {
private static final String KEY_DATA_STATE = "data_state";
private static final String KEY_SERVICE_STATE = "service_state";
@@ -166,8 +163,8 @@ public class Status extends PreferenceActivity {
private static class MyHandler extends Handler {
private WeakReference<Status> mStatus;
- public MyHandler(Status activity) {
- mStatus = new WeakReference<Status>(activity);
+ public MyHandler(Status status) {
+ mStatus = new WeakReference<Status>(status);
}
@Override
@@ -257,14 +254,14 @@ public class Status extends PreferenceActivity {
}
@Override
- protected void onCreate(Bundle icicle) {
+ public void onCreate(Bundle icicle) {
super.onCreate(icicle);
mHandler = new MyHandler(this);
- mCM = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
- mTelephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
- mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
+ mCM = (ConnectivityManager) getSystemService(Activity.CONNECTIVITY_SERVICE);
+ mTelephonyManager = (TelephonyManager)getSystemService(Activity.TELEPHONY_SERVICE);
+ mWifiManager = (WifiManager) getSystemService(Activity.WIFI_SERVICE);
addPreferencesFromResource(R.xml.device_info_status);
mBatteryLevel = findPreference(KEY_BATTERY_LEVEL);
@@ -279,13 +276,14 @@ public class Status extends PreferenceActivity {
mUnavailable = mRes.getString(R.string.status_unavailable);
if (UserHandle.myUserId() == UserHandle.USER_OWNER) {
+ PhoneFactory.makeDefaultPhone(getActivity());
mPhone = PhoneFactory.getDefaultPhone();
}
// Note - missing in zaku build, be careful later...
mSignalStrength = findPreference(KEY_SIGNAL_STRENGTH);
mUptime = findPreference("up_time");
- if (mPhone == null || Utils.isWifiOnly(getApplicationContext())) {
+ if (mPhone == null || Utils.isWifiOnly(getActivity())) {
for (String key : PHONE_RELATED_ENTRIES) {
removePreferenceFromScreen(key);
}
@@ -315,7 +313,7 @@ public class Status extends PreferenceActivity {
setSummaryText(KEY_IMEI, mPhone.getDeviceId());
setSummaryText(KEY_IMEI_SV,
- ((TelephonyManager) getSystemService(TELEPHONY_SERVICE))
+ ((TelephonyManager) getSystemService(Activity.TELEPHONY_SERVICE))
.getDeviceSoftwareVersion());
// device is not CDMA, do not display CDMA features
@@ -339,7 +337,7 @@ public class Status extends PreferenceActivity {
// If formattedNumber is null or empty, it'll display as "Unknown".
setSummaryText(KEY_PHONE_NUMBER, formattedNumber);
- mPhoneStateReceiver = new PhoneStateIntentReceiver(this, mHandler);
+ mPhoneStateReceiver = new PhoneStateIntentReceiver(getActivity(), mHandler);
mPhoneStateReceiver.notifySignalStrength(EVENT_SIGNAL_STRENGTH_CHANGED);
mPhoneStateReceiver.notifyServiceState(EVENT_SERVICE_STATE_CHANGED);
@@ -371,34 +369,39 @@ public class Status extends PreferenceActivity {
} else {
removePreferenceFromScreen(KEY_SERIAL_NUMBER);
}
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
// Make every pref on this screen copy its data to the clipboard on longpress.
// Super convenient for capturing the IMEI, MAC addr, serial, etc.
getListView().setOnItemLongClickListener(
- new AdapterView.OnItemLongClickListener() {
- @Override
- public boolean onItemLongClick(AdapterView<?> parent, View view,
- int position, long id) {
- ListAdapter listAdapter = (ListAdapter) parent.getAdapter();
- Preference pref = (Preference) listAdapter.getItem(position);
-
- ClipboardManager cm = (ClipboardManager)
- getSystemService(Context.CLIPBOARD_SERVICE);
- cm.setText(pref.getSummary());
- Toast.makeText(
- Status.this,
- com.android.internal.R.string.text_copied,
- Toast.LENGTH_SHORT).show();
- return true;
- }
- });
+ new AdapterView.OnItemLongClickListener() {
+ @Override
+ public boolean onItemLongClick(AdapterView<?> parent, View view,
+ int position, long id) {
+ ListAdapter listAdapter = (ListAdapter) parent.getAdapter();
+ Preference pref = (Preference) listAdapter.getItem(position);
+
+ ClipboardManager cm = (ClipboardManager)
+ getSystemService(Context.CLIPBOARD_SERVICE);
+ cm.setText(pref.getSummary());
+ Toast.makeText(
+ getActivity(),
+ com.android.internal.R.string.text_copied,
+ Toast.LENGTH_SHORT).show();
+ return true;
+ }
+ });
}
@Override
- protected void onResume() {
+ public void onResume() {
super.onResume();
- if (mPhone != null && !Utils.isWifiOnly(getApplicationContext())) {
+ if (mPhone != null && !Utils.isWifiOnly(getActivity())) {
mPhoneStateReceiver.registerIntent();
updateSignalStrength();
@@ -407,17 +410,17 @@ public class Status extends PreferenceActivity {
mTelephonyManager.listen(mPhoneStateListener,
PhoneStateListener.LISTEN_DATA_CONNECTION_STATE);
if (mShowLatestAreaInfo) {
- registerReceiver(mAreaInfoReceiver, new IntentFilter(CB_AREA_INFO_RECEIVED_ACTION),
+ getActivity().registerReceiver(mAreaInfoReceiver, new IntentFilter(CB_AREA_INFO_RECEIVED_ACTION),
CB_AREA_INFO_SENDER_PERMISSION, null);
// Ask CellBroadcastReceiver to broadcast the latest area info received
Intent getLatestIntent = new Intent(GET_LATEST_CB_AREA_INFO_ACTION);
- sendBroadcastAsUser(getLatestIntent, UserHandle.ALL,
+ getActivity().sendBroadcastAsUser(getLatestIntent, UserHandle.ALL,
CB_AREA_INFO_SENDER_PERMISSION);
}
}
- registerReceiver(mConnectivityReceiver, mConnectivityIntentFilter,
- android.Manifest.permission.CHANGE_NETWORK_STATE, null);
- registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
+ getActivity().registerReceiver(mConnectivityReceiver, mConnectivityIntentFilter,
+ android.Manifest.permission.CHANGE_NETWORK_STATE, null);
+ getActivity().registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
mHandler.sendEmptyMessage(EVENT_UPDATE_STATS);
}
@@ -425,15 +428,15 @@ public class Status extends PreferenceActivity {
public void onPause() {
super.onPause();
- if (mPhone != null && !Utils.isWifiOnly(getApplicationContext())) {
+ if (mPhone != null && !Utils.isWifiOnly(getActivity())) {
mPhoneStateReceiver.unregisterIntent();
mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
}
if (mShowLatestAreaInfo) {
- unregisterReceiver(mAreaInfoReceiver);
+ getActivity().unregisterReceiver(mAreaInfoReceiver);
}
- unregisterReceiver(mBatteryInfoReceiver);
- unregisterReceiver(mConnectivityReceiver);
+ getActivity().unregisterReceiver(mBatteryInfoReceiver);
+ getActivity().unregisterReceiver(mConnectivityReceiver);
mHandler.removeMessages(EVENT_UPDATE_STATS);
}
diff --git a/src/com/android/settings/deviceinfo/StorageVolumePreferenceCategory.java b/src/com/android/settings/deviceinfo/StorageVolumePreferenceCategory.java
index 29b1e92..d62d62c 100644
--- a/src/com/android/settings/deviceinfo/StorageVolumePreferenceCategory.java
+++ b/src/com/android/settings/deviceinfo/StorageVolumePreferenceCategory.java
@@ -38,6 +38,7 @@ import android.provider.MediaStore;
import android.text.format.Formatter;
import com.android.settings.R;
+import com.android.settings.Settings;
import com.android.settings.deviceinfo.StorageMeasurement.MeasurementDetails;
import com.android.settings.deviceinfo.StorageMeasurement.MeasurementReceiver;
import com.google.android.collect.Lists;
@@ -425,8 +426,7 @@ public class StorageVolumePreferenceCategory extends PreferenceCategory {
intent.putExtra(StorageVolume.EXTRA_STORAGE_VOLUME, mVolume);
} else if (pref == mItemApps) {
intent = new Intent(Intent.ACTION_MANAGE_PACKAGE_STORAGE);
- intent.setClass(getContext(),
- com.android.settings.Settings.ManageApplicationsActivity.class);
+ intent.setClass(getContext(), Settings.ManageApplicationsActivity.class);
} else if (pref == mItemDownloads) {
intent = new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS).putExtra(
DownloadManager.INTENT_EXTRAS_SORT_BY_SIZE, true);
diff --git a/src/com/android/settings/fuelgauge/PowerUsageDetail.java b/src/com/android/settings/fuelgauge/PowerUsageDetail.java
index 01bd4f3..a1e7278 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageDetail.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageDetail.java
@@ -38,8 +38,6 @@ import android.os.BatteryStats;
import android.os.Bundle;
import android.os.Process;
import android.os.UserHandle;
-import android.preference.PreferenceActivity;
-import android.provider.Settings;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
@@ -54,6 +52,7 @@ import com.android.internal.os.BatteryStatsHelper;
import com.android.internal.util.FastPrintWriter;
import com.android.settings.DisplaySettings;
import com.android.settings.R;
+import com.android.settings.SettingsActivity;
import com.android.settings.WirelessSettings;
import com.android.settings.applications.InstalledAppDetails;
import com.android.settings.bluetooth.BluetoothSettings;
@@ -81,7 +80,7 @@ public class PowerUsageDetail extends Fragment implements Button.OnClickListener
};
public static void startBatteryDetailPage(
- PreferenceActivity caller, BatteryStatsHelper helper, BatteryEntry entry,
+ SettingsActivity caller, BatteryStatsHelper helper, BatteryEntry entry,
boolean showLocationButton) {
// Initialize mStats if necessary.
helper.getStats();
@@ -400,8 +399,8 @@ public class PowerUsageDetail extends Fragment implements Button.OnClickListener
mReportButton.setOnClickListener(this);
// check if error reporting is enabled in secure settings
- int enabled = Settings.Global.getInt(getActivity().getContentResolver(),
- Settings.Global.SEND_ACTION_APP_ERROR, 0);
+ int enabled = android.provider.Settings.Global.getInt(getActivity().getContentResolver(),
+ android.provider.Settings.Global.SEND_ACTION_APP_ERROR, 0);
if (enabled != 0) {
if (mPackages != null && mPackages.length > 0) {
try {
@@ -431,35 +430,35 @@ public class PowerUsageDetail extends Fragment implements Button.OnClickListener
Bundle args = new Bundle();
args.putString(InstalledAppDetails.ARG_PACKAGE_NAME, mPackages[0]);
- PreferenceActivity pa = (PreferenceActivity)getActivity();
- pa.startPreferencePanel(InstalledAppDetails.class.getName(), args,
+ SettingsActivity sa = (SettingsActivity) getActivity();
+ sa.startPreferencePanel(InstalledAppDetails.class.getName(), args,
R.string.application_info_label, null, null, 0);
}
private void doAction(int action) {
- PreferenceActivity pa = (PreferenceActivity)getActivity();
+ SettingsActivity sa = (SettingsActivity)getActivity();
switch (action) {
case ACTION_DISPLAY_SETTINGS:
- pa.startPreferencePanel(DisplaySettings.class.getName(), null,
+ sa.startPreferencePanel(DisplaySettings.class.getName(), null,
R.string.display_settings_title, null, null, 0);
break;
case ACTION_WIFI_SETTINGS:
- pa.startPreferencePanel(WifiSettings.class.getName(), null,
+ sa.startPreferencePanel(WifiSettings.class.getName(), null,
R.string.wifi_settings, null, null, 0);
break;
case ACTION_BLUETOOTH_SETTINGS:
- pa.startPreferencePanel(BluetoothSettings.class.getName(), null,
+ sa.startPreferencePanel(BluetoothSettings.class.getName(), null,
R.string.bluetooth_settings, null, null, 0);
break;
case ACTION_WIRELESS_SETTINGS:
- pa.startPreferencePanel(WirelessSettings.class.getName(), null,
+ sa.startPreferencePanel(WirelessSettings.class.getName(), null,
R.string.radio_controls_title, null, null, 0);
break;
case ACTION_APP_DETAILS:
startApplicationDetailsActivity();
break;
case ACTION_LOCATION_SETTINGS:
- pa.startPreferencePanel(LocationSettings.class.getName(), null,
+ sa.startPreferencePanel(LocationSettings.class.getName(), null,
R.string.location_settings_title, null, null, 0);
break;
case ACTION_FORCE_STOP:
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index 06aff2e..24b5060 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -29,7 +29,6 @@ import android.os.Parcel;
import android.os.UserHandle;
import android.os.UserManager;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
import android.preference.PreferenceFragment;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
@@ -43,6 +42,7 @@ import com.android.internal.os.BatteryStatsHelper;
import com.android.internal.os.PowerProfile;
import com.android.settings.HelpUtils;
import com.android.settings.R;
+import com.android.settings.SettingsActivity;
import java.util.List;
@@ -141,8 +141,8 @@ public class PowerUsageSummary extends PreferenceFragment {
byte[] histData = hist.marshall();
Bundle args = new Bundle();
args.putByteArray(BatteryHistoryDetail.EXTRA_STATS, histData);
- PreferenceActivity pa = (PreferenceActivity)getActivity();
- pa.startPreferencePanel(BatteryHistoryDetail.class.getName(), args,
+ SettingsActivity sa = (SettingsActivity) getActivity();
+ sa.startPreferencePanel(BatteryHistoryDetail.class.getName(), args,
R.string.history_details_title, null, null, 0);
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
@@ -151,7 +151,7 @@ public class PowerUsageSummary extends PreferenceFragment {
}
PowerGaugePreference pgp = (PowerGaugePreference) preference;
BatteryEntry entry = pgp.getInfo();
- PowerUsageDetail.startBatteryDetailPage((PreferenceActivity) getActivity(), mStatsHelper,
+ PowerUsageDetail.startBatteryDetailPage((SettingsActivity) getActivity(), mStatsHelper,
entry, true);
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
diff --git a/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnablerActivity.java b/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnablerActivity.java
index 5693e20..67e32ab 100644
--- a/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnablerActivity.java
+++ b/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnablerActivity.java
@@ -15,13 +15,11 @@
*/
package com.android.settings.inputmethod;
-import android.app.Fragment;
import android.content.Intent;
-import android.preference.PreferenceActivity;
-import com.android.settings.ChooseLockPassword.ChooseLockPasswordFragment;
+import com.android.settings.SettingsActivity;
-public class InputMethodAndSubtypeEnablerActivity extends PreferenceActivity {
+public class InputMethodAndSubtypeEnablerActivity extends SettingsActivity {
@Override
public Intent getIntent() {
final Intent modIntent = new Intent(super.getIntent());
diff --git a/src/com/android/settings/inputmethod/InputMethodPreference.java b/src/com/android/settings/inputmethod/InputMethodPreference.java
index aa6430f..1d920de 100644
--- a/src/com/android/settings/inputmethod/InputMethodPreference.java
+++ b/src/com/android/settings/inputmethod/InputMethodPreference.java
@@ -18,6 +18,7 @@ package com.android.settings.inputmethod;
import com.android.internal.inputmethod.InputMethodUtils;
import com.android.settings.R;
+import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;
@@ -31,8 +32,6 @@ import android.content.res.Configuration;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
-import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
@@ -115,7 +114,7 @@ public class InputMethodPreference extends CheckBoxPreference {
@Override
public boolean onLongClick(View arg0) {
final Bundle bundle = new Bundle();
- bundle.putString(Settings.EXTRA_INPUT_METHOD_ID, imiId);
+ bundle.putString(android.provider.Settings.EXTRA_INPUT_METHOD_ID, imiId);
startFragment(mFragment, InputMethodAndSubtypeEnabler.class.getName(),
0, bundle);
return true;
@@ -147,7 +146,7 @@ public class InputMethodPreference extends CheckBoxPreference {
@Override
public boolean onLongClick(View arg0) {
final Bundle bundle = new Bundle();
- bundle.putString(Settings.EXTRA_INPUT_METHOD_ID, imiId);
+ bundle.putString(android.provider.Settings.EXTRA_INPUT_METHOD_ID, imiId);
startFragment(mFragment, InputMethodAndSubtypeEnabler.class.getName(),
0, bundle);
return true;
@@ -206,13 +205,12 @@ public class InputMethodPreference extends CheckBoxPreference {
public static boolean startFragment(
Fragment fragment, String fragmentClass, int requestCode, Bundle extras) {
- if (fragment.getActivity() instanceof PreferenceActivity) {
- PreferenceActivity preferenceActivity = (PreferenceActivity)fragment.getActivity();
- preferenceActivity.startPreferencePanel(fragmentClass, extras, 0, null, fragment,
- requestCode);
+ if (fragment.getActivity() instanceof SettingsActivity) {
+ SettingsActivity sa = (SettingsActivity) fragment.getActivity();
+ sa.startPreferencePanel(fragmentClass, extras, 0, null, fragment, requestCode);
return true;
} else {
- Log.w(TAG, "Parent isn't PreferenceActivity, thus there's no way to launch the "
+ Log.w(TAG, "Parent isn't Settings, thus there's no way to launch the "
+ "given Fragment (name: " + fragmentClass + ", requestCode: " + requestCode
+ ")");
return false;
diff --git a/src/com/android/settings/inputmethod/KeyboardLayoutDialogFragment.java b/src/com/android/settings/inputmethod/KeyboardLayoutDialogFragment.java
index 451b36e..c77b2c9 100644
--- a/src/com/android/settings/inputmethod/KeyboardLayoutDialogFragment.java
+++ b/src/com/android/settings/inputmethod/KeyboardLayoutDialogFragment.java
@@ -17,7 +17,6 @@
package com.android.settings.inputmethod;
import com.android.settings.R;
-import com.android.settings.Settings.KeyboardLayoutPickerActivity;
import android.app.AlertDialog;
import android.app.Activity;
@@ -29,7 +28,6 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.Loader;
-import android.content.res.Resources;
import android.hardware.input.InputDeviceIdentifier;
import android.hardware.input.InputManager;
import android.hardware.input.KeyboardLayout;
diff --git a/src/com/android/settings/inputmethod/UserDictionaryAddWordFragment.java b/src/com/android/settings/inputmethod/UserDictionaryAddWordFragment.java
index 86c3e79..4f231cb 100644
--- a/src/com/android/settings/inputmethod/UserDictionaryAddWordFragment.java
+++ b/src/com/android/settings/inputmethod/UserDictionaryAddWordFragment.java
@@ -18,7 +18,6 @@ package com.android.settings.inputmethod;
import android.app.Fragment;
import android.os.Bundle;
-import android.preference.PreferenceActivity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@@ -29,6 +28,7 @@ import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import com.android.settings.R;
+import com.android.settings.SettingsActivity;
import com.android.settings.inputmethod.UserDictionaryAddWordContents.LocaleRenderer;
import java.util.ArrayList;
@@ -137,8 +137,8 @@ public class UserDictionaryAddWordFragment extends Fragment
final long id) {
final LocaleRenderer locale = (LocaleRenderer)parent.getItemAtPosition(pos);
if (locale.isMoreLanguages()) {
- PreferenceActivity preferenceActivity = (PreferenceActivity)getActivity();
- preferenceActivity.startPreferenceFragment(new UserDictionaryLocalePicker(this), true);
+ SettingsActivity sa = (SettingsActivity)getActivity();
+ sa.startPreferenceFragment(new UserDictionaryLocalePicker(this), true);
} else {
mContents.updateLocale(locale.getLocaleString());
}
diff --git a/src/com/android/settings/location/LocationSettings.java b/src/com/android/settings/location/LocationSettings.java
index 6612ba9..40156cf 100644
--- a/src/com/android/settings/location/LocationSettings.java
+++ b/src/com/android/settings/location/LocationSettings.java
@@ -17,23 +17,24 @@
package com.android.settings.location;
import android.app.ActionBar;
+import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.location.SettingInjectorService;
+import android.os.Bundle;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
-import android.provider.Settings;
import android.util.Log;
import android.view.Gravity;
import android.widget.CompoundButton;
import android.widget.Switch;
import com.android.settings.R;
+import com.android.settings.SettingsActivity;
import java.util.Collections;
import java.util.Comparator;
@@ -67,10 +68,48 @@ public class LocationSettings extends LocationSettingsBase
}
@Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ final Activity activity = getActivity();
+
+ mSwitch = new Switch(activity);
+ final int padding = activity.getResources().getDimensionPixelSize(
+ R.dimen.action_bar_switch_padding);
+ mSwitch.setPaddingRelative(0, 0, padding, 0);
+ mSwitch.setOnCheckedChangeListener(this);
+ }
+
+ @Override
+ public void onStart() {
+ super.onStart();
+
+ final SettingsActivity activity = (SettingsActivity) getActivity();
+
+ // Only show the master switch when we're not being used as Setup Wizard.
+ if (!activity.onIsHidingHeaders()) {
+ activity.getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
+ ActionBar.DISPLAY_SHOW_CUSTOM);
+ activity.getActionBar().setCustomView(mSwitch, new ActionBar.LayoutParams(
+ ActionBar.LayoutParams.WRAP_CONTENT,
+ ActionBar.LayoutParams.WRAP_CONTENT,
+ Gravity.CENTER_VERTICAL | Gravity.END));
+ }
+ }
+
+ @Override
+ public void onStop() {
+ super.onStop();
+ final SettingsActivity activity = (SettingsActivity) getActivity();
+ if (!activity.onIsHidingHeaders()) {
+ activity.getActionBar().setDisplayOptions(0, ActionBar.DISPLAY_SHOW_CUSTOM);
+ activity.getActionBar().setCustomView(null);
+ }
+ }
+
+ @Override
public void onResume() {
super.onResume();
- mSwitch = new Switch(getActivity());
- mSwitch.setOnCheckedChangeListener(this);
mValidListener = true;
createPreferenceHierarchy();
}
@@ -101,7 +140,7 @@ public class LocationSettings extends LocationSettingsBase
}
private PreferenceScreen createPreferenceHierarchy() {
- final PreferenceActivity activity = (PreferenceActivity) getActivity();
+ final SettingsActivity activity = (SettingsActivity) getActivity();
PreferenceScreen root = getPreferenceScreen();
if (root != null) {
root.removeAll();
@@ -139,22 +178,6 @@ public class LocationSettings extends LocationSettingsBase
addLocationServices(activity, root);
- // Only show the master switch when we're not in multi-pane mode, and not being used as
- // Setup Wizard.
- if (activity.onIsHidingHeaders() || !activity.onIsMultiPane()) {
- final int padding = activity.getResources().getDimensionPixelSize(
- R.dimen.action_bar_switch_padding);
- mSwitch.setPaddingRelative(0, 0, padding, 0);
- activity.getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
- ActionBar.DISPLAY_SHOW_CUSTOM);
- activity.getActionBar().setCustomView(mSwitch, new ActionBar.LayoutParams(
- ActionBar.LayoutParams.WRAP_CONTENT,
- ActionBar.LayoutParams.WRAP_CONTENT,
- Gravity.CENTER_VERTICAL | Gravity.END));
- }
-
- setHasOptionsMenu(true);
-
refreshLocationMode();
return root;
}
@@ -202,16 +225,16 @@ public class LocationSettings extends LocationSettingsBase
@Override
public void onModeChanged(int mode, boolean restricted) {
switch (mode) {
- case Settings.Secure.LOCATION_MODE_OFF:
+ case android.provider.Settings.Secure.LOCATION_MODE_OFF:
mLocationMode.setSummary(R.string.location_mode_location_off_title);
break;
- case Settings.Secure.LOCATION_MODE_SENSORS_ONLY:
+ case android.provider.Settings.Secure.LOCATION_MODE_SENSORS_ONLY:
mLocationMode.setSummary(R.string.location_mode_sensors_only_title);
break;
- case Settings.Secure.LOCATION_MODE_BATTERY_SAVING:
+ case android.provider.Settings.Secure.LOCATION_MODE_BATTERY_SAVING:
mLocationMode.setSummary(R.string.location_mode_battery_saving_title);
break;
- case Settings.Secure.LOCATION_MODE_HIGH_ACCURACY:
+ case android.provider.Settings.Secure.LOCATION_MODE_HIGH_ACCURACY:
mLocationMode.setSummary(R.string.location_mode_high_accuracy_title);
break;
default:
@@ -221,7 +244,7 @@ public class LocationSettings extends LocationSettingsBase
// Restricted user can't change the location mode, so disable the master switch. But in some
// corner cases, the location might still be enabled. In such case the master switch should
// be disabled but checked.
- boolean enabled = (mode != Settings.Secure.LOCATION_MODE_OFF);
+ boolean enabled = (mode != android.provider.Settings.Secure.LOCATION_MODE_OFF);
mSwitch.setEnabled(!restricted);
mLocationMode.setEnabled(enabled && !restricted);
mCategoryRecentLocationRequests.setEnabled(enabled);
@@ -247,9 +270,9 @@ public class LocationSettings extends LocationSettingsBase
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
- setLocationMode(Settings.Secure.LOCATION_MODE_HIGH_ACCURACY);
+ setLocationMode(android.provider.Settings.Secure.LOCATION_MODE_HIGH_ACCURACY);
} else {
- setLocationMode(Settings.Secure.LOCATION_MODE_OFF);
+ setLocationMode(android.provider.Settings.Secure.LOCATION_MODE_OFF);
}
}
}
diff --git a/src/com/android/settings/location/RecentLocationApps.java b/src/com/android/settings/location/RecentLocationApps.java
index 5708434..164f4e7 100644
--- a/src/com/android/settings/location/RecentLocationApps.java
+++ b/src/com/android/settings/location/RecentLocationApps.java
@@ -26,10 +26,10 @@ import android.os.Bundle;
import android.os.Process;
import android.os.UserHandle;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
import android.util.Log;
import com.android.settings.R;
+import com.android.settings.SettingsActivity;
import com.android.settings.applications.InstalledAppDetails;
import java.util.ArrayList;
@@ -44,10 +44,10 @@ public class RecentLocationApps {
private static final int RECENT_TIME_INTERVAL_MILLIS = 15 * 60 * 1000;
- private final PreferenceActivity mActivity;
+ private final SettingsActivity mActivity;
private final PackageManager mPackageManager;
- public RecentLocationApps(PreferenceActivity activity) {
+ public RecentLocationApps(SettingsActivity activity) {
mActivity = activity;
mPackageManager = activity.getPackageManager();
}
diff --git a/src/com/android/settings/nfc/AndroidBeam.java b/src/com/android/settings/nfc/AndroidBeam.java
index 158ca78..b3cd9c2 100644
--- a/src/com/android/settings/nfc/AndroidBeam.java
+++ b/src/com/android/settings/nfc/AndroidBeam.java
@@ -21,16 +21,14 @@ import android.app.Activity;
import android.app.Fragment;
import android.nfc.NfcAdapter;
import android.os.Bundle;
-import android.os.Handler;
-import android.preference.PreferenceActivity;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
-import android.widget.ImageView;
import android.widget.Switch;
import com.android.settings.R;
+import com.android.settings.SettingsActivity;
public class AndroidBeam extends Fragment
implements CompoundButton.OnCheckedChangeListener {
@@ -46,7 +44,7 @@ public class AndroidBeam extends Fragment
mActionBarSwitch = new Switch(activity);
- if (activity instanceof PreferenceActivity) {
+ if (activity instanceof SettingsActivity) {
final int padding = activity.getResources().getDimensionPixelSize(
R.dimen.action_bar_switch_padding);
mActionBarSwitch.setPaddingRelative(0, 0, padding, 0);
diff --git a/src/com/android/settings/print/PrintServiceSettingsFragment.java b/src/com/android/settings/print/PrintServiceSettingsFragment.java
index 5b9182b..357183f 100644
--- a/src/com/android/settings/print/PrintServiceSettingsFragment.java
+++ b/src/com/android/settings/print/PrintServiceSettingsFragment.java
@@ -38,13 +38,11 @@ import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
-import android.preference.PreferenceActivity;
import android.print.PrintManager;
import android.print.PrinterDiscoverySession;
import android.print.PrinterDiscoverySession.OnPrintersChangeListener;
import android.print.PrinterId;
import android.print.PrinterInfo;
-import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
@@ -64,6 +62,7 @@ import android.widget.SearchView;
import android.widget.TextView;
import com.android.settings.R;
+import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.print.PrintSettingsFragment.ToggleSwitch;
import com.android.settings.print.PrintSettingsFragment.ToggleSwitch.OnBeforeCheckedChangeListener;
@@ -330,8 +329,8 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
mToggleSwitch.setCheckedInternal(enabled);
// Title.
- PreferenceActivity activity = (PreferenceActivity) getActivity();
- if (!activity.onIsMultiPane() || activity.onIsHidingHeaders()) {
+ SettingsActivity activity = (SettingsActivity) getActivity();
+ if (!activity.onIsHidingHeaders()) {
mOldActivityTitle = getActivity().getTitle();
String title = arguments.getString(PrintSettingsFragment.EXTRA_TITLE);
getActivity().getActionBar().setTitle(title);
@@ -470,8 +469,8 @@ public class PrintServiceSettingsFragment extends SettingsPreferenceFragment
}
public void register(ContentResolver contentResolver) {
- contentResolver.registerContentObserver(Settings.Secure.getUriFor(
- Settings.Secure.ENABLED_PRINT_SERVICES), false, this);
+ contentResolver.registerContentObserver(android.provider.Settings.Secure.getUriFor(
+ android.provider.Settings.Secure.ENABLED_PRINT_SERVICES), false, this);
}
public void unregister(ContentResolver contentResolver) {
diff --git a/src/com/android/settings/quicklaunch/QuickLaunchSettings.java b/src/com/android/settings/quicklaunch/QuickLaunchSettings.java
index 5654323..0081a1e 100644
--- a/src/com/android/settings/quicklaunch/QuickLaunchSettings.java
+++ b/src/com/android/settings/quicklaunch/QuickLaunchSettings.java
@@ -16,6 +16,7 @@
package com.android.settings.quicklaunch;
+import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
@@ -27,7 +28,6 @@ import android.database.Cursor;
import android.os.Bundle;
import android.os.Handler;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.provider.Settings.Bookmarks;
@@ -40,6 +40,7 @@ import android.view.View;
import android.widget.AdapterView;
import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
import java.net.URISyntaxException;
@@ -49,7 +50,7 @@ import java.net.URISyntaxException;
* Shows a list of possible shortcuts, the current application each is bound to,
* and allows choosing a new bookmark for a shortcut.
*/
-public class QuickLaunchSettings extends PreferenceActivity implements
+public class QuickLaunchSettings extends SettingsPreferenceFragment implements
AdapterView.OnItemLongClickListener, DialogInterface.OnClickListener {
private static final String TAG = "QuickLaunchSettings";
@@ -91,7 +92,7 @@ public class QuickLaunchSettings extends PreferenceActivity implements
private static final String CLEAR_DIALOG_SHORTCUT = "CLEAR_DIALOG_SHORTCUT";
@Override
- protected void onCreate(Bundle savedInstanceState) {
+ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.quick_launch_settings);
@@ -100,27 +101,35 @@ public class QuickLaunchSettings extends PreferenceActivity implements
mShortcutToPreference = new SparseArray<ShortcutPreference>();
mBookmarksObserver = new BookmarksObserver(mUiHandler);
initShortcutPreferences();
- mBookmarksCursor = managedQuery(Bookmarks.CONTENT_URI, sProjection, null, null);
+ mBookmarksCursor = getActivity().getContentResolver().query(Bookmarks.CONTENT_URI,
+ sProjection, null, null, null);
getListView().setOnItemLongClickListener(this);
}
@Override
- protected void onResume() {
+ public void onResume() {
super.onResume();
+ mBookmarksCursor = getActivity().getContentResolver().query(Bookmarks.CONTENT_URI,
+ sProjection, null, null, null);
getContentResolver().registerContentObserver(Bookmarks.CONTENT_URI, true,
mBookmarksObserver);
refreshShortcuts();
}
@Override
- protected void onPause() {
+ public void onPause() {
super.onPause();
getContentResolver().unregisterContentObserver(mBookmarksObserver);
}
@Override
- protected void onRestoreInstanceState(Bundle state) {
- super.onRestoreInstanceState(state);
+ public void onStop() {
+ mBookmarksCursor.close();
+ }
+
+ @Override
+ public void onActivityCreated(Bundle state) {
+ super.onActivityCreated(state);
// Restore the clear dialog's info
mClearDialogBookmarkTitle = state.getString(CLEAR_DIALOG_BOOKMARK_TITLE);
@@ -128,7 +137,7 @@ public class QuickLaunchSettings extends PreferenceActivity implements
}
@Override
- protected void onSaveInstanceState(Bundle outState) {
+ public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
// Save the clear dialog's info
@@ -137,12 +146,12 @@ public class QuickLaunchSettings extends PreferenceActivity implements
}
@Override
- protected Dialog onCreateDialog(int id) {
+ public Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_CLEAR_SHORTCUT: {
// Create the dialog for clearing a shortcut
- return new AlertDialog.Builder(this)
+ return new AlertDialog.Builder(getActivity())
.setTitle(getString(R.string.quick_launch_clear_dialog_title))
.setIconAttribute(android.R.attr.alertDialogIcon)
.setMessage(getString(R.string.quick_launch_clear_dialog_message,
@@ -156,18 +165,6 @@ public class QuickLaunchSettings extends PreferenceActivity implements
return super.onCreateDialog(id);
}
- @Override
- protected void onPrepareDialog(int id, Dialog dialog) {
- switch (id) {
-
- case DIALOG_CLEAR_SHORTCUT: {
- AlertDialog alertDialog = (AlertDialog) dialog;
- alertDialog.setMessage(getString(R.string.quick_launch_clear_dialog_message,
- mClearDialogShortcut, mClearDialogBookmarkTitle));
- }
- }
- }
-
private void showClearDialog(ShortcutPreference pref) {
if (!pref.hasBookmark()) return;
@@ -197,7 +194,7 @@ public class QuickLaunchSettings extends PreferenceActivity implements
// Open the screen to pick a bookmark for this shortcut
ShortcutPreference pref = (ShortcutPreference) preference;
- Intent intent = new Intent(this, BookmarkPicker.class);
+ Intent intent = new Intent(getActivity(), BookmarkPicker.class);
intent.putExtra(BookmarkPicker.EXTRA_SHORTCUT, pref.getShortcut());
startActivityForResult(intent, REQUEST_PICK_BOOKMARK);
@@ -214,8 +211,8 @@ public class QuickLaunchSettings extends PreferenceActivity implements
}
@Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (resultCode != RESULT_OK) {
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (resultCode != Activity.RESULT_OK) {
return;
}
@@ -253,7 +250,7 @@ public class QuickLaunchSettings extends PreferenceActivity implements
}
private ShortcutPreference createPreference(char shortcut) {
- ShortcutPreference pref = new ShortcutPreference(QuickLaunchSettings.this, shortcut);
+ ShortcutPreference pref = new ShortcutPreference(getActivity(), shortcut);
mShortcutGroup.addPreference(pref);
mShortcutToPreference.put(shortcut, pref);
return pref;
@@ -303,7 +300,7 @@ public class QuickLaunchSettings extends PreferenceActivity implements
if (shortcut == 0) continue;
ShortcutPreference pref = getOrCreatePreference(shortcut);
- CharSequence title = Bookmarks.getTitle(this, c);
+ CharSequence title = Bookmarks.getTitle(getActivity(), c);
/*
* The title retrieved from Bookmarks.getTitle() will be in
diff --git a/src/com/android/settings/tts/TextToSpeechSettings.java b/src/com/android/settings/tts/TextToSpeechSettings.java
index 0ff7f4f..a3003e8 100644
--- a/src/com/android/settings/tts/TextToSpeechSettings.java
+++ b/src/com/android/settings/tts/TextToSpeechSettings.java
@@ -20,6 +20,7 @@ import static android.provider.Settings.Secure.TTS_DEFAULT_RATE;
import static android.provider.Settings.Secure.TTS_DEFAULT_SYNTH;
import com.android.settings.R;
+import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.tts.TtsEnginePreference.RadioButtonGroupState;
@@ -30,9 +31,7 @@ import android.content.Intent;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory;
-import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import android.speech.tts.TextToSpeech;
import android.speech.tts.UtteranceProgressListener;
@@ -212,7 +211,7 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
// Set up the default rate.
try {
- mDefaultRate = Settings.Secure.getInt(resolver, TTS_DEFAULT_RATE);
+ mDefaultRate = android.provider.Settings.Secure.getInt(resolver, TTS_DEFAULT_RATE);
} catch (SettingNotFoundException e) {
// Default rate setting not found, initialize it
mDefaultRate = TextToSpeech.Engine.DEFAULT_RATE;
@@ -222,12 +221,12 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
mCurrentEngine = mTts.getCurrentEngine();
- PreferenceActivity preferenceActivity = null;
- if (getActivity() instanceof PreferenceActivity) {
- preferenceActivity = (PreferenceActivity) getActivity();
+ SettingsActivity activity = null;
+ if (getActivity() instanceof SettingsActivity) {
+ activity = (SettingsActivity) getActivity();
} else {
throw new IllegalStateException("TextToSpeechSettings used outside a " +
- "PreferenceActivity");
+ "Settings");
}
mEnginePreferenceCategory.removeAll();
@@ -235,7 +234,7 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
List<EngineInfo> engines = mEnginesHelper.getEngines();
for (EngineInfo engine : engines) {
TtsEnginePreference enginePref = new TtsEnginePreference(getActivity(), engine,
- this, preferenceActivity);
+ this, activity);
mEnginePreferenceCategory.addPreference(enginePref);
}
@@ -422,7 +421,8 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
// Default rate
mDefaultRate = Integer.parseInt((String) objValue);
try {
- Settings.Secure.putInt(getContentResolver(), TTS_DEFAULT_RATE, mDefaultRate);
+ android.provider.Settings.Secure.putInt(getContentResolver(),
+ TTS_DEFAULT_RATE, mDefaultRate);
if (mTts != null) {
mTts.setSpeechRate(mDefaultRate / 100.0f);
}
@@ -565,7 +565,7 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
return;
}
- Settings.Secure.putString(getContentResolver(), TTS_DEFAULT_SYNTH, engine);
+ android.provider.Settings.Secure.putString(getContentResolver(), TTS_DEFAULT_SYNTH, engine);
mAvailableStrLocals = data.getStringArrayListExtra(
TextToSpeech.Engine.EXTRA_AVAILABLE_VOICES);
diff --git a/src/com/android/settings/tts/TtsEnginePreference.java b/src/com/android/settings/tts/TtsEnginePreference.java
index 486fdf8..7e50c47 100644
--- a/src/com/android/settings/tts/TtsEnginePreference.java
+++ b/src/com/android/settings/tts/TtsEnginePreference.java
@@ -22,7 +22,6 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
import android.speech.tts.TextToSpeech.EngineInfo;
import android.util.Log;
import android.view.View;
@@ -33,6 +32,7 @@ import android.widget.RadioButton;
import com.android.settings.R;
+import com.android.settings.SettingsActivity;
import com.android.settings.Utils;
@@ -63,7 +63,7 @@ public class TtsEnginePreference extends Preference {
* The preference activity that owns this preference. Required
* for instantiating the engine specific settings screen.
*/
- private final PreferenceActivity mPreferenceActivity;
+ private final SettingsActivity mSettingsActivity;
/**
* The engine information for the engine this preference represents.
@@ -95,12 +95,12 @@ public class TtsEnginePreference extends Preference {
};
public TtsEnginePreference(Context context, EngineInfo info, RadioButtonGroupState state,
- PreferenceActivity prefActivity) {
+ SettingsActivity prefActivity) {
super(context);
setLayoutResource(R.layout.preference_tts_engine);
mSharedState = state;
- mPreferenceActivity = prefActivity;
+ mSettingsActivity = prefActivity;
mEngineInfo = info;
mPreventRadioButtonCallbacks = false;
@@ -156,10 +156,10 @@ public class TtsEnginePreference extends Preference {
}
// Note that we use this instead of the (easier to use)
- // PreferenceActivity.startPreferenceFragment because the
+ // SettingsActivity.startPreferenceFragment because the
// title will not be updated correctly in the fragment
// breadcrumb since it isn't inflated from the XML layout.
- mPreferenceActivity.startPreferencePanel(
+ mSettingsActivity.startPreferencePanel(
TtsEngineSettingsFragment.class.getName(),
args, 0, mEngineInfo.label, null, 0);
}
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index bbae37d..849ab94 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -47,7 +47,6 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
-import android.preference.PreferenceActivity;
import android.preference.PreferenceGroup;
import android.provider.ContactsContract;
import android.provider.ContactsContract.Contacts;
@@ -67,6 +66,7 @@ import com.android.settings.OwnerInfoSettings;
import com.android.settings.R;
import com.android.settings.RestrictedSettingsFragment;
import com.android.settings.SelectableEditTextPreference;
+import com.android.settings.SettingsActivity;
import com.android.settings.Utils;
public class UserSettings extends RestrictedSettingsFragment
@@ -377,7 +377,7 @@ public class UserSettings extends RestrictedSettingsFragment
Bundle extras = new Bundle();
extras.putInt(RestrictedProfileSettings.EXTRA_USER_ID, userId);
extras.putBoolean(RestrictedProfileSettings.EXTRA_NEW_USER, newUser);
- ((PreferenceActivity) getActivity()).startPreferencePanel(
+ ((SettingsActivity) getActivity()).startPreferencePanel(
RestrictedProfileSettings.class.getName(),
extras, R.string.user_restrictions_title, null,
null, 0);
@@ -390,7 +390,7 @@ public class UserSettings extends RestrictedSettingsFragment
int titleResId = info.id == UserHandle.USER_OWNER ? R.string.owner_info_settings_title
: (info.isRestricted() ? R.string.profile_info_settings_title
: R.string.user_info_settings_title);
- ((PreferenceActivity) getActivity()).startPreferencePanel(
+ ((SettingsActivity) getActivity()).startPreferencePanel(
OwnerInfoSettings.class.getName(),
extras, titleResId, null, null, 0);
}
diff --git a/src/com/android/settings/wfd/WifiDisplaySettings.java b/src/com/android/settings/wfd/WifiDisplaySettings.java
index d7f4708..c3f22a7 100755
--- a/src/com/android/settings/wfd/WifiDisplaySettings.java
+++ b/src/com/android/settings/wfd/WifiDisplaySettings.java
@@ -42,15 +42,12 @@ import android.os.Looper;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.provider.Settings;
-import android.text.Html;
import android.util.Slog;
import android.util.TypedValue;
-import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@@ -59,14 +56,11 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
-import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageView;
-import android.widget.Switch;
import android.widget.TextView;
import com.android.internal.app.MediaRouteDialogPresenter;
-import com.android.settings.ProgressCategory;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
diff --git a/src/com/android/settings/wifi/WifiInfo.java b/src/com/android/settings/wifi/WifiInfo.java
index 291a495..cdbb580 100644
--- a/src/com/android/settings/wifi/WifiInfo.java
+++ b/src/com/android/settings/wifi/WifiInfo.java
@@ -19,18 +19,17 @@ package com.android.settings.wifi;
import com.android.settings.R;
import android.os.Bundle;
-import android.preference.PreferenceActivity;
+import com.android.settings.SettingsPreferenceFragment;
/**
* Wifi information menu item on the diagnostic screen
*/
-public class WifiInfo extends PreferenceActivity {
+public class WifiInfo extends SettingsPreferenceFragment {
@Override
- protected void onCreate(Bundle savedInstanceState) {
+ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.testing_wifi_settings);
}
-
}
diff --git a/src/com/android/settings/wifi/WifiPickerActivity.java b/src/com/android/settings/wifi/WifiPickerActivity.java
index e1e7c51..deef8fa 100644
--- a/src/com/android/settings/wifi/WifiPickerActivity.java
+++ b/src/com/android/settings/wifi/WifiPickerActivity.java
@@ -16,7 +16,6 @@
package com.android.settings.wifi;
import com.android.settings.ButtonBarHandler;
-import com.android.settings.ChooseLockGeneric.ChooseLockGenericFragment;
import com.android.settings.wifi.p2p.WifiP2pSettings;
import android.app.Fragment;
@@ -54,8 +53,8 @@ public class WifiPickerActivity extends PreferenceActivity implements ButtonBarH
/**
* Almost dead copy of
- * {@link PreferenceActivity#startWithFragment(String, Bundle, Fragment, int)}, except
- * this has additional codes for button bar handling.
+ * {@link PreferenceActivity#startWithFragment(String, Bundle, Fragment, int)}, except this has
+ * additional codes for button bar handling.
*/
@Override
public void startWithFragment(String fragmentName, Bundle args,
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 1caf58b..41a4905 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -19,8 +19,10 @@ package com.android.settings.wifi;
import static android.net.wifi.WifiConfiguration.INVALID_NETWORK_ID;
import static android.os.UserManager.DISALLOW_CONFIG_WIFI;
+import android.preference.PreferenceActivity;
import com.android.settings.R;
import com.android.settings.RestrictedSettingsFragment;
+import com.android.settings.SettingsActivity;
import com.android.settings.wifi.p2p.WifiP2pSettings;
import android.app.ActionBar;
@@ -49,9 +51,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen;
-import android.provider.Settings;
import android.util.AttributeSet;
import android.util.Log;
import android.view.ContextMenu;
@@ -172,6 +172,8 @@ public class WifiSettings extends RestrictedSettingsFragment
// the action bar uses a different set of controls for Setup Wizard
private boolean mSetupWizardMode;
+ private Switch mSwitch;
+
/* End of "used in Wifi Setup context" */
public WifiSettings() {
@@ -383,42 +385,66 @@ public class WifiSettings extends RestrictedSettingsFragment
if (mSetupWizardMode) {
getView().setSystemUiVisibility(
-// View.STATUS_BAR_DISABLE_BACK |
View.STATUS_BAR_DISABLE_HOME |
View.STATUS_BAR_DISABLE_RECENT |
View.STATUS_BAR_DISABLE_NOTIFICATION_ALERTS |
View.STATUS_BAR_DISABLE_CLOCK);
}
+ mEmptyView = (TextView) getView().findViewById(android.R.id.empty);
+ getListView().setEmptyView(mEmptyView);
+
+ if (!mSetupWizardMode) {
+ registerForContextMenu(getListView());
+ }
+ setHasOptionsMenu(true);
+ }
+
+ @Override
+ public void onStart() {
+ super.onStart();
+
// On/off switch is hidden for Setup Wizard
if (!mSetupWizardMode) {
- Switch actionBarSwitch = new Switch(activity);
+ final Activity activity = getActivity();
+
+ mSwitch = new Switch(activity);
- if (activity instanceof PreferenceActivity) {
- PreferenceActivity preferenceActivity = (PreferenceActivity) activity;
- if (preferenceActivity.onIsHidingHeaders() || !preferenceActivity.onIsMultiPane()) {
+ if (activity instanceof SettingsActivity) {
+ SettingsActivity sa = (SettingsActivity) activity;
+ if (!sa.onIsHidingHeaders()) {
final int padding = activity.getResources().getDimensionPixelSize(
R.dimen.action_bar_switch_padding);
- actionBarSwitch.setPaddingRelative(0, 0, padding, 0);
+ mSwitch.setPaddingRelative(0, 0, padding, 0);
activity.getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
ActionBar.DISPLAY_SHOW_CUSTOM);
- activity.getActionBar().setCustomView(actionBarSwitch, new ActionBar.LayoutParams(
+ activity.getActionBar().setCustomView(mSwitch, new ActionBar.LayoutParams(
ActionBar.LayoutParams.WRAP_CONTENT,
ActionBar.LayoutParams.WRAP_CONTENT,
Gravity.CENTER_VERTICAL | Gravity.END));
}
}
- mWifiEnabler = new WifiEnabler(activity, actionBarSwitch);
+ mWifiEnabler = new WifiEnabler(activity, mSwitch);
}
+ }
- mEmptyView = (TextView) getView().findViewById(android.R.id.empty);
- getListView().setEmptyView(mEmptyView);
-
- if (!mSetupWizardMode) {
- registerForContextMenu(getListView());
+ @Override
+ public void onStop() {
+ super.onStop();
+ Activity activity = getActivity();
+ boolean onIsHidingHeaders = true;
+ if (activity instanceof SettingsActivity){
+ SettingsActivity sa = (SettingsActivity) activity;
+ onIsHidingHeaders = sa.onIsHidingHeaders();
+ } else if (activity instanceof PreferenceActivity) {
+ PreferenceActivity pa = (PreferenceActivity) activity;
+ onIsHidingHeaders = pa.onIsHidingHeaders();
+ }
+ if (!onIsHidingHeaders) {
+ activity.getActionBar().setDisplayOptions(0, ActionBar.DISPLAY_SHOW_CUSTOM);
+ activity.getActionBar().setCustomView(null);
}
- setHasOptionsMenu(true);
}
@Override
@@ -512,8 +538,8 @@ public class WifiSettings extends RestrictedSettingsFragment
showDialog(WPS_PBC_DIALOG_ID);
return true;
case MENU_ID_P2P:
- if (getActivity() instanceof PreferenceActivity) {
- ((PreferenceActivity) getActivity()).startPreferencePanel(
+ if (getActivity() instanceof SettingsActivity) {
+ ((SettingsActivity) getActivity()).startPreferencePanel(
WifiP2pSettings.class.getCanonicalName(),
null,
R.string.wifi_p2p_settings_title, null,
@@ -536,8 +562,8 @@ public class WifiSettings extends RestrictedSettingsFragment
}
return true;
case MENU_ID_ADVANCED:
- if (getActivity() instanceof PreferenceActivity) {
- ((PreferenceActivity) getActivity()).startPreferencePanel(
+ if (getActivity() instanceof SettingsActivity) {
+ ((SettingsActivity) getActivity()).startPreferencePanel(
AdvancedWifiSettings.class.getCanonicalName(),
null,
R.string.wifi_advanced_titlebar, null,
@@ -743,12 +769,12 @@ public class WifiSettings extends RestrictedSettingsFragment
private void setOffMessage() {
if (mEmptyView != null) {
mEmptyView.setText(R.string.wifi_empty_list_wifi_off);
- if (Settings.Global.getInt(getActivity().getContentResolver(),
- Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1) {
+ if (android.provider.Settings.Global.getInt(getActivity().getContentResolver(),
+ android.provider.Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1) {
mEmptyView.append("\n\n");
int resId;
- if (Settings.Secure.isLocationProviderEnabled(getActivity().getContentResolver(),
- LocationManager.NETWORK_PROVIDER)) {
+ if (android.provider.Settings.Secure.isLocationProviderEnabled(
+ getActivity().getContentResolver(), LocationManager.NETWORK_PROVIDER)) {
resId = R.string.wifi_scan_notify_text_location_on;
} else {
resId = R.string.wifi_scan_notify_text_location_off;
diff --git a/src/com/android/settings/wifi/p2p/WifiP2pSettings.java b/src/com/android/settings/wifi/p2p/WifiP2pSettings.java
index 2ca39f0..879ebf8 100644
--- a/src/com/android/settings/wifi/p2p/WifiP2pSettings.java
+++ b/src/com/android/settings/wifi/p2p/WifiP2pSettings.java
@@ -16,7 +16,6 @@
package com.android.settings.wifi.p2p;
-import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
@@ -38,31 +37,23 @@ import android.net.wifi.p2p.WifiP2pManager.PeerListListener;
import android.net.wifi.p2p.WifiP2pManager.PersistentGroupInfoListener;
import android.net.wifi.WpsInfo;
import android.os.Bundle;
-import android.os.Handler;
import android.os.SystemProperties;
import android.preference.Preference;
-import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.text.InputFilter;
import android.text.TextUtils;
import android.util.Log;
-import android.view.Gravity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.EditText;
-import android.widget.Switch;
import android.widget.Toast;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Collection;
-
/*
* Displays Wi-fi p2p settings UI
*/
diff --git a/tests/src/com/android/settings/SettingsHookTests.java b/tests/src/com/android/settings/SettingsHookTests.java
index ec438cb..4dfd484 100644
--- a/tests/src/com/android/settings/SettingsHookTests.java
+++ b/tests/src/com/android/settings/SettingsHookTests.java
@@ -16,20 +16,15 @@
package com.android.settings;
+import com.android.settings.Settings;
import com.android.settings.tests.Manufacturer;
import com.android.settings.tests.Operator;
-import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
-import android.content.res.Resources;
-import android.os.Bundle;
-import android.preference.Preference;
-import android.preference.PreferenceGroup;
import android.test.ActivityInstrumentationTestCase2;
import java.util.List;