Merge "Make the SwitchBar appear immediately" into lmp-preview-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 97d0d05..aa003af 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -130,8 +130,7 @@
<activity android:name="Settings$WifiSettingsActivity"
android:taskAffinity=""
android:label="@string/wifi_settings"
- android:configChanges="orientation|keyboardHidden|screenSize"
- android:excludeFromRecents="true">
+ android:configChanges="orientation|keyboardHidden|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.settings.WIFI_SETTINGS" />
@@ -269,8 +268,7 @@
<activity android:name="Settings$BluetoothSettingsActivity"
android:label="@string/bluetooth_settings_title"
- android:taskAffinity=""
- android:excludeFromRecents="true">
+ android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.settings.BLUETOOTH_SETTINGS" />
@@ -308,8 +306,7 @@
<activity android:name="Settings$TetherSettingsActivity"
android:label="@string/tether_settings_title_all"
- android:taskAffinity=""
- android:excludeFromRecents="true">
+ android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
@@ -351,8 +348,7 @@
<activity android:name="Settings$VpnSettingsActivity"
android:label="@string/vpn_settings_title"
- android:taskAffinity=""
- android:excludeFromRecents="true">
+ android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.net.vpn.SETTINGS" />
@@ -368,8 +364,7 @@
<activity android:name="Settings$DateTimeSettingsActivity"
android:label="@string/date_and_time"
- android:taskAffinity=""
- android:excludeFromRecents="true">
+ android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.settings.DATE_SETTINGS" />
@@ -526,8 +521,7 @@
<activity android:name="Settings$ZenModeSettingsActivity"
android:label="@string/zen_mode_settings_title"
android:exported="true"
- android:taskAffinity=""
- android:excludeFromRecents="true">
+ android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.settings.ZEN_MODE_SETTINGS" />
@@ -542,8 +536,7 @@
<activity android:name="Settings$DisplaySettingsActivity"
android:label="@string/display_settings"
- android:taskAffinity=""
- android:excludeFromRecents="true">
+ android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="com.android.settings.DISPLAY_SETTINGS" />
@@ -607,8 +600,7 @@
<activity android:name="Settings$ManageApplicationsActivity"
android:label="@string/applications_settings"
- android:taskAffinity=""
- android:excludeFromRecents="true">
+ android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.settings.APPLICATION_SETTINGS" />
@@ -736,8 +728,7 @@
<activity android:name="Settings$NotificationStationActivity"
android:theme="@android:style/Theme.DeviceDefault"
android:label="@string/notification_log_title"
- android:taskAffinity=""
- android:excludeFromRecents="true">
+ android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
@@ -751,7 +742,6 @@
<activity android:name="Settings$AppOpsSummaryActivity"
android:label="@string/app_ops_settings"
android:taskAffinity=""
- android:excludeFromRecents="true"
android:enabled="false">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -770,8 +760,7 @@
<activity android:name="Settings$LocationSettingsActivity"
android:label="@string/location_settings_title"
android:configChanges="orientation|keyboardHidden|screenSize"
- android:taskAffinity=""
- android:excludeFromRecents="true">
+ android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.settings.LOCATION_SOURCE_SETTINGS" />
@@ -806,8 +795,7 @@
<activity android:name="MonitoringCertInfoActivity"
android:label="@string/ssl_ca_cert_dialog_title"
android:theme="@style/Transparent"
- android:taskAffinity=""
- android:excludeFromRecents="true">
+ android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="com.android.settings.MONITORING_CERT_INFO" />
@@ -817,8 +805,7 @@
<activity android:name="Settings$TrustedCredentialsSettingsActivity"
android:label="@string/trusted_credentials"
- android:taskAffinity=""
- android:excludeFromRecents="true">
+ android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="com.android.settings.TRUSTED_CREDENTIALS" />
@@ -929,8 +916,7 @@
<activity android:name="Settings$AccessibilitySettingsActivity"
android:label="@string/accessibility_settings"
android:configChanges="orientation|keyboardHidden|screenSize"
- android:taskAffinity=""
- android:excludeFromRecents="true">
+ android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.settings.ACCESSIBILITY_SETTINGS" />
@@ -1307,8 +1293,7 @@
<activity android:name="Settings$WifiDisplaySettingsActivity"
android:label="@string/wifi_display_settings_title"
- android:taskAffinity=""
- android:excludeFromRecents="true">
+ android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.settings.WIFI_DISPLAY_SETTINGS" />
@@ -1436,8 +1421,7 @@
<activity android:name="Settings$PowerUsageSummaryActivity"
android:label="@string/power_usage_summary_title"
- android:taskAffinity=""
- android:excludeFromRecents="true">
+ android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.POWER_USAGE_SUMMARY" />
@@ -1463,8 +1447,7 @@
<activity android:name="Settings$BatterySaverSettingsActivity"
android:label="@string/battery_saver"
- android:taskAffinity=""
- android:excludeFromRecents="true">
+ android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.settings.BATTERY_SAVER_SETTINGS" />
@@ -1565,8 +1548,7 @@
<activity android:name="Settings$DataUsageSummaryActivity"
android:label="@string/data_usage_summary_title"
- android:taskAffinity=""
- android:excludeFromRecents="true">
+ android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
@@ -1580,8 +1562,7 @@
<activity android:name="Settings$DreamSettingsActivity"
android:label="@string/screensaver_settings_title"
- android:taskAffinity=""
- android:excludeFromRecents="true">
+ android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.settings.DREAM_SETTINGS" />
@@ -1596,8 +1577,7 @@
<activity android:name="Settings$UserSettingsActivity"
android:label="@string/user_settings_title"
- android:taskAffinity=""
- android:excludeFromRecents="true">
+ android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.settings.USER_SETTINGS" />
@@ -1611,8 +1591,7 @@
<activity android:name="Settings$PaymentSettingsActivity"
android:label="@string/nfc_payment_settings_title"
- android:taskAffinity=""
- android:excludeFromRecents="true">
+ android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.settings.NFC_PAYMENT_SETTINGS" />
@@ -1655,8 +1634,7 @@
<activity android:name="Settings$NotificationAccessSettingsActivity"
android:label="@string/manage_notification_access"
- android:taskAffinity=""
- android:excludeFromRecents="true">
+ android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS" />
@@ -1670,8 +1648,7 @@
<activity android:name="Settings$ConditionProviderSettingsActivity"
android:label="@string/manage_condition_providers"
- android:taskAffinity=""
- android:excludeFromRecents="true">
+ android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS" />
@@ -1686,8 +1663,7 @@
<activity android:name="Settings$NotificationSettingsActivity"
android:label="@string/notification_settings"
android:exported="true"
- android:taskAffinity=""
- android:excludeFromRecents="true">
+ android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.settings.NOTIFICATION_SETTINGS" />
@@ -1704,7 +1680,6 @@
<activity-alias android:name="Settings$SoundSettingsActivity"
android:label="@string/notification_settings"
android:taskAffinity=""
- android:excludeFromRecents="true"
android:targetActivity="Settings$NotificationSettingsActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -1733,8 +1708,7 @@
<activity android:name="Settings$NotificationDisplaySettingsActivity"
android:label="@string/notification_display_settings"
android:exported="true"
- android:taskAffinity=""
- android:excludeFromRecents="true">
+ android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.settings.ACTION_NOTIFICATION_DISPLAY_SETTINGS" />
@@ -1749,8 +1723,7 @@
<activity android:name="Settings$OtherSoundSettingsActivity"
android:label="@string/other_sound_settings"
android:exported="true"
- android:taskAffinity=""
- android:excludeFromRecents="true">
+ android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.settings.ACTION_OTHER_SOUND_SETTINGS" />
@@ -1765,8 +1738,7 @@
<activity android:name="Settings$AppNotificationSettingsActivity"
android:label="@string/app_notifications_title"
android:exported="true"
- android:taskAffinity=""
- android:excludeFromRecents="true">
+ android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.settings.ACTION_APP_NOTIFICATION_SETTINGS" />
@@ -1782,7 +1754,6 @@
<activity android:name="RegulatoryInfoDisplayActivity"
android:label="@string/regulatory_information"
android:taskAffinity=""
- android:excludeFromRecents="true"
android:enabled="@bool/config_show_regulatory_info">
<intent-filter>
<action android:name="android.settings.SHOW_REGULATORY_INFO" />
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 30516a1..b835add 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -47,27 +47,12 @@
<color name="lock_pattern_view_success_color">#ff009688</color>
<color name="lock_pattern_view_error_color">#fff4511e</color>
- <color name="material_blue_grey_50">#ffeceff1</color>
- <color name="material_blue_grey_100">#ffcfd8dc</color>
- <color name="material_blue_grey_300">#ff90a4ae</color>
- <color name="material_blue_grey_500">#ff607d8b</color>
- <color name="material_blue_grey_700">#ff455a64</color>
-
- <color name="material_orange_100">#ffffe0b2</color>
- <color name="material_orange_300">#ffffb74d</color>
- <color name="material_orange_500">#ffff9800</color>
- <color name="material_orange_700">#fff57c00</color>
- <color name="material_orange_A200">#ffffab40</color>
- <color name="material_orange_A400">#ffff9100</color>
-
- <color name="material_accent_color_light">#FF009688</color>
- <color name="material_accent_color_dark">#FF80CBC4</color>
<color name="material_empty_color_light">#FFCED7DB</color>
- <!-- Palette colors referenced by top-level themes and manually copied into base theme. -->
+ <!-- Palette colors referenced by top-level themes. -->
<color name="theme_primary">#ff263238</color>
- <color name="theme_primary_dark">@color/theme_primary</color>
- <color name="theme_accent">@color/material_accent_color_light</color>
+ <color name="theme_primary_dark">#ff21272b</color>
+ <color name="theme_accent">#ff009688</color>
<color name="dashboard_background_color">#ffe1e1e0</color>
<color name="switchbar_background_color">#ff384248</color>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 8ddde44..ef3976d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3725,6 +3725,9 @@
<!-- [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>
@@ -3735,7 +3738,7 @@
<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 turn off when your device is plugged in.</string>
+ <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 />
diff --git a/res/values/themes.xml b/res/values/themes.xml
index 1aec813..9087ed1 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -67,14 +67,7 @@
layouts against a remote context using our local theme colors. Due to the implementation
details of Theme, we can't reference any local resources and MUST instead use the values
directly. So use #ff263238 instead of @color/theme_primary and so on. -->
- <style name="Theme.SettingsBase" parent="@android:style/Theme.Material.Light.DarkActionBar">
- <!-- Should match @color/theme_primary. -->
- <item name="android:colorPrimary">#ff263238</item>
- <!-- Should match @color/theme_primary_dark. -->
- <item name="android:colorPrimaryDark">#ff263238</item>
- <!-- Should match @color/theme_accent. -->
- <item name="android:colorAccent">#ff009688</item>
- </style>
+ <style name="Theme.SettingsBase" parent="@android:style/Theme.Material.Settings" />
<style name="Theme.Settings" parent="Theme.SettingsBase">
<item name="@*android:preferenceHeaderPanelStyle">@style/PreferenceHeaderPanelSinglePane</item>
@@ -119,7 +112,7 @@
<item name="android:contentInsetStart">@dimen/actionbar_subsettings_contentInsetStart</item>
</style>
- <style name="Theme.DialogWhenLarge" parent="android:style/Theme.Material.Light.DialogWhenLarge">
+ <style name="Theme.DialogWhenLarge" parent="@android:style/Theme.Material.Light.DialogWhenLarge">
<!-- Used by the ActionBar -->
<item name="android:colorPrimary">@color/theme_primary</item>
<!-- Used by the StatusBar -->
diff --git a/res/xml/battery_saver_settings.xml b/res/xml/battery_saver_settings.xml
index a3729c5..472586a 100644
--- a/res/xml/battery_saver_settings.xml
+++ b/res/xml/battery_saver_settings.xml
@@ -18,6 +18,14 @@
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"
diff --git a/src/com/android/settings/fuelgauge/BatteryHistoryChart.java b/src/com/android/settings/fuelgauge/BatteryHistoryChart.java
index 04f4050..7ab2526 100644
--- a/src/com/android/settings/fuelgauge/BatteryHistoryChart.java
+++ b/src/com/android/settings/fuelgauge/BatteryHistoryChart.java
@@ -201,10 +201,7 @@
int mLevelBottom;
int mLevelLeft;
int mLevelRight;
- static final int PHONE_SIGNAL_X_MASK = CHART_DATA_X_MASK;
- static final int PHONE_SIGNAL_BIN_MASK = CHART_DATA_BIN_MASK;
- static final int PHONE_SIGNAL_BIN_SHIFT = CHART_DATA_BIN_SHIFT;
-
+
int mNumHist;
long mHistStart;
long mHistDataEnd;
@@ -360,18 +357,22 @@
mBatteryCriticalPaint.setStyle(Paint.Style.STROKE);
mTimeRemainPaint.setColor(0xFFCED7BB);
mTimeRemainPaint.setStyle(Paint.Style.FILL);
- mChargingPaint.setARGB(255, 0, 128, 0);
mChargingPaint.setStyle(Paint.Style.STROKE);
mScreenOnPaint.setStyle(Paint.Style.STROKE);
mGpsOnPaint.setStyle(Paint.Style.STROKE);
mWifiRunningPaint.setStyle(Paint.Style.STROKE);
mCpuRunningPaint.setStyle(Paint.Style.STROKE);
mPhoneSignalChart.setColors(new int[] {
- 0x00000000, 0xffa00000, 0xffa07000, 0xffa0a000,
- 0xff80a000, 0xff409000, 0xff008000
+ 0x00000000, 0xffc43828, 0xffe54918, 0xfff47b00,
+ 0xfffabf2c, 0xff679e37, 0xff0a7f42
});
mDebugRectPaint.setARGB(255, 255, 0, 0);
mDebugRectPaint.setStyle(Paint.Style.STROKE);
+ mScreenOnPaint.setColor(0xFF009688);
+ mGpsOnPaint.setColor(0xFF009688);
+ mWifiRunningPaint.setColor(0xFF009688);
+ mCpuRunningPaint.setColor(0xFF009688);
+ mChargingPaint.setColor(0xFF009688);
TypedArray a =
context.obtainStyledAttributes(
@@ -428,6 +429,11 @@
case R.styleable.BatteryHistoryChart_barPrimaryColor:
mBatteryBackgroundPaint.setColor(a.getInt(attr, 0));
+ mScreenOnPaint.setColor(a.getInt(attr, 0));
+ mGpsOnPaint.setColor(a.getInt(attr, 0));
+ mWifiRunningPaint.setColor(a.getInt(attr, 0));
+ mCpuRunningPaint.setColor(a.getInt(attr, 0));
+ mChargingPaint.setColor(a.getInt(attr, 0));
break;
case R.styleable.BatteryHistoryChart_barPredictionColor:
@@ -692,17 +698,9 @@
// Compress lines to make more room for chart.
mLineWidth = textHeight/3;
}
- mScreenOnPaint.setARGB(255, 32, 64, 255);
- mGpsOnPaint.setARGB(255, 32, 64, 255);
- mWifiRunningPaint.setARGB(255, 32, 64, 255);
- mCpuRunningPaint.setARGB(255, 32, 64, 255);
} else {
mLargeMode = false;
mLineWidth = mThinLineWidth;
- mScreenOnPaint.setARGB(255, 0, 0, 255);
- mGpsOnPaint.setARGB(255, 0, 0, 255);
- mWifiRunningPaint.setARGB(255, 0, 0, 255);
- mCpuRunningPaint.setARGB(255, 0, 0, 255);
}
if (mLineWidth <= 0) mLineWidth = 1;
diff --git a/src/com/android/settings/fuelgauge/BatterySaverSettings.java b/src/com/android/settings/fuelgauge/BatterySaverSettings.java
index b62ddb7..808fb25 100644
--- a/src/com/android/settings/fuelgauge/BatterySaverSettings.java
+++ b/src/com/android/settings/fuelgauge/BatterySaverSettings.java
@@ -24,40 +24,50 @@
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
-import android.os.Message;
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
- implements SwitchBar.OnSwitchChangeListener {
+public class BatterySaverSettings extends SettingsPreferenceFragment {
private static final String TAG = "BatterySaverSettings";
+ private static final String KEY_ALWAYS_ON = "always_on";
private static final String KEY_TURN_ON_AUTOMATICALLY = "turn_on_automatically";
private static final long WAIT_FOR_SWITCH_ANIM = 500;
- private final H mHandler = new H();
+ private final Handler mHandler = new Handler();
private final SettingsObserver mSettingsObserver = new SettingsObserver(mHandler);
private Context mContext;
- private SwitchBar mSwitchBar;
- private boolean mSwitchBarListenerAdded;
+ private boolean mCreated;
+ private SettingPref mAlwaysOnPref;
private SettingPref mTriggerPref;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
-
+ if (mCreated) return;
+ mCreated = true;
addPreferencesFromResource(R.xml.battery_saver_settings);
mContext = getActivity();
- mSwitchBar = ((SettingsActivity) mContext).getSwitchBar();
- updateSwitchBar();
+ 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;
+ }
+ }
+ };
mTriggerPref = new SettingPref(SettingPref.TYPE_GLOBAL, KEY_TURN_ON_AUTOMATICALLY,
Global.LOW_POWER_MODE_TRIGGER_LEVEL,
mContext.getResources().getInteger(
@@ -71,76 +81,34 @@
return res.getString(R.string.battery_saver_turn_on_automatically_never);
}
};
+ mAlwaysOnPref.init(this);
mTriggerPref.init(this);
}
- private void updateSwitchBar() {
- final boolean mode = Global.getInt(getContentResolver(), Global.LOW_POWER_MODE, 0) != 0;
- if (mSwitchBarListenerAdded) {
- mSwitchBar.removeOnSwitchChangeListener(this);
- }
- mSwitchBar.getSwitch().setChecked(mode);
- if (mSwitchBarListenerAdded) {
- mSwitchBar.addOnSwitchChangeListener(this);
- }
- }
-
- private void updateTriggerLevel() {
- mTriggerPref.update(mContext);
- }
-
@Override
public void onResume() {
super.onResume();
- updateSwitchBar();
mSettingsObserver.setListening(true);
- mSwitchBar.show();
- mSwitchBar.addOnSwitchChangeListener(this);
- mSwitchBarListenerAdded = true;
}
@Override
public void onPause() {
super.onPause();
mSettingsObserver.setListening(false);
- if (mSwitchBarListenerAdded) {
- mSwitchBar.removeOnSwitchChangeListener(this);
- mSwitchBarListenerAdded = false;
- }
- mSwitchBar.hide();
}
- @Override
- public void onSwitchChanged(Switch switchView, boolean isChecked) {
- mHandler.postSetMode(isChecked);
- }
-
- private void handleSetMode(final boolean mode) {
- AsyncTask.execute(new Runnable() {
- @Override
- public void run() {
- Log.d(TAG, "LOW_POWER_MODE from settings: " + mode);
- Global.putInt(getContentResolver(), Global.LOW_POWER_MODE, mode ? 1 : 0);
- }
- });
- }
-
- private final class H extends Handler {
- private static final int SET_MODE = 1;
-
- public void postSetMode(boolean mode) {
- removeMessages(SET_MODE);
- final Message m = obtainMessage(SET_MODE, mode ? 1 : 0, 0);
- sendMessageDelayed(m, mode ? WAIT_FOR_SWITCH_ANIM : 0);
- }
-
+ private final Runnable mStartMode = new Runnable() {
@Override
- public void handleMessage(Message msg) {
- if (msg.what == SET_MODE) {
- handleSetMode(msg.arg1 != 0);
- }
+ public void run() {
+ 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);
+ }
+ });
}
- }
+ };
private final class SettingsObserver extends ContentObserver {
private final Uri LOW_POWER_MODE_URI = Global.getUriFor(Global.LOW_POWER_MODE);
@@ -154,10 +122,10 @@
@Override
public void onChange(boolean selfChange, Uri uri) {
if (LOW_POWER_MODE_URI.equals(uri)) {
- updateSwitchBar();
+ mAlwaysOnPref.update(mContext);
}
if (LOW_POWER_MODE_TRIGGER_LEVEL_URI.equals(uri)) {
- updateTriggerLevel();
+ mTriggerPref.update(mContext);
}
}
diff --git a/src/com/android/settings/wifi/AccessPoint.java b/src/com/android/settings/wifi/AccessPoint.java
index 688fc63..a504284 100644
--- a/src/com/android/settings/wifi/AccessPoint.java
+++ b/src/com/android/settings/wifi/AccessPoint.java
@@ -19,6 +19,7 @@
import com.android.settings.R;
import android.content.Context;
+import android.graphics.drawable.Drawable;
import android.net.NetworkInfo.DetailedState;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
@@ -44,6 +45,8 @@
};
private static final int[] STATE_NONE = {};
+ private static int[] wifi_signal_attributes = { R.attr.wifi_signal };
+
/** These values are matched in string arrays -- changes must be kept in sync */
static final int SECURITY_NONE = 0;
static final int SECURITY_WEP = 1;
@@ -144,21 +147,18 @@
AccessPoint(Context context, WifiConfiguration config) {
super(context);
- setWidgetLayoutResource(R.layout.preference_widget_wifi_signal);
loadConfig(config);
refresh();
}
AccessPoint(Context context, ScanResult result) {
super(context);
- setWidgetLayoutResource(R.layout.preference_widget_wifi_signal);
loadResult(result);
refresh();
}
AccessPoint(Context context, Bundle savedState) {
super(context);
- setWidgetLayoutResource(R.layout.preference_widget_wifi_signal);
mConfig = savedState.getParcelable(KEY_CONFIG);
if (mConfig != null) {
@@ -206,18 +206,28 @@
@Override
protected void onBindView(View view) {
super.onBindView(view);
- ImageView signal = (ImageView) view.findViewById(R.id.signal);
- if (mRssi == Integer.MAX_VALUE) {
- signal.setImageDrawable(null);
+ updateIcon(getLevel());
+ notifyChanged();
+ }
+
+ protected void updateIcon(int level) {
+ if (level == -1) {
+ setIcon(null);
} else {
- signal.setImageLevel(getLevel());
- signal.setImageDrawable(getContext().getTheme().obtainStyledAttributes(
- new int[] {R.attr.wifi_signal}).getDrawable(0));
- signal.setImageState((security != SECURITY_NONE) ?
- STATE_SECURED : STATE_NONE, true);
+ Drawable drawable = getIcon();
+
+ if (drawable == null) {
+ drawable = getContext().getTheme().obtainStyledAttributes(
+ wifi_signal_attributes).getDrawable(0);
+ setIcon(drawable);
+ }
+
+ drawable.setLevel(level);
+ drawable.setState((security != SECURITY_NONE) ? STATE_SECURED : STATE_NONE);
}
}
+
@Override
public int compareTo(Preference preference) {
if (!(preference instanceof AccessPoint)) {
@@ -231,6 +241,7 @@
// Reachable one goes before unreachable one.
if (mRssi != Integer.MAX_VALUE && other.mRssi == Integer.MAX_VALUE) return -1;
if (mRssi == Integer.MAX_VALUE && other.mRssi != Integer.MAX_VALUE) return 1;
+ if (mRssi == Integer.MAX_VALUE && other.mRssi != Integer.MAX_VALUE) return 1;
// Configured one goes before unconfigured one.
if (networkId != WifiConfiguration.INVALID_NETWORK_ID
@@ -364,6 +375,8 @@
/** Updates the title and summary; may indirectly call notifyChanged() */
private void refresh() {
setTitle(ssid);
+ updateIcon(getLevel());
+
StringBuilder summary = new StringBuilder();
Context context = getContext();
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index 7ccfc6b..6304997 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -551,7 +551,7 @@
} catch (IllegalArgumentException e) {
return R.string.wifi_ip_settings_invalid_dns;
}
- linkProperties.addDns(dnsAddr);
+ linkProperties.addDnsServer(dnsAddr);
}
if (mDns2View.length() > 0) {
@@ -561,7 +561,7 @@
} catch (IllegalArgumentException e) {
return R.string.wifi_ip_settings_invalid_dns;
}
- linkProperties.addDns(dnsAddr);
+ linkProperties.addDnsServer(dnsAddr);
}
return 0;
}
@@ -788,7 +788,7 @@
}
}
- Iterator<InetAddress> dnsIterator = linkProperties.getDnses().iterator();
+ Iterator<InetAddress> dnsIterator = linkProperties.getDnsServers().iterator();
if (dnsIterator.hasNext()) {
mDns1View.setText(dnsIterator.next().getHostAddress());
}