From 1bcb9d94ce036f85a6e6657fb8b51c400ec5a531 Mon Sep 17 00:00:00 2001 From: wilsonshih Date: Tue, 18 May 2021 17:04:01 +0800 Subject: [PATCH 01/12] Read the starting surface icon size from framework Bug: 177264697 Test: Manual verify icon size on splash screen. Change-Id: Iec6b0c519cf4692ac6851911ed1e21a3c1b752b4 --- .../com/android/launcher3/QuickstepTransitionManager.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index 80754a00f4..0ac0223d91 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -1340,14 +1340,14 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener iconAlphaStart = hasSplashScreen ? 0 : 1f; - // TOOD: Share value from shell when available. - final float windowIconSize = Utilities.pxFromSp(108, r.getDisplayMetrics()); + final int windowIconSize = ResourceUtils.getDimenByName("starting_surface_icon_size", + r, 108); cropCenterXStart = windowTargetBounds.centerX(); cropCenterYStart = windowTargetBounds.centerY(); - cropWidthStart = (int) windowIconSize; - cropHeightStart = (int) windowIconSize; + cropWidthStart = windowIconSize; + cropHeightStart = windowIconSize; cropWidthEnd = windowTargetBounds.width(); cropHeightEnd = windowTargetBounds.height(); From 6ed382efee0ed2571aa239dd03cbbf268aa0141f Mon Sep 17 00:00:00 2001 From: Steven Ng Date: Tue, 1 Jun 2021 23:21:03 +0100 Subject: [PATCH 02/12] Remove elevation from the full widgets picker container Test: Open the full widgets picker and observe no shadow added to the rounded corners. Bug: 189808029 Change-Id: I539f6ebc0310cd4a037cd5eab6db4ee22b579195 --- res/layout/widgets_full_sheet.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/res/layout/widgets_full_sheet.xml b/res/layout/widgets_full_sheet.xml index a01aa2c581..dca3e79c62 100644 --- a/res/layout/widgets_full_sheet.xml +++ b/res/layout/widgets_full_sheet.xml @@ -25,8 +25,7 @@ android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="?android:attr/colorBackground" - android:elevation="4dp"> + android:background="?android:attr/colorBackground"> Date: Wed, 26 May 2021 19:13:11 -0400 Subject: [PATCH 03/12] Update preferences to Material Next styling Styles are forked from SettingsLib to avoid using any private APIs. Test: Settings root, all apps, and about have new style on S Bug: 187732263 Fix: 188254205, 188012913 Change-Id: I0ca55eecbc82cfa5d0b8707beb4bb7c82b2aa2b1 --- Android.bp | 1 + AndroidManifest-common.xml | 2 +- .../home_settings_switch_thumb_color.xml | 27 ++++++ .../home_settings_switch_track_color.xml | 28 ++++++ .../home_settings_switch_thumb.xml | 29 ++++++ .../home_settings_switch_track.xml | 26 +++++ res/layout-v31/settings_activity.xml | 69 ++++++++++++++ res/values-night-v31/colors.xml | 27 ++++++ res/values-v31/colors.xml | 9 ++ res/values-v31/config.xml | 20 ++++ res/values-v31/styles.xml | 95 +++++++++++++++++++ res/values/styles.xml | 10 +- 12 files changed, 337 insertions(+), 6 deletions(-) create mode 100644 res/color-v31/home_settings_switch_thumb_color.xml create mode 100644 res/color-v31/home_settings_switch_track_color.xml create mode 100644 res/drawable-v31/home_settings_switch_thumb.xml create mode 100644 res/drawable-v31/home_settings_switch_track.xml create mode 100644 res/layout-v31/settings_activity.xml create mode 100644 res/values-night-v31/colors.xml create mode 100644 res/values-v31/config.xml create mode 100644 res/values-v31/styles.xml diff --git a/Android.bp b/Android.bp index 1b6ffe42b7..45d022f4fd 100644 --- a/Android.bp +++ b/Android.bp @@ -112,6 +112,7 @@ android_library { "androidx.preference_preference", "androidx.slice_slice-view", "androidx.cardview_cardview", + "com.google.android.material_material", "iconloader_base", ], manifest: "AndroidManifest-common.xml", diff --git a/AndroidManifest-common.xml b/AndroidManifest-common.xml index d725a16f80..4eecf29d67 100644 --- a/AndroidManifest-common.xml +++ b/AndroidManifest-common.xml @@ -144,7 +144,7 @@ diff --git a/res/color-v31/home_settings_switch_thumb_color.xml b/res/color-v31/home_settings_switch_thumb_color.xml new file mode 100644 index 0000000000..91d3d9b5e4 --- /dev/null +++ b/res/color-v31/home_settings_switch_thumb_color.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + diff --git a/res/color-v31/home_settings_switch_track_color.xml b/res/color-v31/home_settings_switch_track_color.xml new file mode 100644 index 0000000000..50784f527d --- /dev/null +++ b/res/color-v31/home_settings_switch_track_color.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + diff --git a/res/drawable-v31/home_settings_switch_thumb.xml b/res/drawable-v31/home_settings_switch_thumb.xml new file mode 100644 index 0000000000..260d5ea35f --- /dev/null +++ b/res/drawable-v31/home_settings_switch_thumb.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/res/drawable-v31/home_settings_switch_track.xml b/res/drawable-v31/home_settings_switch_track.xml new file mode 100644 index 0000000000..502a3007a9 --- /dev/null +++ b/res/drawable-v31/home_settings_switch_track.xml @@ -0,0 +1,26 @@ + + + + + + + + \ No newline at end of file diff --git a/res/layout-v31/settings_activity.xml b/res/layout-v31/settings_activity.xml new file mode 100644 index 0000000000..59e14f22dd --- /dev/null +++ b/res/layout-v31/settings_activity.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/values-night-v31/colors.xml b/res/values-night-v31/colors.xml new file mode 100644 index 0000000000..2c1bc90074 --- /dev/null +++ b/res/values-night-v31/colors.xml @@ -0,0 +1,27 @@ + + + + @android:color/system_accent1_100 + @android:color/system_neutral1_700 + @android:color/system_neutral1_900 + + @android:color/system_neutral2_300 + @android:color/system_accent2_700 + @android:color/system_neutral1_700 + \ No newline at end of file diff --git a/res/values-v31/colors.xml b/res/values-v31/colors.xml index 7b37001ade..53c6a35ff1 100644 --- a/res/values-v31/colors.xml +++ b/res/values-v31/colors.xml @@ -37,4 +37,13 @@ @android:color/system_neutral1_900 + @android:color/system_accent1_600 + @android:color/system_neutral1_100 + @android:color/system_neutral1_50 + + @android:color/system_accent1_100 + @android:color/system_accent2_100 + @android:color/system_neutral2_100 + @android:color/system_accent1_600 + @android:color/system_neutral2_600 diff --git a/res/values-v31/config.xml b/res/values-v31/config.xml new file mode 100644 index 0000000000..afb9e6d9e8 --- /dev/null +++ b/res/values-v31/config.xml @@ -0,0 +1,20 @@ + + + + false + false + \ No newline at end of file diff --git a/res/values-v31/styles.xml b/res/values-v31/styles.xml new file mode 100644 index 0000000000..0d2fce0307 --- /dev/null +++ b/res/values-v31/styles.xml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/values/styles.xml b/res/values/styles.xml index 92824ad205..0f8169ef49 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -154,18 +154,18 @@ - - From 67094bfdfbe4cc5dcc9a8b44dfff89681e8ffa9b Mon Sep 17 00:00:00 2001 From: Pat Manning Date: Wed, 26 May 2021 12:38:13 +0000 Subject: [PATCH 04/12] Prevent clearing home between display size changes. Split display support was previously based on the sizes of supported device profiles. If a device supporting split display increased display size too much, it could trigger a grid migration (due to number of hotseat icons displayed vs in the DB changing as it was no longer seen as split display). The migration would not run however, as the grid had not actually changed, but would still have cleard the DB in preparation of the migration. By counting the number of supported profiles instead, we can estimate the number of screens invariant of display size changes and avoid undesired grid migrations. Test: manual Fix: 187689871 Bug: 187689871 Change-Id: If740c501cab0e80ef6144356ec5618ee30134ed7 --- .../launcher3/InvariantDeviceProfile.java | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index 318dde1ecc..115d3aeebb 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -36,7 +36,6 @@ import android.graphics.Rect; import android.text.TextUtils; import android.util.AttributeSet; import android.util.DisplayMetrics; -import android.util.Log; import android.util.SparseArray; import android.util.TypedValue; import android.util.Xml; @@ -45,7 +44,6 @@ import android.view.Display; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; -import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.DisplayController.Info; import com.android.launcher3.util.IntArray; @@ -250,17 +248,10 @@ public class InvariantDeviceProfile { private String initGrid(Context context, String gridName) { Info displayInfo = DisplayController.INSTANCE.get(context).getInfo(); - // Determine if we have split display - - boolean isTablet = false, isPhone = false; - for (WindowBounds bounds : displayInfo.supportedBounds) { - if (displayInfo.isTablet(bounds)) { - isTablet = true; - } else { - isPhone = true; - } - } - boolean isSplitDisplay = isPhone && isTablet && ENABLE_TWO_PANEL_HOME.get(); + // Each screen has two profiles (portrait/landscape), so devices with four or more + // supported profiles implies two or more internal displays. + boolean isSplitDisplay = + displayInfo.supportedBounds.size() >= 4 && ENABLE_TWO_PANEL_HOME.get(); ArrayList allOptions = getPredefinedDeviceProfiles(context, gridName, isSplitDisplay); From 49cb49b1f54de25d05f8c24e22ae7db5b79fb411 Mon Sep 17 00:00:00 2001 From: Pat Manning Date: Tue, 1 Jun 2021 14:49:22 +0000 Subject: [PATCH 05/12] End drag touch event when crossing task drag threshold, and only when task is going up (drag to dismiss) Test: manual Fix: 188618115 Bug: 188618115 Change-Id: I51d157e224eaeee34ed131e4945bb92d6baf18cd --- quickstep/res/values/dimens.xml | 5 +- .../TaskViewTouchController.java | 48 ++++++++++++++----- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index c85d3dcbdb..60eeaffbbb 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -45,8 +45,9 @@ 2.25dp - 1.75dp - 0.75dp + 1.5dp + 1dp + 5dp 16dp 70dp diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java index c6ea953aff..180af0bd9f 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java @@ -21,6 +21,7 @@ import static com.android.launcher3.touch.SingleAxisSwipeDetector.DIRECTION_BOTH import android.animation.Animator; import android.animation.AnimatorListenerAdapter; +import android.os.SystemClock; import android.view.MotionEvent; import android.view.View; import android.view.animation.Interpolator; @@ -72,6 +73,7 @@ public abstract class TaskViewTouchController private float mProgressMultiplier; private float mEndDisplacement; private FlingBlockCheck mFlingBlockCheck = new FlingBlockCheck(); + private Float mOverrideVelocity = null; private TaskView mTaskBeingDragged; @@ -268,6 +270,7 @@ public abstract class TaskViewTouchController mCurrentAnimation.pause(); } mFlingBlockCheck.unblockFling(); + mOverrideVelocity = null; } @Override @@ -283,19 +286,36 @@ public abstract class TaskViewTouchController mFlingBlockCheck.onEvent(); } - // Once halfway through task dismissal interpolation, switch from reversible dragging-task - // animation to playing the remaining task translation animations - if (mCurrentAnimation.getProgressFraction() < ANIMATION_PROGRESS_FRACTION_MIDPOINT) { - // Halve the value as we are animating the drag across the full length for only the - // first half of the progress - mCurrentAnimation.setPlayFraction( - Utilities.boundToRange(totalDisplacement * mProgressMultiplier / 2, 0, 1)); + if (isGoingUp) { + if (mCurrentAnimation.getProgressFraction() < ANIMATION_PROGRESS_FRACTION_MIDPOINT) { + // Halve the value when dismissing, as we are animating the drag across the full + // length for only the first half of the progress + mCurrentAnimation.setPlayFraction( + Utilities.boundToRange(totalDisplacement * mProgressMultiplier / 2, 0, 1)); + } else { + // Set mOverrideVelocity to control task dismiss velocity in onDragEnd + int velocityDimenId = R.dimen.default_task_dismiss_drag_velocity; + if (mRecentsView.showAsGrid()) { + if (mTaskBeingDragged.isFocusedTask()) { + velocityDimenId = + R.dimen.default_task_dismiss_drag_velocity_grid_focus_task; + } else { + velocityDimenId = R.dimen.default_task_dismiss_drag_velocity_grid; + } + } + mOverrideVelocity = -mTaskBeingDragged.getResources().getDimension(velocityDimenId); + + // Once halfway through task dismissal interpolation, switch from reversible + // dragging-task animation to playing the remaining task translation animations + final long now = SystemClock.uptimeMillis(); + MotionEvent upAction = MotionEvent.obtain(now, now, + MotionEvent.ACTION_UP, 0.0f, 0.0f, 0); + mDetector.onTouchEvent(upAction); + upAction.recycle(); + } } else { - float dragVelocity = -mTaskBeingDragged.getResources().getDimension( - mRecentsView.showAsGrid() ? R.dimen.default_task_dismiss_drag_velocity_grid - : R.dimen.default_task_dismiss_drag_velocity); - onDragEnd(dragVelocity); - return true; + mCurrentAnimation.setPlayFraction( + Utilities.boundToRange(totalDisplacement * mProgressMultiplier, 0, 1)); } return true; @@ -303,6 +323,10 @@ public abstract class TaskViewTouchController @Override public void onDragEnd(float velocity) { + if (mOverrideVelocity != null) { + velocity = mOverrideVelocity; + mOverrideVelocity = null; + } // Limit velocity, as very large scalar values make animations play too quickly float maxTaskDismissDragVelocity = mTaskBeingDragged.getResources().getDimension( R.dimen.max_task_dismiss_drag_velocity); From 243fbd3e5d3b929cdecf48f8fdc287749b02aecb Mon Sep 17 00:00:00 2001 From: zakcohen Date: Wed, 2 Jun 2021 10:33:31 -0700 Subject: [PATCH 06/12] AssistContentRequester move binder call to background thread. The call into system server is synchronous, so make the call off the main thread to avoid jank. Bug: 189251291 Test: Local with flag enabled Change-Id: I1787a0ad68488755bf19e813ecfe9fc079cfaed8 --- .../util/AssistContentRequester.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/quickstep/src/com/android/quickstep/util/AssistContentRequester.java b/quickstep/src/com/android/quickstep/util/AssistContentRequester.java index 71c6382323..b1e38ebcbb 100644 --- a/quickstep/src/com/android/quickstep/util/AssistContentRequester.java +++ b/quickstep/src/com/android/quickstep/util/AssistContentRequester.java @@ -54,6 +54,7 @@ public class AssistContentRequester { private final IActivityTaskManager mActivityTaskManager; private final String mPackageName; private final Executor mCallbackExecutor; + private final Executor mSystemInteractionExecutor; // If system loses the callback, our internal cache of original callback will also get cleared. private final Map mPendingCallbacks = @@ -63,6 +64,7 @@ public class AssistContentRequester { mActivityTaskManager = ActivityTaskManager.getService(); mPackageName = context.getApplicationContext().getPackageName(); mCallbackExecutor = Executors.MAIN_EXECUTOR; + mSystemInteractionExecutor = Executors.UI_HELPER_EXECUTOR; } /** @@ -71,13 +73,16 @@ public class AssistContentRequester { * @param taskId to query for the content. * @param callback to call when the content is available, called on the main thread. */ - public void requestAssistContent(int taskId, Callback callback) { - try { - mActivityTaskManager.requestAssistDataForTask( - new AssistDataReceiver(callback, this), taskId, mPackageName); - } catch (RemoteException e) { - Log.e(TAG, "Requesting assist content failed for task: " + taskId, e); - } + public void requestAssistContent(final int taskId, final Callback callback) { + // ActivityTaskManager interaction here is synchronous, so call off the main thread. + mSystemInteractionExecutor.execute(() -> { + try { + mActivityTaskManager.requestAssistDataForTask( + new AssistDataReceiver(callback, this), taskId, mPackageName); + } catch (RemoteException e) { + Log.e(TAG, "Requesting assist content failed for task: " + taskId, e); + } + }); } private void executeOnMainExecutor(Runnable callback) { From 8796707172228fa74d77be0244568de73392983f Mon Sep 17 00:00:00 2001 From: Alina Zaidi Date: Tue, 1 Jun 2021 15:17:16 +0100 Subject: [PATCH 07/12] Update scrim in widget pickers. Also adjust padding in pin widget bottom sheet. Test: Tested manually Bug: 189802334 Change-Id: Ic25547ab1519139afdbf07aaefeb9168cf3501ff --- res/color-night-v31/widgets_picker_scrim.xml | 22 +++++++++++++++++++ res/color-v31/widgets_picker_scrim.xml | 22 +++++++++++++++++++ res/color/widgets_picker_scrim.xml | 22 +++++++++++++++++++ res/layout/add_item_confirmation_activity.xml | 4 +++- .../launcher3/dragndrop/AddItemActivity.java | 13 ++++++----- .../launcher3/views/WidgetsEduView.java | 4 +--- .../widget/AddItemWidgetsBottomSheet.java | 19 ++++++++++++++++ .../launcher3/widget/BaseWidgetSheet.java | 5 +---- 8 files changed, 98 insertions(+), 13 deletions(-) create mode 100644 res/color-night-v31/widgets_picker_scrim.xml create mode 100644 res/color-v31/widgets_picker_scrim.xml create mode 100644 res/color/widgets_picker_scrim.xml diff --git a/res/color-night-v31/widgets_picker_scrim.xml b/res/color-night-v31/widgets_picker_scrim.xml new file mode 100644 index 0000000000..be7010b80b --- /dev/null +++ b/res/color-night-v31/widgets_picker_scrim.xml @@ -0,0 +1,22 @@ + + + + + diff --git a/res/color-v31/widgets_picker_scrim.xml b/res/color-v31/widgets_picker_scrim.xml new file mode 100644 index 0000000000..648824ac1e --- /dev/null +++ b/res/color-v31/widgets_picker_scrim.xml @@ -0,0 +1,22 @@ + + + + + diff --git a/res/color/widgets_picker_scrim.xml b/res/color/widgets_picker_scrim.xml new file mode 100644 index 0000000000..1cf97f61f7 --- /dev/null +++ b/res/color/widgets_picker_scrim.xml @@ -0,0 +1,22 @@ + + + + + diff --git a/res/layout/add_item_confirmation_activity.xml b/res/layout/add_item_confirmation_activity.xml index ddc98156e9..9439baf1b3 100644 --- a/res/layout/add_item_confirmation_activity.xml +++ b/res/layout/add_item_confirmation_activity.xml @@ -31,7 +31,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/add_item_dialog_background" - android:padding="24dp" + android:paddingTop="24dp" android:theme="?attr/widgetsTheme" android:layout_gravity="bottom" android:orientation="vertical"> @@ -42,6 +42,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" + android:paddingHorizontal="24dp" android:textColor="?android:attr/textColorPrimary" android:textSize="24sp" android:ellipsize="end" @@ -53,6 +54,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" + android:paddingHorizontal="24dp" android:paddingTop="8dp" android:text="@string/add_item_request_drag_hint" android:textSize="14sp" diff --git a/src/com/android/launcher3/dragndrop/AddItemActivity.java b/src/com/android/launcher3/dragndrop/AddItemActivity.java index 5dae5a672d..b4288ce1f5 100644 --- a/src/com/android/launcher3/dragndrop/AddItemActivity.java +++ b/src/com/android/launcher3/dragndrop/AddItemActivity.java @@ -59,6 +59,7 @@ import com.android.launcher3.pm.PinRequestHelper; import com.android.launcher3.util.SystemUiController; import com.android.launcher3.views.AbstractSlideInView; import com.android.launcher3.views.BaseDragLayer; +import com.android.launcher3.widget.AddItemWidgetsBottomSheet; import com.android.launcher3.widget.LauncherAppWidgetHost; import com.android.launcher3.widget.LauncherAppWidgetProviderInfo; import com.android.launcher3.widget.NavigableAppWidgetHostView; @@ -89,6 +90,7 @@ public class AddItemActivity extends BaseActivity private LauncherAppState mApp; private InvariantDeviceProfile mIdp; private BaseDragLayer mDragLayer; + private AddItemWidgetsBottomSheet mSlideInView; private WidgetCell mWidgetCell; @@ -124,8 +126,6 @@ public class AddItemActivity extends BaseActivity mDragLayer = findViewById(R.id.add_item_drag_layer); mDragLayer.recreateControllers(); mDragLayer.setInsets(mDeviceProfile.getInsets()); - AbstractSlideInView slideInView = findViewById(R.id.add_item_bottom_sheet); - slideInView.addOnCloseListener(this); mWidgetCell = findViewById(R.id.widget_cell); if (mRequest.getRequestType() == PinItemRequest.REQUEST_TYPE_SHORTCUT) { @@ -151,6 +151,9 @@ public class AddItemActivity extends BaseActivity TextView widgetAppName = findViewById(R.id.widget_appName); widgetAppName.setText(getApplicationInfo().labelRes); + mSlideInView = findViewById(R.id.add_item_bottom_sheet); + mSlideInView.addOnCloseListener(this); + mSlideInView.show(); setupNavBarColor(); } @@ -279,7 +282,7 @@ public class AddItemActivity extends BaseActivity */ public void onCancelClick(View v) { logCommand(LAUNCHER_ADD_EXTERNAL_ITEM_CANCELLED); - finish(); + mSlideInView.close(/* animate= */ true); } /** @@ -290,7 +293,7 @@ public class AddItemActivity extends BaseActivity ItemInstallQueue.INSTANCE.get(this).queueItem(mRequest.getShortcutInfo()); logCommand(LAUNCHER_ADD_EXTERNAL_ITEM_PLACED_AUTOMATICALLY); mRequest.accept(); - finish(); + mSlideInView.close(/* animate= */ true); return; } @@ -313,7 +316,7 @@ public class AddItemActivity extends BaseActivity mWidgetOptions.putInt(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId); mRequest.accept(mWidgetOptions); logCommand(LAUNCHER_ADD_EXTERNAL_ITEM_PLACED_AUTOMATICALLY); - finish(); + mSlideInView.close(/* animate= */ true); } @Override diff --git a/src/com/android/launcher3/views/WidgetsEduView.java b/src/com/android/launcher3/views/WidgetsEduView.java index e69cb5b04b..c6fa98a456 100644 --- a/src/com/android/launcher3/views/WidgetsEduView.java +++ b/src/com/android/launcher3/views/WidgetsEduView.java @@ -35,8 +35,6 @@ public class WidgetsEduView extends AbstractSlideInView implements Ins private static final int DEFAULT_CLOSE_DURATION = 200; - protected static final int FINAL_SCRIM_BG_COLOR = 0x88000000; - private Rect mInsets = new Rect(); private View mEduView; @@ -87,7 +85,7 @@ public class WidgetsEduView extends AbstractSlideInView implements Ins @Override protected int getScrimColor(Context context) { - return FINAL_SCRIM_BG_COLOR; + return context.getResources().getColor(R.color.widgets_picker_scrim); } @Override diff --git a/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java b/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java index 9e0830309e..804973f423 100644 --- a/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java +++ b/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java @@ -23,8 +23,11 @@ import android.content.Context; import android.content.res.Configuration; import android.graphics.Rect; import android.util.AttributeSet; +import android.view.ViewGroup; +import android.view.ViewParent; import com.android.launcher3.Insettable; +import com.android.launcher3.R; import com.android.launcher3.dragndrop.AddItemActivity; import com.android.launcher3.views.AbstractSlideInView; @@ -48,6 +51,17 @@ public class AddItemWidgetsBottomSheet extends AbstractSlideInView } protected int getScrimColor(Context context) { - int alpha = context.getResources().getInteger(R.integer.extracted_color_gradient_alpha); - return setColorAlphaBound(context.getColor(R.color.wallpaper_popup_scrim), alpha); + return context.getResources().getColor(R.color.widgets_picker_scrim); } @Override From 19d623d9210f2f75d25b860158da3ee6dfdd83db Mon Sep 17 00:00:00 2001 From: Weilun Du Date: Wed, 2 Jun 2021 20:24:50 +0000 Subject: [PATCH 08/12] Revert "Update preferences to Material Next styling" Revert "Add dependency for settings activity collapsing toolbar" Revert submission 14740617-collapse3 Reason for revert: Build breakage Reverted Changes: I5ef658979:Add dependency for settings activity collapsing to... I0ca55eecb:Update preferences to Material Next styling Bug: 189919452 Change-Id: I4aa0bfc473334266a951d84064b4e8e406fff0a4 --- Android.bp | 1 - AndroidManifest-common.xml | 2 +- .../home_settings_switch_thumb_color.xml | 27 ------ .../home_settings_switch_track_color.xml | 28 ------ .../home_settings_switch_thumb.xml | 29 ------ .../home_settings_switch_track.xml | 26 ----- res/layout-v31/settings_activity.xml | 69 -------------- res/values-night-v31/colors.xml | 27 ------ res/values-v31/colors.xml | 9 -- res/values-v31/config.xml | 20 ---- res/values-v31/styles.xml | 95 ------------------- res/values/styles.xml | 10 +- 12 files changed, 6 insertions(+), 337 deletions(-) delete mode 100644 res/color-v31/home_settings_switch_thumb_color.xml delete mode 100644 res/color-v31/home_settings_switch_track_color.xml delete mode 100644 res/drawable-v31/home_settings_switch_thumb.xml delete mode 100644 res/drawable-v31/home_settings_switch_track.xml delete mode 100644 res/layout-v31/settings_activity.xml delete mode 100644 res/values-night-v31/colors.xml delete mode 100644 res/values-v31/config.xml delete mode 100644 res/values-v31/styles.xml diff --git a/Android.bp b/Android.bp index 45d022f4fd..1b6ffe42b7 100644 --- a/Android.bp +++ b/Android.bp @@ -112,7 +112,6 @@ android_library { "androidx.preference_preference", "androidx.slice_slice-view", "androidx.cardview_cardview", - "com.google.android.material_material", "iconloader_base", ], manifest: "AndroidManifest-common.xml", diff --git a/AndroidManifest-common.xml b/AndroidManifest-common.xml index 4eecf29d67..d725a16f80 100644 --- a/AndroidManifest-common.xml +++ b/AndroidManifest-common.xml @@ -144,7 +144,7 @@ diff --git a/res/color-v31/home_settings_switch_thumb_color.xml b/res/color-v31/home_settings_switch_thumb_color.xml deleted file mode 100644 index 91d3d9b5e4..0000000000 --- a/res/color-v31/home_settings_switch_thumb_color.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - diff --git a/res/color-v31/home_settings_switch_track_color.xml b/res/color-v31/home_settings_switch_track_color.xml deleted file mode 100644 index 50784f527d..0000000000 --- a/res/color-v31/home_settings_switch_track_color.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - diff --git a/res/drawable-v31/home_settings_switch_thumb.xml b/res/drawable-v31/home_settings_switch_thumb.xml deleted file mode 100644 index 260d5ea35f..0000000000 --- a/res/drawable-v31/home_settings_switch_thumb.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/res/drawable-v31/home_settings_switch_track.xml b/res/drawable-v31/home_settings_switch_track.xml deleted file mode 100644 index 502a3007a9..0000000000 --- a/res/drawable-v31/home_settings_switch_track.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/res/layout-v31/settings_activity.xml b/res/layout-v31/settings_activity.xml deleted file mode 100644 index 59e14f22dd..0000000000 --- a/res/layout-v31/settings_activity.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/res/values-night-v31/colors.xml b/res/values-night-v31/colors.xml deleted file mode 100644 index 2c1bc90074..0000000000 --- a/res/values-night-v31/colors.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - @android:color/system_accent1_100 - @android:color/system_neutral1_700 - @android:color/system_neutral1_900 - - @android:color/system_neutral2_300 - @android:color/system_accent2_700 - @android:color/system_neutral1_700 - \ No newline at end of file diff --git a/res/values-v31/colors.xml b/res/values-v31/colors.xml index 53c6a35ff1..7b37001ade 100644 --- a/res/values-v31/colors.xml +++ b/res/values-v31/colors.xml @@ -37,13 +37,4 @@ @android:color/system_neutral1_900 - @android:color/system_accent1_600 - @android:color/system_neutral1_100 - @android:color/system_neutral1_50 - - @android:color/system_accent1_100 - @android:color/system_accent2_100 - @android:color/system_neutral2_100 - @android:color/system_accent1_600 - @android:color/system_neutral2_600 diff --git a/res/values-v31/config.xml b/res/values-v31/config.xml deleted file mode 100644 index afb9e6d9e8..0000000000 --- a/res/values-v31/config.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - false - false - \ No newline at end of file diff --git a/res/values-v31/styles.xml b/res/values-v31/styles.xml deleted file mode 100644 index 0d2fce0307..0000000000 --- a/res/values-v31/styles.xml +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/res/values/styles.xml b/res/values/styles.xml index 0f8169ef49..92824ad205 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -154,18 +154,18 @@ - - From 1bd7ccd90b611bae9ac1f2696382a54d0d3eb471 Mon Sep 17 00:00:00 2001 From: Jon Spivack Date: Wed, 2 Jun 2021 15:55:06 -0700 Subject: [PATCH 09/12] TaskOverlayFactoryGo: Keep persistent instance of AssistContentRequester Holding a reference to AssistContentRequester prevents it from being deleted by the garbage collector while it is still in use. Bug: 189985872 Test: Manual (Pixel 3A) Test: m -j RunLauncherGoGoogleRoboTests Change-Id: I204aab907175a171c496c3bd146a8b23d2bbcf16 --- .../quickstep/TaskOverlayFactoryGo.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/go/quickstep/src/com/android/quickstep/TaskOverlayFactoryGo.java b/go/quickstep/src/com/android/quickstep/TaskOverlayFactoryGo.java index 754782bd49..65cdcf06ba 100644 --- a/go/quickstep/src/com/android/quickstep/TaskOverlayFactoryGo.java +++ b/go/quickstep/src/com/android/quickstep/TaskOverlayFactoryGo.java @@ -53,14 +53,17 @@ public final class TaskOverlayFactoryGo extends TaskOverlayFactory { public static final int ERROR_PERMISSIONS = 1; private static final String TAG = "TaskOverlayFactoryGo"; - // Empty constructor required for ResourceBasedOverride - public TaskOverlayFactoryGo(Context context) {} + private AssistContentRequester mContentRequester; + + public TaskOverlayFactoryGo(Context context) { + mContentRequester = new AssistContentRequester(context); + } /** * Create a new overlay instance for the given View */ public TaskOverlayGo createOverlay(TaskThumbnailView thumbnailView) { - return new TaskOverlayGo(thumbnailView); + return new TaskOverlayGo(thumbnailView, mContentRequester); } /** @@ -72,9 +75,12 @@ public final class TaskOverlayFactoryGo extends TaskOverlayFactory { private String mTaskPackageName; private String mWebUrl; private boolean mAssistPermissionsEnabled; + private AssistContentRequester mFactoryContentRequester; - private TaskOverlayGo(TaskThumbnailView taskThumbnailView) { + private TaskOverlayGo(TaskThumbnailView taskThumbnailView, + AssistContentRequester assistContentRequester) { super(taskThumbnailView); + mFactoryContentRequester = assistContentRequester; } /** @@ -105,9 +111,7 @@ public final class TaskOverlayFactoryGo extends TaskOverlayFactory { } int taskId = task.key.id; - AssistContentRequester contentRequester = - new AssistContentRequester(mApplicationContext); - contentRequester.requestAssistContent(taskId, this::onAssistContentReceived); + mFactoryContentRequester.requestAssistContent(taskId, this::onAssistContentReceived); } /** Provide Assist Content to the overlay. */ From 2b006fb27b81c03eb3afb1aef48073dd50e5d6a8 Mon Sep 17 00:00:00 2001 From: shawnlin Date: Thu, 3 Jun 2021 12:57:13 +0800 Subject: [PATCH 10/12] Detach the nav once the endTarget is determined as HOME Bug: 189900722 Test: manual - swipe up to home from an app and observe the nav Change-Id: I421de17fe4d8413deaf9ebd63166a6d2d00d096e --- .../src/com/android/quickstep/AbsSwipeUpHandler.java | 6 +++++- .../com/android/quickstep/RecentsAnimationController.java | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index be927e0107..306032cff2 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -972,6 +972,10 @@ public abstract class AbsSwipeUpHandler, } if (endTarget == HOME) { duration = HOME_DURATION; + // Early detach the nav bar once the endTarget is determined as HOME + if (mRecentsAnimationController != null) { + mRecentsAnimationController.detachNavigationBarFromApp(true); + } } else if (endTarget == RECENTS) { if (mRecentsView != null) { int nearestPage = mRecentsView.getDestinationPage(); @@ -1496,7 +1500,7 @@ public abstract class AbsSwipeUpHandler, if (LIVE_TILE.get()) { mStateCallback.setStateOnUiThread(STATE_CURRENT_TASK_FINISHED); if (mRecentsAnimationController != null) { - mRecentsAnimationController.getController().detachNavigationBarFromApp(true); + mRecentsAnimationController.detachNavigationBarFromApp(true); } } else if (!hasTargets() || mRecentsAnimationController == null) { // If there are no targets or the animation not started, then there is nothing to finish diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationController.java b/quickstep/src/com/android/quickstep/RecentsAnimationController.java index 462f71440c..50d0569cf2 100644 --- a/quickstep/src/com/android/quickstep/RecentsAnimationController.java +++ b/quickstep/src/com/android/quickstep/RecentsAnimationController.java @@ -154,6 +154,14 @@ public class RecentsAnimationController { }); } + /** + * @see RecentsAnimationControllerCompat#detachNavigationBarFromApp + */ + @UiThread + public void detachNavigationBarFromApp(boolean moveHomeToTop) { + UI_HELPER_EXECUTOR.execute(() -> mController.detachNavigationBarFromApp(moveHomeToTop)); + } + /** * Sets the final surface transaction on a Task. This is used by Launcher to notify the system * that animating Activity to PiP has completed and the associated task surface should be From abd33b38e2a37ca24b70247fff9fe80b9e38b975 Mon Sep 17 00:00:00 2001 From: Stevie Kideckel Date: Wed, 2 Jun 2021 16:57:18 +0000 Subject: [PATCH 11/12] Use the LayoutManager as the source of truth for visible positions During animations, the view group child may not correspond to the visible views that appear at the top. The previous logic is kept in the case that the layout manager returns null for any reason, which can happen before layout has occurred for the position. Fix: 189588014 Test: verified locally Change-Id: Ie8b5dcef50287e9e90a21f86e30a1ebcbbcba30f --- .../widget/picker/WidgetsRecyclerView.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java b/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java index e30e245452..090362ba33 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java +++ b/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java @@ -154,8 +154,25 @@ public class WidgetsRecyclerView extends BaseRecyclerView implements OnItemTouch return -1; } - View child = getChildAt(0); - int rowIndex = getChildPosition(child); + int rowIndex = -1; + View child = null; + + LayoutManager layoutManager = getLayoutManager(); + if (layoutManager instanceof LinearLayoutManager) { + // Use the LayoutManager as the source of truth for visible positions. During + // animations, the view group child may not correspond to the visible views that appear + // at the top. + rowIndex = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition(); + child = layoutManager.findViewByPosition(rowIndex); + } + + if (child == null) { + // If the layout manager returns null for any reason, which can happen before layout + // has occurred for the position, then look at the child of this view as a ViewGroup. + child = getChildAt(0); + rowIndex = getChildPosition(child); + } + for (int i = 0; i < getChildCount(); i++) { View view = getChildAt(i); if (view instanceof TableLayout) { From eb367e471b03a9edbb4499a230e4d8433b596d9f Mon Sep 17 00:00:00 2001 From: Stevie Kideckel Date: Wed, 2 Jun 2021 16:21:54 +0000 Subject: [PATCH 12/12] Scroll to the selected widget picker row after headers are clicked This keeps the row in view. Currently, this will scroll the row to the centre-bottom of the screen due to the top padding being double counted, but that will remedied in a future CL. This also resolves the issue where the last row's widgets aren't visible by handling that case specially Fix: 188665456 Bug: 183378651 Test: verified locally Change-Id: I9acb9087a8cdaf130ac5955c810c96462b368f36 --- .../widget/picker/WidgetsListAdapter.java | 55 +++++++++++++++++-- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/src/com/android/launcher3/widget/picker/WidgetsListAdapter.java b/src/com/android/launcher3/widget/picker/WidgetsListAdapter.java index 7963431932..3936ec8e80 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsListAdapter.java +++ b/src/com/android/launcher3/widget/picker/WidgetsListAdapter.java @@ -25,6 +25,7 @@ import android.view.View.OnLongClickListener; import android.view.ViewGroup; import android.widget.TableRow; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView.Adapter; @@ -48,8 +49,10 @@ import java.util.Arrays; import java.util.Comparator; import java.util.List; import java.util.Map; +import java.util.OptionalInt; import java.util.function.Predicate; import java.util.stream.Collectors; +import java.util.stream.IntStream; /** * Recycler view adapter for the widget tray. @@ -87,6 +90,7 @@ public class WidgetsListAdapter extends Adapter implements OnHeaderC || new PackageUserKey(entry.mPkgItem.packageName, entry.mPkgItem.user) .equals(mWidgetsContentVisiblePackageUserKey); @Nullable private Predicate mFilter = null; + @Nullable private RecyclerView mRecyclerView; public WidgetsListAdapter(Context context, LayoutInflater layoutInflater, WidgetPreviewLoader widgetPreviewLoader, IconCache iconCache, @@ -106,6 +110,16 @@ public class WidgetsListAdapter extends Adapter implements OnHeaderC layoutInflater, /*onHeaderClickListener=*/ this, /* listAdapter= */ this)); } + @Override + public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) { + mRecyclerView = recyclerView; + } + + @Override + public void onDetachedFromRecyclerView(@NonNull RecyclerView recyclerView) { + mRecyclerView = null; + } + public void setFilter(Predicate filter) { mFilter = filter; } @@ -168,12 +182,10 @@ public class WidgetsListAdapter extends Adapter implements OnHeaderC mAllEntries.forEach(entry -> { if (entry instanceof WidgetsListHeaderEntry) { ((WidgetsListHeaderEntry) entry).setIsWidgetListShown( - new PackageUserKey(entry.mPkgItem.packageName, entry.mPkgItem.user) - .equals(mWidgetsContentVisiblePackageUserKey)); + isHeaderForVisibleContent(entry)); } else if (entry instanceof WidgetsListSearchHeaderEntry) { ((WidgetsListSearchHeaderEntry) entry).setIsWidgetListShown( - new PackageUserKey(entry.mPkgItem.packageName, entry.mPkgItem.user) - .equals(mWidgetsContentVisiblePackageUserKey)); + isHeaderForVisibleContent(entry)); } }); List newVisibleEntries = mAllEntries.stream() @@ -183,6 +195,13 @@ public class WidgetsListAdapter extends Adapter implements OnHeaderC mDiffReporter.process(mVisibleEntries, newVisibleEntries, mRowComparator); } + private boolean isHeaderForVisibleContent(WidgetsListBaseEntry entry) { + return (entry instanceof WidgetsListHeaderEntry + || entry instanceof WidgetsListSearchHeaderEntry) + && new PackageUserKey(entry.mPkgItem.packageName, entry.mPkgItem.user) + .equals(mWidgetsContentVisiblePackageUserKey); + } + /** * Resets any expanded widget header. */ @@ -247,12 +266,40 @@ public class WidgetsListAdapter extends Adapter implements OnHeaderC if (showWidgets) { mWidgetsContentVisiblePackageUserKey = packageUserKey; updateVisibleEntries(); + // Scroll the layout manager to the header position to keep it anchored to the same + // position. + scrollToSelectedHeaderPosition(); } else if (packageUserKey.equals(mWidgetsContentVisiblePackageUserKey)) { mWidgetsContentVisiblePackageUserKey = null; updateVisibleEntries(); } } + private void scrollToSelectedHeaderPosition() { + OptionalInt selectedHeaderPosition = + IntStream.range(0, mVisibleEntries.size()) + .filter(index -> isHeaderForVisibleContent(mVisibleEntries.get(index))) + .findFirst(); + RecyclerView.LayoutManager layoutManager = + mRecyclerView == null ? null : mRecyclerView.getLayoutManager(); + if (!selectedHeaderPosition.isPresent() || layoutManager == null) { + return; + } + + // Scroll to the selected header position. LinearLayoutManager scrolls the minimum distance + // necessary, so this will keep the selected header in place during clicks, without + // interrupting the animation. + int position = selectedHeaderPosition.getAsInt(); + if (position == mVisibleEntries.size() - 2) { + // If the selected header is in the last position (-1 for the content), then scroll to + // the final position so the last list of widgets will show. + layoutManager.scrollToPosition(mVisibleEntries.size() - 1); + } else { + // Otherwise, scroll to the position of the selected header. + layoutManager.scrollToPosition(position); + } + } + /** * Sets the max horizontal spans that are allowed for grouping more than one widgets in a table * row.