From 017c8d52d5f64a805a44750796324b0300b6aaa5 Mon Sep 17 00:00:00 2001 From: Andy Wickham Date: Tue, 18 Feb 2020 23:58:57 +0000 Subject: [PATCH] Disables Back gesture while sandbox is running. We'll want to detect this gesture ourselves to distinguish between left and right edge and update the UI accordingly. Note: This exclusion only works if the sandbox is launched into the same task as Launcher (i.e. from Launcher itself). I haven't found a way to get this to happen over adb. Test: Launched BackGestureTutorialActivity from Launcher and verified Back gesture animations did not play and the onBackPressed callback was not called. Verified these did still work in other apps. Bug: 148542211 Change-Id: Iebc3428738edbf8ebfcff157f5952b787eb46bac --- .../BackGestureTutorialActivity.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialActivity.java b/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialActivity.java index 295ab4897e..d2a0951c62 100644 --- a/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialActivity.java +++ b/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialActivity.java @@ -16,7 +16,10 @@ package com.android.quickstep.interaction; import android.graphics.Color; +import android.graphics.Rect; import android.os.Bundle; +import android.util.DisplayMetrics; +import android.view.Display; import android.view.View; import android.view.Window; @@ -26,6 +29,7 @@ import com.android.launcher3.R; import com.android.quickstep.interaction.BackGestureTutorialFragment.TutorialStep; import com.android.quickstep.interaction.BackGestureTutorialFragment.TutorialType; +import java.util.List; import java.util.Optional; /** Shows the Back gesture interactive tutorial in full screen mode. */ @@ -46,6 +50,12 @@ public class BackGestureTutorialActivity extends FragmentActivity { .commit(); } + @Override + public void onAttachedToWindow() { + super.onAttachedToWindow(); + disableSystemGestures(); + } + @Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); @@ -70,4 +80,14 @@ public class BackGestureTutorialActivity extends FragmentActivity { | View.SYSTEM_UI_FLAG_FULLSCREEN); getWindow().setNavigationBarColor(Color.TRANSPARENT); } + + private void disableSystemGestures() { + Display display = getDisplay(); + if (display != null) { + DisplayMetrics metrics = new DisplayMetrics(); + display.getMetrics(metrics); + getWindow().setSystemGestureExclusionRects( + List.of(new Rect(0, 0, metrics.widthPixels, metrics.heightPixels))); + } + } }