Skip to content

Commit

Permalink
Gear: Add pulse ambient edge lightning settings
Browse files Browse the repository at this point in the history
Strings are adapted from AICP resources_devicesettings.

Change-Id: I2c25ea044bc23e3e5fdf4e41f98243d297cc3f27
  • Loading branch information
Dhina17 authored and travarilo committed Feb 22, 2024
1 parent 90806b5 commit 3a3ca7e
Show file tree
Hide file tree
Showing 17 changed files with 668 additions and 18 deletions.
22 changes: 22 additions & 0 deletions res/drawable/ambient_edge_light_color_selector_inner_bg.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2023 The LibreMobileOS Foundation
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.
-->

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<corners android:radius="@dimen/ambient_edge_light_color_selector_inner_bg_radius" />
<solid android:color="@android:color/white" />
</shape>
22 changes: 22 additions & 0 deletions res/drawable/ambient_edge_light_color_selector_outer_bg.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2023 The LibreMobileOS Foundation
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.
-->

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="@dimen/ambient_edge_light_color_selector_outer_bg_radius" />
<solid android:color="@color/ambient_edge_light_color_selector_item_outer_bg_color" />
</shape>
27 changes: 27 additions & 0 deletions res/drawable/ic_color_selected.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2023 The LibreMobileOS Foundation
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.
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#000000"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM10,17l-5,-5 1.41,-1.41L10,14.17l7.59,-7.59L19,8l-9,9z" />
</vector>
40 changes: 40 additions & 0 deletions res/layout/ambient_edge_light_color_selector_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2023 The LibreMobileOS Foundation
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.
-->

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/color_container"
android:layout_width="@dimen/ambient_edge_light_color_selector_item_width"
android:layout_height="@dimen/ambient_edge_light_color_selector_item_height"
android:layout_margin="@dimen/ambient_edge_light_color_selector_item_margin"
android:background="@drawable/ambient_edge_light_color_selector_outer_bg"
android:padding="@dimen/ambient_edge_light_color_selector_item_padding">

<View
android:id="@+id/color_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/ambient_edge_light_color_selector_inner_bg" />

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/select_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_color_selected"
android:tint="@color/ambient_edge_light_color_selector_selected_icon_tint_color" />
</FrameLayout>
26 changes: 26 additions & 0 deletions res/layout/ambient_edge_light_color_selector_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2023 The LibreMobileOS Foundation
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.
-->

<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/color_selector_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingHorizontal="@dimen/ambient_edge_light_color_selector_view_padding_horizontal"
android:scrollbars="none"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
app:spanCount="@integer/ambient_edge_light_color_selector_view_span_count" />
2 changes: 2 additions & 0 deletions res/values-night/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
<resources>

<color name="about_logo">@*android:color/system_neutral1_800</color>

<color name="ambient_edge_light_color_selector_item_outer_bg_color">#FF2B2930</color>
</resources>
15 changes: 15 additions & 0 deletions res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -762,4 +762,19 @@
<item>4</item>
<item>5</item>
</string-array>

<!-- NOTE: Make sure you are adding colors hex in #AARRGGBB (8 chars) and capital letters. -->
<!-- Since it's expect this format to check in the AmbientEdgeLightSettings. -->
<string-array name="ambient_edge_light_manual_colors">
<item>#FF6ACEFF</item>
<item>#FF7BFFDF</item>
<item>#FFB18CFF</item>
<item>#FFB3FF84</item>
<item>#FF26BEFF</item>
<item>#FFCDCDCD</item>
<item>#FFFFDC62</item>
<item>#FFFEDADA</item>
<item>#FFFF7676</item>
<item>#FF615EFF</item>
</string-array>
</resources>
40 changes: 22 additions & 18 deletions res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2021-2023 BananaDroid
SPDX-License-Identifier: Apache-2.0
-->
<resources>

<!-- Preference Category -->
<color name="preference_background_color">@*android:color/accent_device_default</color>

<color name="white">#FFF</color>

<color name="about_logo">@*android:color/system_neutral1_100</color>

<color name="option_border_default">#5f6368</color>

<color name="user_crd_bg">@*android:color/system_neutral1_0</color>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2021-2023 BananaDroid
SPDX-License-Identifier: Apache-2.0
-->
<resources>

<!-- Preference Category -->
<color name="preference_background_color">@*android:color/accent_device_default</color>

<color name="white">#FFF</color>

<color name="about_logo">@*android:color/system_neutral1_100</color>

<color name="option_border_default">#5f6368</color>

<color name="user_crd_bg">@*android:color/system_neutral1_0</color>

<!-- Ambient edge light -->
<color name="ambient_edge_light_color_selector_item_outer_bg_color">@android:color/white</color>
<color name="ambient_edge_light_color_selector_selected_icon_tint_color">#AA000000</color>
</resources>
3 changes: 3 additions & 0 deletions res/values/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,7 @@
relative to the natural orientation of the display
(true for some tablets) -->
<integer name="config_volumeRockerVsDisplayOrientation">1</integer>

<!-- Whether to show Ambient Edge Light feature in Settings Options -->
<bool name="config_show_ambient_edge_light">true</bool>
</resources>
15 changes: 15 additions & 0 deletions res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2024 BananaDroid
SPDX-License-Identifier: Apache-2.0
-->
<resources>
<!-- Ambient edge light -->
<dimen name="ambient_edge_light_color_selector_inner_bg_radius">40dp</dimen>
<dimen name="ambient_edge_light_color_selector_outer_bg_radius">12.5dp</dimen>
<dimen name="ambient_edge_light_color_selector_item_width">48dp</dimen>
<dimen name="ambient_edge_light_color_selector_item_height">48dp</dimen>
<dimen name="ambient_edge_light_color_selector_item_margin">8dp</dimen>
<dimen name="ambient_edge_light_color_selector_item_padding">4dp</dimen>
<dimen name="ambient_edge_light_color_selector_view_padding_horizontal">24dp</dimen>
</resources>
9 changes: 9 additions & 0 deletions res/values/integers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2024 BananaDroid
SPDX-License-Identifier: Apache-2.0
-->
<resources>

