[Search] Update all apps header protection
- Introduce spacing between header protection and search box
- introduce vertical padding for "personal | work" tab
- animate tab header protection color change when docking
Test: Manual
preview: https://drive.google.com/file/d/1eS4B7hcLExxCdjSp1IzBcziKm-9w87UR/view?usp=sharing&resourcekey=0--mtY6bCC9GJpFSUC8I5d6w
Bug: 184946772
Change-Id: I840af27c7557f1dffd7a15874aa09833514b4bb1
diff --git a/res/drawable/all_apps_tabs_background.xml b/res/drawable/all_apps_tabs_background.xml
index 377b653..f882522 100644
--- a/res/drawable/all_apps_tabs_background.xml
+++ b/res/drawable/all_apps_tabs_background.xml
@@ -13,9 +13,14 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<shape android:shape="rectangle"
- xmlns:android="http://schemas.android.com/apk/res/android"
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
- <solid android:color="?androidprv:attr/colorSurface" />
- <corners android:radius="@dimen/all_apps_header_pill_corner_radius" />
-</shape>
\ No newline at end of file
+ <item
+ android:top="6dp"
+ android:bottom="6dp">
+ <shape android:shape="rectangle">
+ <solid android:color="?androidprv:attr/colorSurface" />
+ <corners android:radius="@dimen/all_apps_header_pill_corner_radius" />
+ </shape>
+ </item>
+</layer-list>
\ No newline at end of file
diff --git a/res/layout/all_apps_personal_work_tabs.xml b/res/layout/all_apps_personal_work_tabs.xml
index f089f83..686dda8 100644
--- a/res/layout/all_apps_personal_work_tabs.xml
+++ b/res/layout/all_apps_personal_work_tabs.xml
@@ -16,11 +16,10 @@
<com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabs"
- android:layout_width="match_parent"
+ android:layout_width="@dimen/all_apps_header_pills_width"
android:layout_height="@dimen/all_apps_header_pill_height"
+ android:layout_gravity="center_horizontal"
android:background="@drawable/all_apps_tabs_background"
- android:layout_marginLeft="@dimen/all_apps_tabs_side_padding"
- android:layout_marginRight="@dimen/all_apps_tabs_side_padding"
android:orientation="horizontal"
android:elevation="2dp"
style="@style/TextHeadline">
diff --git a/res/layout/secondary_launcher.xml b/res/layout/secondary_launcher.xml
index 94fcdb9..b15a320 100644
--- a/res/layout/secondary_launcher.xml
+++ b/res/layout/secondary_launcher.xml
@@ -71,8 +71,6 @@
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="@dimen/all_apps_header_pill_height"
- android:layout_marginLeft="@dimen/all_apps_tabs_side_padding"
- android:layout_marginRight="@dimen/all_apps_tabs_side_padding"
android:orientation="horizontal"
style="@style/TextHeadline">
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index e605ca8..dc33ab8 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -19,6 +19,7 @@
<!-- Attributes used for launcher theme -->
<attr name="allAppsScrimColor" format="color" />
+ <attr name="allappsHeaderProtectionColor" format="color" />
<attr name="allAppsNavBarScrimColor" format="color" />
<attr name="allAppsTheme" format="reference" />
<attr name="popupColorPrimary" format="color" />
diff --git a/res/values/colors.xml b/res/values/colors.xml
index e6553a2..3d21311 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -17,7 +17,8 @@
** limitations under the License.
*/
-->
-<resources>
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
<!-- The color tints to apply to the text and drag view when hovering
over the delete target or the info target -->
<color name="delete_target_hover_tint">#FFC1C1C1</color>
@@ -58,5 +59,4 @@
<color name="wallpaper_popup_scrim">?android:attr/colorAccent</color>
<color name="wallpaper_scrim_color">#0D878787</color>
-
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 451f82b..bfa02c0 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -91,7 +91,7 @@
<dimen name="all_apps_empty_search_bg_top_offset">144dp</dimen>
<dimen name="all_apps_background_canvas_width">700dp</dimen>
<dimen name="all_apps_background_canvas_height">475dp</dimen>
- <dimen name="all_apps_header_pill_height">36dp</dimen>
+ <dimen name="all_apps_header_pill_height">48dp</dimen>
<dimen name="all_apps_header_pill_corner_radius">18dp</dimen>
<dimen name="all_apps_header_pills_width">320dp</dimen>
<dimen name="all_apps_header_tab_height">48dp</dimen>
@@ -99,7 +99,7 @@
<dimen name="all_apps_header_top_padding">36dp</dimen>
<dimen name="all_apps_work_profile_tab_footer_top_padding">16dp</dimen>
<dimen name="all_apps_work_profile_tab_footer_bottom_padding">20dp</dimen>
- <dimen name="all_apps_tabs_side_padding">32dp</dimen>
+ <dimen name="all_apps_tabs_vertical_padding">6dp</dimen>
<dimen name="all_apps_divider_height">1dp</dimen>
<dimen name="all_apps_tip_bottom_margin">8dp</dimen>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 6d22951..14ec573 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -33,6 +33,7 @@
<style name="LauncherTheme" parent="@style/BaseLauncherTheme">
<item name="android:textColorSecondary">#DE000000</item>
<item name="allAppsScrimColor">?android:attr/colorBackgroundFloating</item>
+ <item name="allappsHeaderProtectionColor">@color/popup_color_tertiary_light</item>
<item name="allAppsNavBarScrimColor">#66FFFFFF</item>
<item name="allAppsTheme">@style/AllAppsTheme</item>
<item name="popupColorPrimary">@color/popup_color_primary_light</item>
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 9df95bf..18de49a 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -127,7 +127,6 @@
private Rect mInsets = new Rect();
private SearchAdapterProvider mSearchAdapterProvider;
- private final int mHeaderTopPadding;
private final int mScrimColor;
private final int mHeaderProtectionColor;
private final float mHeaderThreshold;
@@ -152,9 +151,7 @@
mScrimColor = Themes.getAttrColor(context, R.attr.allAppsScrimColor);
mHeaderThreshold = getResources().getDimensionPixelSize(
R.dimen.dynamic_grid_cell_border_spacing);
- mHeaderTopPadding = context.getResources()
- .getDimensionPixelSize(R.dimen.all_apps_header_top_padding);
- mHeaderProtectionColor = context.getColor(R.color.all_apps_tab_bg);
+ mHeaderProtectionColor = Themes.getAttrColor(context, R.attr.allappsHeaderProtectionColor);
mLauncher.addOnDeviceProfileChangeListener(this);
diff --git a/src/com/android/launcher3/allapps/FloatingHeaderView.java b/src/com/android/launcher3/allapps/FloatingHeaderView.java
index f55ab25..af7896a 100644
--- a/src/com/android/launcher3/allapps/FloatingHeaderView.java
+++ b/src/com/android/launcher3/allapps/FloatingHeaderView.java
@@ -52,6 +52,7 @@
private final Rect mClip = new Rect(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE);
private final ValueAnimator mAnimator = ValueAnimator.ofInt(0, 0);
+ private final ValueAnimator mHeaderAnimator = ValueAnimator.ofInt(0, 1).setDuration(100);
private final Point mTempOffset = new Point();
private final Paint mBGPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private final RecyclerView.OnScrollListener mOnScrollListener =
@@ -132,6 +133,7 @@
}
mFixedRows = rows.toArray(new FloatingHeaderRow[rows.size()]);
mAllRows = mFixedRows;
+ mHeaderAnimator.addUpdateListener(valueAnimator -> invalidate());
}
@Override
@@ -268,7 +270,6 @@
}
} else {
mHeaderCollapsed = false;
- invalidate();
}
mTranslationY = currentScrollY;
} else if (!mHeaderCollapsed) {
@@ -281,7 +282,8 @@
} else if (mTranslationY <= -mMaxTranslation) { // hide or stay hidden
mHeaderCollapsed = true;
mSnappedScrolledY = -mMaxTranslation;
- invalidate();
+ mHeaderAnimator.setCurrentFraction(0);
+ mHeaderAnimator.start();
}
}
}
@@ -296,8 +298,10 @@
@Override
protected void dispatchDraw(Canvas canvas) {
- if (mHeaderCollapsed && mHeaderColor != Color.TRANSPARENT) {
+ if (mHeaderCollapsed && mTabLayout.getVisibility() == VISIBLE
+ && mHeaderColor != Color.TRANSPARENT) {
mBGPaint.setColor(mHeaderColor);
+ mBGPaint.setAlpha((int) (255 * mHeaderAnimator.getAnimatedFraction()));
canvas.drawRect(0, 0, getWidth(), getHeight() + mTranslationY, mBGPaint);
}
super.dispatchDraw(canvas);
diff --git a/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java b/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java
index 8039fd1..c7cbde8 100644
--- a/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java
+++ b/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java
@@ -36,7 +36,7 @@
public class PersonalWorkSlidingTabStrip extends LinearLayout implements PageIndicator {
private final Paint mSelectedIndicatorPaint;
- private int mSelectedIndicatorHeight;
+ private int mTabVerticalPadding;
private final int mSelectedIndicatorRadius;
private int mIndicatorLeft = -1;
@@ -52,8 +52,8 @@
super(context, attrs);
setWillNotDraw(false);
- mSelectedIndicatorHeight =
- getResources().getDimensionPixelSize(R.dimen.all_apps_header_pill_height);
+ mTabVerticalPadding =
+ getResources().getDimensionPixelSize(R.dimen.all_apps_tabs_vertical_padding);
mSelectedIndicatorRadius = getResources().getDimensionPixelSize(
R.dimen.all_apps_header_pill_corner_radius);
@@ -112,9 +112,9 @@
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
- canvas.drawRoundRect(mIndicatorLeft, getHeight() - mSelectedIndicatorHeight,
- mIndicatorRight, getHeight(), mSelectedIndicatorRadius, mSelectedIndicatorRadius,
- mSelectedIndicatorPaint);
+ canvas.drawRoundRect(mIndicatorLeft, mTabVerticalPadding, mIndicatorRight,
+ getHeight() - mTabVerticalPadding, mSelectedIndicatorRadius,
+ mSelectedIndicatorRadius, mSelectedIndicatorPaint);
}
@Override