diff options
author | AdrianDC <radian.dc@gmail.com> | 2015-11-11 21:06:22 +0100 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2015-11-16 11:51:27 -0800 |
commit | e7eb10420c291ee6d83dddcb632e3ce0720110c4 (patch) | |
tree | fdb8d499081344c515dd18a4309d3c63220c4050 | |
parent | 9066e31fb0b771726c83e63e2830a7ff6a5aa7bc (diff) | |
download | frameworks_base-e7eb10420c291ee6d83dddcb632e3ce0720110c4.zip frameworks_base-e7eb10420c291ee6d83dddcb632e3ce0720110c4.tar.gz frameworks_base-e7eb10420c291ee6d83dddcb632e3ce0720110c4.tar.bz2 |
LEDs Brightness: Update the slider for M
* Add notification details needed for M
* Sync with some changes made in the Display Brightness dialog
* Clean ic_settings indents with Settings ic_settings_24dp.xml
Change-Id: I8b6ac1920704f43f4776cbd3bdfb3d0ed8d223dc
Signed-off-by: AdrianDC <radian.dc@gmail.com>
5 files changed, 55 insertions, 30 deletions
diff --git a/packages/SystemUI/res/drawable/ic_settings.xml b/packages/SystemUI/res/drawable/ic_settings.xml index 9c78742..545bc2d 100644 --- a/packages/SystemUI/res/drawable/ic_settings.xml +++ b/packages/SystemUI/res/drawable/ic_settings.xml @@ -1,26 +1,25 @@ -<!-- 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"+ +<!-- + Copyright (C) 2015 The Android Open Source Project -http://www.apache.org/licenses/LICENSE-2.0 + 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. + 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. --> -<vector xmlns:android="http://schemas.android.com/apk/res/android" -android:width="24dp" -android:height="24dp" android:viewportWidth="24.0" - android:viewportHeight="24.0"> - - -<path - android:pathData="M19.4,13.0c0.0,-0.3 0.1,-0.6 0.1,-1.0s0.0,-0.7 -0.1,-1.0l2.1,-1.7c0.2,-0.2 0.2,-0.4 0.1,-0.6l-2.0,-3.5C19.5,5.1 19.3,5.0 19.0,5.1l-2.5,1.0c-0.5,-0.4 -1.1,-0.7 -1.7,-1.0l-0.4,-2.6C14.5,2.2 14.2,2.0 14.0,2.0l-4.0,0.0C9.8,2.0 9.5,2.2 9.5,2.4L9.1,5.1C8.5,5.3 8.0,5.7 7.4,6.1L5.0,5.1C4.7,5.0 4.5,5.1 4.3,5.3l-2.0,3.5C2.2,8.9 2.3,9.2 2.5,9.4L4.6,11.0c0.0,0.3 -0.1,0.6 -0.1,1.0s0.0,0.7 0.1,1.0l-2.1,1.7c-0.2,0.2 -0.2,0.4 -0.1,0.6l2.0,3.5C4.5,18.9 4.7,19.0 5.0,18.9l2.5,-1.0c0.5,0.4 1.1,0.7 1.7,1.0l0.4,2.6c0.0,0.2 0.2,0.4 0.5,0.4l4.0,0.0c0.2,0.0 0.5,-0.2 0.5,-0.4l0.4,-2.6c0.6,-0.3 1.2,-0.6 1.7,-1.0l2.5,1.0c0.2,0.1 0.5,0.0 0.6,-0.2l2.0,-3.5c0.1,-0.2 0.1,-0.5 -0.1,-0.6L19.4,13.0zM12.0,15.5c-1.9,0.0 -3.5,-1.6 -3.5,-3.5s1.6,-3.5 3.5,-3.5s3.5,1.6 3.5,3.5S13.9,15.5 12.0,15.5z" - android:fillColor="#ffffffff" - /> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0"> + <path + android:pathData="M19.4,13.0c0.0,-0.3 0.1,-0.6 0.1,-1.0s0.0,-0.7 -0.1,-1.0l2.1,-1.7c0.2,-0.2 0.2,-0.4 0.1,-0.6l-2.0,-3.5C19.5,5.1 19.3,5.0 19.0,5.1l-2.5,1.0c-0.5,-0.4 -1.1,-0.7 -1.7,-1.0l-0.4,-2.6C14.5,2.2 14.2,2.0 14.0,2.0l-4.0,0.0C9.8,2.0 9.5,2.2 9.5,2.4L9.1,5.1C8.5,5.3 8.0,5.7 7.4,6.1L5.0,5.1C4.7,5.0 4.5,5.1 4.3,5.3l-2.0,3.5C2.2,8.9 2.3,9.2 2.5,9.4L4.6,11.0c0.0,0.3 -0.1,0.6 -0.1,1.0s0.0,0.7 0.1,1.0l-2.1,1.7c-0.2,0.2 -0.2,0.4 -0.1,0.6l2.0,3.5C4.5,18.9 4.7,19.0 5.0,18.9l2.5,-1.0c0.5,0.4 1.1,0.7 1.7,1.0l0.4,2.6c0.0,0.2 0.2,0.4 0.5,0.4l4.0,0.0c0.2,0.0 0.5,-0.2 0.5,-0.4l0.4,-2.6c0.6,-0.3 1.2,-0.6 1.7,-1.0l2.5,1.0c0.2,0.1 0.5,0.0 0.6,-0.2l2.0,-3.5c0.1,-0.2 0.1,-0.5 -0.1,-0.6L19.4,13.0zM12.0,15.5c-1.9,0.0 -3.5,-1.6 -3.5,-3.5s1.6,-3.5 3.5,-3.5s3.5,1.6 3.5,3.5S13.9,15.5 12.0,15.5z" + android:fillColor="#ffffffff" /> </vector> diff --git a/packages/SystemUI/res/layout/quick_settings_notification_brightness_dialog.xml b/packages/SystemUI/res/layout/quick_settings_notification_brightness_dialog.xml index bfca7b9..1f51fe3 100644 --- a/packages/SystemUI/res/layout/quick_settings_notification_brightness_dialog.xml +++ b/packages/SystemUI/res/layout/quick_settings_notification_brightness_dialog.xml @@ -14,10 +14,9 @@ limitations under the License. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui" - android:paddingStart="16dp" - android:paddingEnd="16dp" - + xmlns:systemui="http://schemas.android.com/apk/res-auto" + android:paddingLeft="16dp" + android:paddingRight="16dp" style="@style/BrightnessDialogContainer"> <com.android.systemui.settings.ToggleSlider @@ -26,6 +25,7 @@ android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_weight="1" - /> + android:contentDescription="@string/accessibility_notification_brightness" + android:importantForAccessibility="no" /> </LinearLayout> diff --git a/packages/SystemUI/res/values/cm_strings.xml b/packages/SystemUI/res/values/cm_strings.xml index 6a70d24..b90fc0c 100644 --- a/packages/SystemUI/res/values/cm_strings.xml +++ b/packages/SystemUI/res/values/cm_strings.xml @@ -66,4 +66,11 @@ <!-- Title shown in recents popup for uninstalling the application --> <string name="advanced_dev_option_uninstall">Uninstall</string> + <!-- Content description of the light brightness slider (not shown on the screen). [CHAR LIMIT=NONE] --> + <string name="accessibility_notification_brightness">Light brightness</string> + + <!-- Lights settings, LED notification --> + <string name="led_notification_title">Light settings</string> + <string name="led_notification_text">LED light enabled by settings</string> + </resources> diff --git a/packages/SystemUI/src/com/android/systemui/settings/NotificationBrightnessController.java b/packages/SystemUI/src/com/android/systemui/settings/NotificationBrightnessController.java index 0637ff4..617ef8f 100644 --- a/packages/SystemUI/src/com/android/systemui/settings/NotificationBrightnessController.java +++ b/packages/SystemUI/src/com/android/systemui/settings/NotificationBrightnessController.java @@ -25,9 +25,12 @@ import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; +import android.os.Message; import android.os.UserHandle; import android.provider.Settings; +import com.android.systemui.R; + import java.lang.Exception; import java.util.ArrayList; @@ -39,6 +42,9 @@ public class NotificationBrightnessController implements ToggleSlider.Listener { public static final int LIGHT_BRIGHTNESS_MINIMUM = 1; public static final int LIGHT_BRIGHTNESS_MAXIMUM = 255; + // Minimum delay between LED notification updates + private final static long LED_UPDATE_DELAY_MS = 250; + private int mCurrentBrightness; private final int mMinimumBrightness; private final int mMaximumBrightness; @@ -131,9 +137,19 @@ public class NotificationBrightnessController implements ToggleSlider.Listener { mNotificationBuilder = new Notification.Builder(mContext); mNotificationBundle.putBoolean(Notification.EXTRA_FORCE_SHOW_LIGHTS, true); - mNotificationBuilder.setExtras(mNotificationBundle); + mNotificationBuilder.setExtras(mNotificationBundle) + .setContentTitle(mContext.getString(R.string.led_notification_title)) + .setContentText(mContext.getString(R.string.led_notification_text)) + .setSmallIcon(R.drawable.ic_settings) + .setOngoing(true); } + private Handler mLedHandler = new Handler() { + public void handleMessage(Message msg) { + updateNotification(); + } + }; + public void addStateChangedCallback(BrightnessStateChangeCallback cb) { mChangeCallbacks.add(cb); } @@ -212,7 +228,14 @@ public class NotificationBrightnessController implements ToggleSlider.Listener { /** Fetch the brightness from the system settings and update the slider */ private void updateNotification() { + // Dampen rate of consecutive LED changes + if (mLedHandler.hasMessages(0)) { + return; + } + if (mNotificationAllow) { + mLedHandler.sendEmptyMessageDelayed(0, LED_UPDATE_DELAY_MS); + // Instead of canceling the notification, force it to update with the color. // Use a white light for a better preview of the brightness. int notificationColor = 0xFFFFFF | (mCurrentBrightness << 24); diff --git a/packages/SystemUI/src/com/android/systemui/settings/NotificationBrightnessDialog.java b/packages/SystemUI/src/com/android/systemui/settings/NotificationBrightnessDialog.java index dae4e4e..82c1b3c 100644 --- a/packages/SystemUI/src/com/android/systemui/settings/NotificationBrightnessDialog.java +++ b/packages/SystemUI/src/com/android/systemui/settings/NotificationBrightnessDialog.java @@ -17,11 +17,7 @@ package com.android.systemui.settings; import android.app.Activity; -import android.app.Dialog; -import android.content.Context; -import android.content.res.Resources; import android.os.Bundle; -import android.os.Handler; import android.view.Gravity; import android.view.KeyEvent; import android.view.Window; |