Add mode: Choose name and icon for new custom modes

This also unifies the "icon picker" screen with the new "add mode" screen since in both cases we want to edit name and icon together (and not save updates until the user confirms).

Bug: 326442408
Bug: 346278854
Test: atest com.android.settings.notification.modes
Flag: android.app.modes_ui
Change-Id: I8a9d07ba0b6c55f3abc1b9884f278d51d178dc83
This commit is contained in:
Matías Hernández
2024-07-01 18:25:54 +02:00
parent 0037dfe9a9
commit 574fcaf1b2
18 changed files with 1154 additions and 69 deletions

View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2024 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.
-->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/done"
android:text="@string/done"
style="@style/ActionPrimaryButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginEnd="20dp"
/>
</FrameLayout>

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2024 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.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@android:id/edit"
android:maxLines="1"
android:inputType="text|textCapSentences"
android:imeOptions="actionDone"
android:selectAllOnFocus="true"
android:hint="@string/zen_mode_edit_name_hint" />
</LinearLayout>

View File

@@ -9451,6 +9451,18 @@
<!-- [CHAR LIMIT=40] Zen mode settings: Title for the "choose mode icon" screen -->
<string name="zen_mode_icon_picker_title">Change icon</string>
<!-- Priority Modes: Title for the "rename mode" screen [CHAR LIMIT=20] -->
<string name="zen_mode_rename_title">Rename</string>
<!-- Priority Modes: Title for the "add mode" screen [CHAR LIMIT=20] -->
<string name="zen_mode_new_custom_title">Add mode</string>
<!-- Priority Modes: Default name for new custom modes [CHAR LIMIT=30] -->
<string name="zen_mode_new_custom_default_name">Custom mode</string>
<!-- Priority Modes: Hint for the EditText for editing a mode's name [CHAR LIMIT=30] -->
<string name="zen_mode_edit_name_hint">Mode name</string>
<!-- Content description for help icon button [CHAR LIMIT=20] -->
<string name="warning_button_text">Warning</string>

View File

@@ -18,20 +18,30 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="zen_mode_icon_picker_page"
android:key="zen_mode_edit_name_icon"
settings:searchable="false"
android:title="@string/zen_mode_icon_picker_title">
android:title="@string/zen_mode_rename_title">
<com.android.settingslib.widget.LayoutPreference
android:key="current_icon"
android:key="chosen_icon"
android:layout="@layout/settings_entity_header" />
<com.android.settings.applications.SpacePreference
android:layout_height="16dp" />
<com.android.settingslib.widget.LayoutPreference
android:key="name"
android:layout="@layout/modes_edit_name" />
<com.android.settings.applications.SpacePreference
android:layout_height="32dp" />
<com.android.settingslib.widget.LayoutPreference
android:key="icon_list"
android:selectable="false"
android:layout="@layout/modes_icon_list"/>
<com.android.settingslib.widget.LayoutPreference
android:key="done"
android:layout="@layout/modes_edit_done_button" />
</PreferenceScreen>