Skip to content

Commit

Permalink
Settings: Notification light(LED) settings
Browse files Browse the repository at this point in the history
This commit adds the ability to configure the Notification light
color and pulse rate both for the default and a custom applications
list.

This work was done in collaboration with Marko Mihovilić (m1h4) who
wrote the initial implementation as a stand-alone application and
helped with the fixes below.

NOTE: Google Talk notifications originate from the "Google Services
Framework" so in order to override their settings you need to add
this package instead of the Google Talk package.

Patch set 2  - fixes the color returned from picker (remove alpha)
Patch set 3  - whitespace, formatting and minor code cleanup
Patch set 4  - fix derp in Notification light checkbox default
Patch set 5  - part 1 of the changes based on Danny's feedback
Patch set 6  - part 2 of the changes based on Danny's feedback
Patch set 7  - final tweaks to the layout, smaller icons etc.
Patch set 8  - adds the ability to test LED (thanks Marko)
             - Use long click to get the test option
             - most of Danny's suggested fixes
Patch set 9  - moves the test button to colorpicker
             - fixes the app picker dialog to load smoothly
             - minor string fixes to match google writing guidelines
Patch set 11 - switched to using a hashmap for string manipulation
             - minor string and whitespace cleanup
Patch set 12 - Use textUtil.join (thanks Danesh)
             - remove some orphaned code
             - don't refresh whole list on preference change
Patch set 13 - Fix preference not updating when testing before saving
             - Automatically dismiss test dialog after test
             - remove some dead code
             - some cleanup
             - remove ^M from files
Patch set 14 - Fix preference update after test, take daproy#2
Patch set 15 - Fix NPE on empty settings
             - Sort application list by name
Patch set 16 - German translation
Patch set 17 - German translation update

Change-Id: I6837210367123bc02ea27a9b7b6b3cf80c738bf1
  • Loading branch information
DvTonder authored and Patrick Schaaf committed Apr 15, 2012
1 parent 7237f6c commit ee032ae
Show file tree
Hide file tree
Showing 18 changed files with 2,763 additions and 49 deletions.
2 changes: 2 additions & 0 deletions AndroidManifest.xml
Expand Up @@ -1388,6 +1388,8 @@

<activity android:name=".ApnEditor" />

<activity android:name=".notificationlight.NotificationLightSettings" />

<activity android:name="Settings$AnonymousStatsActivity"
android:label="@string/anonymous_statistics_title"
android:configChanges="orientation|keyboardHidden|screenSize"
Expand Down
109 changes: 109 additions & 0 deletions res/layout/dialog_light_settings.xml
@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2010 Daniel Nilsson
Copyright (C) 2012 THe CyanogenMod 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. -->

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<com.android.settings.notificationlight.ColorPickerView
android:id="@+id/color_picker_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" />

<LinearLayout
android:id="@+id/color_panel_view"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_alignLeft="@id/color_picker_view"
android:layout_alignRight="@id/color_picker_view"
android:layout_below="@id/color_picker_view"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp"
android:orientation="horizontal" >

<com.android.settings.notificationlight.ColorPanelView
android:id="@+id/old_color_panel"
android:layout_width="0px"
android:layout_height="fill_parent"
android:layout_weight="0.5" />

<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="center"
android:text="@string/picker_arrow"
android:textColor="#ffffff"
android:textSize="20sp" />

<com.android.settings.notificationlight.ColorPanelView
android:id="@+id/new_color_panel"
android:layout_width="0px"
android:layout_height="fill_parent"
android:layout_weight="0.5" />
</LinearLayout>

<LinearLayout
android:id="@+id/speed_title_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/color_panel_view"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="4dp"
android:orientation="vertical" >

<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@android:drawable/divider_horizontal_dark" />

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="@string/pulse_speed_title"
android:textAppearance="?android:attr/textAppearanceSmall" />

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="4dip" >

<Spinner
android:id="@+id/on_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />

<View
android:layout_width="8dip"
android:layout_height="fill_parent" />

<Spinner
android:id="@+id/off_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>

</RelativeLayout>
71 changes: 71 additions & 0 deletions res/layout/preference_application_light.xml
@@ -0,0 +1,71 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/app_light_pref"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical"
android:background="?android:attr/selectableItemBackground" >

<ImageView
android:id="@+android:id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="4dip"
android:maxWidth="36dip"
android:maxHeight="36dip"
android:adjustViewBounds="true"
android:layout_gravity="center" />

<RelativeLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_margin="4dip"
android:layout_weight="1">

<TextView android:id="@+android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:ellipsize="marquee"
android:fadingEdge="horizontal" />

<TextView android:id="@+android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@android:id/title"
android:layout_alignLeft="@android:id/title"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"
android:maxLines="1" />
</RelativeLayout>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >

<TextView
android:id="@+id/textViewTimeOnValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textAppearance="?android:attr/textAppearanceSmall" />

