Loading packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenLongPress.kt +5 −5 Original line number Diff line number Diff line Loading @@ -36,25 +36,25 @@ import androidx.compose.ui.input.pointer.pointerInput import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.android.systemui.communal.ui.compose.extensions.detectLongPressGesture import com.android.systemui.keyguard.ui.viewmodel.KeyguardTouchHandlingViewModel import com.android.systemui.lifecycle.rememberViewModel /** Container for lockscreen content that handles long-press to bring up the settings menu. */ @Composable // TODO(b/344879669): now that it's more generic than long-press, rename it. fun LockscreenLongPress( viewModel: KeyguardTouchHandlingViewModel, viewModelFactory: KeyguardTouchHandlingViewModel.Factory, modifier: Modifier = Modifier, content: @Composable BoxScope.(onSettingsMenuPlaces: (coordinates: Rect?) -> Unit) -> Unit, ) { val isEnabled: Boolean by viewModel.isLongPressHandlingEnabled.collectAsStateWithLifecycle(initialValue = false) val viewModel = rememberViewModel("LockscreenLongPress") { viewModelFactory.create() } val (settingsMenuBounds, setSettingsMenuBounds) = remember { mutableStateOf<Rect?>(null) } val interactionSource = remember { MutableInteractionSource() } Box( modifier = modifier .pointerInput(isEnabled) { if (isEnabled) { .pointerInput(viewModel.isLongPressHandlingEnabled) { if (viewModel.isLongPressHandlingEnabled) { detectLongPressGesture { viewModel.onLongPress(isA11yAction = false) } } } Loading packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/CommunalBlueprint.kt +4 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,10 @@ class CommunalBlueprint @Inject constructor() : ComposableLockscreenSceneBluepri @Composable override fun ContentScope.Content(viewModel: LockscreenContentViewModel, modifier: Modifier) { LockscreenLongPress(viewModel = viewModel.touchHandling, modifier = modifier) { _ -> LockscreenLongPress( viewModelFactory = viewModel.touchHandlingFactory, modifier = modifier, ) { _ -> Box(modifier.background(Color.Black)) { Text( text = "TODO(b/316211368): communal blueprint", Loading packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/DefaultBlueprint.kt +4 −2 Original line number Diff line number Diff line Loading @@ -78,8 +78,10 @@ constructor( with(notificationSection) { HeadsUpNotifications() } } LockscreenLongPress(viewModel = viewModel.touchHandling, modifier = modifier) { onSettingsMenuPlaced -> LockscreenLongPress( viewModelFactory = viewModel.touchHandlingFactory, modifier = modifier, ) { onSettingsMenuPlaced -> Layout( content = { // Constrained to above the lock icon. Loading packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/SettingsMenuSection.kt +6 −12 Original line number Diff line number Diff line Loading @@ -42,25 +42,19 @@ class SettingsMenuSection @Inject constructor( private val viewModel: KeyguardSettingsMenuViewModel, private val touchHandlingViewModel: KeyguardTouchHandlingViewModel, private val touchHandlingViewModelFactory: KeyguardTouchHandlingViewModel.Factory, private val vibratorHelper: VibratorHelper, private val activityStarter: ActivityStarter, ) { @Composable @SuppressWarnings("InflateParams") // null is passed into the inflate call, on purpose. fun SettingsMenu( onPlaced: (Rect?) -> Unit, modifier: Modifier = Modifier, ) { fun SettingsMenu(onPlaced: (Rect?) -> Unit, modifier: Modifier = Modifier) { val (disposableHandle, setDisposableHandle) = remember { mutableStateOf<DisposableHandle?>(null) } AndroidView( factory = { context -> LayoutInflater.from(context) .inflate( R.layout.keyguard_settings_popup_menu, null, ) .inflate(R.layout.keyguard_settings_popup_menu, null) .apply { isVisible = false alpha = 0f Loading @@ -69,7 +63,7 @@ constructor( KeyguardSettingsViewBinder.bind( view = this, viewModel = viewModel, touchHandlingViewModel = touchHandlingViewModel, touchHandlingViewModelFactory = touchHandlingViewModelFactory, rootViewModel = null, vibratorHelper = vibratorHelper, activityStarter = activityStarter, Loading @@ -81,11 +75,11 @@ constructor( modifier = modifier .padding( bottom = dimensionResource(R.dimen.keyguard_affordance_vertical_offset), bottom = dimensionResource(R.dimen.keyguard_affordance_vertical_offset) ) .padding( horizontal = dimensionResource(R.dimen.keyguard_affordance_horizontal_offset), dimensionResource(R.dimen.keyguard_affordance_horizontal_offset) ) .onPlaced { coordinates -> onPlaced( Loading packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -260,7 +260,7 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { @Mock protected DreamingToLockscreenTransitionViewModel mDreamingToLockscreenTransitionViewModel; @Mock protected KeyguardTransitionInteractor mKeyguardTransitionInteractor; @Mock protected KeyguardTouchHandlingViewModel mKeyuardTouchHandlingViewModel; @Mock protected KeyguardTouchHandlingViewModel.Factory mKeyguardTouchHandlingViewModelFactory; @Mock protected WallpaperFocalAreaViewModel mWallpaperFocalAreaViewModel; @Mock protected AlternateBouncerInteractor mAlternateBouncerInteractor; @Mock protected MotionEvent mDownMotionEvent; Loading Loading @@ -565,7 +565,7 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { mMainDispatcher, mKeyguardTransitionInteractor, mDumpManager, mKeyuardTouchHandlingViewModel, mKeyguardTouchHandlingViewModelFactory, mWallpaperFocalAreaViewModel, mKeyguardInteractor, mActivityStarter, Loading Loading
packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenLongPress.kt +5 −5 Original line number Diff line number Diff line Loading @@ -36,25 +36,25 @@ import androidx.compose.ui.input.pointer.pointerInput import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.android.systemui.communal.ui.compose.extensions.detectLongPressGesture import com.android.systemui.keyguard.ui.viewmodel.KeyguardTouchHandlingViewModel import com.android.systemui.lifecycle.rememberViewModel /** Container for lockscreen content that handles long-press to bring up the settings menu. */ @Composable // TODO(b/344879669): now that it's more generic than long-press, rename it. fun LockscreenLongPress( viewModel: KeyguardTouchHandlingViewModel, viewModelFactory: KeyguardTouchHandlingViewModel.Factory, modifier: Modifier = Modifier, content: @Composable BoxScope.(onSettingsMenuPlaces: (coordinates: Rect?) -> Unit) -> Unit, ) { val isEnabled: Boolean by viewModel.isLongPressHandlingEnabled.collectAsStateWithLifecycle(initialValue = false) val viewModel = rememberViewModel("LockscreenLongPress") { viewModelFactory.create() } val (settingsMenuBounds, setSettingsMenuBounds) = remember { mutableStateOf<Rect?>(null) } val interactionSource = remember { MutableInteractionSource() } Box( modifier = modifier .pointerInput(isEnabled) { if (isEnabled) { .pointerInput(viewModel.isLongPressHandlingEnabled) { if (viewModel.isLongPressHandlingEnabled) { detectLongPressGesture { viewModel.onLongPress(isA11yAction = false) } } } Loading
packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/CommunalBlueprint.kt +4 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,10 @@ class CommunalBlueprint @Inject constructor() : ComposableLockscreenSceneBluepri @Composable override fun ContentScope.Content(viewModel: LockscreenContentViewModel, modifier: Modifier) { LockscreenLongPress(viewModel = viewModel.touchHandling, modifier = modifier) { _ -> LockscreenLongPress( viewModelFactory = viewModel.touchHandlingFactory, modifier = modifier, ) { _ -> Box(modifier.background(Color.Black)) { Text( text = "TODO(b/316211368): communal blueprint", Loading
packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/DefaultBlueprint.kt +4 −2 Original line number Diff line number Diff line Loading @@ -78,8 +78,10 @@ constructor( with(notificationSection) { HeadsUpNotifications() } } LockscreenLongPress(viewModel = viewModel.touchHandling, modifier = modifier) { onSettingsMenuPlaced -> LockscreenLongPress( viewModelFactory = viewModel.touchHandlingFactory, modifier = modifier, ) { onSettingsMenuPlaced -> Layout( content = { // Constrained to above the lock icon. Loading
packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/SettingsMenuSection.kt +6 −12 Original line number Diff line number Diff line Loading @@ -42,25 +42,19 @@ class SettingsMenuSection @Inject constructor( private val viewModel: KeyguardSettingsMenuViewModel, private val touchHandlingViewModel: KeyguardTouchHandlingViewModel, private val touchHandlingViewModelFactory: KeyguardTouchHandlingViewModel.Factory, private val vibratorHelper: VibratorHelper, private val activityStarter: ActivityStarter, ) { @Composable @SuppressWarnings("InflateParams") // null is passed into the inflate call, on purpose. fun SettingsMenu( onPlaced: (Rect?) -> Unit, modifier: Modifier = Modifier, ) { fun SettingsMenu(onPlaced: (Rect?) -> Unit, modifier: Modifier = Modifier) { val (disposableHandle, setDisposableHandle) = remember { mutableStateOf<DisposableHandle?>(null) } AndroidView( factory = { context -> LayoutInflater.from(context) .inflate( R.layout.keyguard_settings_popup_menu, null, ) .inflate(R.layout.keyguard_settings_popup_menu, null) .apply { isVisible = false alpha = 0f Loading @@ -69,7 +63,7 @@ constructor( KeyguardSettingsViewBinder.bind( view = this, viewModel = viewModel, touchHandlingViewModel = touchHandlingViewModel, touchHandlingViewModelFactory = touchHandlingViewModelFactory, rootViewModel = null, vibratorHelper = vibratorHelper, activityStarter = activityStarter, Loading @@ -81,11 +75,11 @@ constructor( modifier = modifier .padding( bottom = dimensionResource(R.dimen.keyguard_affordance_vertical_offset), bottom = dimensionResource(R.dimen.keyguard_affordance_vertical_offset) ) .padding( horizontal = dimensionResource(R.dimen.keyguard_affordance_horizontal_offset), dimensionResource(R.dimen.keyguard_affordance_horizontal_offset) ) .onPlaced { coordinates -> onPlaced( Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -260,7 +260,7 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { @Mock protected DreamingToLockscreenTransitionViewModel mDreamingToLockscreenTransitionViewModel; @Mock protected KeyguardTransitionInteractor mKeyguardTransitionInteractor; @Mock protected KeyguardTouchHandlingViewModel mKeyuardTouchHandlingViewModel; @Mock protected KeyguardTouchHandlingViewModel.Factory mKeyguardTouchHandlingViewModelFactory; @Mock protected WallpaperFocalAreaViewModel mWallpaperFocalAreaViewModel; @Mock protected AlternateBouncerInteractor mAlternateBouncerInteractor; @Mock protected MotionEvent mDownMotionEvent; Loading Loading @@ -565,7 +565,7 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { mMainDispatcher, mKeyguardTransitionInteractor, mDumpManager, mKeyuardTouchHandlingViewModel, mKeyguardTouchHandlingViewModelFactory, mWallpaperFocalAreaViewModel, mKeyguardInteractor, mActivityStarter, Loading