Merge "Use 32dp as the content margin for widgets pickers in large screen devices" into sc-v2-dev
This commit is contained in:
commit
8d5cd17801
14 files changed
+88
-14
No files matched your search
@@ -37,7 +37,7 @@
|
|||||||
android:id="@+id/add_item_bottom_sheet_content"
|
android:id="@+id/add_item_bottom_sheet_content"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="24dp"
|
android:paddingVertical="24dp"
|
||||||
android:background="@drawable/add_item_dialog_background"
|
android:background="@drawable/add_item_dialog_background"
|
||||||
android:orientation="vertical" >
|
android:orientation="vertical" >
|
||||||
|
|
||||||
@@ -46,6 +46,7 @@
|
|||||||
android:id="@+id/widget_appName"
|
android:id="@+id/widget_appName"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
android:textSize="24sp"
|
android:textSize="24sp"
|
||||||
@@ -55,8 +56,10 @@
|
|||||||
android:maxLines="1" />
|
android:maxLines="1" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/widget_drag_instruction"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:paddingTop="8dp"
|
android:paddingTop="8dp"
|
||||||
android:text="@string/add_item_request_drag_hint"
|
android:text="@string/add_item_request_drag_hint"
|
||||||
@@ -75,12 +78,15 @@
|
|||||||
android:id="@+id/widget_cell"
|
android:id="@+id/widget_cell"
|
||||||
layout="@layout/widget_cell"
|
layout="@layout/widget_cell"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin" />
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/actions_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin"
|
||||||
android:gravity="center_vertical|end"
|
android:gravity="center_vertical|end"
|
||||||
android:paddingVertical="8dp"
|
android:paddingVertical="8dp"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
<include layout="@layout/widgets_table_container"
|
<include layout="@layout/widgets_table_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin"
|
||||||
android:layout_gravity="center_horizontal" />
|
android:layout_gravity="center_horizontal" />
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -57,6 +57,7 @@
|
|||||||
android:id="@+id/search_widgets_list_view"
|
android:id="@+id/search_widgets_list_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:clipToPadding="false" />
|
android:clipToPadding="false" />
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
android:id="@+id/widgets_view_pager"
|
android:id="@+id/widgets_view_pager"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:paddingTop="@dimen/widget_picker_view_pager_top_padding"
|
android:paddingTop="@dimen/widget_picker_view_pager_top_padding"
|
||||||
android:descendantFocusability="afterDescendants"
|
android:descendantFocusability="afterDescendants"
|
||||||
|
|||||||
@@ -18,4 +18,5 @@
|
|||||||
android:id="@+id/primary_widgets_list_view"
|
android:id="@+id/primary_widgets_list_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin"
|
||||||
android:clipToPadding="false" />
|
android:clipToPadding="false" />
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
android:id="@+id/search_and_recommendations_container"
|
android:id="@+id/search_and_recommendations_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin"
|
||||||
android:layout_marginBottom="16dp"
|
android:layout_marginBottom="16dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
@@ -53,7 +54,6 @@
|
|||||||
android:id="@+id/recommended_widget_table"
|
android:id="@+id/recommended_widget_table"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin"
|
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:background="@drawable/widgets_recommendation_background"
|
android:background="@drawable/widgets_recommendation_background"
|
||||||
android:paddingVertical="@dimen/recommended_widgets_table_vertical_padding"
|
android:paddingVertical="@dimen/recommended_widgets_table_vertical_padding"
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
android:id="@+id/widgets_list_header"
|
android:id="@+id/widgets_list_header"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin"
|
|
||||||
android:paddingVertical="@dimen/widget_list_header_view_vertical_padding"
|
android:paddingVertical="@dimen/widget_list_header_view_vertical_padding"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
launcher:appIconSize="48dp">
|
launcher:appIconSize="48dp">
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="24dp"
|
||||||
android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin"
|
|
||||||
android:background="@drawable/bg_widgets_searchbox">
|
android:background="@drawable/bg_widgets_searchbox">
|
||||||
|
|
||||||
<com.android.launcher3.ExtendedEditText
|
<com.android.launcher3.ExtendedEditText
|
||||||
|
|||||||
@@ -17,5 +17,4 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/widgets_table"
|
android:id="@+id/widgets_table"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content" />
|
||||||
android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin" />
|
|
||||||
@@ -17,4 +17,7 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<!-- DragController -->
|
<!-- DragController -->
|
||||||
<dimen name="drag_flingToDeleteMinVelocity">-1000dp</dimen>
|
<dimen name="drag_flingToDeleteMinVelocity">-1000dp</dimen>
|
||||||
|
|
||||||
|
<!-- Widgets pickers -->
|
||||||
|
<dimen name="widget_list_horizontal_margin">32dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -49,6 +49,8 @@ public class AddItemWidgetsBottomSheet extends AbstractSlideInView<AddItemActivi
|
|||||||
private final Rect mInsets;
|
private final Rect mInsets;
|
||||||
private ScrollView mWidgetPreviewScrollView;
|
private ScrollView mWidgetPreviewScrollView;
|
||||||
|
|
||||||
|
private int mContentHorizontalMarginInPx;
|
||||||
|
|
||||||
public AddItemWidgetsBottomSheet(Context context, AttributeSet attrs) {
|
public AddItemWidgetsBottomSheet(Context context, AttributeSet attrs) {
|
||||||
this(context, attrs, 0);
|
this(context, attrs, 0);
|
||||||
}
|
}
|
||||||
@@ -56,6 +58,8 @@ public class AddItemWidgetsBottomSheet extends AbstractSlideInView<AddItemActivi
|
|||||||
public AddItemWidgetsBottomSheet(Context context, AttributeSet attrs, int defStyleAttr) {
|
public AddItemWidgetsBottomSheet(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
super(context, attrs, defStyleAttr);
|
super(context, attrs, defStyleAttr);
|
||||||
mInsets = new Rect();
|
mInsets = new Rect();
|
||||||
|
mContentHorizontalMarginInPx = getResources().getDimensionPixelSize(
|
||||||
|
R.dimen.widget_list_horizontal_margin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -173,6 +177,26 @@ public class AddItemWidgetsBottomSheet extends AbstractSlideInView<AddItemActivi
|
|||||||
}
|
}
|
||||||
mContent.setPadding(mContent.getPaddingStart(),
|
mContent.setPadding(mContent.getPaddingStart(),
|
||||||
mContent.getPaddingTop(), mContent.getPaddingEnd(), mInsets.bottom);
|
mContent.getPaddingTop(), mContent.getPaddingEnd(), mInsets.bottom);
|
||||||
|
|
||||||
|
int contentHorizontalMarginInPx = getResources().getDimensionPixelSize(
|
||||||
|
R.dimen.widget_list_horizontal_margin);
|
||||||
|
if (contentHorizontalMarginInPx != mContentHorizontalMarginInPx) {
|
||||||
|
setContentHorizontalMargin(findViewById(R.id.widget_appName),
|
||||||
|
contentHorizontalMarginInPx);
|
||||||
|
setContentHorizontalMargin(findViewById(R.id.widget_drag_instruction),
|
||||||
|
contentHorizontalMarginInPx);
|
||||||
|
setContentHorizontalMargin(findViewById(R.id.widget_cell), contentHorizontalMarginInPx);
|
||||||
|
setContentHorizontalMargin(findViewById(R.id.actions_container),
|
||||||
|
contentHorizontalMarginInPx);
|
||||||
|
mContentHorizontalMarginInPx = contentHorizontalMarginInPx;
|
||||||
|
}
|
||||||
return windowInsets;
|
return windowInsets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void setContentHorizontalMargin(View view, int contentHorizontalMargin) {
|
||||||
|
ViewGroup.MarginLayoutParams layoutParams =
|
||||||
|
((ViewGroup.MarginLayoutParams) view.getLayoutParams());
|
||||||
|
layoutParams.setMarginStart(contentHorizontalMargin);
|
||||||
|
layoutParams.setMarginEnd(contentHorizontalMargin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -66,8 +66,12 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView<Launcher>
|
|||||||
/* Touch handling related member variables. */
|
/* Touch handling related member variables. */
|
||||||
private Toast mWidgetInstructionToast;
|
private Toast mWidgetInstructionToast;
|
||||||
|
|
||||||
|
private int mContentHorizontalMarginInPx;
|
||||||
|
|
||||||
public BaseWidgetSheet(Context context, AttributeSet attrs, int defStyleAttr) {
|
public BaseWidgetSheet(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
super(context, attrs, defStyleAttr);
|
super(context, attrs, defStyleAttr);
|
||||||
|
mContentHorizontalMarginInPx = getResources().getDimensionPixelSize(
|
||||||
|
R.dimen.widget_list_horizontal_margin);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getScrimColor(Context context) {
|
protected int getScrimColor(Context context) {
|
||||||
@@ -119,8 +123,16 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView<Launcher>
|
|||||||
@Override
|
@Override
|
||||||
public void setInsets(Rect insets) {
|
public void setInsets(Rect insets) {
|
||||||
mInsets.set(insets);
|
mInsets.set(insets);
|
||||||
|
int contentHorizontalMarginInPx = getResources().getDimensionPixelSize(
|
||||||
|
R.dimen.widget_list_horizontal_margin);
|
||||||
|
if (contentHorizontalMarginInPx != mContentHorizontalMarginInPx) {
|
||||||
|
onContentHorizontalMarginChanged(contentHorizontalMarginInPx);
|
||||||
|
mContentHorizontalMarginInPx = contentHorizontalMarginInPx;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Called when the horizontal margin of the content view has changed. */
|
||||||
|
protected abstract void onContentHorizontalMarginChanged(int contentHorizontalMarginInPx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Measures the dimension of this view and its children by taking system insets, navigation bar,
|
* Measures the dimension of this view and its children by taking system insets, navigation bar,
|
||||||
|
|||||||
@@ -70,11 +70,10 @@ public class WidgetsBottomSheet extends BaseWidgetSheet {
|
|||||||
private static final int DEFAULT_CLOSE_DURATION = 200;
|
private static final int DEFAULT_CLOSE_DURATION = 200;
|
||||||
private static final long EDUCATION_TIP_DELAY_MS = 300;
|
private static final long EDUCATION_TIP_DELAY_MS = 300;
|
||||||
|
|
||||||
private final int mWidgetSheetContentHorizontalPadding;
|
|
||||||
|
|
||||||
private ItemInfo mOriginalItemInfo;
|
private ItemInfo mOriginalItemInfo;
|
||||||
private final int mMaxTableHeight;
|
private final int mMaxTableHeight;
|
||||||
private int mMaxHorizontalSpan = DEFAULT_MAX_HORIZONTAL_SPANS;
|
private int mMaxHorizontalSpan = DEFAULT_MAX_HORIZONTAL_SPANS;
|
||||||
|
private final int mWidgetCellHorizontalPadding;
|
||||||
|
|
||||||
private final OnLayoutChangeListener mLayoutChangeListenerToShowTips =
|
private final OnLayoutChangeListener mLayoutChangeListenerToShowTips =
|
||||||
new OnLayoutChangeListener() {
|
new OnLayoutChangeListener() {
|
||||||
@@ -119,9 +118,8 @@ public class WidgetsBottomSheet extends BaseWidgetSheet {
|
|||||||
if (!hasSeenEducationTip()) {
|
if (!hasSeenEducationTip()) {
|
||||||
addOnLayoutChangeListener(mLayoutChangeListenerToShowTips);
|
addOnLayoutChangeListener(mLayoutChangeListenerToShowTips);
|
||||||
}
|
}
|
||||||
|
mWidgetCellHorizontalPadding = getResources().getDimensionPixelSize(
|
||||||
mWidgetSheetContentHorizontalPadding = getResources().getDimensionPixelSize(
|
R.dimen.widget_cell_horizontal_padding);
|
||||||
R.dimen.widget_list_horizontal_margin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -142,8 +140,7 @@ public class WidgetsBottomSheet extends BaseWidgetSheet {
|
|||||||
private boolean updateMaxSpansPerRow() {
|
private boolean updateMaxSpansPerRow() {
|
||||||
if (getMeasuredWidth() == 0) return false;
|
if (getMeasuredWidth() == 0) return false;
|
||||||
|
|
||||||
int maxHorizontalSpan = computeMaxHorizontalSpans(mContent,
|
int maxHorizontalSpan = computeMaxHorizontalSpans(mContent, mWidgetCellHorizontalPadding);
|
||||||
mWidgetSheetContentHorizontalPadding);
|
|
||||||
if (mMaxHorizontalSpan != maxHorizontalSpan) {
|
if (mMaxHorizontalSpan != maxHorizontalSpan) {
|
||||||
// Ensure the table layout is showing widgets in the right column after measure.
|
// Ensure the table layout is showing widgets in the right column after measure.
|
||||||
mMaxHorizontalSpan = maxHorizontalSpan;
|
mMaxHorizontalSpan = maxHorizontalSpan;
|
||||||
@@ -274,6 +271,14 @@ public class WidgetsBottomSheet extends BaseWidgetSheet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onContentHorizontalMarginChanged(int contentHorizontalMarginInPx) {
|
||||||
|
ViewGroup.MarginLayoutParams layoutParams =
|
||||||
|
((ViewGroup.MarginLayoutParams) findViewById(R.id.widgets_table).getLayoutParams());
|
||||||
|
layoutParams.setMarginStart(contentHorizontalMarginInPx);
|
||||||
|
layoutParams.setMarginEnd(contentHorizontalMarginInPx);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Pair<View, String> getAccessibilityTarget() {
|
protected Pair<View, String> getAccessibilityTarget() {
|
||||||
return Pair.create(findViewById(R.id.title), getContext().getString(
|
return Pair.create(findViewById(R.id.title), getContext().getString(
|
||||||
|
|||||||
@@ -358,6 +358,29 @@ public class WidgetsFullSheet extends BaseWidgetSheet
|
|||||||
bottomPadding);
|
bottomPadding);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onContentHorizontalMarginChanged(int contentHorizontalMarginInPx) {
|
||||||
|
setContentViewChildHorizontalMargin(mSearchAndRecommendationViewHolder.mContainer,
|
||||||
|
contentHorizontalMarginInPx);
|
||||||
|
if (mViewPager == null) {
|
||||||
|
setContentViewChildHorizontalMargin(
|
||||||
|
mAdapters.get(AdapterHolder.PRIMARY).mWidgetsRecyclerView,
|
||||||
|
contentHorizontalMarginInPx);
|
||||||
|
} else {
|
||||||
|
setContentViewChildHorizontalMargin(mViewPager, contentHorizontalMarginInPx);
|
||||||
|
}
|
||||||
|
setContentViewChildHorizontalMargin(
|
||||||
|
mAdapters.get(AdapterHolder.SEARCH).mWidgetsRecyclerView,
|
||||||
|
contentHorizontalMarginInPx);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setContentViewChildHorizontalMargin(View view, int horizontalMarginInPx) {
|
||||||
|
ViewGroup.MarginLayoutParams layoutParams =
|
||||||
|
(ViewGroup.MarginLayoutParams) view.getLayoutParams();
|
||||||
|
layoutParams.setMarginStart(horizontalMarginInPx);
|
||||||
|
layoutParams.setMarginEnd(horizontalMarginInPx);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
doMeasure(widthMeasureSpec, heightMeasureSpec);
|
doMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
|
|||||||
Reference in new issue
Block a user