[tp] Some UX polish for strings and text.

- "Clock color & size" instead of "Clock settings"
- Improved re-enablement dialog text for lock screen shortcuts
- Allow two lines of text for lock screen shorcut option items, with
  hyphenation and ellipsizing
- Improved re-enablement dialog messaging.

Fix: 282079529
Test: manually verified that everything above shows up correctly
Change-Id: Ie3e933e4943ba8297c42e7f59a225c1c1146434b
diff --git a/res/layout/keyguard_quick_affordance.xml b/res/layout/keyguard_quick_affordance.xml
index 1e5c339..a86489a 100644
--- a/res/layout/keyguard_quick_affordance.xml
+++ b/res/layout/keyguard_quick_affordance.xml
@@ -62,8 +62,10 @@
         android:id="@id/text"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
+        android:gravity="center_horizontal"
         android:textColor="@color/text_color_primary"
-        android:singleLine="true"
+        android:maxLines="2"
+        android:hyphenationFrequency="normal"
         android:ellipsize="end"
         android:text="Placeholder for stable size calculation, please do not remove."
         tools:ignore="HardcodedText" />
diff --git a/res/values/strings.xml b/res/values/strings.xml
index c023924..40142d1 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -34,7 +34,7 @@
     <string name="clock_picker_entry_content_description">Change a custom clock</string>
 
     <!-- Title of a section of the customization picker where the user can configure Clock face. [CHAR LIMIT=19] -->
-    <string name="clock_settings_title">Clock Settings</string>
+    <string name="clock_settings_title">Clock color &amp; size</string>
 
     <!-- Title of a section of the customization picker where the user can configure clock color and size. [CHAR LIMIT=20] -->
     <string name="clock_color_and_size_title">Clock color &amp; size</string>
@@ -360,14 +360,7 @@
     enabled. The dialog contains a list of instructions that the user needs to take in order to
     enable the option before it can be selected again. [CHAR LIMIT=NONE].
     -->
-    <string name="keyguard_affordance_enablement_dialog_headline">Shortcut unavailable</string>
-
-    <!--
-    Supporting text for a popup dialog shown when the user attempts to select an option that is not
-    currently enabled. The dialog contains a list of instructions that the user needs to take in
-    order to enable the option before it can be selected again. [CHAR LIMIT=NONE].
-    -->
-    <string name="keyguard_affordance_enablement_dialog_title">To select `<xliff:g id="appName" example="Wallet">%1$s</xliff:g>` check the following</string>
+    <string name="keyguard_affordance_enablement_dialog_headline">Can\'t add shortcut</string>
 
     <!--
     Template for an action that opens a specific app. [CHAR LIMIT=16]
diff --git a/src/com/android/customization/picker/quickaffordance/data/repository/KeyguardQuickAffordancePickerRepository.kt b/src/com/android/customization/picker/quickaffordance/data/repository/KeyguardQuickAffordancePickerRepository.kt
index 9729661..b17af80 100644
--- a/src/com/android/customization/picker/quickaffordance/data/repository/KeyguardQuickAffordancePickerRepository.kt
+++ b/src/com/android/customization/picker/quickaffordance/data/repository/KeyguardQuickAffordancePickerRepository.kt
@@ -80,7 +80,7 @@
             name = name,
             iconResourceId = iconResourceId,
             isEnabled = isEnabled,
-            enablementInstructions = enablementInstructions ?: emptyList(),
+            enablementExplanation = enablementExplanation ?: "",
             enablementActionText = enablementActionText,
             enablementActionIntent = enablementActionIntent,
             configureIntent = configureIntent,
diff --git a/src/com/android/customization/picker/quickaffordance/shared/model/KeyguardQuickAffordancePickerAffordanceModel.kt b/src/com/android/customization/picker/quickaffordance/shared/model/KeyguardQuickAffordancePickerAffordanceModel.kt
index 5ca7d56..e53f790 100644
--- a/src/com/android/customization/picker/quickaffordance/shared/model/KeyguardQuickAffordancePickerAffordanceModel.kt
+++ b/src/com/android/customization/picker/quickaffordance/shared/model/KeyguardQuickAffordancePickerAffordanceModel.kt
@@ -31,8 +31,8 @@
     @DrawableRes val iconResourceId: Int,
     /** Whether this quick affordance is enabled. */
     val isEnabled: Boolean,