<TextView
android:id="@+id/textViewTimeOffValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>

<ImageView
android:id="@+id/light_color"
android:layout_width="32dip"
android:layout_height="wrap_content"
android:layout_gravity="center" />

</LinearLayout>
2 changes: 1 addition & 1 deletion res/layout/preference_icon.xml
Expand Up @@ -59,4 +59,4 @@

</RelativeLayout>

</LinearLayout>
</LinearLayout>
11 changes: 11 additions & 0 deletions res/layout/pulse_time_item.xml
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textViewName"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:textAppearance="?android:attr/textAppearanceMedium" >

</TextView>
35 changes: 34 additions & 1 deletion res/values-de/strings.xml
Expand Up @@ -597,7 +597,6 @@
<string name="vibrate_in_silent_title" msgid="3897968069156767036">"Im Lautlos-Modus vibrieren"</string>
<string name="vibrate_on_ring_title" msgid="40343855247989536">"Vibrieren und klingeln"</string>
<string name="notification_sound_title" msgid="312032901303146002">"Standardbenachrichtigung"</string>
<string name="notification_pulse_title" msgid="1247988024534030629">"Benachrichtigungslicht"</string>
<string name="incoming_call_volume_title" msgid="8073714801365904099">"Klingelton"</string>
<string name="notification_volume_title" msgid="2012640760341080408">"Benachrichtigung"</string>
<string name="checkbox_notification_same_as_incoming_call" msgid="1073644356290338921">"Lautstärke für eingehende Anrufe für Benachrichtigungen verwenden"</string>
Expand Down Expand Up @@ -2021,4 +2020,38 @@
<string name="storage_switch_summary_off">Benutze SD-Karte für Apps und Medien</string>
<string name="storage_switch_unavailable">Dieses Gerät hat keinen erweiterten internen Speicher</string>

<!-- Display settings screen, notification light settings -->
<string name="notification_pulse_title">Benachrichtigungslicht</string>
<string name="notification_light_general_title">Allgemein</string>
<string name="notification_light_applist_title">Apps</string>
<string name="notification_light_default_value">Standard</string>
<string name="notification_light_use_custom">App-Anpassung</string>
<string name="notification_light_enabled">Farben anpassen</string>
<string name="notification_light_disabled">Farben nicht anpassen</string>

<!-- Notification light dialogs -->
<string name="edit_light_settings">Farbeinstellungen ändern</string>
<string name="pulse_speed_title">Pulsdauer und Geschwindigkeit</string>
<string name="picker_arrow">→</string>
<string name="default_time">Normal</string>
<string name="custom_time">Angepasst</string>
<string name="dialog_test">Test</string>
<string name="dialog_delete_title">Löschen</string>
<string name="dialog_delete_message">Anpassung für diese App entfernen?</string>
<string name="dialog_test_message">Display abschalten, um diese Einstellung zu testen.</string>
<string name="dialog_test_button">Abbrechen</string>

<!-- Values for the notification light pulse spinners -->
<string name="pulse_length_always_on">Immer an</string>
<string name="pulse_length_very_short">Sehr kurz</string>
<string name="pulse_length_short">Kurz</string>
<string name="pulse_length_normal">Normal</string>
<string name="pulse_length_long">Lang</string>
<string name="pulse_length_very_long">Sehr lang</string>
<string name="pulse_speed_very_fast">Sehr schnell</string>
<string name="pulse_speed_fast">Schnell</string>
<string name="pulse_speed_normal">Normal</string>
<string name="pulse_speed_slow">Langsam</string>
<string name="pulse_speed_very_slow">Sehr langsam</string>

</resources>
37 changes: 36 additions & 1 deletion res/values/arrays.xml
Expand Up @@ -1078,12 +1078,47 @@
<item>@string/root_access_all</item>
</string-array>

<string-array name="root_access_values">
<string-array name="root_access_values" translatable="false">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
</string-array>

<!-- Values for the notification light pulse spinners -->
<string-array name="notification_pulse_length_entries">
<item>@string/pulse_length_always_on</item>
<item>@string/pulse_length_very_short</item>
<item>@string/pulse_length_short</item>
<item>@string/pulse_length_normal</item>
<item>@string/pulse_length_long</item>
<item>@string/pulse_length_very_long</item>
</string-array>

<string-array name="notification_pulse_length_values" translatable="false">
<item>0</item>
<item>250</item>
<item>500</item>
<item>1000</item>
<item>2500</item>
<item>5000</item>
</string-array>

<string-array name="notification_pulse_speed_entries">
<item>@string/pulse_speed_very_fast</item>
<item>@string/pulse_speed_fast</item>
<item>@string/pulse_speed_normal</item>
<item>@string/pulse_speed_slow</item>
<item>@string/pulse_speed_very_slow</item>
</string-array>

<string-array name="notification_pulse_speed_values" translatable="false">
<item>250</item>
<item>500</item>
<item>1000</item>
<item>2500</item>
<item>5000</item>
</string-array>

