Merge "Tune Overview size according to VisD" into sc-v2-dev
diff --git a/quickstep/res/values/colors.xml b/quickstep/res/values/colors.xml
index 167c7c3..2f24441 100644
--- a/quickstep/res/values/colors.xml
+++ b/quickstep/res/values/colors.xml
@@ -26,6 +26,6 @@
<color name="all_apps_prediction_row_separator_dark">#3cffffff</color>
<!-- Taskbar -->
- <color name="taskbar_background">#101010</color>
+ <color name="taskbar_background">@color/overview_scrim_dark</color>
<color name="taskbar_icon_selection_ripple">#E0E0E0</color>
</resources>
\ No newline at end of file
diff --git a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java
index 370fb8e..6cfbf62 100644
--- a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java
+++ b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java
@@ -125,6 +125,10 @@
* If we're launching and app and should not be blurring the screen for performance reasons.
*/
private boolean mBlurDisabledForAppLaunch;
+ /**
+ * If we requested early wake-up offsets to SurfaceFlinger.
+ */
+ private boolean mInEarlyWakeUp;
// Workaround for animating the depth when multiwindow mode changes.
private boolean mIgnoreStateChangesDuringMultiWindowAnimation = false;
@@ -270,10 +274,21 @@
int blur = opaque || isOverview || !mCrossWindowBlursEnabled
|| mBlurDisabledForAppLaunch ? 0 : (int) (depth * mMaxBlurRadius);
- new SurfaceControl.Transaction()
+ SurfaceControl.Transaction transaction = new SurfaceControl.Transaction()
.setBackgroundBlurRadius(mSurface, blur)
- .setOpaque(mSurface, opaque)
- .apply();
+ .setOpaque(mSurface, opaque);
+
+ // Set early wake-up flags when we know we're executing an expensive operation, this way
+ // SurfaceFlinger will adjust its internal offsets to avoid jank.
+ boolean wantsEarlyWakeUp = depth > 0 && depth < 1;
+ if (wantsEarlyWakeUp && !mInEarlyWakeUp) {
+ transaction.setEarlyWakeupStart();
+ mInEarlyWakeUp = true;
+ } else if (!wantsEarlyWakeUp && mInEarlyWakeUp) {
+ transaction.setEarlyWakeupEnd();
+ mInEarlyWakeUp = false;
+ }
+ transaction.apply();
}
return true;
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
index be3f5d9..08300e2 100644
--- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
@@ -166,15 +166,14 @@
private void initButtons(ViewGroup navContainer, ViewGroup endContainer,
TaskbarNavButtonController navButtonController) {
- // Hide when keyguard is showing, show when bouncer is showing
- mPropertyHolders.add(new StatePropertyHolder(mBackButton,
- flags -> (flags & FLAG_KEYGUARD_VISIBLE) == 0 ||
- (flags & FLAG_ONLY_BACK_FOR_BOUNCER_VISIBLE) != 0));
-
mBackButton = addButton(R.drawable.ic_sysbar_back, BUTTON_BACK,
mNavButtonContainer, mControllers.navButtonController, R.id.back);
mPropertyHolders.add(new StatePropertyHolder(mBackButton,
flags -> (flags & FLAG_IME_VISIBLE) == 0));
+ // Hide when keyguard is showing, show when bouncer is showing
+ mPropertyHolders.add(new StatePropertyHolder(mBackButton,
+ flags -> (flags & FLAG_KEYGUARD_VISIBLE) == 0 ||
+ (flags & FLAG_ONLY_BACK_FOR_BOUNCER_VISIBLE) != 0));
// home and recents buttons
View homeButton = addButton(R.drawable.ic_sysbar_home, BUTTON_HOME, navContainer,
diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
index 742d02d..89c2ed8 100644
--- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
+++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
@@ -15,7 +15,6 @@
*/
package com.android.quickstep;
-import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.quickstep.util.ActiveGestureLog.INTENT_EXTRA_LOG_TRACE_ID;
@@ -199,6 +198,12 @@
public void onRecentsAnimationCanceled(ThumbnailData thumbnailData) {
interactionHandler.onGestureCancelled();
cmd.removeListener(this);
+
+ RecentsView createdRecents =
+ activityInterface.getCreatedActivity().getOverviewPanel();
+ if (createdRecents != null) {
+ createdRecents.onRecentsAnimationComplete();
+ }
}
};
diff --git a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
index de79372..540a9ca 100644
--- a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
+++ b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
@@ -24,6 +24,7 @@
import android.annotation.TargetApi;
import android.app.ActivityManager.RunningTaskInfo;
import android.content.Context;
+import android.content.res.Configuration;
import android.os.Build;
import android.util.AttributeSet;
import android.view.MotionEvent;
@@ -36,11 +37,10 @@
import com.android.quickstep.FallbackActivityInterface;
import com.android.quickstep.GestureState;
import com.android.quickstep.RecentsActivity;
-import com.android.quickstep.util.TaskViewSimulator;
import com.android.quickstep.util.SplitSelectStateController;
+import com.android.quickstep.util.TaskViewSimulator;
import com.android.quickstep.views.OverviewActionsView;
import com.android.quickstep.views.RecentsView;
-import com.android.quickstep.views.SplitPlaceholderView;
import com.android.quickstep.views.TaskView;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.recents.model.Task.TaskKey;
@@ -184,6 +184,7 @@
} else {
if (mActivity.isInState(RecentsState.MODAL_TASK)) {
mActivity.getStateManager().goToState(DEFAULT);
+ resetModalVisuals();
}
}
}
@@ -221,4 +222,12 @@
// Do not let touch escape to siblings below this view.
return result || mActivity.getStateManager().getState().overviewUi();
}
+
+ @Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+
+ // Reset modal state if full configuration changes
+ setModalStateEnabled(false);
+ }
}
diff --git a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
index 152c2bd..6b2d19c 100644
--- a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
@@ -227,6 +227,7 @@
} else {
if (mActivity.isInState(LauncherState.OVERVIEW_MODAL_TASK)) {
mActivity.getStateManager().goToState(LauncherState.OVERVIEW);
+ resetModalVisuals();
}
}
}
@@ -254,9 +255,6 @@
super.onConfigurationChanged(newConfig);
// If overview is in modal state when rotate, reset it to overview state without running
// animation.
- if (mActivity.isInState(OVERVIEW_MODAL_TASK)) {
- mActivity.getStateManager().goToState(LauncherState.OVERVIEW, false);
- resetModalVisuals();
- }
+ setModalStateEnabled(false);
}
}
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index f26fc89..d00db2d 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -1379,6 +1379,7 @@
|| !mOrientationHandler.equals(oldOrientationHandler)) {
// Changed orientations, update controllers so they intercept accordingly.
mActivity.getDragLayer().recreateControllers();
+ setModalStateEnabled(false);
}
boolean isInLandscape = mOrientationState.getTouchRotation() != ROTATION_0
@@ -1838,7 +1839,7 @@
public void onGestureAnimationEnd() {
mGestureActive = false;
if (mOrientationState.setGestureActive(false)) {
- updateOrientationHandler();
+ updateOrientationHandler(/* forceRecreateDragLayerControllers = */ false);
}
setEnableFreeScroll(true);
diff --git a/res/drawable-v31/bg_deferred_app_widget.xml b/res/drawable-v31/bg_deferred_app_widget.xml
new file mode 100644
index 0000000..a08998d
--- /dev/null
+++ b/res/drawable-v31/bg_deferred_app_widget.xml
@@ -0,0 +1,23 @@
+<?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.
+-->
+<inset xmlns:android="http://schemas.android.com/apk/res/android"
+ android:inset="8dp">
+ <shape android:shape="rectangle">
+ <corners android:radius="@android:dimen/system_app_widget_background_radius" />
+ <solid android:color="#77000000" />
+ </shape>
+</inset>
diff --git a/res/layout/add_item_confirmation_activity.xml b/res/layout/add_item_confirmation_activity.xml
index c57b75a..e29e1b1 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" />
<TextView
+ android:id="@+id/widget_drag_instruction"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin"
android:gravity="center_horizontal"
android:paddingTop="8dp"
android:text="@string/add_item_request_drag_hint"
@@ -75,12 +78,15 @@
android:id="@+id/widget_cell"
layout="@layout/widget_cell"
android:layout_width="match_parent"
- android:layout_height="wrap_content" />
+ android:layout_height="wrap_content"
+ android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin" />
</ScrollView>
<LinearLayout
+ android:id="@+id/actions_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin"
android:gravity="center_vertical|end"
android:paddingVertical="8dp"
android:orientation="horizontal">
diff --git a/res/layout/widgets_bottom_sheet_content.xml b/res/layout/widgets_bottom_sheet_content.xml
index 3b3ff8b..3d330dc 100644
--- a/res/layout/widgets_bottom_sheet_content.xml
+++ b/res/layout/widgets_bottom_sheet_content.xml
@@ -47,6 +47,7 @@
<include layout="@layout/widgets_table_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin"
android:layout_gravity="center_horizontal" />
</ScrollView>
</LinearLayout>
diff --git a/res/layout/widgets_full_sheet.xml b/res/layout/widgets_full_sheet.xml
index 1b4f3b9..96b73c2 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 f0ddc2b..fefad19 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 fbe559c..0f7e020 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 4a3e20d..938c8ed 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 7f84050..8f0eae7 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 cb27f4f..9178a75 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">
<com.android.launcher3.ExtendedEditText
diff --git a/res/layout/widgets_table_container.xml b/res/layout/widgets_table_container.xml
index ab470d8..ab96b1343 100644
--- a/res/layout/widgets_table_container.xml
+++ b/res/layout/widgets_table_container.xml
@@ -17,5 +17,4 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widgets_table"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin" />
+ android:layout_height="wrap_content" />
diff --git a/res/values-hi/strings.xml b/res/values-hi/strings.xml
index e231074..53640fe 100644
--- a/res/values-hi/strings.xml
+++ b/res/values-hi/strings.xml
@@ -71,7 +71,7 @@
<string name="all_apps_button_label" msgid="8130441508702294465">"ऐप्लिकेशन सूची"</string>
<string name="all_apps_button_personal_label" msgid="1315764287305224468">"निजी ऐप्लिकेशन की सूची"</string>
<string name="all_apps_button_work_label" msgid="7270707118948892488">"काम से जुड़े ऐप्लिकेशन की सूची"</string>
- <string name="remove_drop_target_label" msgid="7812859488053230776">"निकालें"</string>
+ <string name="remove_drop_target_label" msgid="7812859488053230776">"हटाएं"</string>
<string name="uninstall_drop_target_label" msgid="4722034217958379417">"अनइंस्टॉल करें"</string>
<string name="app_info_drop_target_label" msgid="692894985365717661">"ऐप्लिकेशन की जानकारी"</string>
<string name="install_drop_target_label" msgid="2539096853673231757">"इंस्टॉल करें"</string>
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
index 47a88f2..3727932 100644
--- a/res/values-sw600dp/dimens.xml
+++ b/res/values-sw600dp/dimens.xml
@@ -17,4 +17,7 @@
<resources>
<!-- DragController -->
<dimen name="drag_flingToDeleteMinVelocity">-1000dp</dimen>
+
+<!-- Widgets pickers -->
+ <dimen name="widget_list_horizontal_margin">32dp</dimen>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 80ea307..010d15b 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -196,6 +196,7 @@
<dimen name="drop_target_text_size">16sp</dimen>
<dimen name="drop_target_shadow_elevation">2dp</dimen>
<dimen name="drop_target_bar_margin_horizontal">4dp</dimen>
+ <dimen name="drop_target_button_drawable_padding">8dp</dimen>
<!-- the distance an icon must be dragged before button drop targets accept it -->
<dimen name="drag_distanceThreshold">30dp</dimen>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index e4a245a..b7661b9 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -259,7 +259,7 @@
<!-- Drop targets -->
<style name="DropTargetButtonBase" parent="@android:style/TextAppearance.DeviceDefault">
- <item name="android:drawablePadding">8dp</item>
+ <item name="android:drawablePadding">@dimen/drop_target_button_drawable_padding</item>
<item name="android:padding">14dp</item>
<item name="android:textColor">@color/drop_target_text</item>
<item name="android:textSize">@dimen/drop_target_text_size</item>
diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java
index 0d33b6f..468d490 100644
--- a/src/com/android/launcher3/ButtonDropTarget.java
+++ b/src/com/android/launcher3/ButtonDropTarget.java
@@ -66,6 +66,8 @@
private final int mDragDistanceThreshold;
/** The size of the drawable shown in the drop target. */
private final int mDrawableSize;
+ /** The padding, in pixels, between the text and drawable. */
+ private final int mDrawablePadding;
protected CharSequence mText;
protected Drawable mDrawable;
@@ -85,6 +87,8 @@
Resources resources = getResources();
mDragDistanceThreshold = resources.getDimensionPixelSize(R.dimen.drag_distanceThreshold);
mDrawableSize = resources.getDimensionPixelSize(R.dimen.drop_target_text_size);
+ mDrawablePadding = resources.getDimensionPixelSize(
+ R.dimen.drop_target_button_drawable_padding);
}
@Override
@@ -300,6 +304,8 @@
mTextVisible = isVisible;
setText(newText);
setCompoundDrawablesRelative(mDrawable, null, null, null);
+ int drawablePadding = mTextVisible ? mDrawablePadding : 0;
+ setCompoundDrawablePadding(drawablePadding);
}
}
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 74b0d9c..3f7a3ad 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -1614,7 +1614,7 @@
return false;
}
- if (FeatureFlags.IS_STUDIO_BUILD) {
+ if (FeatureFlags.IS_STUDIO_BUILD && !Utilities.IS_RUNNING_IN_TEST_HARNESS) {
duration *= Settings.Global.getFloat(getContext().getContentResolver(),
Settings.Global.WINDOW_ANIMATION_SCALE, 1);
}
diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java
index 1779ddb..9b71918 100644
--- a/src/com/android/launcher3/config/FeatureFlags.java
+++ b/src/com/android/launcher3/config/FeatureFlags.java
@@ -175,8 +175,8 @@
"ENABLE_SMARTSPACE_UNIVERSAL", false,
"Replace Smartspace with a version rendered by System UI.");
- public static final BooleanFlag ENABLE_SMARTSPACE_ENHANCED = new DeviceFlag(
- "ENABLE_SMARTSPACE_ENHANCED", false,
+ public static final BooleanFlag ENABLE_SMARTSPACE_ENHANCED = getDebugFlag(
+ "ENABLE_SMARTSPACE_ENHANCED", true,
"Replace Smartspace with the enhanced version. "
+ "Ignored if ENABLE_SMARTSPACE_UNIVERSAL is enabled.");
diff --git a/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java b/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java
index f3087c0..d0464a4 100644
--- a/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java
+++ b/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java
@@ -165,7 +165,7 @@
@Override
public void run() {
- DeviceProfile deviceProfile = mIdp.getDeviceProfile(mContext);
+ DeviceProfile deviceProfile = mIdp.getDeviceProfile(previewContext);
String query = (deviceProfile.isTwoPanels ? LauncherSettings.Favorites.SCREEN
+ " = " + Workspace.LEFT_PANEL_ID + " or " : "")
+ LauncherSettings.Favorites.SCREEN + " = " + Workspace.FIRST_SCREEN_ID
diff --git a/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java b/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java
index b92c476..d2d569f 100644
--- a/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java
+++ b/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java
@@ -49,6 +49,8 @@
private final Rect mInsets;
private ScrollView mWidgetPreviewScrollView;
+ private int mContentHorizontalMarginInPx;
+
public AddItemWidgetsBottomSheet(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
@@ -56,6 +58,8 @@
public AddItemWidgetsBottomSheet(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mInsets = new Rect();
+ mContentHorizontalMarginInPx = getResources().getDimensionPixelSize(
+ R.dimen.widget_list_horizontal_margin);
}
/**
@@ -173,6 +177,26 @@
}
mContent.setPadding(mContent.getPaddingStart(),
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;
}
+
+ private static void setContentHorizontalMargin(View view, int contentHorizontalMargin) {
+ ViewGroup.MarginLayoutParams layoutParams =
+ ((ViewGroup.MarginLayoutParams) view.getLayoutParams());
+ layoutParams.setMarginStart(contentHorizontalMargin);
+ layoutParams.setMarginEnd(contentHorizontalMargin);
+ }
}
diff --git a/src/com/android/launcher3/widget/BaseWidgetSheet.java b/src/com/android/launcher3/widget/BaseWidgetSheet.java
index 8e9769c..b6cec12 100644
--- a/src/com/android/launcher3/widget/BaseWidgetSheet.java
+++ b/src/com/android/launcher3/widget/BaseWidgetSheet.java
@@ -66,8 +66,12 @@
/* 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 @@
@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/DeferredAppWidgetHostView.java b/src/com/android/launcher3/widget/DeferredAppWidgetHostView.java
index 149ac57..9c32e42 100644
--- a/src/com/android/launcher3/widget/DeferredAppWidgetHostView.java
+++ b/src/com/android/launcher3/widget/DeferredAppWidgetHostView.java
@@ -25,6 +25,7 @@
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.TypedValue;
+import android.view.View;
import android.widget.RemoteViews;
import com.android.launcher3.R;
@@ -55,6 +56,11 @@
}
@Override
+ public void addView(View child) {
+ // Not allowed
+ }
+
+ @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
diff --git a/src/com/android/launcher3/widget/WidgetsBottomSheet.java b/src/com/android/launcher3/widget/WidgetsBottomSheet.java
index 406de10..6beff3a 100644
--- a/src/com/android/launcher3/widget/WidgetsBottomSheet.java
+++ b/src/com/android/launcher3/widget/WidgetsBottomSheet.java
@@ -70,11 +70,10 @@
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 @@
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 @@
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;
@@ -275,6 +272,14 @@
}
@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<View, String> getAccessibilityTarget() {
return Pair.create(findViewById(R.id.title), getContext().getString(
mIsOpen ? R.string.widgets_list : R.string.widgets_list_closed));
diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
index e4ce27c..e36ea90 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
@@ -359,6 +359,29 @@
}
@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);
diff --git a/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java b/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java
index 32dd21c..c24fc8e 100644
--- a/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java
+++ b/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java
@@ -41,9 +41,7 @@
Pattern.compile("^("
+ "(?<local>(BuildFromAndroidStudio|"
+ "([0-9]+|[A-Z])-eng\\.[a-z]+\\.[0-9]+\\.[0-9]+))|"
- + "(?<presubmit>([0-9]+|[A-Z])-P[0-9]+)|"
- + "(?<postsubmit>([0-9]+|[A-Z])-[0-9]+)|"
- + "(?<platform>[0-9]+|[A-Z])"
+ + "(?<platform>[A-Z][a-z]*)"
+ ")$");
private static final Pattern PLATFORM_BUILD =
Pattern.compile("^("
@@ -56,7 +54,7 @@
public static final int PLATFORM_PRESUBMIT = 0x8;
public static final int PLATFORM_POSTSUBMIT = 0x10;
- private static int sRunFlavor = PLATFORM_PRESUBMIT; // b/194528425
+ private static int sRunFlavor;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)