Merge "Updated Wi-Fi Settings icons to new filled-in teal format." into lmp-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 11665b0..0fb6228 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1670,7 +1670,7 @@
android:launchMode="singleTop"
android:excludeFromRecents="true"
android:theme="@style/Theme.CryptKeeper"
- android:configChanges="keyboard|keyboardHidden|uiMode"
+ android:configChanges="mnc|mcc|keyboard|keyboardHidden|uiMode"
android:windowSoftInputMode="adjustResize"
android:screenOrientation="nosensor">
<intent-filter android:priority="10">
diff --git a/res/drawable-hdpi/ic_person_white.png b/res/drawable-hdpi/ic_person_white.png
deleted file mode 100644
index 009524a..0000000
--- a/res/drawable-hdpi/ic_person_white.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_person_white.png b/res/drawable-mdpi/ic_person_white.png
deleted file mode 100644
index 563f1d1..0000000
--- a/res/drawable-mdpi/ic_person_white.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_person_white.png b/res/drawable-xhdpi/ic_person_white.png
deleted file mode 100644
index 0200ece..0000000
--- a/res/drawable-xhdpi/ic_person_white.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_person_white.png b/res/drawable-xxhdpi/ic_person_white.png
deleted file mode 100644
index 6a6f033..0000000
--- a/res/drawable-xxhdpi/ic_person_white.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_person_white.png b/res/drawable-xxxhdpi/ic_person_white.png
deleted file mode 100644
index 9092553..0000000
--- a/res/drawable-xxxhdpi/ic_person_white.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/ic_avatar_default_1.xml b/res/drawable/ic_avatar_default_1.xml
deleted file mode 100644
index edd919a..0000000
--- a/res/drawable/ic_avatar_default_1.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item>
- <shape android:shape="oval">
- <size android:width="40dp" android:height="40dp" />
- <solid android:color="@color/pink_500" />
- </shape>
- </item>
- <item android:top="8dp" android:bottom="8dp" android:left="8dp" android:right="8dp"
- android:drawable="@drawable/ic_person_white" />
-</layer-list>
-
diff --git a/res/drawable/ic_avatar_default_2.xml b/res/drawable/ic_avatar_default_2.xml
deleted file mode 100644
index 77918a0..0000000
--- a/res/drawable/ic_avatar_default_2.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item>
- <shape android:shape="oval">
- <size android:width="40dp" android:height="40dp" />
- <solid android:color="@color/indigo_500" />
- </shape>
- </item>
- <item android:top="8dp" android:bottom="8dp" android:left="8dp" android:right="8dp"
- android:drawable="@drawable/ic_person_white" />
-</layer-list>
-
diff --git a/res/drawable/ic_avatar_default_3.xml b/res/drawable/ic_avatar_default_3.xml
deleted file mode 100644
index 49fd6c4..0000000
--- a/res/drawable/ic_avatar_default_3.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item>
- <shape android:shape="oval">
- <size android:width="40dp" android:height="40dp" />
- <solid android:color="@color/blue_500" />
- </shape>
- </item>
- <item android:top="8dp" android:bottom="8dp" android:left="8dp" android:right="8dp"
- android:drawable="@drawable/ic_person_white" />
-</layer-list>
-
diff --git a/res/drawable/ic_avatar_default_4.xml b/res/drawable/ic_avatar_default_4.xml
deleted file mode 100644
index 6992f90..0000000
--- a/res/drawable/ic_avatar_default_4.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item>
- <shape android:shape="oval">
- <size android:width="40dp" android:height="40dp" />
- <solid android:color="@color/teal_500" />
- </shape>
- </item>
- <item android:top="8dp" android:bottom="8dp" android:left="8dp" android:right="8dp"
- android:drawable="@drawable/ic_person_white" />
-</layer-list>
-
diff --git a/res/drawable/ic_avatar_default_5.xml b/res/drawable/ic_avatar_default_5.xml
deleted file mode 100644
index 2aa0db2..0000000
--- a/res/drawable/ic_avatar_default_5.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item>
- <shape android:shape="oval">
- <size android:width="40dp" android:height="40dp" />
- <solid android:color="@color/green_500" />
- </shape>
- </item>
- <item android:top="8dp" android:bottom="8dp" android:left="8dp" android:right="8dp"
- android:drawable="@drawable/ic_person_white" />
-</layer-list>
-
diff --git a/res/drawable/ic_avatar_default_6.xml b/res/drawable/ic_avatar_default_6.xml
deleted file mode 100644
index 7f9bb32..0000000
--- a/res/drawable/ic_avatar_default_6.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item>
- <shape android:shape="oval">
- <size android:width="40dp" android:height="40dp" />
- <solid android:color="@color/light_green_500" />
- </shape>
- </item>
- <item android:top="8dp" android:bottom="8dp" android:left="8dp" android:right="8dp"
- android:drawable="@drawable/ic_person_white" />
-</layer-list>
-
diff --git a/res/drawable/ic_avatar_default_7.xml b/res/drawable/ic_avatar_default_7.xml
deleted file mode 100644
index 1c1c5f3..0000000
--- a/res/drawable/ic_avatar_default_7.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item>
- <shape android:shape="oval">
- <size android:width="40dp" android:height="40dp" />
- <solid android:color="@color/orange_500" />
- </shape>
- </item>
- <item android:top="8dp" android:bottom="8dp" android:left="8dp" android:right="8dp"
- android:drawable="@drawable/ic_person_white" />
-</layer-list>
-
diff --git a/res/drawable/ic_avatar_default_8.xml b/res/drawable/ic_avatar_default_8.xml
deleted file mode 100644
index 478454e..0000000
--- a/res/drawable/ic_avatar_default_8.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item>
- <shape android:shape="oval">
- <size android:width="40dp" android:height="40dp" />
- <solid android:color="@color/deep_orange_500" />
- </shape>
- </item>
- <item android:top="8dp" android:bottom="8dp" android:left="8dp" android:right="8dp"
- android:drawable="@drawable/ic_person_white" />
-</layer-list>
-
diff --git a/res/drawable/ic_avatar_guest.xml b/res/drawable/ic_avatar_guest.xml
deleted file mode 100644
index f81fe89..0000000
--- a/res/drawable/ic_avatar_guest.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item>
- <shape android:shape="oval">
- <size android:width="40dp" android:height="40dp" />
- <solid android:color="@color/grey_500" />
- </shape>
- </item>
- <item android:top="8dp" android:bottom="8dp" android:left="8dp" android:right="8dp"
- android:drawable="@drawable/ic_person_white" />
-</layer-list>
-
diff --git a/res/drawable/ic_default_user.png b/res/drawable/ic_default_user.png
deleted file mode 100644
index ddf797f..0000000
--- a/res/drawable/ic_default_user.png
+++ /dev/null
Binary files differ
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 58687c9..1c299f5 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -80,18 +80,6 @@
<color name="setup_wizard_preference_background_color_dark">@*android:color/background_material_dark</color>
<color name="setup_wizard_preference_background_color_light">@*android:color/background_material_light</color>
- <!-- Default avatar colors -->
- <color name="pink_500">#ffe91e63</color>
- <color name="indigo_500">#ff3f51b5</color>
- <color name="blue_500">#ff4285f4</color>
- <color name="teal_500">#ff00bcd4</color>
- <color name="green_500">#ff0f9d58</color>
- <color name="light_green_500">#ff8bc34a</color>
- <color name="orange_500">#ffff9800</color>
- <color name="deep_orange_500">#ffff5722</color>
- <!-- Avatar color used for guest -->
- <color name="grey_500">#ff9e9e9e</color>
-
<color name="wifi_divider">#ffe0e0e0</color>
</resources>
diff --git a/src/com/android/settings/CryptKeeper.java b/src/com/android/settings/CryptKeeper.java
index 7e92cc6..90f9f54 100644
--- a/src/com/android/settings/CryptKeeper.java
+++ b/src/com/android/settings/CryptKeeper.java
@@ -38,7 +38,7 @@
import android.os.storage.IMountService;
import android.os.storage.StorageManager;
import android.provider.Settings;
-import android.telecomm.TelecommManager;
+import android.telecom.TelecomManager;
import android.telephony.TelephonyManager;
import android.text.Editable;
import android.text.TextUtils;
@@ -892,7 +892,7 @@
}
int textId;
- if (getTelecommManager().isInCall()) {
+ if (getTelecomManager().isInCall()) {
// Show "return to call"
textId = R.string.cryptkeeper_return_to_call;
} else {
@@ -906,9 +906,9 @@
}
private void takeEmergencyCallAction() {
- TelecommManager telecommManager = getTelecommManager();
- if (telecommManager.isInCall()) {
- telecommManager.showInCallScreen(false /* showDialpad */);
+ TelecomManager telecomManager = getTelecomManager();
+ if (telecomManager.isInCall()) {
+ telecomManager.showInCallScreen(false /* showDialpad */);
} else {
launchEmergencyDialer();
}
@@ -927,8 +927,8 @@
return (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
}
- private TelecommManager getTelecommManager() {
- return (TelecommManager) getSystemService(Context.TELECOMM_SERVICE);
+ private TelecomManager getTelecomManager() {
+ return (TelecomManager) getSystemService(Context.TELECOM_SERVICE);
}
/**
diff --git a/src/com/android/settings/UserSpinnerAdapter.java b/src/com/android/settings/UserSpinnerAdapter.java
index 32ef3be..b44caac 100644
--- a/src/com/android/settings/UserSpinnerAdapter.java
+++ b/src/com/android/settings/UserSpinnerAdapter.java
@@ -31,6 +31,7 @@
import android.widget.SpinnerAdapter;
import android.widget.TextView;
+import com.android.internal.util.UserIcons;
import com.android.settings.drawable.CircleFramedDrawable;
import com.android.settings.R;
@@ -57,7 +58,11 @@
} else {
name = userInfo.name;
Bitmap bitmap = um.getUserIcon(userHandle.getIdentifier());
- icon = (bitmap == null) ? null : CircleFramedDrawable.getInstance(context, bitmap);
+ if (bitmap != null) {
+ icon = CircleFramedDrawable.getInstance(context, bitmap);
+ } else {
+ icon = UserIcons.getDefaultUserIcon(userInfo.id, /* light= */ false);
+ }
}
}
}
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 466944d..60bf226 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -70,6 +70,8 @@
import android.widget.ListView;
import android.widget.TabWidget;
+import com.android.internal.util.ImageUtils;
+import com.android.internal.util.UserIcons;
import com.android.settings.UserSpinnerAdapter.UserDetails;
import com.android.settings.dashboard.DashboardCategory;
import com.android.settings.dashboard.DashboardTile;
@@ -847,10 +849,13 @@
* Returns a circular icon for a user.
*/
public static Drawable getUserIcon(Context context, UserManager um, UserInfo user) {
- if (user.iconPath == null) return null;
- Bitmap icon = um.getUserIcon(user.id);
- if (icon == null) return null;
- return CircleFramedDrawable.getInstance(context, icon);
+ if (user.iconPath != null) {
+ Bitmap icon = um.getUserIcon(user.id);
+ if (icon != null) {
+ return CircleFramedDrawable.getInstance(context, icon);
+ }
+ }
+ return UserIcons.getDefaultUserIcon(user.id, /* light= */ false);
}
/**
diff --git a/src/com/android/settings/accounts/AccountSettings.java b/src/com/android/settings/accounts/AccountSettings.java
index f057cbf..3c0d9e9 100644
--- a/src/com/android/settings/accounts/AccountSettings.java
+++ b/src/com/android/settings/accounts/AccountSettings.java
@@ -117,6 +117,7 @@
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mUm = (UserManager) getSystemService(Context.USER_SERVICE);
+ mProfileNotAvailablePreference = new Preference(getActivity());
mAuthorities = getActivity().getIntent().getStringArrayExtra(EXTRA_AUTHORITIES);
if (mAuthorities != null) {
mAuthoritiesCount = mAuthorities.length;
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index 1282409..826a451 100755
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -392,7 +392,7 @@
final CachedBluetoothDevice device = (CachedBluetoothDevice) v.getTag();
final Activity activity = getActivity();
- DeviceProfilesSettings profileFrag = (DeviceProfilesSettings)activity.
+ DeviceProfilesSettings profileFragment = (DeviceProfilesSettings)activity.
getFragmentManager().findFragmentById(R.id.bluetooth_fragment_settings);
if (mSettingsDialogView != null){
@@ -402,23 +402,26 @@
}
}
- if (profileFrag == null) {
+ if (profileFragment == null) {
LayoutInflater inflater = getActivity().getLayoutInflater();
mSettingsDialogView = inflater.inflate(R.layout.bluetooth_device_settings, null);
- profileFrag = (DeviceProfilesSettings)activity.getFragmentManager()
+ profileFragment = (DeviceProfilesSettings)activity.getFragmentManager()
.findFragmentById(R.id.bluetooth_fragment_settings);
// To enable scrolling we store the name field in a seperate header and add to
- // the ListView of the profileFrag.
+ // the ListView of the profileFragment.
View header = inflater.inflate(R.layout.bluetooth_device_settings_header, null);
- profileFrag.getListView().addHeaderView(header);
+ profileFragment.getListView().addHeaderView(header);
}
final View dialogLayout = mSettingsDialogView;
AlertDialog.Builder settingsDialog = new AlertDialog.Builder(activity);
- profileFrag.setDevice(device);
+ profileFragment.setDevice(device);
final EditText deviceName = (EditText)dialogLayout.findViewById(R.id.name);
deviceName.setText(device.getName(), TextView.BufferType.EDITABLE);
+
+ final DeviceProfilesSettings dpsFragment = profileFragment;
+ final Context context = v.getContext();
settingsDialog.setView(dialogLayout);
settingsDialog.setTitle(R.string.bluetooth_preference_paired_devices);
settingsDialog.setPositiveButton(R.string.okay,
@@ -429,7 +432,7 @@
device.setName(deviceName.getText().toString());
}
});
- final Context context = v.getContext();
+
settingsDialog.setNegativeButton(R.string.forget,
new DialogInterface.OnClickListener() {
@Override
@@ -442,6 +445,16 @@
}
});
+ // We must ensure that the fragment gets destroyed to avoid duplicate fragments.
+ settingsDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
+ public void onDismiss(final DialogInterface dialog) {
+ if (!activity.isDestroyed()) {
+ activity.getFragmentManager().beginTransaction().remove(dpsFragment)
+ .commitAllowingStateLoss();
+ }
+ }
+ });
+
AlertDialog dialog = settingsDialog.create();
dialog.create();
dialog.show();
diff --git a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
index ee25300..5c2beba 100755
--- a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
+++ b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
@@ -232,7 +232,7 @@
status == BluetoothProfile.STATE_CONNECTED;
if (isConnected) {
- askDisconnect(getActivity(), profile);
+ askDisconnect(mManager.getForegroundActivity(), profile);
} else {
if (profile.isPreferred(device)) {
// profile is preferred but not connected: disable auto-connect
diff --git a/src/com/android/settings/drawable/CircleFramedDrawable.java b/src/com/android/settings/drawable/CircleFramedDrawable.java
index f68dace..97c96a0 100644
--- a/src/com/android/settings/drawable/CircleFramedDrawable.java
+++ b/src/com/android/settings/drawable/CircleFramedDrawable.java
@@ -107,7 +107,7 @@
canvas.drawPath(fillPath, mPaint);
// mask in the icon where the bitmap is opaque
- mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));
+ mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(icon, cropRect, circleRect, mPaint);
// prepare paint for frame drawing
diff --git a/src/com/android/settings/fuelgauge/BatterySaverSettings.java b/src/com/android/settings/fuelgauge/BatterySaverSettings.java
index e303dc8..bd989d0 100644
--- a/src/com/android/settings/fuelgauge/BatterySaverSettings.java
+++ b/src/com/android/settings/fuelgauge/BatterySaverSettings.java
@@ -16,14 +16,20 @@
package com.android.settings.fuelgauge;
+import static android.os.PowerManager.ACTION_POWER_SAVE_MODE_CHANGING;
+
+import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
import android.content.res.Resources;
import android.database.ContentObserver;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
+import android.os.PowerManager;
import android.provider.Settings.Global;
import android.util.Log;
import android.widget.Switch;
@@ -43,6 +49,7 @@
private final Handler mHandler = new Handler();
private final SettingsObserver mSettingsObserver = new SettingsObserver(mHandler);
+ private final Receiver mReceiver = new Receiver();
private Context mContext;
private boolean mCreated;
@@ -50,6 +57,7 @@
private SwitchBar mSwitchBar;
private Switch mSwitch;
private boolean mValidListener;
+ private PowerManager mPowerManager;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
@@ -76,6 +84,8 @@
}
};
mTriggerPref.init(this);
+
+ mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
}
@Override
@@ -88,6 +98,7 @@
public void onResume() {
super.onResume();
mSettingsObserver.setListening(true);
+ mReceiver.setListening(true);
if (!mValidListener) {
mSwitchBar.addOnSwitchChangeListener(this);
mValidListener = true;
@@ -99,6 +110,7 @@
public void onPause() {
super.onPause();
mSettingsObserver.setListening(false);
+ mReceiver.setListening(false);
if (mValidListener) {
mSwitchBar.removeOnSwitchChangeListener(this);
mValidListener = false;
@@ -107,43 +119,78 @@
@Override
public void onSwitchChanged(Switch switchView, boolean isChecked) {
+ mHandler.removeCallbacks(mStartMode);
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);
+ if (DEBUG) Log.d(TAG, "Stopping low power mode from settings");
+ trySetPowerSaveMode(false);
+ }
+ }
+
+ private void trySetPowerSaveMode(boolean mode) {
+ if (!mPowerManager.setPowerSaveMode(mode)) {
+ if (DEBUG) Log.d(TAG, "Setting mode failed, fallback to current value");
+ mHandler.post(mUpdateSwitch);
}
}
private void updateSwitch() {
- final boolean checked = Global.getInt(getContentResolver(), Global.LOW_POWER_MODE, 0) != 0;
- if (checked == mSwitch.isChecked()) return;
+ final boolean mode = mPowerManager.isPowerSaveMode();
+ if (DEBUG) Log.d(TAG, "updateSwitch: isChecked=" + mSwitch.isChecked() + " mode=" + mode);
+ if (mode == mSwitch.isChecked()) return;
// set listener to null so that that code below doesn't trigger onCheckedChanged()
if (mValidListener) {
mSwitchBar.removeOnSwitchChangeListener(this);
}
- mSwitch.setChecked(checked);
+ mSwitch.setChecked(mode);
if (mValidListener) {
mSwitchBar.addOnSwitchChangeListener(this);
}
}
+ private final Runnable mUpdateSwitch = new Runnable() {
+ @Override
+ public void run() {
+ updateSwitch();
+ }
+ };
+
private final Runnable mStartMode = new Runnable() {
@Override
public void run() {
AsyncTask.execute(new Runnable() {
@Override
public void run() {
- if (DEBUG) Log.d(TAG, "Starting LOW_POWER_MODE from settings");
- Global.putInt(getContentResolver(), Global.LOW_POWER_MODE, 1);
+ if (DEBUG) Log.d(TAG, "Starting low power mode from settings");
+ trySetPowerSaveMode(true);
}
});
}
};
+ private final class Receiver extends BroadcastReceiver {
+ private boolean mRegistered;
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (DEBUG) Log.d(TAG, "Received " + intent.getAction());
+ mHandler.post(mUpdateSwitch);
+ }
+
+ public void setListening(boolean listening) {
+ if (listening && !mRegistered) {
+ mContext.registerReceiver(this, new IntentFilter(ACTION_POWER_SAVE_MODE_CHANGING));
+ mRegistered = true;
+ } else if (!listening && mRegistered) {
+ mContext.unregisterReceiver(this);
+ mRegistered = false;
+ }
+ }
+ }
+
private final class SettingsObserver extends ContentObserver {
- private final Uri LOW_POWER_MODE_URI = Global.getUriFor(Global.LOW_POWER_MODE);
private final Uri LOW_POWER_MODE_TRIGGER_LEVEL_URI
= Global.getUriFor(Global.LOW_POWER_MODE_TRIGGER_LEVEL);
@@ -153,9 +200,6 @@
@Override
public void onChange(boolean selfChange, Uri uri) {
- if (LOW_POWER_MODE_URI.equals(uri)) {
- updateSwitch();
- }
if (LOW_POWER_MODE_TRIGGER_LEVEL_URI.equals(uri)) {
mTriggerPref.update(mContext);
}
@@ -164,7 +208,6 @@
public void setListening(boolean listening) {
final ContentResolver cr = getContentResolver();
if (listening) {
- cr.registerContentObserver(LOW_POWER_MODE_URI, false, this);
cr.registerContentObserver(LOW_POWER_MODE_TRIGGER_LEVEL_URI, false, this);
} else {
cr.unregisterContentObserver(this);
diff --git a/src/com/android/settings/sim/SimSettings.java b/src/com/android/settings/sim/SimSettings.java
index 259ebf1..836ea24 100644
--- a/src/com/android/settings/sim/SimSettings.java
+++ b/src/com/android/settings/sim/SimSettings.java
@@ -38,7 +38,7 @@
import android.telephony.SubInfoRecord;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
-import android.telecomm.PhoneAccount;
+import android.telecom.PhoneAccount;
import android.telephony.CellInfo;
import android.text.TextUtils;
import android.util.Log;
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index f5ea6aa..0d7b279 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -16,10 +16,6 @@
package com.android.settings.users;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.Activity;
@@ -37,7 +33,6 @@
import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.graphics.Bitmap;
-import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Bundle;
@@ -60,6 +55,7 @@
import android.view.View.OnClickListener;
import android.widget.SimpleAdapter;
+import com.android.internal.util.UserIcons;
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.ChooseLockGeneric;
import com.android.settings.OwnerInfoSettings;
@@ -70,6 +66,10 @@
import com.android.settings.Utils;
import com.android.settings.drawable.CircleFramedDrawable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
/**
* Screen that manages the list of users on the device.
* Guest user is an always visible entry, even if the guest is not currently
@@ -119,19 +119,6 @@
private static final String KEY_ADD_USER_LONG_MESSAGE_DISPLAYED =
"key_add_user_long_message_displayed";
- static final int[] USER_DRAWABLES = {
- R.drawable.ic_avatar_default_1,
- R.drawable.ic_avatar_default_2,
- R.drawable.ic_avatar_default_3,
- R.drawable.ic_avatar_default_4,
- R.drawable.ic_avatar_default_5,
- R.drawable.ic_avatar_default_6,
- R.drawable.ic_avatar_default_7,
- R.drawable.ic_avatar_default_8
- };
-
- private static final int GUEST_DRAWABLE_ID = R.drawable.ic_avatar_guest;
-
private static final String KEY_TITLE = "title";
private static final String KEY_SUMMARY = "summary";
@@ -154,10 +141,8 @@
private EditUserInfoController mEditUserInfoController =
new EditUserInfoController();
- // A place to cache the generated guest avatar
- private Drawable mGuestDrawable;
// A place to cache the generated default avatar
- private Drawable mDefaultAvatarDrawable;
+ private Drawable mDefaultIconDrawable;
private Handler mHandler = new Handler() {
@Override
@@ -325,7 +310,7 @@
private void loadProfile() {
if (mIsGuest) {
// No need to load profile information
- mMePreference.setIcon(getEncircledGuestDrawable());
+ mMePreference.setIcon(getEncircledDefaultIcon());
mMePreference.setTitle(R.string.user_exit_guest_title);
return;
}
@@ -423,9 +408,7 @@
Secure.putIntForUser(getContentResolver(),
Secure.LOCATION_MODE, Secure.LOCATION_MODE_OFF, userId);
mUserManager.setUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, true, user);
- Bitmap bitmap = createBitmapFromDrawable(
- USER_DRAWABLES[userId % UserSettings.USER_DRAWABLES.length]);
- mUserManager.setUserIcon(userId, bitmap);
+ assignDefaultPhoto(newUserInfo);
// Add shared accounts
AccountManager am = AccountManager.get(getActivity());
Account [] accounts = am.getAccounts();
@@ -437,15 +420,6 @@
return newUserInfo;
}
- private Bitmap createBitmapFromDrawable(int resId) {
- Drawable icon = getResources().getDrawable(resId);
- icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight());
- Bitmap bitmap = Bitmap.createBitmap(icon.getIntrinsicWidth(), icon.getIntrinsicHeight(),
- Bitmap.Config.ARGB_8888);
- icon.draw(new Canvas(bitmap));
- return bitmap;
- }
-
private UserInfo createTrustedUser() {
UserInfo newUserInfo = mUserManager.createUser(
getResources().getString(R.string.user_new_user_name), 0);
@@ -787,13 +761,15 @@
}
if (user.iconPath != null) {
if (mUserIcons.get(user.id) == null) {
+ // Icon not loaded yet, print a placeholder
missingIcons.add(user.id);
- pref.setIcon(getEncircledDefaultAvatar());
+ pref.setIcon(getEncircledDefaultIcon());
} else {
setPhotoId(pref, user);
}
} else {
- pref.setIcon(getEncircledDefaultAvatar());
+ // Icon not available yet, print a placeholder
+ pref.setIcon(getEncircledDefaultIcon());
}
}
@@ -803,7 +779,7 @@
null, null);
pref.setEnabled(false);
pref.setTitle(R.string.user_new_user_name);
- pref.setIcon(getEncircledDefaultAvatar());
+ pref.setIcon(getEncircledDefaultIcon());
mUserListCategory.addPreference(pref);
}
@@ -826,7 +802,7 @@
mIsOwner && voiceCapable? this : null /* settings icon handler */,
null /* delete icon handler */);
pref.setTitle(R.string.user_guest);
- pref.setIcon(getEncircledGuestDrawable());
+ pref.setIcon(getEncircledDefaultIcon());
pref.setOnPreferenceClickListener(this);
mUserListCategory.addPreference(pref);
}
@@ -854,7 +830,8 @@
for (int userId : values[0]) {
Bitmap bitmap = mUserManager.getUserIcon(userId);
if (bitmap == null) {
- bitmap = createBitmapFromDrawable(R.drawable.ic_avatar_default_1);
+ bitmap = UserIcons.convertToBitmap(UserIcons.getDefaultUserIcon(userId,
+ /* light= */ false));
}
mUserIcons.append(userId, bitmap);
}
@@ -870,24 +847,17 @@
}
private void assignDefaultPhoto(UserInfo user) {
- Bitmap bitmap = createBitmapFromDrawable(
- USER_DRAWABLES[user.id % UserSettings.USER_DRAWABLES.length]);
+ Bitmap bitmap = UserIcons.convertToBitmap(UserIcons.getDefaultUserIcon(user.id,
+ /* light= */ false));
mUserManager.setUserIcon(user.id, bitmap);
}
- private Drawable getEncircledGuestDrawable() {
- if (mGuestDrawable == null) {
- mGuestDrawable = encircle(createBitmapFromDrawable(GUEST_DRAWABLE_ID));
+ private Drawable getEncircledDefaultIcon() {
+ if (mDefaultIconDrawable == null) {
+ mDefaultIconDrawable = encircle(UserIcons.convertToBitmap(
+ UserIcons.getDefaultUserIcon(UserHandle.USER_NULL, /* light= */ false)));
}
- return mGuestDrawable;
- }
-
- private Drawable getEncircledDefaultAvatar() {
- if (mDefaultAvatarDrawable == null) {
- mDefaultAvatarDrawable =
- encircle(createBitmapFromDrawable(R.drawable.ic_avatar_default_1));
- }
- return mDefaultAvatarDrawable;
+ return mDefaultIconDrawable;
}
private void setPhotoId(Preference pref, UserInfo user) {
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index 04814a5..e6dd9c7 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -18,6 +18,7 @@
import static android.net.wifi.WifiConfiguration.INVALID_NETWORK_ID;
+import android.app.ActivityManager;
import android.content.Context;
import android.content.res.Resources;
import android.net.IpConfiguration;
@@ -38,6 +39,7 @@
import android.net.wifi.WifiEnterpriseConfig.Phase2;
import android.net.wifi.WifiInfo;
import android.os.Handler;
+import android.os.UserHandle;
import android.security.Credentials;
import android.security.KeyStore;
import android.text.Editable;
@@ -298,7 +300,8 @@
addRow(group, R.string.wifi_security, mAccessPoint.getSecurityString(false));
mView.findViewById(R.id.ip_fields).setVisibility(View.GONE);
}
- if (mAccessPoint.networkId != INVALID_NETWORK_ID) {
+ if (mAccessPoint.networkId != INVALID_NETWORK_ID
+ && ActivityManager.getCurrentUser() == UserHandle.USER_OWNER) {
mConfigUi.setForgetButton(res.getString(R.string.wifi_forget));
}
}
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 50789b8..6d4237c 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -20,6 +20,7 @@
import static android.os.UserManager.DISALLOW_CONFIG_WIFI;
import android.app.Activity;
+import android.app.ActivityManager;
import android.app.Dialog;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -45,6 +46,7 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
+import android.os.UserHandle;
import android.preference.Preference;
import android.preference.PreferenceScreen;
import android.util.Log;
@@ -512,7 +514,9 @@
menu.add(Menu.NONE, MENU_ID_CONNECT, 0, R.string.wifi_menu_connect);
}
if (mSelectedAccessPoint.networkId != INVALID_NETWORK_ID) {
- menu.add(Menu.NONE, MENU_ID_FORGET, 0, R.string.wifi_menu_forget);
+ if (ActivityManager.getCurrentUser() == UserHandle.USER_OWNER) {
+ menu.add(Menu.NONE, MENU_ID_FORGET, 0, R.string.wifi_menu_forget);
+ }
menu.add(Menu.NONE, MENU_ID_MODIFY, 0, R.string.wifi_menu_modify);
if (mSelectedAccessPoint.security != AccessPoint.SECURITY_NONE) {