Merge "Import revised translations."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 1b80ce8..7f04228 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -118,6 +118,10 @@
android:value="com.android.settings.wifi.WifiSettings" />
<meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
android:resource="@id/wireless_settings" />
+ <meta-data android:name="com.android.settings.PARENT_FRAGMENT_TITLE"
+ android:resource="@string/wireless_networks_settings_title" />
+ <meta-data android:name="com.android.settings.PARENT_FRAGMENT_CLASS"
+ android:value="com.android.settings.Settings$WirelessSettingsActivity" />
</activity>
<activity android:name=".wifi.WifiSettingsForSetupWizardXL"
@@ -210,6 +214,10 @@
android:value="com.android.settings.bluetooth.BluetoothSettings" />
<meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
android:resource="@id/wireless_settings" />
+ <meta-data android:name="com.android.settings.PARENT_FRAGMENT_TITLE"
+ android:resource="@string/wireless_networks_settings_title" />
+ <meta-data android:name="com.android.settings.PARENT_FRAGMENT_CLASS"
+ android:value="com.android.settings.Settings$WirelessSettingsActivity" />
</activity>
<activity android:name=".bluetooth.DevicePickerActivity"
@@ -234,6 +242,10 @@
android:value="com.android.settings.TetherSettings" />
<meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
android:resource="@id/wireless_settings" />
+ <meta-data android:name="com.android.settings.PARENT_FRAGMENT_TITLE"
+ android:resource="@string/wireless_networks_settings_title" />
+ <meta-data android:name="com.android.settings.PARENT_FRAGMENT_CLASS"
+ android:value="com.android.settings.Settings$WirelessSettingsActivity" />
</activity>
<activity android:name="Settings$VpnSettingsActivity"
@@ -252,6 +264,10 @@
android:value="com.android.settings.vpn.VpnSettings" />
<meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
android:resource="@id/wireless_settings" />
+ <meta-data android:name="com.android.settings.PARENT_FRAGMENT_TITLE"
+ android:resource="@string/wireless_networks_settings_title" />
+ <meta-data android:name="com.android.settings.PARENT_FRAGMENT_CLASS"
+ android:value="com.android.settings.Settings$WirelessSettingsActivity" />
</activity>
<activity android:name="Settings$DateTimeSettingsActivity"
@@ -327,6 +343,10 @@
android:value="com.android.settings.inputmethod.InputMethodAndSubtypeEnabler" />
<meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
android:resource="@id/language_settings" />
+ <meta-data android:name="com.android.settings.PARENT_FRAGMENT_TITLE"
+ android:resource="@string/language_keyboard_settings_title" />
+ <meta-data android:name="com.android.settings.PARENT_FRAGMENT_CLASS"
+ android:value="com.android.settings.Settings$InputMethodAndLanguageSettingsActivity" />
</activity>
<activity android:name="PhysicalKeyboardSettings"
@@ -354,6 +374,10 @@
android:value="com.android.settings.UserDictionarySettings" />
<meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
android:resource="@id/language_settings" />
+ <meta-data android:name="com.android.settings.PARENT_FRAGMENT_TITLE"
+ android:resource="@string/language_keyboard_settings_title" />
+ <meta-data android:name="com.android.settings.PARENT_FRAGMENT_CLASS"
+ android:value="com.android.settings.Settings$InputMethodAndLanguageSettingsActivity" />
</activity>
<activity android:name="Settings$SoundSettingsActivity"
@@ -475,6 +499,10 @@
android:value="com.android.settings.applications.ManageApplications" />
<meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
android:resource="@id/application_settings" />
+ <meta-data android:name="com.android.settings.PARENT_FRAGMENT_TITLE"
+ android:resource="@string/applications_settings_header" />
+ <meta-data android:name="com.android.settings.PARENT_FRAGMENT_CLASS"
+ android:value="com.android.settings.Settings$ApplicationSettingsActivity" />
</activity>
<!-- Keep compatibility with old shortcuts. -->
@@ -518,6 +546,10 @@
android:value="com.android.settings.applications.ManageApplications" />
<meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
android:resource="@id/application_settings" />
+ <meta-data android:name="com.android.settings.PARENT_FRAGMENT_TITLE"
+ android:resource="@string/applications_settings_header" />
+ <meta-data android:name="com.android.settings.PARENT_FRAGMENT_CLASS"
+ android:value="com.android.settings.Settings$ApplicationSettingsActivity" />
</activity>
<!-- Provide direct entry into manage apps showing running services. -->
@@ -535,6 +567,10 @@
android:value="com.android.settings.applications.ManageApplications" />
<meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
android:resource="@id/application_settings" />
+ <meta-data android:name="com.android.settings.PARENT_FRAGMENT_TITLE"
+ android:resource="@string/applications_settings_header" />
+ <meta-data android:name="com.android.settings.PARENT_FRAGMENT_CLASS"
+ android:value="com.android.settings.Settings$ApplicationSettingsActivity" />
</activity>
<activity android:name="Settings$SecuritySettingsActivity"
@@ -752,6 +788,10 @@
android:value="com.android.settings.DevelopmentSettings" />
<meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
android:resource="@id/application_settings" />
+ <meta-data android:name="com.android.settings.PARENT_FRAGMENT_TITLE"
+ android:resource="@string/applications_settings_header" />
+ <meta-data android:name="com.android.settings.PARENT_FRAGMENT_CLASS"
+ android:value="com.android.settings.Settings$ApplicationSettingsActivity" />
</activity>
@@ -927,6 +967,10 @@
android:value="com.android.settings.fuelgauge.PowerUsageSummary" />
<meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
android:resource="@id/application_settings" />
+ <meta-data android:name="com.android.settings.PARENT_FRAGMENT_TITLE"
+ android:resource="@string/applications_settings_header" />
+ <meta-data android:name="com.android.settings.PARENT_FRAGMENT_CLASS"
+ android:value="com.android.settings.Settings$ApplicationSettingsActivity" />
</activity>
<activity
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 8bc4139..fb6cb06 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -487,7 +487,7 @@
<!-- Main Settings screen settings title for things like Wi-Fi, bluetooth, airplane mode. This will take you to another screen with those settings. -->
<string name="radio_controls_title">Wireless & networks</string>
<!-- Wireless Settings screen title for things like Wi-Fi, bluetooth, airplane mode. -->
- <string name="wireless_networks_settings_title">Wireless & network settings</string>
+ <string name="wireless_networks_settings_title">Wireless & networks</string>
<!-- Main Settings screen settings summary text for the "Wireless controls" setting -->
<string name="radio_controls_summary">Manage Wi-Fi, Bluetooth, airplane mode, mobile networks, & VPNs</string>
@@ -1728,9 +1728,6 @@
<!-- Bluetooth Tethering settings. Message for untethering from a bluetooth device [CHAR LIMIT=50]-->
<string name="bluetooth_untether_blank"><xliff:g id="device_name">%1$s</xliff:g> will be untethered.</string>
- <string name="bluetooth_tether_settings_text">Bluetooth tethering settings</string>
- <string name="bluetooth_tether_settings_subtext">Select Bluetooth devices to tether</string>
-
<!-- Tethering help button - calls up a web view with general tethering info -->
<string name="tethering_help_button_text">Help</string>
@@ -2183,7 +2180,7 @@
<!-- Title of setting on main settings screen. This item will take the user to the screen to tweak settings realted to locale and text -->
<string name="language_settings">Language & input</string>
<!-- Title of Language and keyboard settings screen -->
- <string name="language_keyboard_settings_title">Language & keyboard settings</string>
+ <string name="language_keyboard_settings_title">Language & input</string>
<!-- On Language & keyboard settings screen, heading. Inside the "Language & keyboard settings" screen, this is the header for settings that relate to language (select the system language, user dictionary for the language). -->
<string name="language_settings_category">Language settings</string>
<!-- On Language & keyboard settings screen, heading. Inside the "Language & keyboard settings" screen, this is the header for settings that relate to keyboard (enable/disable each keyboard, settings for each keyboard). -->
diff --git a/res/xml/tether_prefs.xml b/res/xml/tether_prefs.xml
index d475a14..f16200d 100644
--- a/res/xml/tether_prefs.xml
+++ b/res/xml/tether_prefs.xml
@@ -38,15 +38,6 @@
android:title="@string/bluetooth_tether_checkbox_text"
android:persistent="false" />
- <!-- BluetoothSettings will have extra argument to know this request is
- for tethering, not for BT setting in general. -->
- <PreferenceScreen
- android:fragment="com.android.settings.bluetooth.BluetoothSettings"
- android:key="bluetooth_tether_settings"
- android:title="@string/bluetooth_tether_settings_text"
- android:summary="@string/bluetooth_tether_settings_subtext" >
- </PreferenceScreen>
-
<PreferenceScreen
android:key="tethering_help"
android:title="@string/tethering_help_button_text" >
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 00706ad..b91c7ee 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -16,12 +16,17 @@
package com.android.settings;
+import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.preference.PreferenceActivity;
+import android.preference.PreferenceActivity.Header;
+import android.util.Log;
+import android.view.View;
+import android.view.View.OnClickListener;
import java.util.HashMap;
import java.util.List;
@@ -35,10 +40,20 @@
"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 META_DATA_KEY_PARENT_TITLE =
+ "com.android.settings.PARENT_FRAGMENT_TITLE";
+ private static final String META_DATA_KEY_PARENT_FRAGMENT_CLASS =
+ "com.android.settings.PARENT_FRAGMENT_CLASS";
+
+ private static final String SAVE_KEY_CURRENT_HEADER = "com.android.settings.CURRENT_HEADER";
+ private static final String SAVE_KEY_PARENT_HEADER = "com.android.settings.PARENT_HEADER";
private String mFragmentClass;
private int mTopLevelHeaderId;
private Header mFirstHeader;
+ private Header mCurrentHeader;
+ private Header mParentHeader;
+ private boolean mInLocalHeaderSwitch;
// TODO: Update Call Settings based on airplane mode state.
@@ -47,7 +62,9 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
getMetaData();
+ mInLocalHeaderSwitch = true;
super.onCreate(savedInstanceState);
+ mInLocalHeaderSwitch = false;
if (!onIsHidingHeaders() && onIsMultiPane()) {
highlightHeader();
@@ -55,6 +72,84 @@
// a specific settings screen.
setTitle(R.string.settings_label);
}
+
+ // Retrieve any saved state
+ if (savedInstanceState != null) {
+ mCurrentHeader = savedInstanceState.getParcelable(SAVE_KEY_CURRENT_HEADER);
+ mParentHeader = savedInstanceState.getParcelable(SAVE_KEY_PARENT_HEADER);
+ }
+
+ // If the current header was saved, switch to it
+ if (savedInstanceState != null && mCurrentHeader != null) {
+ //switchToHeaderLocal(mCurrentHeader);
+ showBreadCrumbs(mCurrentHeader.title, null);
+ }
+
+ if (mParentHeader != null) {
+ setParentTitle(mParentHeader.title, null, new OnClickListener() {
+ public void onClick(View v) {
+ switchToParent(mParentHeader.fragment);
+ }
+ });
+ }
+ }
+
+ @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);
+ }
+ if (mParentHeader != null) {
+ outState.putParcelable(SAVE_KEY_PARENT_HEADER, mParentHeader);
+ }
+ }
+
+ private void switchToHeaderLocal(Header header) {
+ mInLocalHeaderSwitch = true;
+ switchToHeader(header);
+ mInLocalHeaderSwitch = false;
+ }
+
+ @Override
+ public void switchToHeader(Header header) {
+ if (!mInLocalHeaderSwitch) {
+ mCurrentHeader = null;
+ mParentHeader = null;
+ }
+ super.switchToHeader(header);
+ }
+
+ /**
+ * Switch to parent fragment and store the grand parent's info
+ * @param class name of the activity wrapper for the parent fragment.
+ */
+ private void switchToParent(String className) {
+ final ComponentName cn = new ComponentName(this, className);
+ try {
+ final PackageManager pm = getPackageManager();
+ final ActivityInfo parentInfo = pm.getActivityInfo(cn, PackageManager.GET_META_DATA);
+
+ if (parentInfo != null && parentInfo.metaData != null) {
+ String fragmentClass = parentInfo.metaData.getString(META_DATA_KEY_FRAGMENT_CLASS);
+ CharSequence fragmentTitle = parentInfo.loadLabel(pm);
+ Header parentHeader = new Header();
+ parentHeader.fragment = fragmentClass;
+ parentHeader.title = fragmentTitle;
+ mCurrentHeader = parentHeader;
+
+ switchToHeaderLocal(parentHeader);
+
+ mParentHeader = new Header();
+ mParentHeader.fragment
+ = parentInfo.metaData.getString(META_DATA_KEY_PARENT_FRAGMENT_CLASS);
+ mParentHeader.title = parentInfo.metaData.getString(META_DATA_KEY_PARENT_TITLE);
+ }
+ } catch (NameNotFoundException nnfe) {
+ Log.w("Settings", "Could not find parent activity : " + className);
+ }
}
@Override
@@ -64,7 +159,7 @@
// If it is not launched from history, then reset to top-level
if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0
&& mFirstHeader != null) {
- switchToHeader(mFirstHeader);
+ switchToHeaderLocal(mFirstHeader);
}
}
@@ -126,7 +221,9 @@
if (fragmentClass != null) {
Header header = new Header();
header.fragment = fragmentClass;
+ header.title = getTitle();
header.fragmentArguments = getIntent().getExtras();
+ mCurrentHeader = header;
return header;
}
return super.onGetInitialHeader();
@@ -178,6 +275,17 @@
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);
+
+ // Check if it has a parent specified and create a Header object
+ final int parentHeaderTitleRes = ai.metaData.getInt(META_DATA_KEY_PARENT_TITLE);
+ String parentFragmentClass = ai.metaData.getString(META_DATA_KEY_PARENT_FRAGMENT_CLASS);
+ if (parentFragmentClass != null) {
+ mParentHeader = new Header();
+ mParentHeader.fragment = parentFragmentClass;
+ if (parentHeaderTitleRes != 0) {
+ mParentHeader.title = getResources().getString(parentHeaderTitleRes);
+ }
+ }
} catch (NameNotFoundException nnfe) {
}
}
diff --git a/src/com/android/settings/TetherSettings.java b/src/com/android/settings/TetherSettings.java
index bc27dc0..81d23ab 100644
--- a/src/com/android/settings/TetherSettings.java
+++ b/src/com/android/settings/TetherSettings.java
@@ -51,7 +51,6 @@
private static final String ENABLE_WIFI_AP = "enable_wifi_ap";
private static final String WIFI_AP_SETTINGS = "wifi_ap_settings";
private static final String ENABLE_BLUETOOTH_TETHERING = "enable_bluetooth_tethering";
- private static final String BLUETOOTH_TETHER_SETTINGS = "bluetooth_tether_settings";
private static final String TETHERING_HELP = "tethering_help";
private static final String USB_HELP_MODIFIER = "usb_";
private static final String WIFI_HELP_MODIFIER = "wifi_";
@@ -68,7 +67,6 @@
private WifiApEnabler mWifiApEnabler;
private CheckBoxPreference mBluetoothTether;
- private PreferenceScreen mBluetoothSettings;
private PreferenceScreen mTetherHelp;
@@ -97,7 +95,6 @@
mWifiApSettings = (PreferenceScreen) findPreference(WIFI_AP_SETTINGS);
mUsbTether = (CheckBoxPreference) findPreference(USB_TETHER_SETTINGS);
mBluetoothTether = (CheckBoxPreference) findPreference(ENABLE_BLUETOOTH_TETHERING);
- mBluetoothSettings = (PreferenceScreen) findPreference(BLUETOOTH_TETHER_SETTINGS);
mTetherHelp = (PreferenceScreen) findPreference(TETHERING_HELP);
ConnectivityManager cm =
@@ -121,14 +118,11 @@
}
if (!bluetoothAvailable) {
getPreferenceScreen().removePreference(mBluetoothTether);
- getPreferenceScreen().removePreference(mBluetoothSettings);
} else {
if (mBluetoothPan.isTetheringOn()) {
mBluetoothTether.setChecked(true);
- mBluetoothSettings.setEnabled(true);
} else {
mBluetoothTether.setChecked(false);
- mBluetoothSettings.setEnabled(false);
}
}
/* Don't change the title for two-pane settings
@@ -360,17 +354,14 @@
int btState = adapter.getState();
if (btState == BluetoothAdapter.STATE_TURNING_OFF) {
mBluetoothTether.setEnabled(false);
- mBluetoothSettings.setEnabled(false);
mBluetoothTether.setSummary(R.string.wifi_stopping);
} else if (btState == BluetoothAdapter.STATE_TURNING_ON) {
mBluetoothTether.setEnabled(false);
- mBluetoothSettings.setEnabled(false);
mBluetoothTether.setSummary(R.string.bluetooth_turning_on);
} else if (mBluetoothPan.isTetheringOn()) {
mBluetoothTether.setChecked(true);
if (btState == BluetoothAdapter.STATE_ON) {
mBluetoothTether.setEnabled(true);
- mBluetoothSettings.setEnabled(true);
if (bluetoothTethered) {
mBluetoothTether.setSummary(R.string.bluetooth_tethering_connected_subtext);
} else if (bluetoothErrored) {
@@ -382,7 +373,6 @@
} else {
mBluetoothTether.setEnabled(true);
mBluetoothTether.setChecked(false);
- mBluetoothSettings.setEnabled(false);
mBluetoothTether.setSummary(R.string.bluetooth_tethering_off_subtext);
}
}
@@ -433,9 +423,6 @@
adapter.enable();
mBluetoothTether.setSummary(R.string.bluetooth_turning_on);
mBluetoothTether.setEnabled(false);
- mBluetoothSettings.setEnabled(false);
- } else {
- mBluetoothSettings.setEnabled(true);
}
mBluetoothPan.setBluetoothTethering(true);
@@ -453,16 +440,12 @@
}
mBluetoothPan.setBluetoothTethering(false);
- mBluetoothSettings.setEnabled(false);
if (errored) {
mBluetoothTether.setSummary(R.string.bluetooth_tethering_errored_subtext);
} else {
mBluetoothTether.setSummary(R.string.bluetooth_tethering_off_subtext);
}
}
- } else if (preference == mBluetoothSettings) {
- preference.getExtras().putString(BluetoothSettings.ACTION,
- BluetoothSettings.ACTION_LAUNCH_TETHER_PICKER);
} else if (preference == mTetherHelp) {
showDialog(DIALOG_TETHER_HELP);
return true;
diff --git a/src/com/android/settings/bluetooth/BluetoothEventRedirector.java b/src/com/android/settings/bluetooth/BluetoothEventRedirector.java
index 3042e3d..57e359d 100644
--- a/src/com/android/settings/bluetooth/BluetoothEventRedirector.java
+++ b/src/com/android/settings/bluetooth/BluetoothEventRedirector.java
@@ -142,6 +142,8 @@
Profile.HID, newState);
} else if (action.equals(BluetoothPan.ACTION_PAN_STATE_CHANGED)) {
+ // TODO: uncomment and execute for reverse tethering only
+/*
final int newState = intent.getIntExtra(
BluetoothPan.EXTRA_PAN_STATE, 0);
final int oldState = intent.getIntExtra(
@@ -152,6 +154,7 @@
}
mManager.getCachedDeviceManager().onProfileStateChanged(device,
Profile.PAN, newState);
+*/
} else if (action.equals(BluetoothDevice.ACTION_CLASS_CHANGED)) {
mManager.getCachedDeviceManager().onBtClassChanged(device);
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index aae1311..89efd72 100644
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -42,6 +42,7 @@
import android.preference.PreferenceCategory;
import android.preference.PreferenceScreen;
import android.text.TextUtils;
+import android.util.Log;
import android.view.View;
import java.util.List;
@@ -65,24 +66,21 @@
private static final int SCREEN_TYPE_SETTINGS = 0;
private static final int SCREEN_TYPE_DEVICEPICKER = 1;
- private static final int SCREEN_TYPE_TETHERING = 2;
- private static final int SCREEN_TYPE_SCAN = 3;
+ private static final int SCREEN_TYPE_SCAN = 2;
public static final String ACTION = "bluetooth_action";
- public static final String ACTION_LAUNCH_TETHER_PICKER =
- "com.android.settings.bluetooth.action.LAUNCH_TETHER_PICKER";
public static final String ACTION_LAUNCH_SCAN_MODE =
"com.android.settings.bluetooth.action.LAUNCH_SCAN_MODE";
- private int mScreenType;
+ /*package*/ int mScreenType;
private int mFilterType;
private boolean mNeedAuth;
private String mLaunchPackage;
private String mLaunchClass;
- private BluetoothDevice mSelectedDevice= null;
+ /*package*/ BluetoothDevice mSelectedDevice= null;
- private LocalBluetoothManager mLocalManager;
+ /*package*/ LocalBluetoothManager mLocalManager;
private BluetoothEnabler mEnabler;
private BluetoothDiscoverableEnabler mDiscoverableEnabler;
@@ -111,8 +109,6 @@
if (mScreenType == SCREEN_TYPE_DEVICEPICKER) {
sendDevicePickedIntent(device);
finish();
- } else if (mScreenType == SCREEN_TYPE_TETHERING) {
- onPanDevicePicked();
} else if (mScreenType == SCREEN_TYPE_SCAN) {
finish();
}
@@ -168,12 +164,6 @@
activity.setTitle(activity.getString(R.string.device_picker));
addPreferencesFromResource(R.xml.device_picker);
- } else if (action.equals(ACTION_LAUNCH_TETHER_PICKER)) {
- mScreenType = SCREEN_TYPE_TETHERING;
- mFilterType = BluetoothDevicePicker.FILTER_TYPE_PANU;
-
- activity.setTitle(activity.getString(R.string.device_picker));
- addPreferencesFromResource(R.xml.device_picker);
} else if (action.equals(ACTION_LAUNCH_SCAN_MODE)) {
mScreenType = SCREEN_TYPE_SCAN;
@@ -293,15 +283,9 @@
} else {
btPreference.getCachedDevice().onClicked();
}
- } else if (mScreenType == SCREEN_TYPE_TETHERING) {
- mLocalManager.stopScanning();
- mLocalManager.persistSelectedDeviceInPicker(mSelectedDevice.getAddress());
- if ((device.getBondState() == BluetoothDevice.BOND_BONDED)) {
- onPanDevicePicked();
- // don't call finish so that users can see it connecting
- } else {
- btPreference.getCachedDevice().onClicked();
- }
+ } else {
+ Log.e(TAG, "onPreferenceTreeClick has invalid mScreenType: "
+ + mScreenType);
}
return true;
}
@@ -391,14 +375,10 @@
}
private void createDevicePreference(CachedBluetoothDevice cachedDevice) {
- BluetoothDevicePreference preference;
- if (mScreenType == SCREEN_TYPE_TETHERING) {
- preference = new BluetoothDevicePreference(
- getActivity(), cachedDevice, CachedBluetoothDevice.PAN_PROFILE);
- } else {
- preference = new BluetoothDevicePreference(
- getActivity(), cachedDevice, CachedBluetoothDevice.OTHER_PROFILES);
- }
+ BluetoothDevicePreference preference = new BluetoothDevicePreference(
+ getActivity(), cachedDevice,
+ CachedBluetoothDevice.OTHER_PROFILES);
+
if (mScreenType == SCREEN_TYPE_SETTINGS) {
preference.setOnSettingsClickListener(this);
}
@@ -422,7 +402,8 @@
((ProgressCategory) mDeviceList).setProgress(start);
}
}
- private void onBluetoothStateChanged(int bluetoothState) {
+
+ /*package*/ void onBluetoothStateChanged(int bluetoothState) {
// When bluetooth is enabled (and we are in the activity, which we are),
// we should start a scan
if (bluetoothState == BluetoothAdapter.STATE_ON) {
@@ -434,47 +415,7 @@
}
}
- private void onPanDevicePicked() {
- final Activity activity = getActivity();
- final LocalBluetoothProfileManager profileManager =
- LocalBluetoothProfileManager.getProfileManager(mLocalManager, Profile.PAN);
- int status = profileManager.getConnectionStatus(mSelectedDevice);
- if (SettingsBtStatus.isConnectionStatusConnected(status)) {
- String name = mSelectedDevice.getName();
- if (TextUtils.isEmpty(name)) {
- name = activity.getString(R.string.bluetooth_device);
- }
- String message = activity.getString(R.string.bluetooth_untether_blank, name);
- DialogInterface.OnClickListener disconnectListener =
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- profileManager.disconnect(mSelectedDevice);
- }
- };
- new AlertDialog.Builder(activity)
- .setTitle(name)
- .setMessage(message)
- .setPositiveButton(android.R.string.ok, disconnectListener)
- .setNegativeButton(android.R.string.cancel, null)
- .create()
- .show();
- } else if (status == SettingsBtStatus.CONNECTION_STATUS_DISCONNECTED) {
- if (profileManager.getConnectedDevices().size() >= BluetoothPan.MAX_CONNECTIONS) {
- new AlertDialog.Builder(activity)
- .setIcon(android.R.drawable.ic_dialog_alert)
- .setTitle(R.string.bluetooth_error_title)
- .setMessage(activity.getString(R.string.bluetooth_tethering_overflow_error,
- BluetoothPan.MAX_CONNECTIONS))
- .setNegativeButton(android.R.string.ok, null)
- .create()
- .show();
- return;
- }
- profileManager.connect(mSelectedDevice);
- }
- }
-
- private void sendDevicePickedIntent(BluetoothDevice device) {
+ /*package*/ void sendDevicePickedIntent(BluetoothDevice device) {
Intent intent = new Intent(BluetoothDevicePicker.ACTION_DEVICE_SELECTED);
intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
if (mScreenType == SCREEN_TYPE_DEVICEPICKER &&
diff --git a/src/com/android/settings/vpn/VpnSettings.java b/src/com/android/settings/vpn/VpnSettings.java
index ea16f9d..c11b2fd 100644
--- a/src/com/android/settings/vpn/VpnSettings.java
+++ b/src/com/android/settings/vpn/VpnSettings.java
@@ -197,6 +197,17 @@
}
@Override
+ public void onDestroy() {
+ super.onDestroy();
+ // Remove any onClick listeners
+ if (mVpnListContainer != null) {
+ for (int i = 0; i < mVpnListContainer.getPreferenceCount(); i++) {
+ mVpnListContainer.getPreference(i).setOnPreferenceClickListener(null);
+ }
+ }
+ }
+
+ @Override
public Dialog onCreateDialog (int id) {
switch (id) {
case DIALOG_CONNECT:
@@ -1050,6 +1061,7 @@
changeState(p, VpnState.IDLE);
}
}
+ if (getActivity() == null) return;
getActivity().unbindService(this);
showPreferences();
}
@@ -1058,6 +1070,7 @@
cv.open();
setDefaultState(list);
+ if (getActivity() == null) return;
getActivity().unbindService(this);
showPreferences();
}