<integer name="ambient_edge_light_color_selector_view_span_count">5</integer>
</resources>
17 changes: 17 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -822,4 +822,21 @@
<!-- Ignore window secure -->
<string name="ignore_window_secure_title">Ignore secure window flag</string>
<string name="ignore_window_secure_summary">Remove screenshot and screenrecord limits for all apps. This can be convenient in some cases but may lead to privacy leaks.</string>

<!-- Ambient edge lighting -->
<string name="ambient_edge_light_action_title">Ambient edge lighting</string>
<string name="ambient_edge_light_title">Edge lighting</string>
<string name="ambient_edge_light_enable_title">Enable edge lighting</string>
<string name="ambient_edge_light_summary">Light up the side edges of the screen on notification pulse</string>
<string name="ambient_edge_light_color_mode_category_title">Color</string>
<string name="ambient_edge_light_color_mode_auto">Auto</string>
<string name="ambient_edge_light_color_mode_app">App color</string>
<string name="ambient_edge_light_color_mode_manual">Manual</string>
<string name="ambient_edge_light_color_mode_auto_summary">Set edge light color to the system color</string>
<string name="ambient_edge_light_color_mode_app_summary">Set edge light color to the app color</string>
<string name="ambient_edge_light_color_mode_manual_summary">Pick a color manualy</string>
<string name="ambient_edge_light_advanced_category_title">Advanced</string>
<string name="ambient_edge_light_duration_title">Light duration</string>
<string name="ambient_edge_light_repeat_count_title">Repeat count</string>
<string name="ambient_edge_light_width_title">Light width</string>
</resources>
87 changes: 87 additions & 0 deletions res/xml/ambient_edge_light_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2023 The LibreMobileOS Foundation
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.
-->

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
android:key="ambient_edge_lights"
android:title="@string/ambient_edge_light_action_title">

<com.banana.support.preferences.SecureSettingMainSwitchPreference
android:key="pulse_ambient_light"
android:title="@string/ambient_edge_light_enable_title" />

<PreferenceCategory
android:key="pulse_ambient_light_color_category"
android:title="@string/ambient_edge_light_color_mode_category_title"
android:dependency="pulse_ambient_light" >

<com.android.settingslib.widget.SelectorWithWidgetPreference
android:key="pulse_ambient_light_color_mode_auto"
android:title="@string/ambient_edge_light_color_mode_auto"
android:summary="@string/ambient_edge_light_color_mode_auto_summary" />

<com.android.settingslib.widget.SelectorWithWidgetPreference
android:key="pulse_ambient_light_color_mode_app"
android:title="@string/ambient_edge_light_color_mode_app"
android:summary="@string/ambient_edge_light_color_mode_app_summary" />

<com.android.settingslib.widget.SelectorWithWidgetPreference
android:key="pulse_ambient_light_color_mode_manual"
android:title="@string/ambient_edge_light_color_mode_manual"
android:summary="@string/ambient_edge_light_color_mode_manual_summary" />

<com.android.settingslib.widget.LayoutPreference
android:key="pulse_ambient_light_color_selector"
android:layout="@layout/ambient_edge_light_color_selector_view" />

</PreferenceCategory>

<PreferenceCategory
android:key="pulse_ambient_light_advanced_category"
android:title="@string/ambient_edge_light_advanced_category_title"
android:dependency="pulse_ambient_light" >

<com.banana.support.preferences.CustomSecureSeekBarPreference
android:key="pulse_ambient_light_duration"
android:title="@string/ambient_edge_light_duration_title"
android:max="10"
android:min="1"
android:defaultValue="2"
android:dependency="pulse_ambient_light"
settings:units="sec" />

<com.banana.support.preferences.CustomSecureSeekBarPreference
android:key="pulse_ambient_light_repeat_count"
android:title="@string/ambient_edge_light_repeat_count_title"
android:max="10"
android:min="0"
android:defaultValue="0"
android:dependency="pulse_ambient_light"
settings:units="times" />

<com.banana.support.preferences.CustomSecureSeekBarPreference
android:key="pulse_ambient_light_width"
android:title="@string/ambient_edge_light_width_title"
android:max="150"
android:min="1"
android:defaultValue="125"
android:dependency="pulse_ambient_light"
settings:units="px" />

</PreferenceCategory>

</PreferenceScreen>
8 changes: 8 additions & 0 deletions res/xml/bg_doze.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@
android:defaultValue="false"
android:summary="@string/pulse_on_new_tracks_summary" />

<Preference
android:key="ambient_edge_light"
android:title="@string/ambient_edge_light_title"
android:summary="@string/ambient_edge_light_summary"
android:fragment="com.banana.settings.fragments.doze.AmbientEdgeLightSettings"
settings:controller="com.banana.settings.fragments.doze.AmbientEdgeLightPreferenceController"
settings:requiresConfig="@bool/config_show_ambient_edge_light" />

<PreferenceCategory
android:key="doze_sensor"
android:title="@string/doze_sensor_title" >
Expand Down
Loading

0 comments on commit 3a3ca7e

Please sign in to comment.