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
diff --git a/quickstep/res/layout/split_instructions_view.xml b/quickstep/res/layout/split_instructions_view.xml
index c663bf4..0bbbfd5 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" />
+
+ <androidx.appcompat.widget.AppCompatTextView
+ android:id="@+id/split_instructions_text_cancel"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textColor="?androidprv:attr/textColorOnAccent"
+ android:layout_marginStart="@dimen/split_instructions_start_margin_cancel"
+ android:text="@string/toast_split_select_app_cancel"
+ android:visibility="gone"/>
</com.android.quickstep.views.SplitInstructionsView>
\ No newline at end of file
diff --git a/quickstep/res/values/strings.xml b/quickstep/res/values/strings.xml
index 3dade66..077b233 100644
--- a/quickstep/res/values/strings.xml
+++ b/quickstep/res/values/strings.xml
@@ -230,6 +230,7 @@
<string name="action_split">Split</string>
<!-- Label for toast with instructions for split screen selection mode. [CHAR_LIMIT=50] -->
<string name="toast_split_select_app">Tap another app to use split screen</string>
+ <string name="toast_split_select_app_cancel"><b>Cancel</b></string>
<string name="toast_split_select_cont_desc">Exit split screen selection</string>
<!-- Label for toast when app selected for split isn't supported. [CHAR_LIMIT=50] -->
<string name="toast_split_app_unsupported">Choose another app to use split screen</string>
diff --git a/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt b/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt
index 6ee65d4..b7c6bf5 100644
--- a/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt
+++ b/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt
@@ -252,6 +252,7 @@
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 e8f06ee..8bc85cf 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 @@
*
* 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<SplitInstructionsView> UNFOLD =
new FloatProperty<SplitInstructionsView>("SplitInstructionsUnfold") {
@@ -97,22 +97,13 @@
}
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 @@
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 AppCompatTextView getTextView() {
- return mTextView;
+ return mInstructionTextView;
}
}
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index ac701d6..b2d869b 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -427,6 +427,7 @@
<dimen name="split_instructions_drawable_padding">10dp</dimen>
<dimen name="split_instructions_bottom_margin_phone_landscape">24dp</dimen>
<dimen name="split_instructions_bottom_margin_phone_portrait">60dp</dimen>
+ <dimen name="split_instructions_start_margin_cancel">8dp</dimen>
<!-- Workspace grid visualization parameters -->
<dimen name="grid_visualization_rounding_radius">28dp</dimen>