From 04ebcf468627c87e4a103959735260fe2bea5998 Mon Sep 17 00:00:00 2001 From: vadimt Date: Wed, 3 Feb 2021 15:31:51 -0800 Subject: [PATCH 1/6] Postponing registering widget listener For the swipe-to-home gesture, the call will happen after the animation. This fixes jank during swiping up from an ap to home. Also renaming some methods for clarity. Bug: 175048504, 173072373 Test: tracing Change-Id: I070b23edb633d2ac0985d5eb9f75c789f8569772 --- src/com/android/launcher3/Launcher.java | 8 +- .../launcher3/LauncherAppWidgetHost.java | 77 +++++++++---------- 2 files changed, 43 insertions(+), 42 deletions(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 0274775244..c7d17a858a 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -922,7 +922,7 @@ public class Launcher extends StatefulActivity implements Launche } logStopAndResume(false /* isResume */); - mAppWidgetHost.setListenIfResumed(false); + mAppWidgetHost.setActivityStarted(false); NotificationListener.removeNotificationsChangedListener(); } @@ -935,7 +935,7 @@ public class Launcher extends StatefulActivity implements Launche mOverlayManager.onActivityStarted(this); } - mAppWidgetHost.setListenIfResumed(true); + mAppWidgetHost.setActivityStarted(true); TraceHelper.INSTANCE.endSection(traceToken); mLifecycleRegistry.setCurrentState(Lifecycle.State.STARTED); } @@ -956,6 +956,7 @@ public class Launcher extends StatefulActivity implements Launche NotificationListener.setNotificationsChangedListener(mPopupDataProvider); DiscoveryBounce.showForHomeIfNeeded(this); + mAppWidgetHost.setActivityResumed(true); } private void logStopAndResume(boolean isResume) { @@ -1049,7 +1050,7 @@ public class Launcher extends StatefulActivity implements Launche @Override public void onStateSetEnd(LauncherState state) { super.onStateSetEnd(state); - getAppWidgetHost().setResumed(state == LauncherState.NORMAL); + getAppWidgetHost().setStateIsNormal(state == LauncherState.NORMAL); getWorkspace().setClipChildren(!state.hasFlag(FLAG_MULTI_PAGE)); finishAutoCancelActionMode(); @@ -1108,6 +1109,7 @@ public class Launcher extends StatefulActivity implements Launche if (!mDeferOverlayCallbacks) { mOverlayManager.onActivityPaused(this); } + mAppWidgetHost.setActivityResumed(false); } class LauncherOverlayCallbacksImpl implements LauncherOverlayCallbacks { diff --git a/src/com/android/launcher3/LauncherAppWidgetHost.java b/src/com/android/launcher3/LauncherAppWidgetHost.java index 7ea68512ee..fea26df7da 100644 --- a/src/com/android/launcher3/LauncherAppWidgetHost.java +++ b/src/com/android/launcher3/LauncherAppWidgetHost.java @@ -49,8 +49,11 @@ import java.util.function.IntConsumer; public class LauncherAppWidgetHost extends AppWidgetHost { private static final int FLAG_LISTENING = 1; - private static final int FLAG_RESUMED = 1 << 1; - private static final int FLAG_LISTEN_IF_RESUMED = 1 << 2; + private static final int FLAG_STATE_IS_NORMAL = 1 << 1; + private static final int FLAG_ACTIVITY_STARTED = 1 << 2; + private static final int FLAG_ACTIVITY_RESUMED = 1 << 3; + private static final int FLAGS_SHOULD_LISTEN = + FLAG_STATE_IS_NORMAL | FLAG_ACTIVITY_STARTED | FLAG_ACTIVITY_RESUMED; public static final int APPWIDGET_HOST_ID = 1024; @@ -59,7 +62,7 @@ public class LauncherAppWidgetHost extends AppWidgetHost { private final SparseArray mPendingViews = new SparseArray<>(); private final Context mContext; - private int mFlags = FLAG_RESUMED; + private int mFlags = FLAG_STATE_IS_NORMAL; private IntConsumer mAppWidgetRemovedCallback = null; @@ -130,49 +133,45 @@ public class LauncherAppWidgetHost extends AppWidgetHost { } /** - * Updates the resumed state of the host. - * When a host is not resumed, it defers calls to startListening until host is resumed again. - * But if the host was already listening, it will not call stopListening. - * - * @see #setListenIfResumed(boolean) + * Sets or unsets a flag the can change whether the widget host should be in the listening + * state. */ - public void setResumed(boolean isResumed) { - if (isResumed == ((mFlags & FLAG_RESUMED) != 0)) { - return; - } - if (isResumed) { - mFlags |= FLAG_RESUMED; - // Start listening if we were supposed to start listening on resume - if ((mFlags & FLAG_LISTEN_IF_RESUMED) != 0 && (mFlags & FLAG_LISTENING) == 0) { - startListening(); - } + private void setShouldListenFlag(int flag, boolean on) { + if (on) { + mFlags |= flag; } else { - mFlags &= ~FLAG_RESUMED; + mFlags &= ~flag; + } + + final boolean listening = isListening(); + if (!listening && (mFlags & FLAGS_SHOULD_LISTEN) == FLAGS_SHOULD_LISTEN) { + // Postpone starting listening until all flags are on. + startListening(); + } else if (listening && (mFlags & FLAG_ACTIVITY_STARTED) == 0) { + // Postpone stopping listening until the activity is stopped. + stopListening(); } } /** - * Updates the listening state of the host. If the host is not resumed, startListening is - * deferred until next resume. - * - * @see #setResumed(boolean) + * Registers an "entering/leaving Normal state" event. */ - public void setListenIfResumed(boolean listenIfResumed) { - if (listenIfResumed == ((mFlags & FLAG_LISTEN_IF_RESUMED) != 0)) { - return; - } - if (listenIfResumed) { - mFlags |= FLAG_LISTEN_IF_RESUMED; - if ((mFlags & FLAG_RESUMED) != 0) { - // If we are resumed, start listening immediately. Note we do not check for - // duplicate calls before calling startListening as startListening is safe to call - // multiple times. - startListening(); - } - } else { - mFlags &= ~FLAG_LISTEN_IF_RESUMED; - stopListening(); - } + public void setStateIsNormal(boolean isNormal) { + setShouldListenFlag(FLAG_STATE_IS_NORMAL, isNormal); + } + + /** + * Registers an "activity started/stopped" event. + */ + public void setActivityStarted(boolean isStarted) { + setShouldListenFlag(FLAG_ACTIVITY_STARTED, isStarted); + } + + /** + * Registers an "activity paused/resumed" event. + */ + public void setActivityResumed(boolean isResumed) { + setShouldListenFlag(FLAG_ACTIVITY_RESUMED, isResumed); } @Override From 3a39b564349cf87d45f7181e6b3d1555ccbd1c5b Mon Sep 17 00:00:00 2001 From: Samuel Fufa Date: Thu, 4 Feb 2021 13:05:07 -0600 Subject: [PATCH 2/6] Only show OOBE once Bug: 179333425 Test: Manual Change-Id: I23de8fffa31ae06b0f4feccfb75144c7c55143c2 --- .../launcher3/search/DeviceSearchEdu.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/quickstep/src/com/android/launcher3/search/DeviceSearchEdu.java b/quickstep/src/com/android/launcher3/search/DeviceSearchEdu.java index 425e557ecb..71270cc94a 100644 --- a/quickstep/src/com/android/launcher3/search/DeviceSearchEdu.java +++ b/quickstep/src/com/android/launcher3/search/DeviceSearchEdu.java @@ -73,11 +73,9 @@ public class DeviceSearchEdu extends AbstractSlideInView implements } - private void close(boolean animate, boolean markAsSeen) { - handleClose(animate); - if (markAsSeen) { - mLauncher.getOnboardingPrefs().markChecked(SEARCH_EDU_SEEN); - } + private void dismiss() { + handleClose(true); + mLauncher.getOnboardingPrefs().markChecked(SEARCH_EDU_SEEN); } @Override @@ -110,7 +108,7 @@ public class DeviceSearchEdu extends AbstractSlideInView implements findViewById(R.id.dismiss_edu).setOnClickListener((view) -> { mSwitchFocusOnDismiss = true; - close(true, true); + dismiss(); }); } @@ -176,7 +174,7 @@ public class DeviceSearchEdu extends AbstractSlideInView implements @Override public void onStateTransitionStart(LauncherState toState) { - close(true, false); + dismiss(); } @Override @@ -203,7 +201,7 @@ public class DeviceSearchEdu extends AbstractSlideInView implements if (mSearchInput != null) { mSearchInput.setText(charSequence.toString()); mSwitchFocusOnDismiss = true; - close(true, true); + dismiss(); } } @@ -215,7 +213,7 @@ public class DeviceSearchEdu extends AbstractSlideInView implements @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { mSearchInput.onEditorAction(i); - close(true, true); + dismiss(); return true; } } From 4fc871f9776606799538fe08bfd62069e692d206 Mon Sep 17 00:00:00 2001 From: thiruram Date: Wed, 3 Feb 2021 14:55:23 -0800 Subject: [PATCH 3/6] [AA+] Add LAUNCHER_ALLAPPS_ENTRY, LAUNCHER_ALLAPPS_EXIT events. This would help us to define clear start and end events for AllApps sessions on the server side. Bug: 178562918 Change-Id: I77f236c9bc1a21e868545b1309e47d91d6fc1d96 --- .../allapps/search/LiveSearchManager.java | 19 +++++++++++++++++++ .../launcher3/logging/StatsLogManager.java | 6 ++++++ 2 files changed, 25 insertions(+) diff --git a/src/com/android/launcher3/allapps/search/LiveSearchManager.java b/src/com/android/launcher3/allapps/search/LiveSearchManager.java index 71aedb8272..e52c79049f 100644 --- a/src/com/android/launcher3/allapps/search/LiveSearchManager.java +++ b/src/com/android/launcher3/allapps/search/LiveSearchManager.java @@ -16,6 +16,8 @@ package com.android.launcher3.allapps.search; import static com.android.launcher3.LauncherState.ALL_APPS; +import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_ENTRY; +import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_EXIT; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.THREAD_POOL_EXECUTOR; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; @@ -46,6 +48,8 @@ import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAppWidgetProviderInfo; import com.android.launcher3.LauncherState; import com.android.launcher3.logging.InstanceId; +import com.android.launcher3.logging.InstanceIdSequence; +import com.android.launcher3.logging.StatsLogManager.StatsLogger; import com.android.launcher3.statemanager.StateManager.StateListener; import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.SafeCloseable; @@ -71,6 +75,7 @@ public class LiveSearchManager implements StateListener { new HashMap<>(); private SearchWidgetHost mSearchWidgetHost; private InstanceId mLogInstanceId; + private LauncherState mPrevLauncherState; public LiveSearchManager(Launcher launcher) { mLauncher = launcher; @@ -133,6 +138,11 @@ public class LiveSearchManager implements StateListener { } } + @Override + public void onStateTransitionStart(LauncherState toState) { + mPrevLauncherState = mLauncher.getStateManager().getCurrentStableState(); + } + @Override public void onStateTransitionComplete(LauncherState finalState) { if (finalState != ALL_APPS) { @@ -142,6 +152,15 @@ public class LiveSearchManager implements StateListener { clearWidgetHost(); } + + StatsLogger logger = mLauncher.getStatsLogManager().logger(); + if (finalState.equals(ALL_APPS)) { + mLogInstanceId = new InstanceIdSequence().newInstanceId(); + logger.withInstanceId(mLogInstanceId).log(LAUNCHER_ALLAPPS_ENTRY); + } else if (mPrevLauncherState.equals(ALL_APPS)) { + logger.withInstanceId(mLogInstanceId).log(LAUNCHER_ALLAPPS_EXIT); + mLogInstanceId = null; + } } /** diff --git a/src/com/android/launcher3/logging/StatsLogManager.java b/src/com/android/launcher3/logging/StatsLogManager.java index 2066cd3d71..0292d20ef5 100644 --- a/src/com/android/launcher3/logging/StatsLogManager.java +++ b/src/com/android/launcher3/logging/StatsLogManager.java @@ -344,6 +344,12 @@ public class StatsLogManager implements ResourceBasedOverride { @UiEvent(doc = "Current grid size is changed to 2.") LAUNCHER_GRID_SIZE_2(665), + + @UiEvent(doc = "Launcher entered into AllApps state.") + LAUNCHER_ALLAPPS_ENTRY(692), + + @UiEvent(doc = "Launcher exited from AllApps state.") + LAUNCHER_ALLAPPS_EXIT(693), ; // ADD MORE From 993fed23465a10bc76f46948f8910154fafa2496 Mon Sep 17 00:00:00 2001 From: Lucas Dupin Date: Thu, 4 Feb 2021 15:40:45 -0800 Subject: [PATCH 4/6] Style updates - Make pop ups use system colors - Text colors in dark theme should also use system colors Test: visual Bug: 179427049 Change-Id: I9c0eb2b6970ff9bf66fe1d5c0040b10bfa2087b0 --- res/values-v31/colors.xml | 33 +++++++++++++++++++++++++++++++++ res/values/colors.xml | 15 +++++++++++++++ res/values/styles.xml | 24 ++++++++++++------------ 3 files changed, 60 insertions(+), 12 deletions(-) create mode 100644 res/values-v31/colors.xml diff --git a/res/values-v31/colors.xml b/res/values-v31/colors.xml new file mode 100644 index 0000000000..b8600a60ed --- /dev/null +++ b/res/values-v31/colors.xml @@ -0,0 +1,33 @@ + + + + @android:color/system_main_50 + @android:color/system_main_100 + @android:color/system_main_300 + @android:color/system_main_800 + @android:color/system_main_900 + @android:color/system_main_700 + + @android:color/system_main_50 + @android:color/system_main_900 + + @android:color/system_main_50 + @android:color/system_main_200 + @android:color/system_main_400 + \ No newline at end of file diff --git a/res/values/colors.xml b/res/values/colors.xml index 78c2df69e0..0b30253327 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -40,4 +40,19 @@ #9CCC65 #FFFFFFFF #1A73E8 + + #FFF + #F1F3F4 + #E0E0E0 + #3C4043 + #202124 + #757575 + + #FFF + #FF212121 + + #FFFFFFFF + #FFFFFFFF + #CCFFFFFF + diff --git a/res/values/styles.xml b/res/values/styles.xml index dc7182fe90..adc22381a8 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -35,12 +35,12 @@ 46 #66FFFFFF @style/AllAppsTheme - #FFF - #F1F3F4 - #E0E0E0 + @color/popup_color_primary_light + @color/popup_color_secondary_light + @color/popup_color_tertiary_light false false - @android:color/white + @color/workspace_text_color_light #B0000000 #33000000 #44000000 @@ -74,7 +74,7 @@