From 204080732f93cf7637e30601576fd8086612cd97 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Tue, 3 Aug 2021 10:55:46 -0700 Subject: [PATCH 1/3] Updates to user education for large screen - Restrict the width of the education views when on a large screen device - Rather than hardcode the position / padding for the education views, figure it out based on where the view is on the screen so that it's a little less brittle. - Recreate the views for theme or display size change Test: visual - verify the user education screens look correct in phone and on large screen in both portrait & landscape - change display size & verify education is still visible & sized appropriately Bug: 186776550 Change-Id: I1c77a810339448d61b570eb158848c15b2df96c8 --- .../Shell/res/layout/bubble_manage_button.xml | 2 +- .../layout/bubble_stack_user_education.xml | 1 - .../bubbles_manage_button_education.xml | 19 ++--- libs/WindowManager/Shell/res/values/dimen.xml | 10 +-- .../wm/shell/bubbles/BubblePositioner.java | 7 ++ .../wm/shell/bubbles/BubbleStackView.java | 34 +++++---- .../wm/shell/bubbles/ManageEducationView.kt | 74 ++++++++++--------- .../wm/shell/bubbles/StackEducationView.kt | 28 +++++-- 8 files changed, 95 insertions(+), 80 deletions(-) diff --git a/libs/WindowManager/Shell/res/layout/bubble_manage_button.xml b/libs/WindowManager/Shell/res/layout/bubble_manage_button.xml index 7658fca588221..0cf6d73162d24 100644 --- a/libs/WindowManager/Shell/res/layout/bubble_manage_button.xml +++ b/libs/WindowManager/Shell/res/layout/bubble_manage_button.xml @@ -17,7 +17,7 @@ - diff --git a/libs/WindowManager/Shell/res/values/dimen.xml b/libs/WindowManager/Shell/res/values/dimen.xml index 7da31aa7d03a0..757e83a25319e 100644 --- a/libs/WindowManager/Shell/res/values/dimen.xml +++ b/libs/WindowManager/Shell/res/values/dimen.xml @@ -184,14 +184,8 @@ 40dp 20dp 4dp - - - 160dp - - 65dp - - 72dp + + 400dp 48dp diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java index df804ec174d38..6cff05542aa47 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java @@ -241,6 +241,13 @@ public class BubblePositioner { return mPositionRect; } + /** + * @return a rect of the screen size. + */ + public Rect getScreenRect() { + return mScreenRect; + } + /** * @return the relevant insets (status bar, nav bar, cutouts). If taskbar is showing, its * inset is not included here. diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java index 8f2df4ab39722..9e108ea911c6b 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java @@ -110,9 +110,6 @@ public class BubbleStackView extends FrameLayout private static final int FADE_IN_DURATION = 320; - /** Percent to darken the bubbles when they're in the dismiss target. */ - private static final float DARKEN_PERCENT = 0.3f; - /** How long to wait, in milliseconds, before hiding the flyout. */ @VisibleForTesting static final int FLYOUT_HIDE_AFTER = 5000; @@ -559,7 +556,7 @@ public class BubbleStackView extends FrameLayout if (mBubbleData.isExpanded()) { if (mManageEduView != null) { - mManageEduView.hide(false /* show */); + mManageEduView.hide(); } // If we're expanded, tell the animation controller to prepare to drag this bubble, @@ -797,8 +794,6 @@ public class BubbleStackView extends FrameLayout mBubbleContainer.setClipChildren(false); addView(mBubbleContainer, new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)); - updateUserEdu(); - mExpandedViewContainer = new FrameLayout(context); mExpandedViewContainer.setElevation(elevation); mExpandedViewContainer.setClipChildren(false); @@ -1132,10 +1127,10 @@ public class BubbleStackView extends FrameLayout return; } if (mManageEduView == null) { - mManageEduView = new ManageEducationView(mContext); + mManageEduView = new ManageEducationView(mContext, mPositioner); addView(mManageEduView); } - mManageEduView.show(mExpandedBubble.getExpandedView(), mTempRect); + mManageEduView.show(mExpandedBubble.getExpandedView()); } /** @@ -1163,21 +1158,27 @@ public class BubbleStackView extends FrameLayout return false; } if (mStackEduView == null) { - mStackEduView = new StackEducationView(mContext); + mStackEduView = new StackEducationView(mContext, mPositioner); addView(mStackEduView); } mBubbleContainer.bringToFront(); return mStackEduView.show(mPositioner.getDefaultStartPosition()); } + // Recreates & shows the education views. Call when a theme/config change happens. private void updateUserEdu() { - maybeShowStackEdu(); - if (mManageEduView != null) { - mManageEduView.invalidate(); + if (mStackEduView != null && mStackEduView.getVisibility() == VISIBLE) { + removeView(mStackEduView); + mStackEduView = new StackEducationView(mContext, mPositioner); + addView(mStackEduView); + mBubbleContainer.bringToFront(); // Stack appears on top of the stack education + mStackEduView.show(mPositioner.getDefaultStartPosition()); } - maybeShowManageEdu(); - if (mStackEduView != null) { - mStackEduView.invalidate(); + if (mManageEduView != null && mManageEduView.getVisibility() == VISIBLE) { + removeView(mManageEduView); + mManageEduView = new ManageEducationView(mContext, mPositioner); + addView(mManageEduView); + mManageEduView.show(mExpandedBubble.getExpandedView()); } } @@ -1274,6 +1275,7 @@ public class BubbleStackView extends FrameLayout setUpManageMenu(); setUpFlyout(); setUpDismissView(); + updateUserEdu(); mBubbleSize = mPositioner.getBubbleSize(); for (Bubble b : mBubbleData.getBubbles()) { if (b.getIconView() == null) { @@ -2032,7 +2034,7 @@ public class BubbleStackView extends FrameLayout final BubbleViewProvider previouslySelected = mExpandedBubble; beforeExpandedViewAnimation(); if (mManageEduView != null) { - mManageEduView.hide(false /* fromExpansion */); + mManageEduView.hide(); } if (DEBUG_BUBBLE_STACK_VIEW) { diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/ManageEducationView.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/ManageEducationView.kt index 4cc67025fff4d..de9970779b056 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/ManageEducationView.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/ManageEducationView.kt @@ -18,12 +18,13 @@ package com.android.wm.shell.bubbles import android.content.Context import android.graphics.Color import android.graphics.Rect +import android.graphics.drawable.ColorDrawable import android.view.LayoutInflater import android.view.View +import android.view.ViewGroup import android.widget.Button import android.widget.LinearLayout -import android.widget.TextView -import com.android.internal.util.ContrastColorUtil +import com.android.internal.R.color.system_neutral1_900 import com.android.wm.shell.R import com.android.wm.shell.animation.Interpolators @@ -31,21 +32,21 @@ import com.android.wm.shell.animation.Interpolators * User education view to highlight the manage button that allows a user to configure the settings * for the bubble. Shown only the first time a user expands a bubble. */ -class ManageEducationView constructor(context: Context) : LinearLayout(context) { +class ManageEducationView constructor(context: Context, positioner: BubblePositioner) + : LinearLayout(context) { - private val TAG = if (BubbleDebugConfig.TAG_WITH_CLASS_NAME) "BubbleManageEducationView" + private val TAG = if (BubbleDebugConfig.TAG_WITH_CLASS_NAME) "ManageEducationView" else BubbleDebugConfig.TAG_BUBBLES private val ANIMATE_DURATION: Long = 200 - private val ANIMATE_DURATION_SHORT: Long = 40 - private val manageView by lazy { findViewById(R.id.manage_education_view) } - private val manageButton by lazy { findViewById