<!-- **** CYANOGENMOD EDITS END **** -->
</resources>
1 change: 1 addition & 0 deletions res/values/dimens.xml
Expand Up @@ -39,4 +39,5 @@
<dimen name="normal_height">64dip</dimen>
<!-- height of an expanded list item in edit playlist mode -->
<dimen name="expanded_height">128dip</dimen>
<dimen name="dialog_light_settings_width">400dip</dimen>
</resources>
50 changes: 41 additions & 9 deletions res/values/strings.xml
Expand Up @@ -592,8 +592,6 @@
<string name="vibrate_on_ring_title">Vibrate and ring</string>
<!-- Sound settings screen, setting option name -->
<string name="notification_sound_title">Default notification</string>
<!-- Sound settings screen, notification light repeat pulsing title -->
<string name="notification_pulse_title">Pulse notification light</string>
<!-- Sound settings screen, the title of the volume bar to adjust the incoming call volume -->
<string name="incoming_call_volume_title">Ringtone</string>
<!-- Sound settings screen, the title of the volume bar to adjust the notification volume -->
Expand Down Expand Up @@ -758,13 +756,47 @@
<string name="ll_bad_levels">Levels must be increasing</string>
<string name="ll_num_levels">Set number of levels</string>

<!-- Display settings screen, notification light settings -->
<string name="notification_pulse_title">Notification light</string>
<string name="notification_light_general_title">General</string>
<string name="notification_light_applist_title">Applications</string>
<string name="notification_light_default_value">Default</string>
<string name="notification_light_use_custom">Use custom values</string>
<string name="notification_light_enabled">Enabled</string>
<string name="notification_light_disabled">Disabled</string>

<!-- Notification light dialogs -->
<string name="edit_light_settings">Edit light settings</string>
<string name="pulse_speed_title">Pulse length and speed</string>
<string name="picker_arrow">→</string>
<string name="default_time">Normal</string>
<string name="custom_time">Custom</string>
<string name="dialog_test">Test</string>
<string name="dialog_delete_title">Delete</string>
<string name="dialog_delete_message">Remove selected item?</string>
<string name="dialog_test_message">Turn the screen off to see the selected notification in action or dismiss this dialog to stop the test</string>
<string name="dialog_test_button">Dismiss</string>

<!-- Values for the notification light pulse spinners -->
<string name="pulse_length_always_on">Always on</string>
<string name="pulse_length_very_short">Very short</string>
<string name="pulse_length_short">Short</string>
<string name="pulse_length_normal">Normal</string>
<string name="pulse_length_long">Long</string>
<string name="pulse_length_very_long">Very long</string>
<string name="pulse_speed_very_fast">Very fast</string>
<string name="pulse_speed_fast">Fast</string>
<string name="pulse_speed_normal">Normal</string>
<string name="pulse_speed_slow">Slow</string>
<string name="pulse_speed_very_slow">Very slow</string>

<!-- Advanced, Device specific (DeviceParts) settings #CM -->
<string name="advanced_settings_title">Advanced</string>

<!-- INTERFACE Settings #CM -->
<!-- Settings main menu category heading. Interface (Launcher, Themes, System). [CHAR LIMIT=40] -->
<string name="header_category_interface">INTERFACE</string>

<!-- Launcher settings #CM -->
<string name="launcher_settings_title">Launcher</string>

Expand Down Expand Up @@ -896,12 +928,12 @@

<!-- Reset Profiles -->
<string name="profile_reset_title">Reset</string>
<string name="profile_reset_message">Do you want to delete all user created profiles and application groups and restore them to default?</string>
<string name="profile_reset_message">Delete all user created profiles and application groups and restore them to default?</string>

<!-- Delete confimation messages -->
<string name="profile_delete_confirm">Are you sure you want to delete this profile?</string>
<string name="profile_app_delete_confirm">Are you sure you want to remove this application?</string>
<string name="profile_cannot_delete">You cannot delete the active profile</string>
<string name="profile_delete_confirm">Delete this profile?</string>
<string name="profile_app_delete_confirm">Remove this application?</string>
<string name="profile_cannot_delete">An active profile cannot be deleted</string>

<!-- Profile Config screen PreferenceGroup titles -->
<string name="profile_connectionoverrides_title">Connection overrides</string>
Expand Down Expand Up @@ -937,7 +969,7 @@
<string name="profile_appgroups_title">Application groups</string>
<string name="profile_applist_title">Applications</string>
<string name="profile_new_appgroup">New application group</string>
<string name="profile_delete_appgroup">Delete this application group</string>
<string name="profile_delete_appgroup">Delete this application group?</string>
<string name="profile_appgroup_name_prompt">Enter a name for the new application group</string>
<string name="profile_appgroup_name_title">Name</string>
<string name="profile_add_app">Add application</string>
Expand Down

0 comments on commit ee032ae

Please sign in to comment.