[WorkProfile] Update work/personal tab to pills
Bug: 186857875
Test: Manual
Screenshot: https://screenshot.googleplex.com/89jD32tHqNkBUWb
Change-Id: Ia4bb91372896d8a53017e3eadbe985878ce7f0ec
diff --git a/res/color/all_apps_tab_text.xml b/res/color/all_apps_tab_text.xml
index f0c6310..0c9acf9 100644
--- a/res/color/all_apps_tab_text.xml
+++ b/res/color/all_apps_tab_text.xml
@@ -14,6 +14,6 @@
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:color="?android:attr/colorAccent" android:state_selected="true"/>
+ <item android:color="@android:color/white" android:state_selected="true"/>
<item android:color="?android:attr/textColorTertiary"/>
</selector>
\ No newline at end of file
diff --git a/res/drawable/all_apps_tabs_background.xml b/res/drawable/all_apps_tabs_background.xml
new file mode 100644
index 0000000..ca2beec
--- /dev/null
+++ b/res/drawable/all_apps_tabs_background.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ Copyright (C) 2021 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 android:shape="rectangle"
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
+ <solid android:color="?androidprv:attr/colorSurfaceVariant" />
+ <corners android:radius="@dimen/all_apps_header_pill_corner_radius" />
+</shape>
\ 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 5fb5bcb..cefd0ab 100644
--- a/res/layout/all_apps_personal_work_tabs.xml
+++ b/res/layout/all_apps_personal_work_tabs.xml
@@ -19,7 +19,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabs"
android:layout_width="match_parent"
- android:layout_height="@dimen/all_apps_header_tab_height"
+ android:layout_height="@dimen/all_apps_header_pill_height"
+ 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"
diff --git a/res/layout/all_apps_tabs.xml b/res/layout/all_apps_tabs.xml
index 2accd2d..de4a69d 100644
--- a/res/layout/all_apps_tabs.xml
+++ b/res/layout/all_apps_tabs.xml
@@ -22,7 +22,7 @@
android:layout_height="match_parent"
android:layout_below="@id/search_container_all_apps"
android:layout_gravity="center_horizontal|top"
- android:layout_marginTop="@dimen/all_apps_header_tab_height"
+ android:layout_marginTop="@dimen/all_apps_header_pill_height"
android:clipChildren="true"
android:clipToPadding="false"
android:descendantFocusability="afterDescendants"
diff --git a/res/layout/secondary_launcher.xml b/res/layout/secondary_launcher.xml
index e3c60ec..94fcdb9 100644
--- a/res/layout/secondary_launcher.xml
+++ b/res/layout/secondary_launcher.xml
@@ -70,7 +70,7 @@
<com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip
android:id="@+id/tabs"
android:layout_width="match_parent"
- android:layout_height="@dimen/all_apps_header_tab_height"
+ 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"
diff --git a/res/layout/widgets_personal_work_tabs.xml b/res/layout/widgets_personal_work_tabs.xml
index 3d3ae6a..3402415 100644
--- a/res/layout/widgets_personal_work_tabs.xml
+++ b/res/layout/widgets_personal_work_tabs.xml
@@ -19,7 +19,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabs"
android:layout_width="match_parent"
- android:layout_height="@dimen/all_apps_header_tab_height"
+ 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"
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index dd14eaa..b967091 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -91,7 +91,8 @@
<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_tab_height">50dp</dimen>
+ <dimen name="all_apps_header_pill_height">50dp</dimen>
+ <dimen name="all_apps_header_pill_corner_radius">50dp</dimen>
<dimen name="all_apps_tabs_indicator_height">2dp</dimen>
<dimen name="all_apps_header_top_padding">36dp</dimen>
<dimen name="all_apps_work_profile_tab_footer_top_padding">16dp</dimen>
diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
index b4d4856..7156953 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
@@ -146,7 +146,7 @@
mAdapters.put(AdapterHolder.SEARCH, new AdapterHolder(AdapterHolder.SEARCH));
mTabsHeight = mHasWorkProfile
? getContext().getResources()
- .getDimensionPixelSize(R.dimen.all_apps_header_tab_height)
+ .getDimensionPixelSize(R.dimen.all_apps_header_pill_height)
: 0;
mWidgetCellHorizontalPadding = 2 * getResources().getDimensionPixelOffset(
R.dimen.widget_cell_horizontal_padding);
diff --git a/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java b/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java
index 3a3028f..b5db8f4 100644
--- a/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java
+++ b/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java
@@ -39,6 +39,8 @@
private final Paint mDividerPaint;
private int mSelectedIndicatorHeight;
+ private final int mSelectedIndicatorRadius;
+
private int mIndicatorLeft = -1;
private int mIndicatorRight = -1;
private float mScrollOffset;
@@ -54,7 +56,10 @@
setWillNotDraw(false);
mSelectedIndicatorHeight =
- getResources().getDimensionPixelSize(R.dimen.all_apps_tabs_indicator_height);
+ getResources().getDimensionPixelSize(R.dimen.all_apps_header_pill_height);
+
+ mSelectedIndicatorRadius = getResources().getDimensionPixelSize(
+ R.dimen.all_apps_header_pill_corner_radius);
mSelectedIndicatorPaint = new Paint();
mSelectedIndicatorPaint.setColor(
@@ -118,9 +123,9 @@
super.onDraw(canvas);
float y = getHeight() - mDividerPaint.getStrokeWidth();
- canvas.drawLine(getPaddingLeft(), y, getWidth() - getPaddingRight(), y, mDividerPaint);
- canvas.drawRect(mIndicatorLeft, getHeight() - mSelectedIndicatorHeight,
- mIndicatorRight, getHeight(), mSelectedIndicatorPaint);
+ canvas.drawRoundRect(mIndicatorLeft, getHeight() - mSelectedIndicatorHeight,
+ mIndicatorRight, getHeight(), mSelectedIndicatorRadius, mSelectedIndicatorRadius,
+ mSelectedIndicatorPaint);
}
@Override
@@ -144,7 +149,8 @@
}
@Override
- public void setMarkersCount(int numMarkers) { }
+ public void setMarkersCount(int numMarkers) {
+ }
@Override
public boolean hasOverlappingRendering() {