diff options
| author | 2022-11-10 19:11:22 +0000 | |
|---|---|---|
| committer | 2022-11-10 19:11:22 +0000 | |
| commit | 2d5c31acdf76d1836b6b8771eb0e38a8870d4398 (patch) | |
| tree | 10f222abf7ca0698d7980a2c23d359488f47a7af | |
| parent | 2aea66b332d05db3ba297403665872964682bd4d (diff) | |
| parent | e17b87946d53d83b4668e571b2404e544ba242b4 (diff) | |
Merge "[Partial Screensharing] Hide 'show touches' in SysUI Recorder" into tm-qpr-dev
3 files changed, 128 insertions, 7 deletions
diff --git a/packages/SystemUI/res/layout/screen_record_options.xml b/packages/SystemUI/res/layout/screen_record_options.xml index a93691434bc0..d6c9e98d8b4d 100644 --- a/packages/SystemUI/res/layout/screen_record_options.xml +++ b/packages/SystemUI/res/layout/screen_record_options.xml @@ -50,6 +50,7 @@ android:importantForAccessibility="yes"/> </LinearLayout> <LinearLayout + android:id="@+id/show_taps" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" diff --git a/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordPermissionDialog.kt b/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordPermissionDialog.kt index cffd28f9fc96..19bb15a5c2d8 100644 --- a/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordPermissionDialog.kt +++ b/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordPermissionDialog.kt @@ -24,8 +24,9 @@ import android.os.Handler import android.os.Looper import android.os.ResultReceiver import android.view.View +import android.view.View.GONE +import android.view.View.VISIBLE import android.widget.AdapterView -import android.widget.AdapterView.OnItemClickListener import android.widget.ArrayAdapter import android.widget.Spinner import android.widget.Switch @@ -47,6 +48,7 @@ class ScreenRecordPermissionDialog( private val onStartRecordingClicked: Runnable? ) : BaseScreenSharePermissionDialog(context, createOptionList(), null) { private lateinit var tapsSwitch: Switch + private lateinit var tapsView: View private lateinit var audioSwitch: Switch private lateinit var options: Spinner override fun onCreate(savedInstanceState: Bundle?) { @@ -84,16 +86,25 @@ class ScreenRecordPermissionDialog( private fun initRecordOptionsView() { audioSwitch = findViewById(R.id.screenrecord_audio_switch) tapsSwitch = findViewById(R.id.screenrecord_taps_switch) + tapsView = findViewById(R.id.show_taps) + updateTapsViewVisibility() options = findViewById(R.id.screen_recording_options) val a: ArrayAdapter<*> = ScreenRecordingAdapter(context, android.R.layout.simple_spinner_dropdown_item, MODES) a.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) options.adapter = a - options.setOnItemClickListenerInt( - OnItemClickListener { _: AdapterView<*>?, _: View?, _: Int, _: Long -> - audioSwitch.isChecked = true - } - ) + options.setOnItemClickListenerInt { _: AdapterView<*>?, _: View?, _: Int, _: Long -> + audioSwitch.isChecked = true + } + } + + override fun onItemSelected(adapterView: AdapterView<*>?, view: View, pos: Int, id: Long) { + super.onItemSelected(adapterView, view, pos, id) + updateTapsViewVisibility() + } + + private fun updateTapsViewVisibility() { + tapsView.visibility = if (selectedScreenShareOption.mode == SINGLE_APP) GONE else VISIBLE } /** @@ -103,7 +114,7 @@ class ScreenRecordPermissionDialog( */ private fun requestScreenCapture(captureTarget: MediaProjectionCaptureTarget?) { val userContext = userContextProvider.userContext - val showTaps = tapsSwitch.isChecked + val showTaps = selectedScreenShareOption.mode != SINGLE_APP && tapsSwitch.isChecked val audioMode = if (audioSwitch.isChecked) options.selectedItem as ScreenRecordingAudioSource else ScreenRecordingAudioSource.NONE diff --git a/packages/SystemUI/tests/src/com/android/systemui/screenrecord/ScreenRecordPermissionDialogTest.kt b/packages/SystemUI/tests/src/com/android/systemui/screenrecord/ScreenRecordPermissionDialogTest.kt new file mode 100644 index 000000000000..0aa36218b3a7 --- /dev/null +++ b/packages/SystemUI/tests/src/com/android/systemui/screenrecord/ScreenRecordPermissionDialogTest.kt @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2022 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.screenrecord + +import android.testing.AndroidTestingRunner +import android.testing.TestableLooper +import android.view.View +import android.widget.Spinner +import androidx.test.filters.SmallTest +import com.android.systemui.R +import com.android.systemui.SysuiTestCase +import com.android.systemui.animation.DialogLaunchAnimator +import com.android.systemui.flags.FeatureFlags +import com.android.systemui.flags.Flags +import com.android.systemui.plugins.ActivityStarter +import com.android.systemui.settings.UserContextProvider +import com.android.systemui.util.mockito.mock +import com.google.common.truth.Truth.assertThat +import org.junit.After +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.Mock +import org.mockito.Mockito.`when` as whenever +import org.mockito.MockitoAnnotations + +@SmallTest +@RunWith(AndroidTestingRunner::class) +@TestableLooper.RunWithLooper(setAsMainLooper = true) +class ScreenRecordPermissionDialogTest : SysuiTestCase() { + + @Mock private lateinit var starter: ActivityStarter + @Mock private lateinit var controller: RecordingController + @Mock private lateinit var userContextProvider: UserContextProvider + @Mock private lateinit var flags: FeatureFlags + @Mock private lateinit var dialogLaunchAnimator: DialogLaunchAnimator + @Mock private lateinit var onStartRecordingClicked: Runnable + + private lateinit var dialog: ScreenRecordPermissionDialog + + @Before + fun setUp() { + MockitoAnnotations.initMocks(this) + + dialog = + ScreenRecordPermissionDialog( + context, + controller, + starter, + dialogLaunchAnimator, + userContextProvider, + onStartRecordingClicked + ) + dialog.onCreate(null) + whenever(flags.isEnabled(Flags.WM_ENABLE_PARTIAL_SCREEN_SHARING)).thenReturn(true) + } + + @After + fun teardown() { + if (::dialog.isInitialized) { + dialog.dismiss() + } + } + + @Test + fun testShowDialog_partialScreenSharingEnabled_optionsSpinnerIsVisible() { + dialog.show() + + val visibility = dialog.requireViewById<Spinner>(R.id.screen_share_mode_spinner).visibility + assertThat(visibility).isEqualTo(View.VISIBLE) + } + + @Test + fun testShowDialog_singleAppSelected_showTapsIsGone() { + dialog.show() + onSpinnerItemSelected(SINGLE_APP) + + val visibility = dialog.requireViewById<View>(R.id.show_taps).visibility + assertThat(visibility).isEqualTo(View.GONE) + } + + @Test + fun testShowDialog_entireScreenSelected_showTapsIsVisible() { + dialog.show() + onSpinnerItemSelected(ENTIRE_SCREEN) + + val visibility = dialog.requireViewById<View>(R.id.show_taps).visibility + assertThat(visibility).isEqualTo(View.VISIBLE) + } + + private fun onSpinnerItemSelected(position: Int) { + val spinner = dialog.requireViewById<Spinner>(R.id.screen_share_mode_spinner) + spinner.onItemSelectedListener.onItemSelected(spinner, mock(), position, /* id= */ 0) + } +} |