From d6efde5cbb06aceb115abc198fd9efc50e68931c Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Tue, 31 Oct 2023 17:44:38 -0700 Subject: [PATCH] Change SplitInstructionsView cancel from X to "Cancel" * Styling (accent color) is still a TODO, just made it bold for now. Flag: ACONFIG com.android.wm.shell.enable_split_contextual DEVELOPMENT Bug: 295983387 Test: Tested w/ flag on and off, cancel doesn't show with flag off Change-Id: Id5214a86abbe0cf095e32f6f75522ea51d6b1f3c --- .../res/layout/split_instructions_view.xml | 12 +++-- quickstep/res/values/strings.xml | 1 + .../util/SplitAnimationController.kt | 1 + .../views/SplitInstructionsView.java | 45 +++++-------------- res/values/dimens.xml | 1 + 5 files changed, 23 insertions(+), 37 deletions(-) diff --git a/quickstep/res/layout/split_instructions_view.xml b/quickstep/res/layout/split_instructions_view.xml index c663bf470c..0bbbfd5165 100644 --- a/quickstep/res/layout/split_instructions_view.xml +++ b/quickstep/res/layout/split_instructions_view.xml @@ -30,9 +30,15 @@ android:id="@+id/split_instructions_text" android:layout_height="wrap_content" android:layout_width="wrap_content" - android:gravity="center" android:textColor="?androidprv:attr/textColorOnAccent" - android:drawableEnd="@drawable/ic_split_exit" - android:drawablePadding="@dimen/split_instructions_drawable_padding" android:text="@string/toast_split_select_app" /> + + \ No newline at end of file diff --git a/quickstep/res/values/strings.xml b/quickstep/res/values/strings.xml index 3dade66c8e..077b233257 100644 --- a/quickstep/res/values/strings.xml +++ b/quickstep/res/values/strings.xml @@ -230,6 +230,7 @@ Split Tap another app to use split screen + Cancel Exit split screen selection Choose another app to use split screen diff --git a/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt b/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt index 6ee65d4489..b7c6bf5cc0 100644 --- a/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt +++ b/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt @@ -252,6 +252,7 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC splitSelectStateController.splitInstructionsView = splitInstructionsView val timings = AnimUtils.getDeviceOverviewToSplitTimings(launcher.deviceProfile.isTablet) val anim = PendingAnimation(100 /*duration */) + splitInstructionsView.alpha = 0f anim.setViewAlpha(splitInstructionsView, 1f, Interpolators.clampToProgress(Interpolators.LINEAR, timings.instructionsContainerFadeInStartOffset, diff --git a/quickstep/src/com/android/quickstep/views/SplitInstructionsView.java b/quickstep/src/com/android/quickstep/views/SplitInstructionsView.java index e8f06ee9f3..8bc85cf8f3 100644 --- a/quickstep/src/com/android/quickstep/views/SplitInstructionsView.java +++ b/quickstep/src/com/android/quickstep/views/SplitInstructionsView.java @@ -17,14 +17,12 @@ package com.android.quickstep.views; import android.content.Context; -import android.graphics.drawable.Drawable; import android.os.Bundle; import android.util.AttributeSet; import android.util.FloatProperty; -import android.view.MotionEvent; import android.view.ViewGroup; import android.view.accessibility.AccessibilityNodeInfo; -import android.widget.FrameLayout; +import android.widget.LinearLayout; import androidx.annotation.Nullable; import androidx.appcompat.widget.AppCompatTextView; @@ -41,9 +39,11 @@ import com.android.launcher3.statemanager.StatefulActivity; * * Appears and disappears concurrently with a FloatingTaskView. */ -public class SplitInstructionsView extends FrameLayout { +public class SplitInstructionsView extends LinearLayout { private final StatefulActivity mLauncher; - private AppCompatTextView mTextView; + private AppCompatTextView mInstructionTextView; + /** Only used if {@link com.android.wm.shell.FeatureFlags#enableSplitContextual()} is true. */ + private AppCompatTextView mCancelTextView; public static final FloatProperty UNFOLD = new FloatProperty("SplitInstructionsUnfold") { @@ -97,22 +97,13 @@ public class SplitInstructionsView extends FrameLayout { } private void init() { - mTextView = findViewById(R.id.split_instructions_text); + mInstructionTextView = findViewById(R.id.split_instructions_text); + mCancelTextView = findViewById(R.id.split_instructions_text_cancel); - if (!FeatureFlags.enableSplitContextually()) { - mTextView.setCompoundDrawables(null, null, null, null); - return; + if (FeatureFlags.enableSplitContextually()) { + mCancelTextView.setVisibility(VISIBLE); + mCancelTextView.setOnClickListener((v) -> exitSplitSelection()); } - - mTextView.setOnTouchListener((v, event) -> { - if (isTouchInsideRightCompoundDrawable(event)) { - if (event.getAction() == MotionEvent.ACTION_UP) { - exitSplitSelection(); - } - return true; - } - return false; - }); } private void exitSplitSelection() { @@ -121,20 +112,6 @@ public class SplitInstructionsView extends FrameLayout { mLauncher.getStateManager().goToState(LauncherState.NORMAL); } - private boolean isTouchInsideRightCompoundDrawable(MotionEvent event) { - // Get the right compound drawable of the TextView. - Drawable rightDrawable = mTextView.getCompoundDrawablesRelative()[2]; - - // Check if the touch event intersects with the drawable's bounds. - if (rightDrawable != null) { - // We can get away w/o caring about the Y bounds since it's such a small view, if it's - // above/below the drawable just assume they meant to touch it. ¯\_(ツ)_/¯ - return event.getX() >= (mTextView.getWidth() - rightDrawable.getBounds().width()); - } else { - return false; - } - } - @Override public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); @@ -172,6 +149,6 @@ public class SplitInstructionsView extends FrameLayout { } public AppCompatTextView getTextView() { - return mTextView; + return mInstructionTextView; } } diff --git a/res/values/dimens.xml b/res/values/dimens.xml index ac701d653b..b2d869b833 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -427,6 +427,7 @@ 10dp 24dp 60dp + 8dp 28dp