Changed widget picker personal-work tab layout
Used layout margin instead of padding. Also making sure that Talkback would focus on the widgets title once the widget picker is opened.
Before: https://screenshot.googleplex.com/AgZspqTc7yS2Lte
Now: https://screenshot.googleplex.com/5W66ky7XAByCFRZ
Fix: 247121867
Test: Manual
Change-Id: I76534454754c5e57ab51ae7ce06ca4370a3fd22b
diff --git a/res/layout/all_apps_personal_work_tabs.xml b/res/layout/all_apps_personal_work_tabs.xml
index 4459c87..e04b207 100644
--- a/res/layout/all_apps_personal_work_tabs.xml
+++ b/res/layout/all_apps_personal_work_tabs.xml
@@ -16,6 +16,7 @@
<com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:launcher="http://schemas.android.com/apk/res-auto"
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="@dimen/all_apps_header_pill_height"
@@ -24,7 +25,8 @@
android:paddingBottom="@dimen/all_apps_tabs_vertical_padding"
android:layout_marginTop="@dimen/all_apps_tabs_margin_top"
android:orientation="horizontal"
- style="@style/TextHeadline">
+ style="@style/TextHeadline"
+ launcher:alignOnIcon="true">
<Button
android:id="@+id/tab_personal"
diff --git a/res/layout/widgets_full_sheet_paged_view.xml b/res/layout/widgets_full_sheet_paged_view.xml
index 098c9b0..3635c73 100644
--- a/res/layout/widgets_full_sheet_paged_view.xml
+++ b/res/layout/widgets_full_sheet_paged_view.xml
@@ -89,8 +89,7 @@
android:gravity="center_horizontal"
android:orientation="horizontal"
android:paddingVertical="8dp"
- android:paddingLeft="@dimen/widget_tabs_horizontal_padding"
- android:paddingRight="@dimen/widget_tabs_horizontal_padding"
+ android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin"
android:background="?android:attr/colorBackground"
style="@style/TextHeadline"
launcher:layout_sticky="true">
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index f270b10..9847284 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -214,6 +214,10 @@
<attr name="c" format="float|dimension" />
</declare-styleable>
+ <declare-styleable name="PersonalWorkSlidingTabStrip">
+ <attr name="alignOnIcon" format="boolean" />
+ </declare-styleable>
+
<declare-styleable name="ProfileDisplayOption">
<attr name="name" />
<attr name="minWidthDps" format="float" />
diff --git a/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java b/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java
index 49db2a0..e94f3a0 100644
--- a/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java
+++ b/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java
@@ -16,6 +16,7 @@
package com.android.launcher3.workprofile;
import android.content.Context;
+import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.Button;
import android.widget.LinearLayout;
@@ -24,6 +25,7 @@
import androidx.annotation.Nullable;
import com.android.launcher3.DeviceProfile;
+import com.android.launcher3.R;
import com.android.launcher3.pageindicators.PageIndicator;
import com.android.launcher3.views.ActivityContext;
@@ -31,11 +33,17 @@
* Supports two indicator colors, dedicated for personal and work tabs.
*/
public class PersonalWorkSlidingTabStrip extends LinearLayout implements PageIndicator {
+ private final boolean mIsAlignOnIcon;
private OnActivePageChangedListener mOnActivePageChangedListener;
private int mLastActivePage = 0;
public PersonalWorkSlidingTabStrip(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
+ TypedArray typedArray = context.obtainStyledAttributes(attrs,
+ R.styleable.PersonalWorkSlidingTabStrip);
+ mIsAlignOnIcon = typedArray.getBoolean(
+ R.styleable.PersonalWorkSlidingTabStrip_alignOnIcon, false);
+ typedArray.recycle();
}
/**
@@ -76,7 +84,7 @@
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- if (getPaddingLeft() == 0 && getPaddingRight() == 0) {
+ if (mIsAlignOnIcon) {
// If any padding is not specified, restrict the width to emulate padding
int size = MeasureSpec.getSize(widthMeasureSpec);
size = getTabWidth(getContext(), size);