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
This commit is contained in:
Sihua Ma 2022-12-07 15:04:04 -08:00
parent 39768edb67
commit 60813a89f7
4 changed files with 17 additions and 4 deletions

View File

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

View File

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

View File

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

View File

@ -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.NonNull;
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 @@ import com.android.launcher3.views.ActivityContext;
* 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 @@ public class PersonalWorkSlidingTabStrip extends LinearLayout implements PageInd
@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);