From e7eb10420c291ee6d83dddcb632e3ce0720110c4 Mon Sep 17 00:00:00 2001 From: AdrianDC Date: Wed, 11 Nov 2015 21:06:22 +0100 Subject: 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 --- packages/SystemUI/res/drawable/ic_settings.xml | 39 +++++++++++----------- ...ick_settings_notification_brightness_dialog.xml | 10 +++--- packages/SystemUI/res/values/cm_strings.xml | 7 ++++ .../settings/NotificationBrightnessController.java | 25 +++++++++++++- .../settings/NotificationBrightnessDialog.java | 4 --- 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 @@ - - - - - + + 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. --> + android:contentDescription="@string/accessibility_notification_brightness" + android:importantForAccessibility="no" /> 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 @@ Uninstall + + Light brightness + + + Light settings + LED light enabled by settings + 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; -- cgit v1.1