diff --git a/res/layout/add_item_confirmation_activity.xml b/res/layout/add_item_confirmation_activity.xml index c57b75a813..e29e1b1fef 100644 --- a/res/layout/add_item_confirmation_activity.xml +++ b/res/layout/add_item_confirmation_activity.xml @@ -37,7 +37,7 @@ android:id="@+id/add_item_bottom_sheet_content" android:layout_width="match_parent" android:layout_height="wrap_content" - android:padding="24dp" + android:paddingVertical="24dp" android:background="@drawable/add_item_dialog_background" android:orientation="vertical" > @@ -46,6 +46,7 @@ android:id="@+id/widget_appName" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin" android:gravity="center_horizontal" android:textColor="?android:attr/textColorPrimary" android:textSize="24sp" @@ -55,8 +56,10 @@ android:maxLines="1" /> + android:layout_height="wrap_content" + android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin" /> diff --git a/res/layout/widgets_bottom_sheet_content.xml b/res/layout/widgets_bottom_sheet_content.xml index 3b3ff8b426..3d330dce85 100644 --- a/res/layout/widgets_bottom_sheet_content.xml +++ b/res/layout/widgets_bottom_sheet_content.xml @@ -47,6 +47,7 @@ diff --git a/res/layout/widgets_full_sheet.xml b/res/layout/widgets_full_sheet.xml index 1b4f3b984e..96b73c2ce5 100644 --- a/res/layout/widgets_full_sheet.xml +++ b/res/layout/widgets_full_sheet.xml @@ -57,6 +57,7 @@ android:id="@+id/search_widgets_list_view" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin" android:visibility="gone" android:clipToPadding="false" /> diff --git a/res/layout/widgets_full_sheet_paged_view.xml b/res/layout/widgets_full_sheet_paged_view.xml index f0ddc2bb66..fefad19ae3 100644 --- a/res/layout/widgets_full_sheet_paged_view.xml +++ b/res/layout/widgets_full_sheet_paged_view.xml @@ -20,6 +20,7 @@ android:id="@+id/widgets_view_pager" android:layout_width="match_parent" android:layout_height="match_parent" + android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin" android:clipToPadding="false" android:paddingTop="@dimen/widget_picker_view_pager_top_padding" android:descendantFocusability="afterDescendants" diff --git a/res/layout/widgets_full_sheet_recyclerview.xml b/res/layout/widgets_full_sheet_recyclerview.xml index fbe559c663..0f7e020114 100644 --- a/res/layout/widgets_full_sheet_recyclerview.xml +++ b/res/layout/widgets_full_sheet_recyclerview.xml @@ -18,4 +18,5 @@ android:id="@+id/primary_widgets_list_view" android:layout_width="match_parent" android:layout_height="match_parent" + android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin" android:clipToPadding="false" /> \ No newline at end of file diff --git a/res/layout/widgets_full_sheet_search_and_recommendations.xml b/res/layout/widgets_full_sheet_search_and_recommendations.xml index 4a3e20d8ba..938c8ed2c2 100644 --- a/res/layout/widgets_full_sheet_search_and_recommendations.xml +++ b/res/layout/widgets_full_sheet_search_and_recommendations.xml @@ -18,6 +18,7 @@ android:id="@+id/search_and_recommendations_container" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin" android:layout_marginBottom="16dp" android:orientation="vertical"> @@ -53,7 +54,6 @@ android:id="@+id/recommended_widget_table" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin" android:layout_marginTop="8dp" android:background="@drawable/widgets_recommendation_background" android:paddingVertical="@dimen/recommended_widgets_table_vertical_padding" diff --git a/res/layout/widgets_list_row_header.xml b/res/layout/widgets_list_row_header.xml index 7f84050a47..8f0eae7ed3 100644 --- a/res/layout/widgets_list_row_header.xml +++ b/res/layout/widgets_list_row_header.xml @@ -19,7 +19,6 @@ android:id="@+id/widgets_list_header" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin" android:paddingVertical="@dimen/widget_list_header_view_vertical_padding" android:orientation="horizontal" launcher:appIconSize="48dp"> diff --git a/res/layout/widgets_search_bar.xml b/res/layout/widgets_search_bar.xml index cb27f4fb6f..9178a75076 100644 --- a/res/layout/widgets_search_bar.xml +++ b/res/layout/widgets_search_bar.xml @@ -6,7 +6,6 @@ android:layout_height="wrap_content" android:orientation="horizontal" android:layout_marginTop="24dp" - android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin" android:background="@drawable/bg_widgets_searchbox"> + android:layout_height="wrap_content" /> diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml index 47a88f2263..3727932676 100644 --- a/res/values-sw600dp/dimens.xml +++ b/res/values-sw600dp/dimens.xml @@ -17,4 +17,7 @@ -1000dp + + + 32dp diff --git a/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java b/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java index b92c476e5a..d2d569f79f 100644 --- a/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java +++ b/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java @@ -49,6 +49,8 @@ public class AddItemWidgetsBottomSheet extends AbstractSlideInView /* Touch handling related member variables. */ private Toast mWidgetInstructionToast; + private int mContentHorizontalMarginInPx; + public BaseWidgetSheet(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); + mContentHorizontalMarginInPx = getResources().getDimensionPixelSize( + R.dimen.widget_list_horizontal_margin); } protected int getScrimColor(Context context) { @@ -119,8 +123,16 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView @Override public void setInsets(Rect 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, diff --git a/src/com/android/launcher3/widget/WidgetsBottomSheet.java b/src/com/android/launcher3/widget/WidgetsBottomSheet.java index 406de10809..6beff3a30e 100644 --- a/src/com/android/launcher3/widget/WidgetsBottomSheet.java +++ b/src/com/android/launcher3/widget/WidgetsBottomSheet.java @@ -70,11 +70,10 @@ public class WidgetsBottomSheet extends BaseWidgetSheet { private static final int DEFAULT_CLOSE_DURATION = 200; private static final long EDUCATION_TIP_DELAY_MS = 300; - private final int mWidgetSheetContentHorizontalPadding; - private ItemInfo mOriginalItemInfo; private final int mMaxTableHeight; private int mMaxHorizontalSpan = DEFAULT_MAX_HORIZONTAL_SPANS; + private final int mWidgetCellHorizontalPadding; private final OnLayoutChangeListener mLayoutChangeListenerToShowTips = new OnLayoutChangeListener() { @@ -119,9 +118,8 @@ public class WidgetsBottomSheet extends BaseWidgetSheet { if (!hasSeenEducationTip()) { addOnLayoutChangeListener(mLayoutChangeListenerToShowTips); } - - mWidgetSheetContentHorizontalPadding = getResources().getDimensionPixelSize( - R.dimen.widget_list_horizontal_margin); + mWidgetCellHorizontalPadding = getResources().getDimensionPixelSize( + R.dimen.widget_cell_horizontal_padding); } @Override @@ -142,8 +140,7 @@ public class WidgetsBottomSheet extends BaseWidgetSheet { private boolean updateMaxSpansPerRow() { if (getMeasuredWidth() == 0) return false; - int maxHorizontalSpan = computeMaxHorizontalSpans(mContent, - mWidgetSheetContentHorizontalPadding); + int maxHorizontalSpan = computeMaxHorizontalSpans(mContent, mWidgetCellHorizontalPadding); if (mMaxHorizontalSpan != maxHorizontalSpan) { // Ensure the table layout is showing widgets in the right column after measure. 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 protected Pair getAccessibilityTarget() { return Pair.create(findViewById(R.id.title), getContext().getString( diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java index e4ce27c491..e36ea905bc 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java +++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java @@ -358,6 +358,29 @@ public class WidgetsFullSheet extends BaseWidgetSheet 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 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { doMeasure(widthMeasureSpec, heightMeasureSpec);