Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b9eb0180 authored by Ale Nijamkin's avatar Ale Nijamkin Committed by Android (Google) Code Review
Browse files

Merge "Long-press to configure quick affordances (2/2)." into tm-qpr-dev

parents 13a16340 7bda0fd0
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -175,7 +175,9 @@ open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInject
                    getKeyguardQuickAffordancePickerInteractor(context),
                    getUndoInteractor(context),
                    getCurrentWallpaperInfoFactory(context),
                )
                ) { intent ->
                    context.startActivity(intent)
                }
                .also { keyguardQuickAffordancePickerViewModelFactory = it }
    }

+1 −0
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ class KeyguardQuickAffordancePickerRepository(
            enablementInstructions = enablementInstructions ?: emptyList(),
            enablementActionText = enablementActionText,
            enablementActionComponentName = enablementActionComponentName,
            configureIntent = configureIntent,
        )
    }

+3 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@

package com.android.customization.picker.quickaffordance.shared.model

import android.content.Intent
import androidx.annotation.DrawableRes

/** Models a quick affordance. */
@@ -42,4 +43,6 @@ data class KeyguardQuickAffordancePickerAffordanceModel(
     * user to a destination where they can re-enable it.
     */
    val enablementActionComponentName: String?,
    /** Optional [Intent] to use to start an activity to configure this affordance. */
    val configureIntent: Intent?,
)
+9 −0
Original line number Diff line number Diff line
@@ -74,6 +74,15 @@ class AffordancesAdapter : RecyclerView.Adapter<AffordancesAdapter.ViewHolder>()
                null
            }
        )
        holder.itemView.onLongClickListener =
            if (item.onLongClicked != null) {
                View.OnLongClickListener {
                    item.onLongClicked.invoke()
                    true
                }
            } else {
                null
            }
        holder.iconContainerView.setBackgroundResource(
            if (item.isSelected) {
                R.drawable.keyguard_quick_affordance_icon_container_background_selected
+10 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ private constructor(
    private val quickAffordanceInteractor: KeyguardQuickAffordancePickerInteractor,
    undoInteractor: UndoInteractor,
    private val wallpaperInfoFactory: CurrentWallpaperInfoFactory,
    activityStarter: (Intent) -> Unit,
) : ViewModel() {

    @SuppressLint("StaticFieldLeak") private val applicationContext = context.applicationContext
@@ -129,6 +130,7 @@ private constructor(
                                        contentDescription = affordanceModel.name,
                                        isSelected = true,
                                        onClicked = null,
                                        onLongClicked = null,
                                        isEnabled = affordanceModel.isEnabled,
                                    )
                                },
@@ -201,6 +203,12 @@ private constructor(
                                    )
                                }
                            },
                        onLongClicked =
                            if (affordance.configureIntent != null) {
                                { activityStarter(affordance.configureIntent) }
                            } else {
                                null
                            },
                        isEnabled = affordance.isEnabled,
                    )
                }
@@ -374,6 +382,7 @@ private constructor(
        private val quickAffordanceInteractor: KeyguardQuickAffordancePickerInteractor,
        private val undoInteractor: UndoInteractor,
        private val wallpaperInfoFactory: CurrentWallpaperInfoFactory,
        private val activityStarter: (Intent) -> Unit,
    ) : ViewModelProvider.Factory {
        override fun <T : ViewModel> create(modelClass: Class<T>): T {
            @Suppress("UNCHECKED_CAST")
@@ -382,6 +391,7 @@ private constructor(
                quickAffordanceInteractor = quickAffordanceInteractor,
                undoInteractor = undoInteractor,
                wallpaperInfoFactory = wallpaperInfoFactory,
                activityStarter = activityStarter,
            )
                as T
        }
Loading