[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
This commit is contained in:
Samuel Fufa 2021-05-18 16:15:46 -05:00
parent b605d1d73c
commit 76b33404b5
10 changed files with 32 additions and 27 deletions

View File

@ -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>
<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>

View File

@ -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">

View File

@ -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">

View File

@ -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" />

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -127,7 +127,6 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
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 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
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);

View File

@ -52,6 +52,7 @@ public class FloatingHeaderView extends LinearLayout implements
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 @@ public class FloatingHeaderView extends LinearLayout implements
}
mFixedRows = rows.toArray(new FloatingHeaderRow[rows.size()]);
mAllRows = mFixedRows;
mHeaderAnimator.addUpdateListener(valueAnimator -> invalidate());
}
@Override
@ -268,7 +270,6 @@ public class FloatingHeaderView extends LinearLayout implements
}
} else {
mHeaderCollapsed = false;
invalidate();
}
mTranslationY = currentScrollY;
} else if (!mHeaderCollapsed) {
@ -281,7 +282,8 @@ public class FloatingHeaderView extends LinearLayout implements
} else if (mTranslationY <= -mMaxTranslation) { // hide or stay hidden
mHeaderCollapsed = true;
mSnappedScrolledY = -mMaxTranslation;
invalidate();
mHeaderAnimator.setCurrentFraction(0);
mHeaderAnimator.start();
}
}
}
@ -296,8 +298,10 @@ public class FloatingHeaderView extends LinearLayout implements
@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);

View File

@ -36,7 +36,7 @@ import com.android.launcher3.pageindicators.PageIndicator;
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 @@ public class PersonalWorkSlidingTabStrip extends LinearLayout implements PageInd
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 @@ public class PersonalWorkSlidingTabStrip extends LinearLayout implements PageInd
@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