Merge "Update the manage education to be a cling" into rvc-dev

This commit is contained in:
TreeHugger Robot
2020-06-10 20:36:21 +00:00
committed by Android (Google) Code Review
4 changed files with 71 additions and 43 deletions

View File

@@ -17,30 +17,72 @@
<com.android.systemui.bubbles.BubbleManageEducationView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
>
<LinearLayout
android:id="@+id/manage_education_view"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="@dimen/bubbles_manage_education_width">
android:id="@+id/manage_education_view"
android:clickable="true"
android:paddingTop="28dp"
android:paddingBottom="16dp"
android:paddingStart="@dimen/bubble_expanded_view_padding"
android:paddingEnd="48dp"
android:layout_marginEnd="24dp"
android:orientation="vertical"
android:background="@drawable/bubble_stack_user_education_bg"
android:alpha="0.9"
>
<TextView
android:id="@+id/user_education_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingBottom="16dp"
android:fontFamily="@*android:string/config_bodyFontFamilyMedium"
android:maxLines="1"
android:text="@string/bubbles_user_education_manage_title"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Headline"/>
<TextView
android:id="@+id/user_education_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:paddingStart="16dp"
android:paddingBottom="24dp"
android:text="@string/bubbles_user_education_manage"
android:fontFamily="@*android:string/config_bodyFontFamily"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body2"
android:background="@drawable/bubble_manage_user_education_bg"
/>
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body2"/>
<View
android:id="@+id/user_education_pointer"
android:layout_width="@dimen/bubble_pointer_width"
android:layout_height="@dimen/bubble_pointer_height"
/>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal" >
<com.android.systemui.statusbar.AlphaOptimizedButton
style="@android:style/Widget.Material.Button.Borderless"
android:id="@+id/manage"
android:layout_gravity="start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true"
android:clickable="false"
android:text="@string/manage_bubbles_text"
android:textColor="?attr/wallpaperTextColor"
android:alpha="0.89"
/>
<com.android.systemui.statusbar.AlphaOptimizedButton
style="@android:style/Widget.Material.Button.Borderless"
android:id="@+id/got_it"
android:layout_gravity="start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true"
android:text="@string/bubbles_user_education_got_it"
android:textColor="?attr/wallpaperTextColor"
/>
</LinearLayout>
</LinearLayout>
</com.android.systemui.bubbles.BubbleManageEducationView>

View File

@@ -1248,7 +1248,7 @@
<!-- Bubbles user education views -->
<dimen name="bubbles_manage_education_width">160dp</dimen>
<!-- The inset from the top bound of the manage button to place the user education. -->
<dimen name="bubbles_manage_education_top_inset">10dp</dimen>
<dimen name="bubbles_manage_education_top_inset">65dp</dimen>
<!-- Size of padding for the user education cling, this should at minimum be larger than
individual_bubble_size + some padding. -->
<dimen name="bubble_stack_user_education_side_inset">72dp</dimen>

View File

@@ -17,10 +17,8 @@
package com.android.systemui.bubbles;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.ShapeDrawable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
@@ -28,7 +26,6 @@ import android.widget.TextView;
import com.android.internal.util.ContrastColorUtil;
import com.android.systemui.R;
import com.android.systemui.recents.TriangleShape;
/**
* Educational view to highlight the manage button that allows a user to configure the settings
@@ -36,7 +33,6 @@ import com.android.systemui.recents.TriangleShape;
*/
public class BubbleManageEducationView extends LinearLayout {
private View mPointerView;
private View mManageView;
public BubbleManageEducationView(Context context) {
@@ -70,26 +66,8 @@ public class BubbleManageEducationView extends LinearLayout {
ta.recycle();
textColor = ContrastColorUtil.ensureTextContrast(textColor, bgColor, true);
((TextView) findViewById(R.id.user_education_title)).setTextColor(textColor);
((TextView) findViewById(R.id.user_education_description)).setTextColor(textColor);
final Resources res = getResources();
final int pointerWidth = res.getDimensionPixelSize(R.dimen.bubble_pointer_width);
final int pointerHeight = res.getDimensionPixelSize(R.dimen.bubble_pointer_height);
ShapeDrawable triangleShape =
new ShapeDrawable(TriangleShape.create(
pointerWidth, pointerHeight, false /* isPointingUp */));
triangleShape.setTint(bgColor);
mPointerView = findViewById(R.id.user_education_pointer);
mPointerView.setBackground(triangleShape);
}
/**
* Specifies the x value this pointer should point to.
*/
public void setPointerPosition(int x) {
mPointerView.setTranslationX(x - (mPointerView.getWidth() / 2));
}
/**

View File

@@ -1621,12 +1621,19 @@ public class BubbleStackView extends FrameLayout
final int inset = getResources().getDimensionPixelSize(
R.dimen.bubbles_manage_education_top_inset);
mManageEducationView.bringToFront();
mManageEducationView.setManageViewPosition(mTempRect.left,
mTempRect.top - viewHeight + inset);
mManageEducationView.setPointerPosition(mTempRect.centerX() - mTempRect.left);
mManageEducationView.setManageViewPosition(0, mTempRect.top - viewHeight + inset);
mManageEducationView.animate()
.setDuration(ANIMATE_STACK_USER_EDUCATION_DURATION)
.setInterpolator(FAST_OUT_SLOW_IN).alpha(1);
mManageEducationView.findViewById(R.id.manage).setOnClickListener(view -> {
mExpandedBubble.getExpandedView().findViewById(R.id.settings_button)
.performClick();
maybeShowManageEducation(false);
});
mManageEducationView.findViewById(R.id.got_it).setOnClickListener(view ->
maybeShowManageEducation(false));
mManageEducationView.setOnClickListener(view ->
maybeShowManageEducation(false));
});
Prefs.putBoolean(getContext(), HAS_SEEN_BUBBLES_MANAGE_EDUCATION, true);
} else if (!show
@@ -1959,9 +1966,10 @@ public class BubbleStackView extends FrameLayout
*/
@Override
public void subtractObscuredTouchableRegion(Region touchableRegion, View view) {
// If the notification shade is expanded, or the manage menu is open, we shouldn't let the
// If the notification shade is expanded, or the manage menu is open, or we are showing
// manage bubbles user education, we shouldn't let the
// ActivityView steal any touch events from any location.
if (!mIsExpanded || mShowingManage) {
if (!mIsExpanded || mShowingManage || mManageEducationView.getVisibility() == VISIBLE) {
touchableRegion.setEmpty();
}
}