Merge "Bluetooth: Multi HF support" into lmp-dev
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index f95961e..6e1b2b8 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -1240,9 +1240,7 @@
<integer-array name="battery_saver_trigger_values" translatable="false" >
<item>0</item>
<item>5</item>
- <item>10</item>
<item>15</item>
- <item>20</item>
</integer-array>
<!-- Process stats memory use details: labels for memory states -->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d802ba2..29ab3cb 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1255,7 +1255,8 @@
<string name="bluetooth_device_advanced_online_mode_title">Connect</string>
<!-- Bluetooth settings. Connection options screen. The summary of the online mode checkbox. This describes what the setting does in the context of the screen. -->
<string name="bluetooth_device_advanced_online_mode_summary">Connect to Bluetooth device</string>
- <!-- Bluetooth settings. Connection options screen. The title of the header that is above all of the profiles. -->
+ <!-- Bluetooth settings. Connection options screen. The title of the header that is above all of the profiles.
+ When a user decides what Bluetooth capabilities to use with the device. -->
<string name="bluetooth_device_advanced_profile_header_title">Use for</string>
<!-- Bluetooth settings. Connection options screen. Title for option to rename the device. [CHAR LIMIT=30] -->
<string name="bluetooth_device_advanced_rename_device">Rename</string>
@@ -3986,9 +3987,6 @@
<!-- [CHAR_LIMIT=40] Battery saver: Label for feature, title + menu item -->
<string name="battery_saver">Battery saver</string>
- <!-- [CHAR_LIMIT=40] Battery saver: Title for always on option -->
- <string name="battery_saver_always_on_title">Always on</string>
-
<!-- [CHAR_LIMIT=40] Battery saver: Title for automatic entry option -->
<string name="battery_saver_turn_on_automatically_title">Turn on automatically</string>
@@ -3998,9 +3996,6 @@
<!-- [CHAR_LIMIT=40] Battery saver: Value for automatic entry option: pct% battery -->
<string name="battery_saver_turn_on_automatically_pct">at %1$d%% battery</string>
- <!-- [CHAR_LIMIT=NONE] Battery saver: Feature description -->
- <string name="battery_saver_description">To help improve battery life, Battery saver will reduce your device’s performance.\n\nBattery saver will be disabled when your device is plugged in.</string>
-
<!-- Process Stats strings -->
<skip />
@@ -5359,7 +5354,8 @@
<string name="amber_alerts_title">AMBER alerts</string>
<!-- Amber alerts summary. [CHAR LIMIT=60] -->
<string name="amber_alerts_summary">Receive bulletins about child abductions</string>
- <!-- repeat title. [CHAR LIMIT=30] -->
+ <!-- repeat title. Allows the user to set how oftem to repeat alert reminders.
+ For example, they may have alerts just once or every 2 or 15 minutes. [CHAR LIMIT=30] -->
<string name="repeat_title">Repeat</string>
<!-- Call Manager enable settings title. [CHAR LIMIT=50] -->
diff --git a/res/xml/battery_saver_settings.xml b/res/xml/battery_saver_settings.xml
index 472586a..929053f 100644
--- a/res/xml/battery_saver_settings.xml
+++ b/res/xml/battery_saver_settings.xml
@@ -18,14 +18,6 @@
android:title="@string/battery_saver"
android:key="battery_saver">
- <!-- Always on -->
- <SwitchPreference
- android:key="always_on"
- android:title="@string/battery_saver_always_on_title"
- android:switchTextOff=""
- android:switchTextOn=""
- android:persistent="false" />
-
<!-- Turn on automatically -->
<com.android.settings.notification.DropDownPreference
android:key="turn_on_automatically"
@@ -35,7 +27,7 @@
<!-- Feature description text -->
<Preference
android:key="description"
- android:summary="@string/battery_saver_description"
+ android:summary="@*android:string/battery_saver_description"
android:persistent="false"
android:selectable="false" />
diff --git a/src/com/android/settings/fuelgauge/BatterySaverSettings.java b/src/com/android/settings/fuelgauge/BatterySaverSettings.java
index 808fb25..e303dc8 100644
--- a/src/com/android/settings/fuelgauge/BatterySaverSettings.java
+++ b/src/com/android/settings/fuelgauge/BatterySaverSettings.java
@@ -26,14 +26,18 @@
import android.os.Handler;
import android.provider.Settings.Global;
import android.util.Log;
+import android.widget.Switch;
import com.android.settings.R;
+import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.notification.SettingPref;
+import com.android.settings.widget.SwitchBar;
-public class BatterySaverSettings extends SettingsPreferenceFragment {
+public class BatterySaverSettings extends SettingsPreferenceFragment
+ implements SwitchBar.OnSwitchChangeListener {
private static final String TAG = "BatterySaverSettings";
- private static final String KEY_ALWAYS_ON = "always_on";
+ private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
private static final String KEY_TURN_ON_AUTOMATICALLY = "turn_on_automatically";
private static final long WAIT_FOR_SWITCH_ANIM = 500;
@@ -42,8 +46,10 @@
private Context mContext;
private boolean mCreated;
- private SettingPref mAlwaysOnPref;
private SettingPref mTriggerPref;
+ private SwitchBar mSwitchBar;
+ private Switch mSwitch;
+ private boolean mValidListener;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
@@ -53,25 +59,13 @@
addPreferencesFromResource(R.xml.battery_saver_settings);
mContext = getActivity();
- mAlwaysOnPref = new SettingPref(SettingPref.TYPE_GLOBAL, KEY_ALWAYS_ON,
- Global.LOW_POWER_MODE, 0) {
- @Override
- protected boolean setSetting(Context context, int value) {
- mHandler.removeCallbacks(mStartMode);
- if (value == 0) {
- return super.setSetting(context, value);
- } else {
- // about lose animations, make sure we don't turn the mode on until the switch
- // stops moving
- mHandler.postDelayed(mStartMode, WAIT_FOR_SWITCH_ANIM);
- return true;
- }
- }
- };
+ mSwitchBar = ((SettingsActivity) mContext).getSwitchBar();
+ mSwitch = mSwitchBar.getSwitch();
+ mSwitchBar.show();
+
mTriggerPref = new SettingPref(SettingPref.TYPE_GLOBAL, KEY_TURN_ON_AUTOMATICALLY,
Global.LOW_POWER_MODE_TRIGGER_LEVEL,
- mContext.getResources().getInteger(
- com.android.internal.R.integer.config_lowBatteryWarningLevel),
+ 0, /*default*/
getResources().getIntArray(R.array.battery_saver_trigger_values)) {
@Override
protected String getCaption(Resources res, int value) {
@@ -81,20 +75,58 @@
return res.getString(R.string.battery_saver_turn_on_automatically_never);
}
};
- mAlwaysOnPref.init(this);
mTriggerPref.init(this);
}
@Override
+ public void onDestroyView() {
+ super.onDestroyView();
+ mSwitchBar.hide();
+ }
+
+ @Override
public void onResume() {
super.onResume();
mSettingsObserver.setListening(true);
+ if (!mValidListener) {
+ mSwitchBar.addOnSwitchChangeListener(this);
+ mValidListener = true;
+ }
+ updateSwitch();
}
@Override
public void onPause() {
super.onPause();
mSettingsObserver.setListening(false);
+ if (mValidListener) {
+ mSwitchBar.removeOnSwitchChangeListener(this);
+ mValidListener = false;
+ }
+ }
+
+ @Override
+ public void onSwitchChanged(Switch switchView, boolean isChecked) {
+ if (isChecked) {
+ mHandler.postDelayed(mStartMode, WAIT_FOR_SWITCH_ANIM);
+ } else {
+ if (DEBUG) Log.d(TAG, "Stopping LOW_POWER_MODE from settings");
+ Global.putInt(getContentResolver(), Global.LOW_POWER_MODE, 0);
+ }
+ }
+
+ private void updateSwitch() {
+ final boolean checked = Global.getInt(getContentResolver(), Global.LOW_POWER_MODE, 0) != 0;
+ if (checked == mSwitch.isChecked()) return;
+
+ // set listener to null so that that code below doesn't trigger onCheckedChanged()
+ if (mValidListener) {
+ mSwitchBar.removeOnSwitchChangeListener(this);
+ }
+ mSwitch.setChecked(checked);
+ if (mValidListener) {
+ mSwitchBar.addOnSwitchChangeListener(this);
+ }
}
private final Runnable mStartMode = new Runnable() {
@@ -103,8 +135,8 @@
AsyncTask.execute(new Runnable() {
@Override
public void run() {
- Log.d(TAG, "Starting LOW_POWER_MODE from settings");
- Global.putInt(mContext.getContentResolver(), Global.LOW_POWER_MODE, 1);
+ if (DEBUG) Log.d(TAG, "Starting LOW_POWER_MODE from settings");
+ Global.putInt(getContentResolver(), Global.LOW_POWER_MODE, 1);
}
});
}
@@ -122,7 +154,7 @@
@Override
public void onChange(boolean selfChange, Uri uri) {
if (LOW_POWER_MODE_URI.equals(uri)) {
- mAlwaysOnPref.update(mContext);
+ updateSwitch();
}
if (LOW_POWER_MODE_TRIGGER_LEVEL_URI.equals(uri)) {
mTriggerPref.update(mContext);