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

Commit e3068585 authored by dakinola's avatar dakinola Committed by Daniel Akinola
Browse files

Ensure that Screen Recording switches only respond to touch events within the target region

Add onTouchListeners to switches so that switches can only be swiped/toggled from clicking the view itself. Touch events beyond the view bounds, above or below won't affect the checked state of the switch.

Fix: 308519160
Test: Manual testing
Flag: None
Change-Id: Ia061d0b1b1cd84e94b764ef331460e3dacbdec3a
parent 370b8256
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package com.android.systemui.screenrecord

import android.annotation.SuppressLint
import android.app.Activity
import android.app.PendingIntent
import android.content.Intent
@@ -23,6 +24,7 @@ import android.os.Handler
import android.os.Looper
import android.os.ResultReceiver
import android.os.UserHandle
import android.view.MotionEvent.ACTION_MOVE
import android.view.View
import android.view.View.GONE
import android.view.View.VISIBLE
@@ -102,11 +104,19 @@ class ScreenRecordPermissionDialogDelegate(

    @LayoutRes override fun getOptionsViewLayoutId(): Int = R.layout.screen_record_options

    @SuppressLint("ClickableViewAccessibility")
    private fun initRecordOptionsView() {
        audioSwitch = dialog.requireViewById(R.id.screenrecord_audio_switch)
        tapsSwitch = dialog.requireViewById(R.id.screenrecord_taps_switch)

        // Add these listeners so that the switch only responds to movement
        // within its target region, to meet accessibility requirements
        audioSwitch.setOnTouchListener { _, event -> event.action == ACTION_MOVE }
        tapsSwitch.setOnTouchListener { _, event -> event.action == ACTION_MOVE }

        tapsView = dialog.requireViewById(R.id.show_taps)
        updateTapsViewVisibility()

        options = dialog.requireViewById(R.id.screen_recording_options)
        val a: ArrayAdapter<*> =
            ScreenRecordingAdapter(