-    /** If not enabled, the list of user-visible steps to re-enable it. */
-    val enablementInstructions: List<String>,
+    /** If not enabled, the user-visible message explaining why. */
+    val enablementExplanation: String,
     /**
      * If not enabled, an optional label for a button that takes the user to a destination where
      * they can re-enable it.
diff --git a/src/com/android/customization/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModel.kt b/src/com/android/customization/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModel.kt
index 08cb756..f832cde 100644
--- a/src/com/android/customization/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModel.kt
+++ b/src/com/android/customization/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModel.kt
@@ -261,7 +261,7 @@
                                     showEnablementDialog(
                                         icon = affordanceIcon,
                                         name = affordance.name,
-                                        instructions = affordance.enablementInstructions,
+                                        explanation = affordance.enablementExplanation,
                                         actionText = affordance.enablementActionText,
                                         actionIntent = affordance.enablementActionIntent,
                                     )
@@ -346,7 +346,7 @@
     private fun showEnablementDialog(
         icon: Drawable,
         name: String,
-        instructions: List<String>,
+        explanation: String,
         actionText: String?,
         actionIntent: Intent?,
     ) {
@@ -358,39 +358,38 @@
                         contentDescription = null,
                     ),
                 headline = Text.Resource(R.string.keyguard_affordance_enablement_dialog_headline),
-                supportingText =
-                    Text.Loaded(
-                        applicationContext.getString(
-                            R.string.keyguard_affordance_enablement_dialog_title,
-                            name
-                        )
-                    ),
-                message =
-                    Text.Loaded(
-                        buildString {
-                            instructions.forEachIndexed { index, instruction ->
-                                if (index > 0) {
-                                    append('\n')
-                                }
-
-                                append(instruction)
-                            }
-                        }
-                    ),
+                message = Text.Loaded(explanation),
                 buttons =
-                    listOf(
-                        ButtonViewModel(
-                            text = actionText?.let { Text.Loaded(actionText) }
-                                    ?: Text.Resource(
-                                        R.string
-                                            .keyguard_affordance_enablement_dialog_dismiss_button,
+                    buildList {
+                        add(
+                            ButtonViewModel(
+                                text =
+                                    Text.Resource(
+                                        if (actionText != null) {
+                                            // This is not the only button on the dialog.
+                                            R.string.cancel
+                                        } else {
+                                            // This is the only button on the dialog.
+                                            R.string
+                                                .keyguard_affordance_enablement_dialog_dismiss_button
+                                        }
                                     ),
-                            style = ButtonStyle.Primary,
-                            onClicked = {
-                                actionIntent?.let { intent -> requestActivityStart(intent) }
-                            }
-                        ),
-                    ),
+                                style = ButtonStyle.Secondary,
+                            ),
+                        )
+
+                        if (actionText != null) {
+                            add(
+                                ButtonViewModel(
+                                    text = Text.Loaded(actionText),
+                                    style = ButtonStyle.Primary,
+                                    onClicked = {
+                                        actionIntent?.let { intent -> requestActivityStart(intent) }
+                                    }
+                                ),
+                            )
+                        }
+                    },
             )
     }
 
diff --git a/tests/src/com/android/customization/model/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModelTest.kt b/tests/src/com/android/customization/model/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModelTest.kt
index d51f411..3f10674 100644
--- a/tests/src/com/android/customization/model/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModelTest.kt
+++ b/tests/src/com/android/customization/model/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModelTest.kt
@@ -248,7 +248,7 @@
             val dialog = collectLastValue(underTest.dialog)
             val activityStartRequest = collectLastValue(underTest.activityStartRequests)
 
-            val enablementInstructions = listOf("instruction1", "instruction2")
+            val enablementExplanation = "enablementExplanation"
             val enablementActionText = "enablementActionText"
             val packageName = "packageName"
             val action = "action"
@@ -261,7 +261,7 @@
                         name = "disabled",
                         iconResourceId = 1,
                         isEnabled = false,
-                        enablementInstructions = enablementInstructions,
+                        enablementExplanation = enablementExplanation,
                         enablementActionText = enablementActionText,
                         enablementActionIntent = enablementActionIntent,
                     )
@@ -275,15 +275,14 @@
                 .isEqualTo(Icon.Loaded(FakeCustomizationProviderClient.ICON_1, null))
             assertThat(dialog()?.headline)
                 .isEqualTo(Text.Resource(R.string.keyguard_affordance_enablement_dialog_headline))
-            assertThat(dialog()?.message)
-                .isEqualTo(Text.Loaded(enablementInstructions.joinToString("\n")))
-            assertThat(dialog()?.buttons?.size).isEqualTo(1)
-            assertThat(dialog()?.buttons?.first()?.text)
-                .isEqualTo(Text.Loaded(enablementActionText))
+            assertThat(dialog()?.message).isEqualTo(Text.Loaded(enablementExplanation))
+            assertThat(dialog()?.buttons?.size).isEqualTo(2)
+            assertThat(dialog()?.buttons?.first()?.text).isEqualTo(Text.Resource(R.string.cancel))
+            assertThat(dialog()?.buttons?.get(1)?.text).isEqualTo(Text.Loaded(enablementActionText))
 
             // When the button is clicked, we expect an intent of the given enablement action
             // component name to be emitted.
-            dialog()?.buttons?.first()?.onClicked?.invoke()
+            dialog()?.buttons?.get(1)?.onClicked?.invoke()
             assertThat(activityStartRequest()?.`package`).isEqualTo(packageName)
             assertThat(activityStartRequest()?.action).isEqualTo(action)