Merge "Update the recents onboarding UI to the latest mock." into pi-dev
diff --git a/packages/SystemUI/res/drawable/recents_onboarding_toast_rounded_background.xml b/packages/SystemUI/res/drawable/recents_onboarding_toast_rounded_background.xml
new file mode 100644
index 0000000..05db3a8
--- /dev/null
+++ b/packages/SystemUI/res/drawable/recents_onboarding_toast_rounded_background.xml
@@ -0,0 +1,19 @@
+<!--
+ Copyright (C) 2018 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
+ <solid android:color="?android:attr/colorAccent" />
+ <corners android:radius="8dp" />
+</shape>
\ No newline at end of file
diff --git a/packages/SystemUI/res/layout/recents_onboarding.xml b/packages/SystemUI/res/layout/recents_onboarding.xml
index 12f278a..6764eee 100644
--- a/packages/SystemUI/res/layout/recents_onboarding.xml
+++ b/packages/SystemUI/res/layout/recents_onboarding.xml
@@ -14,32 +14,48 @@
limitations under the License.
-->
-<FrameLayout
+<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_height="48dp"
- android:layout_width="match_parent"
- android:background="@android:color/black"
- android:layout_gravity="center">
- <View
- android:layout_width="match_parent"
- android:layout_height="1dp"
- android:background="?android:attr/listDivider"
- android:gravity="top"/>
- <TextView
- android:id="@+id/onboarding_text"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:paddingBottom="13dp"
+ android:orientation="vertical">
+
+ <LinearLayout
android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:textColor="@android:color/white"
- android:textSize="16sp"
- android:drawableBottom="@drawable/ic_chevron_up"/>
- <ImageView
- android:id="@+id/dismiss"
- android:layout_width="48dp"
- android:layout_height="48dp"
- android:padding="12dp"
- android:layout_marginEnd="6dp"
- android:src="@drawable/ic_close_white"
- android:background="?android:attr/selectableItemBackgroundBorderless"
- android:layout_gravity="center_vertical|end"/>
-</FrameLayout>
\ No newline at end of file
+ android:layout_height="40dp"
+ android:paddingStart="24dp"
+ android:paddingEnd="4dp"
+ android:background="@drawable/recents_onboarding_toast_rounded_background"
+ android:layout_gravity="center_horizontal"
+ android:elevation="2dp"
+ android:orientation="horizontal">
+
+ <TextView
+ android:id="@+id/onboarding_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:textColor="@android:color/white"
+ android:textSize="16sp"/>
+ <ImageView
+ android:id="@+id/dismiss"
+ android:layout_width="40dp"
+ android:layout_height="40dp"
+ android:layout_gravity="center_vertical"
+ android:padding="10dp"
+ android:layout_marginStart="2dp"
+ android:layout_marginEnd="2dp"
+ android:alpha="0.7"
+ android:src="@drawable/ic_close_white"
+ android:background="?android:attr/selectableItemBackgroundBorderless"/>
+ </LinearLayout>
+
+ <View
+ android:id="@+id/arrow"
+ android:elevation="2dp"
+ android:layout_width="10dp"
+ android:layout_height="8dp"
+ android:layout_marginTop="-2dp"
+ android:layout_gravity="center_horizontal"/>
+</LinearLayout>
\ No newline at end of file
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 9009531..870aed4 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -845,6 +845,9 @@
<!-- The size of the drag hint text. -->
<dimen name="recents_drag_hint_text_size">14sp</dimen>
+ <!-- The size of corner radius of the arrow in the onboarding toast. -->
+ <dimen name="recents_onboarding_toast_arrow_corner_radius">2dp</dimen>
+
<!-- The min alpha to apply to a task affiliation group color. -->
<item name="recents_task_affiliation_color_min_alpha_percentage" format="float" type="dimen">0.6</item>
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsOnboarding.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsOnboarding.java
index 30e9afd8..0d8aed4 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsOnboarding.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsOnboarding.java
@@ -24,15 +24,16 @@
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
+import android.graphics.CornerPathEffect;
+import android.graphics.Paint;
import android.graphics.PixelFormat;
-import android.graphics.PorterDuff;
-import android.graphics.drawable.ColorDrawable;
-import android.graphics.drawable.RippleDrawable;
+import android.graphics.drawable.ShapeDrawable;
import android.os.Build;
import android.os.SystemProperties;
import android.os.UserManager;
import android.text.TextUtils;
import android.util.Log;
+import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
@@ -76,17 +77,13 @@
private final View mLayout;
private final TextView mTextView;
private final ImageView mDismissView;
- private final ColorDrawable mBackgroundDrawable;
- private final int mDarkBackgroundColor;
- private final int mLightBackgroundColor;
- private final int mDarkContentColor;
- private final int mLightContentColor;
- private final RippleDrawable mDarkRipple;
- private final RippleDrawable mLightRipple;
+ private final View mArrowView;
+ private final int mOnboardingToastColor;
+ private final int mOnboardingToastArrowRadius;
+ private int mNavBarHeight;
private boolean mTaskListenerRegistered;
private boolean mLayoutAttachedToWindow;
- private boolean mBackgroundIsLight;
private int mLastTaskId;
private boolean mHasDismissed;
private int mNumAppsLaunchedSinceDismiss;
@@ -159,24 +156,30 @@
mLayout = LayoutInflater.from(mContext).inflate(R.layout.recents_onboarding, null);
mTextView = mLayout.findViewById(R.id.onboarding_text);
mDismissView = mLayout.findViewById(R.id.dismiss);
- mDarkBackgroundColor = res.getColor(android.R.color.background_dark);
- mLightBackgroundColor = res.getColor(android.R.color.background_light);
- mDarkContentColor = res.getColor(R.color.primary_text_default_material_light);
- mLightContentColor = res.getColor(R.color.primary_text_default_material_dark);
- mDarkRipple = new RippleDrawable(res.getColorStateList(R.color.ripple_material_light),
- null, null);
- mLightRipple = new RippleDrawable(res.getColorStateList(R.color.ripple_material_dark),
- null, null);
- mBackgroundDrawable = new ColorDrawable(mDarkBackgroundColor);
+ mArrowView = mLayout.findViewById(R.id.arrow);
+
+ TypedValue typedValue = new TypedValue();
+ context.getTheme().resolveAttribute(android.R.attr.colorAccent, typedValue, true);
+ mOnboardingToastColor = res.getColor(typedValue.resourceId);
+ mOnboardingToastArrowRadius = res.getDimensionPixelSize(
+ R.dimen.recents_onboarding_toast_arrow_corner_radius);
mLayout.addOnAttachStateChangeListener(mOnAttachStateChangeListener);
- mLayout.setBackground(mBackgroundDrawable);
mDismissView.setOnClickListener(v -> {
hide(true);
mHasDismissed = true;
mNumAppsLaunchedSinceDismiss = 0;
});
+ ViewGroup.LayoutParams arrowLp = mArrowView.getLayoutParams();
+ ShapeDrawable arrowDrawable = new ShapeDrawable(TriangleShape.create(
+ arrowLp.width, arrowLp.height, false));
+ Paint arrowPaint = arrowDrawable.getPaint();
+ arrowPaint.setColor(mOnboardingToastColor);
+ // The corner path effect won't be reflected in the shadow, but shouldn't be noticeable.
+ arrowPaint.setPathEffect(new CornerPathEffect(mOnboardingToastArrowRadius));
+ mArrowView.setBackground(arrowDrawable);
+
if (RESET_PREFS_FOR_DEBUG) {
Prefs.putBoolean(mContext, Prefs.Key.HAS_SEEN_RECENTS_ONBOARDING, false);
Prefs.putInt(mContext, Prefs.Key.NUM_APPS_LAUNCHED, 0);
@@ -234,6 +237,7 @@
int orientation = mContext.getResources().getConfiguration().orientation;
if (!mLayoutAttachedToWindow && orientation == Configuration.ORIENTATION_PORTRAIT) {
mLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
+
mWindowManager.addView(mLayout, getWindowLayoutParams());
int layoutHeight = mLayout.getHeight();
if (layoutHeight == 0) {
@@ -281,29 +285,18 @@
}
}
- public void setContentDarkIntensity(float contentDarkIntensity) {
- boolean backgroundIsLight = contentDarkIntensity > 0.5f;
- if (backgroundIsLight != mBackgroundIsLight) {
- mBackgroundIsLight = backgroundIsLight;
- mBackgroundDrawable.setColor(mBackgroundIsLight
- ? mLightBackgroundColor : mDarkBackgroundColor);
- int contentColor = mBackgroundIsLight ? mDarkContentColor : mLightContentColor;
- mTextView.setTextColor(contentColor);
- mTextView.getCompoundDrawables()[3].setColorFilter(contentColor,
- PorterDuff.Mode.SRC_IN);
- mDismissView.setColorFilter(contentColor);
- mDismissView.setBackground(mBackgroundIsLight ? mDarkRipple : mLightRipple);
- }
+ public void setNavBarHeight(int navBarHeight) {
+ mNavBarHeight = navBarHeight;
}
private WindowManager.LayoutParams getWindowLayoutParams() {
- int flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
- | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
+ int flags = WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
final WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
- WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG,
+ 0, -mNavBarHeight / 2,
+ WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
flags,
PixelFormat.TRANSLUCENT);
lp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/TriangleShape.java b/packages/SystemUI/src/com/android/systemui/recents/TriangleShape.java
new file mode 100644
index 0000000..de85c0f
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/recents/TriangleShape.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.recents;
+
+import android.graphics.Outline;
+import android.graphics.Path;
+import android.graphics.drawable.shapes.PathShape;
+import android.support.annotation.NonNull;
+
+/**
+ * Wrapper around {@link android.graphics.drawable.shapes.PathShape}
+ * that creates a shape with a triangular path (pointing up or down).
+ */
+public class TriangleShape extends PathShape {
+ private Path mTriangularPath;
+
+ public TriangleShape(Path path, float stdWidth, float stdHeight) {
+ super(path, stdWidth, stdHeight);
+ mTriangularPath = path;
+ }
+
+ public static TriangleShape create(float width, float height, boolean isPointingUp) {
+ Path triangularPath = new Path();
+ if (isPointingUp) {
+ triangularPath.moveTo(0, height);
+ triangularPath.lineTo(width, height);
+ triangularPath.lineTo(width / 2, 0);
+ triangularPath.close();
+ } else {
+ triangularPath.moveTo(0, 0);
+ triangularPath.lineTo(width / 2, height);
+ triangularPath.lineTo(width, 0);
+ triangularPath.close();
+ }
+ return new TriangleShape(triangularPath, width, height);
+ }
+
+ @Override
+ public void getOutline(@NonNull Outline outline) {
+ outline.setConvexPath(mTriangularPath);
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index db2139d..14a36d0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -812,9 +812,6 @@
if (mGestureHelper != null) {
mGestureHelper.onDarkIntensityChange(intensity);
}
- if (mRecentsOnboarding != null) {
- mRecentsOnboarding.setContentDarkIntensity(intensity);
- }
}
@Override
@@ -831,6 +828,7 @@
updateButtonLocationOnScreen(getHomeButton(), mHomeButtonBounds);
updateButtonLocationOnScreen(getRecentsButton(), mRecentsButtonBounds);
mGestureHelper.onLayout(changed, left, top, right, bottom);
+ mRecentsOnboarding.setNavBarHeight(getMeasuredHeight());
}
private void updateButtonLocationOnScreen(ButtonDispatcher button, Rect buttonBounds) {