Loading res/values/strings.xml +7 −0 Original line number Diff line number Diff line Loading @@ -360,6 +360,13 @@ 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> <!-- Loading src/com/android/customization/picker/quickaffordance/data/repository/KeyguardQuickAffordancePickerRepository.kt +1 −1 Original line number Diff line number Diff line Loading @@ -82,7 +82,7 @@ class KeyguardQuickAffordancePickerRepository( isEnabled = isEnabled, enablementInstructions = enablementInstructions ?: emptyList(), enablementActionText = enablementActionText, enablementActionComponentName = enablementActionComponentName, enablementActionIntent = enablementActionIntent, configureIntent = configureIntent, ) } Loading src/com/android/customization/picker/quickaffordance/shared/model/KeyguardQuickAffordancePickerAffordanceModel.kt +3 −3 Original line number Diff line number Diff line Loading @@ -39,10 +39,10 @@ data class KeyguardQuickAffordancePickerAffordanceModel( */ val enablementActionText: String?, /** * If not enabled, an optional component name (package and action) for a button that takes the * user to a destination where they can re-enable it. * If not enabled, an optional [Intent] for a button that takes the user to a destination where * they can re-enable it. */ val enablementActionComponentName: String?, val enablementActionIntent: Intent?, /** Optional [Intent] to use to start an activity to configure this affordance. */ val configureIntent: Intent?, ) src/com/android/customization/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModel.kt +11 −31 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.viewModelScope import com.android.customization.picker.quickaffordance.domain.interactor.KeyguardQuickAffordancePickerInteractor import com.android.systemui.shared.customization.data.content.CustomizationProviderContract import com.android.systemui.shared.keyguard.shared.model.KeyguardQuickAffordanceSlots import com.android.systemui.shared.quickaffordance.shared.model.KeyguardPreviewConstants import com.android.wallpaper.R Loading Loading @@ -264,8 +263,7 @@ private constructor( name = affordance.name, instructions = affordance.enablementInstructions, actionText = affordance.enablementActionText, actionComponentName = affordance.enablementActionComponentName, actionIntent = affordance.enablementActionIntent, ) } }, Loading Loading @@ -350,7 +348,7 @@ private constructor( name: String, instructions: List<String>, actionText: String?, actionComponentName: String?, actionIntent: Intent?, ) { _dialog.value = DialogViewModel( Loading @@ -359,7 +357,14 @@ private constructor( drawable = icon, contentDescription = null, ), title = Text.Loaded(name), 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 { Loading @@ -382,9 +387,7 @@ private constructor( ), style = ButtonStyle.Primary, onClicked = { actionComponentName.toIntent()?.let { intent -> requestActivityStart(intent) } actionIntent?.let { intent -> requestActivityStart(intent) } } ), ), Loading Loading @@ -425,29 +428,6 @@ private constructor( return quickAffordanceInteractor.getAffordanceIcon(iconResourceId) } private fun String?.toIntent(): Intent? { if (isNullOrEmpty()) { return null } val splitUp = split( CustomizationProviderContract.LockScreenQuickAffordances.AffordanceTable .COMPONENT_NAME_SEPARATOR ) check(splitUp.size == 1 || splitUp.size == 2) { "Illegal component name \"$this\". Must be either just an action or a package and an" + " action separated by a" + " \"${CustomizationProviderContract.LockScreenQuickAffordances.AffordanceTable.COMPONENT_NAME_SEPARATOR}\"!" } return Intent(splitUp.last()).apply { if (splitUp.size > 1) { setPackage(splitUp[0]) } } } private fun toDescriptionText( context: Context, slots: Map<String, KeyguardQuickAffordanceSlotViewModel>, Loading tests/src/com/android/customization/model/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModelTest.kt +4 −3 Original line number Diff line number Diff line Loading @@ -252,7 +252,7 @@ class KeyguardQuickAffordancePickerViewModelTest { val enablementActionText = "enablementActionText" val packageName = "packageName" val action = "action" val enablementActionComponentName = "$packageName/$action" val enablementActionIntent = Intent(action).apply { `package` = packageName } // Lets add a disabled affordance to the picker: val affordanceIndex = client.addAffordance( Loading @@ -263,7 +263,7 @@ class KeyguardQuickAffordancePickerViewModelTest { isEnabled = false, enablementInstructions = enablementInstructions, enablementActionText = enablementActionText, enablementActionComponentName = enablementActionComponentName, enablementActionIntent = enablementActionIntent, ) ) Loading @@ -273,7 +273,8 @@ class KeyguardQuickAffordancePickerViewModelTest { // We expect there to be a dialog that should be shown: assertThat(dialog()?.icon) .isEqualTo(Icon.Loaded(FakeCustomizationProviderClient.ICON_1, null)) assertThat(dialog()?.title).isEqualTo(Text.Loaded("disabled")) 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) Loading Loading
res/values/strings.xml +7 −0 Original line number Diff line number Diff line Loading @@ -360,6 +360,13 @@ 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> <!-- Loading
src/com/android/customization/picker/quickaffordance/data/repository/KeyguardQuickAffordancePickerRepository.kt +1 −1 Original line number Diff line number Diff line Loading @@ -82,7 +82,7 @@ class KeyguardQuickAffordancePickerRepository( isEnabled = isEnabled, enablementInstructions = enablementInstructions ?: emptyList(), enablementActionText = enablementActionText, enablementActionComponentName = enablementActionComponentName, enablementActionIntent = enablementActionIntent, configureIntent = configureIntent, ) } Loading
src/com/android/customization/picker/quickaffordance/shared/model/KeyguardQuickAffordancePickerAffordanceModel.kt +3 −3 Original line number Diff line number Diff line Loading @@ -39,10 +39,10 @@ data class KeyguardQuickAffordancePickerAffordanceModel( */ val enablementActionText: String?, /** * If not enabled, an optional component name (package and action) for a button that takes the * user to a destination where they can re-enable it. * If not enabled, an optional [Intent] for a button that takes the user to a destination where * they can re-enable it. */ val enablementActionComponentName: String?, val enablementActionIntent: Intent?, /** Optional [Intent] to use to start an activity to configure this affordance. */ val configureIntent: Intent?, )
src/com/android/customization/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModel.kt +11 −31 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.viewModelScope import com.android.customization.picker.quickaffordance.domain.interactor.KeyguardQuickAffordancePickerInteractor import com.android.systemui.shared.customization.data.content.CustomizationProviderContract import com.android.systemui.shared.keyguard.shared.model.KeyguardQuickAffordanceSlots import com.android.systemui.shared.quickaffordance.shared.model.KeyguardPreviewConstants import com.android.wallpaper.R Loading Loading @@ -264,8 +263,7 @@ private constructor( name = affordance.name, instructions = affordance.enablementInstructions, actionText = affordance.enablementActionText, actionComponentName = affordance.enablementActionComponentName, actionIntent = affordance.enablementActionIntent, ) } }, Loading Loading @@ -350,7 +348,7 @@ private constructor( name: String, instructions: List<String>, actionText: String?, actionComponentName: String?, actionIntent: Intent?, ) { _dialog.value = DialogViewModel( Loading @@ -359,7 +357,14 @@ private constructor( drawable = icon, contentDescription = null, ), title = Text.Loaded(name), 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 { Loading @@ -382,9 +387,7 @@ private constructor( ), style = ButtonStyle.Primary, onClicked = { actionComponentName.toIntent()?.let { intent -> requestActivityStart(intent) } actionIntent?.let { intent -> requestActivityStart(intent) } } ), ), Loading Loading @@ -425,29 +428,6 @@ private constructor( return quickAffordanceInteractor.getAffordanceIcon(iconResourceId) } private fun String?.toIntent(): Intent? { if (isNullOrEmpty()) { return null } val splitUp = split( CustomizationProviderContract.LockScreenQuickAffordances.AffordanceTable .COMPONENT_NAME_SEPARATOR ) check(splitUp.size == 1 || splitUp.size == 2) { "Illegal component name \"$this\". Must be either just an action or a package and an" + " action separated by a" + " \"${CustomizationProviderContract.LockScreenQuickAffordances.AffordanceTable.COMPONENT_NAME_SEPARATOR}\"!" } return Intent(splitUp.last()).apply { if (splitUp.size > 1) { setPackage(splitUp[0]) } } } private fun toDescriptionText( context: Context, slots: Map<String, KeyguardQuickAffordanceSlotViewModel>, Loading
tests/src/com/android/customization/model/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModelTest.kt +4 −3 Original line number Diff line number Diff line Loading @@ -252,7 +252,7 @@ class KeyguardQuickAffordancePickerViewModelTest { val enablementActionText = "enablementActionText" val packageName = "packageName" val action = "action" val enablementActionComponentName = "$packageName/$action" val enablementActionIntent = Intent(action).apply { `package` = packageName } // Lets add a disabled affordance to the picker: val affordanceIndex = client.addAffordance( Loading @@ -263,7 +263,7 @@ class KeyguardQuickAffordancePickerViewModelTest { isEnabled = false, enablementInstructions = enablementInstructions, enablementActionText = enablementActionText, enablementActionComponentName = enablementActionComponentName, enablementActionIntent = enablementActionIntent, ) ) Loading @@ -273,7 +273,8 @@ class KeyguardQuickAffordancePickerViewModelTest { // We expect there to be a dialog that should be shown: assertThat(dialog()?.icon) .isEqualTo(Icon.Loaded(FakeCustomizationProviderClient.ICON_1, null)) assertThat(dialog()?.title).isEqualTo(Text.Loaded("disabled")) 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) Loading