Loading packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettingsShadeOverlay.kt +0 −1 Original line number Diff line number Diff line Loading @@ -168,7 +168,6 @@ fun SceneScope.QuickSettingsLayout( modifier = Modifier.fillMaxWidth() .heightIn(max = QuickSettingsShade.Dimensions.GridMaxHeight), viewModel.editModeViewModel::startEditing, ) } } Loading packages/SystemUI/multivalentTests/src/com/android/systemui/brightness/ui/viewmodel/BrightnessSliderViewModelTest.kt +2 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import com.android.systemui.brightness.domain.interactor.brightnessPolicyEnforce import com.android.systemui.brightness.domain.interactor.screenBrightnessInteractor import com.android.systemui.brightness.shared.model.GammaBrightness import com.android.systemui.brightness.shared.model.LinearBrightness import com.android.systemui.classifier.domain.interactor.falsingInteractor import com.android.systemui.common.shared.model.ContentDescription import com.android.systemui.common.shared.model.Icon import com.android.systemui.common.shared.model.Text Loading Loading @@ -61,6 +62,7 @@ class BrightnessSliderViewModelTest : SysuiTestCase() { brightnessPolicyEnforcementInteractor, sliderHapticsViewModelFactory, brightnessMirrorShowingInteractor, falsingInteractor, supportsMirroring = true, brightnessWarningToast, ) Loading packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/viewmodel/EditModeButtonViewModelTest.kt 0 → 100644 +63 −0 Original line number Diff line number Diff line /* * 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. */ package com.android.systemui.qs.panels.ui.viewmodel import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.classifier.fakeFalsingManager import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runCurrent import com.android.systemui.kosmos.runTest import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import org.junit.Test import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) @SmallTest class EditModeButtonViewModelTest : SysuiTestCase() { val kosmos = testKosmos() val underTest = kosmos.editModeButtonViewModelFactory.create() @Test fun falsingFalseTap_editModeDoesntStart() = kosmos.runTest { val isEditing by collectLastValue(editModeViewModel.isEditing) fakeFalsingManager.setFalseTap(true) underTest.onButtonClick() runCurrent() assertThat(isEditing).isFalse() } @Test fun falsingNotFalseTap_editModeStarted() = kosmos.runTest { val isEditing by collectLastValue(editModeViewModel.isEditing) fakeFalsingManager.setFalseTap(false) underTest.onButtonClick() runCurrent() assertThat(isEditing).isTrue() } } packages/SystemUI/src/com/android/systemui/brightness/ui/compose/BrightnessSlider.kt +12 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.brightness.ui.compose import android.view.MotionEvent import androidx.compose.animation.core.animateFloatAsState import androidx.compose.foundation.clickable import androidx.compose.foundation.gestures.Orientation Loading @@ -41,6 +42,7 @@ import androidx.compose.ui.geometry.CornerRadius import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Size import androidx.compose.ui.graphics.Color import androidx.compose.ui.input.pointer.pointerInteropFilter import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.colorResource import androidx.compose.ui.res.stringResource Loading Loading @@ -221,7 +223,16 @@ fun BrightnessSliderContainer( ) .then(if (viewModel.showMirror) Modifier.drawInOverlay() else Modifier) .sliderBackground(containerColor) .fillMaxWidth(), .fillMaxWidth() .pointerInteropFilter { if ( it.actionMasked == MotionEvent.ACTION_UP || it.actionMasked == MotionEvent.ACTION_CANCEL ) { viewModel.emitBrightnessTouchForFalsing() } false }, formatter = viewModel::formatValue, hapticsViewModelFactory = viewModel.hapticsViewModelFactory, ) Loading packages/SystemUI/src/com/android/systemui/brightness/ui/viewmodel/BrightnessSliderViewModel.kt +8 −1 Original line number Diff line number Diff line Loading @@ -16,12 +16,14 @@ package com.android.systemui.brightness.ui.viewmodel import androidx.compose.runtime.getValue import android.content.Context import androidx.annotation.StringRes import androidx.compose.runtime.getValue import com.android.systemui.brightness.domain.interactor.BrightnessPolicyEnforcementInteractor import com.android.systemui.brightness.domain.interactor.ScreenBrightnessInteractor import com.android.systemui.brightness.shared.model.GammaBrightness import com.android.systemui.classifier.Classifier import com.android.systemui.classifier.domain.interactor.FalsingInteractor import com.android.systemui.common.shared.model.ContentDescription import com.android.systemui.common.shared.model.Icon import com.android.systemui.common.shared.model.Text Loading Loading @@ -52,6 +54,7 @@ constructor( private val brightnessPolicyEnforcementInteractor: BrightnessPolicyEnforcementInteractor, val hapticsViewModelFactory: SliderHapticsViewModel.Factory, private val brightnessMirrorShowingInteractor: BrightnessMirrorShowingInteractor, private val falsingInteractor: FalsingInteractor, @Assisted private val supportsMirroring: Boolean, private val brightnessWarningToast: BrightnessWarningToast, ) : ExclusiveActivatable() { Loading Loading @@ -87,6 +90,10 @@ constructor( brightnessWarningToast.show(viewContext, resId) } fun emitBrightnessTouchForFalsing() { falsingInteractor.isFalseTouch(Classifier.BRIGHTNESS_SLIDER) } /** * As a brightness slider is dragged, the corresponding events should be sent using this method. */ Loading Loading
packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettingsShadeOverlay.kt +0 −1 Original line number Diff line number Diff line Loading @@ -168,7 +168,6 @@ fun SceneScope.QuickSettingsLayout( modifier = Modifier.fillMaxWidth() .heightIn(max = QuickSettingsShade.Dimensions.GridMaxHeight), viewModel.editModeViewModel::startEditing, ) } } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/brightness/ui/viewmodel/BrightnessSliderViewModelTest.kt +2 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import com.android.systemui.brightness.domain.interactor.brightnessPolicyEnforce import com.android.systemui.brightness.domain.interactor.screenBrightnessInteractor import com.android.systemui.brightness.shared.model.GammaBrightness import com.android.systemui.brightness.shared.model.LinearBrightness import com.android.systemui.classifier.domain.interactor.falsingInteractor import com.android.systemui.common.shared.model.ContentDescription import com.android.systemui.common.shared.model.Icon import com.android.systemui.common.shared.model.Text Loading Loading @@ -61,6 +62,7 @@ class BrightnessSliderViewModelTest : SysuiTestCase() { brightnessPolicyEnforcementInteractor, sliderHapticsViewModelFactory, brightnessMirrorShowingInteractor, falsingInteractor, supportsMirroring = true, brightnessWarningToast, ) Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/viewmodel/EditModeButtonViewModelTest.kt 0 → 100644 +63 −0 Original line number Diff line number Diff line /* * 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. */ package com.android.systemui.qs.panels.ui.viewmodel import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.classifier.fakeFalsingManager import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runCurrent import com.android.systemui.kosmos.runTest import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import org.junit.Test import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) @SmallTest class EditModeButtonViewModelTest : SysuiTestCase() { val kosmos = testKosmos() val underTest = kosmos.editModeButtonViewModelFactory.create() @Test fun falsingFalseTap_editModeDoesntStart() = kosmos.runTest { val isEditing by collectLastValue(editModeViewModel.isEditing) fakeFalsingManager.setFalseTap(true) underTest.onButtonClick() runCurrent() assertThat(isEditing).isFalse() } @Test fun falsingNotFalseTap_editModeStarted() = kosmos.runTest { val isEditing by collectLastValue(editModeViewModel.isEditing) fakeFalsingManager.setFalseTap(false) underTest.onButtonClick() runCurrent() assertThat(isEditing).isTrue() } }
packages/SystemUI/src/com/android/systemui/brightness/ui/compose/BrightnessSlider.kt +12 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.brightness.ui.compose import android.view.MotionEvent import androidx.compose.animation.core.animateFloatAsState import androidx.compose.foundation.clickable import androidx.compose.foundation.gestures.Orientation Loading @@ -41,6 +42,7 @@ import androidx.compose.ui.geometry.CornerRadius import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Size import androidx.compose.ui.graphics.Color import androidx.compose.ui.input.pointer.pointerInteropFilter import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.colorResource import androidx.compose.ui.res.stringResource Loading Loading @@ -221,7 +223,16 @@ fun BrightnessSliderContainer( ) .then(if (viewModel.showMirror) Modifier.drawInOverlay() else Modifier) .sliderBackground(containerColor) .fillMaxWidth(), .fillMaxWidth() .pointerInteropFilter { if ( it.actionMasked == MotionEvent.ACTION_UP || it.actionMasked == MotionEvent.ACTION_CANCEL ) { viewModel.emitBrightnessTouchForFalsing() } false }, formatter = viewModel::formatValue, hapticsViewModelFactory = viewModel.hapticsViewModelFactory, ) Loading
packages/SystemUI/src/com/android/systemui/brightness/ui/viewmodel/BrightnessSliderViewModel.kt +8 −1 Original line number Diff line number Diff line Loading @@ -16,12 +16,14 @@ package com.android.systemui.brightness.ui.viewmodel import androidx.compose.runtime.getValue import android.content.Context import androidx.annotation.StringRes import androidx.compose.runtime.getValue import com.android.systemui.brightness.domain.interactor.BrightnessPolicyEnforcementInteractor import com.android.systemui.brightness.domain.interactor.ScreenBrightnessInteractor import com.android.systemui.brightness.shared.model.GammaBrightness import com.android.systemui.classifier.Classifier import com.android.systemui.classifier.domain.interactor.FalsingInteractor import com.android.systemui.common.shared.model.ContentDescription import com.android.systemui.common.shared.model.Icon import com.android.systemui.common.shared.model.Text Loading Loading @@ -52,6 +54,7 @@ constructor( private val brightnessPolicyEnforcementInteractor: BrightnessPolicyEnforcementInteractor, val hapticsViewModelFactory: SliderHapticsViewModel.Factory, private val brightnessMirrorShowingInteractor: BrightnessMirrorShowingInteractor, private val falsingInteractor: FalsingInteractor, @Assisted private val supportsMirroring: Boolean, private val brightnessWarningToast: BrightnessWarningToast, ) : ExclusiveActivatable() { Loading Loading @@ -87,6 +90,10 @@ constructor( brightnessWarningToast.show(viewContext, resId) } fun emitBrightnessTouchForFalsing() { falsingInteractor.isFalseTouch(Classifier.BRIGHTNESS_SLIDER) } /** * As a brightness slider is dragged, the corresponding events should be sent using this method. */ Loading