diff --git a/quickstep/res/layout-land/keyboard_quick_switch_taskview.xml b/quickstep/res/layout-land/keyboard_quick_switch_taskview.xml index 4e676298c8..69e157433a 100644 --- a/quickstep/res/layout-land/keyboard_quick_switch_taskview.xml +++ b/quickstep/res/layout-land/keyboard_quick_switch_taskview.xml @@ -23,7 +23,7 @@ android:importantForAccessibility="yes" android:background="@drawable/keyboard_quick_switch_task_view_background" android:clipToOutline="true" - launcher:borderColor="?androidprv:attr/materialColorOutline"> + launcher:focusBorderColor="?androidprv:attr/materialColorOutline"> + launcher:focusBorderColor="?androidprv:attr/materialColorOutline"> + launcher:focusBorderColor="?androidprv:attr/materialColorOutline"> \ No newline at end of file diff --git a/quickstep/res/layout/task.xml b/quickstep/res/layout/task.xml index 4865aef5af..29c9992999 100644 --- a/quickstep/res/layout/task.xml +++ b/quickstep/res/layout/task.xml @@ -24,7 +24,8 @@ android:clipChildren="false" android:defaultFocusHighlightEnabled="false" android:focusable="true" - launcher:borderColor="?androidprv:attr/materialColorOutline"> + launcher:focusBorderColor="?androidprv:attr/materialColorOutline" + launcher:hoverBorderColor="?androidprv:attr/materialColorPrimary"> + launcher:focusBorderColor="?androidprv:attr/materialColorOutline" + launcher:hoverBorderColor="?androidprv:attr/materialColorPrimary"> + launcher:focusBorderColor="?androidprv:attr/materialColorOutline" + launcher:hoverBorderColor="?androidprv:attr/materialColorPrimary"> - + + 44dp + + 4dp 16dp diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index 153c1acd75..4489eaf746 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -158,6 +158,7 @@ import com.android.systemui.shared.system.QuickStepContract; import com.android.systemui.shared.system.RemoteAnimationRunnerCompat; import com.android.wm.shell.startingsurface.IStartingWindowListener; +import java.io.PrintWriter; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; @@ -477,6 +478,9 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener }); } + /** Dump debug logs to bug report. */ + public void dump(@NonNull String prefix, @NonNull PrintWriter printWriter) {} + /** * Content is everything on screen except the background and the floating view (if any). * diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchTaskView.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchTaskView.java index 8a11b57c11..3e1a6ae9cb 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchTaskView.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchTaskView.java @@ -80,7 +80,7 @@ public class KeyboardQuickSwitchTaskView extends ConstraintLayout { setWillNotDraw(false); mBorderColor = ta.getColor( - R.styleable.TaskView_borderColor, DEFAULT_BORDER_COLOR); + R.styleable.TaskView_focusBorderColor, DEFAULT_BORDER_COLOR); ta.recycle(); } diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java index 3e1fef91e8..544f9bf27e 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java @@ -164,7 +164,7 @@ public final class TaskbarAllAppsController { cleanUpOverlay(); }); TaskbarAllAppsViewController viewController = new TaskbarAllAppsViewController( - mOverlayContext, mSlideInView, mControllers); + mOverlayContext, mSlideInView, mControllers, mSearchSessionController); viewController.show(animate); mAppsView = mOverlayContext.getAppsView(); diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java index 84cc00278b..4f75ef5599 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java @@ -17,6 +17,8 @@ package com.android.launcher3.taskbar.allapps; import static com.android.app.animation.Interpolators.EMPHASIZED; +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; import android.animation.PropertyValuesHolder; import android.content.Context; import android.graphics.Canvas; @@ -63,14 +65,23 @@ public class TaskbarAllAppsSlideInView extends AbstractSlideInView) {} + open fun setZeroStatePredictedItems(items: List) = Unit /** Updates the search suggestions shown in the zero-state. */ - open fun setZeroStateSearchSuggestions(items: List) {} + open fun setZeroStateSearchSuggestions(items: List) = Unit + + override fun onAllAppsTransitionStart(toAllApps: Boolean) = Unit + + override fun onAllAppsTransitionEnd(toAllApps: Boolean) = Unit /** Creates a [PreDragCondition] for [view], if it is a search result that requires one. */ open fun createPreDragConditionForSearch(view: View): PreDragCondition? = null + open fun handleBackInvoked(): Boolean = false + companion object { @JvmStatic fun newInstance(context: Context): TaskbarSearchSessionController { diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index 6c73a2de81..ffd22b89e2 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -203,6 +203,8 @@ public class QuickstepLauncher extends Launcher { public static final boolean GO_LOW_RAM_RECENTS_ENABLED = false; + protected static final String RING_APPEAR_ANIMATION_PREFIX = "RingAppearAnimation\t"; + private FixedContainerItems mAllAppsPredictions; private HotseatPredictionController mHotseatPredictionController; private DepthController mDepthController; @@ -1363,5 +1365,8 @@ public class QuickstepLauncher extends Launcher { if (recentsView != null) { recentsView.getSplitSelectController().dump(prefix, writer); } + if (mAppTransitionManager != null) { + mAppTransitionManager.dump(prefix + "\t" + RING_APPEAR_ANIMATION_PREFIX, writer); + } } } diff --git a/quickstep/src/com/android/quickstep/TaskAnimationManager.java b/quickstep/src/com/android/quickstep/TaskAnimationManager.java index 739f10eb6a..c0684d7750 100644 --- a/quickstep/src/com/android/quickstep/TaskAnimationManager.java +++ b/quickstep/src/com/android/quickstep/TaskAnimationManager.java @@ -206,7 +206,8 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn if (mLastAppearedTaskTargets != null) { for (RemoteAnimationTarget lastTarget : mLastAppearedTaskTargets) { for (RemoteAnimationTarget appearedTarget : appearedTaskTargets) { - if (appearedTarget.taskId != lastTarget.taskId) { + if (lastTarget != null && + appearedTarget.taskId != lastTarget.taskId) { mController.removeTaskTarget(lastTarget.taskId); } } diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java index 5301c7c207..6b0843ccf5 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/src/com/android/quickstep/views/TaskView.java @@ -97,7 +97,6 @@ import com.android.quickstep.RemoteAnimationTargets; import com.android.quickstep.RemoteTargetGluer.RemoteTargetHandle; import com.android.quickstep.TaskAnimationManager; import com.android.quickstep.TaskIconCache; -import com.android.quickstep.TaskOverlayFactory; import com.android.quickstep.TaskThumbnailCache; import com.android.quickstep.TaskUtils; import com.android.quickstep.TaskViewUtils; @@ -413,7 +412,9 @@ public class TaskView extends FrameLayout implements Reusable { private boolean mIsClickableAsLiveTile = true; - @Nullable private final BorderAnimator mBorderAnimator; + @Nullable private final BorderAnimator mFocusBorderAnimator; + + @Nullable private final BorderAnimator mHoverBorderAnimator; public TaskView(Context context) { this(context, null); @@ -439,23 +440,40 @@ public class TaskView extends FrameLayout implements Reusable { boolean keyboardFocusHighlightEnabled = FeatureFlags.ENABLE_KEYBOARD_QUICK_SWITCH.get() || DesktopTaskView.DESKTOP_MODE_SUPPORTED; - setWillNotDraw(!keyboardFocusHighlightEnabled); + boolean willDrawBorder = + keyboardFocusHighlightEnabled || FeatureFlags.ENABLE_CURSOR_HOVER_STATES.get(); + setWillNotDraw(!willDrawBorder); - TypedArray ta = context.obtainStyledAttributes( - attrs, R.styleable.TaskView, defStyleAttr, defStyleRes); + if (willDrawBorder) { + TypedArray styledAttrs = context.obtainStyledAttributes( + attrs, R.styleable.TaskView, defStyleAttr, defStyleRes); - mBorderAnimator = !keyboardFocusHighlightEnabled - ? null - : new BorderAnimator( - /* borderRadiusPx= */ (int) mCurrentFullscreenParams.mCornerRadius, - /* borderColor= */ ta.getColor( - R.styleable.TaskView_borderColor, DEFAULT_BORDER_COLOR), - /* borderAnimationParams= */ new BorderAnimator.SimpleParams( - /* borderWidthPx= */ context.getResources().getDimensionPixelSize( - R.dimen.keyboard_quick_switch_border_width), - /* boundsBuilder= */ this::updateBorderBounds, - /* targetView= */ this)); - ta.recycle(); + mFocusBorderAnimator = keyboardFocusHighlightEnabled ? new BorderAnimator( + /* borderRadiusPx= */ (int) mCurrentFullscreenParams.mCornerRadius, + /* borderColor= */ styledAttrs.getColor( + R.styleable.TaskView_focusBorderColor, DEFAULT_BORDER_COLOR), + /* borderAnimationParams= */ new BorderAnimator.SimpleParams( + /* borderWidthPx= */ context.getResources().getDimensionPixelSize( + R.dimen.keyboard_quick_switch_border_width), + /* boundsBuilder= */ this::updateBorderBounds, + /* targetView= */ this)) : null; + + mHoverBorderAnimator = + FeatureFlags.ENABLE_CURSOR_HOVER_STATES.get() ? new BorderAnimator( + /* borderRadiusPx= */ (int) mCurrentFullscreenParams.mCornerRadius, + /* borderColor= */ styledAttrs.getColor( + R.styleable.TaskView_hoverBorderColor, DEFAULT_BORDER_COLOR), + /* borderAnimationParams= */ new BorderAnimator.SimpleParams( + /* borderWidthPx= */ context.getResources() + .getDimensionPixelSize(R.dimen.task_hover_border_width), + /* boundsBuilder= */ this::updateBorderBounds, + /* targetView= */ this)) : null; + + styledAttrs.recycle(); + } else { + mFocusBorderAnimator = null; + mHoverBorderAnimator = null; + } } protected void updateBorderBounds(Rect bounds) { @@ -509,16 +527,48 @@ public class TaskView extends FrameLayout implements Reusable { @Override protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) { super.onFocusChanged(gainFocus, direction, previouslyFocusedRect); - if (mBorderAnimator != null) { - mBorderAnimator.buildAnimator(gainFocus).start(); + if (mFocusBorderAnimator != null) { + mFocusBorderAnimator.buildAnimator(gainFocus).start(); + } + } + + @Override + public boolean onHoverEvent(MotionEvent event) { + if (FeatureFlags.ENABLE_CURSOR_HOVER_STATES.get()) { + switch (event.getAction()) { + case MotionEvent.ACTION_HOVER_ENTER: + mHoverBorderAnimator.buildAnimator(/* isAppearing= */ true).start(); + break; + case MotionEvent.ACTION_HOVER_EXIT: + mHoverBorderAnimator.buildAnimator(/* isAppearing= */ false).start(); + break; + default: + break; + } + } + return super.onHoverEvent(event); + } + + @Override + public boolean onInterceptHoverEvent(MotionEvent event) { + if (FeatureFlags.ENABLE_CURSOR_HOVER_STATES.get()) { + // avoid triggering hover event on child elements which would cause HOVER_EXIT for this + // task view + return true; + } else { + return super.onInterceptHoverEvent(event); } } @Override public void draw(Canvas canvas) { super.draw(canvas); - if (mBorderAnimator != null) { - mBorderAnimator.drawBorder(canvas); + if (mFocusBorderAnimator != null) { + mFocusBorderAnimator.drawBorder(canvas); + } + + if (mHoverBorderAnimator != null) { + mHoverBorderAnimator.drawBorder(canvas); } } diff --git a/res/drawable/ic_split_exit.xml b/res/drawable/ic_split_exit.xml new file mode 100644 index 0000000000..d7e8b03c50 --- /dev/null +++ b/res/drawable/ic_split_exit.xml @@ -0,0 +1,25 @@ + + + + + \ No newline at end of file diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionListener.java b/src/com/android/launcher3/allapps/AllAppsTransitionListener.java new file mode 100644 index 0000000000..4a17e29039 --- /dev/null +++ b/src/com/android/launcher3/allapps/AllAppsTransitionListener.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2023 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. + */ +package com.android.launcher3.allapps; + +/** + * An interface for listening to all-apps open-close transition + */ +public interface AllAppsTransitionListener { + /** + * Called when the transition starts + * @param toAllApps {@code true} if this transition is supposed to end in the AppApps UI + * + * @see ActivityAllAppsContainerView + */ + void onAllAppsTransitionStart(boolean toAllApps); + + /** + * Called when the transition ends + * @param toAllApps {@code true} if the final state is all-apps + * + * @see ActivityAllAppsContainerView + */ + void onAllAppsTransitionEnd(boolean toAllApps); +} diff --git a/src/com/android/launcher3/util/EventLogArray.kt b/src/com/android/launcher3/util/EventLogArray.kt new file mode 100644 index 0000000000..a17d6509e3 --- /dev/null +++ b/src/com/android/launcher3/util/EventLogArray.kt @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2023 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 + */ + +package com.android.launcher3.util + +import java.io.PrintWriter +import java.text.SimpleDateFormat +import java.util.Date +import java.util.Locale + +/** + * A utility class to record and log events. Events are stored in a fixed size array and old logs + * are purged as new events come. + */ +class EventLogArray(private val name: String, size: Int) { + + companion object { + private const val TYPE_ONE_OFF = 0 + private const val TYPE_FLOAT = 1 + private const val TYPE_INTEGER = 2 + private const val TYPE_BOOL_TRUE = 3 + private const val TYPE_BOOL_FALSE = 4 + private fun isEntrySame(entry: EventEntry?, type: Int, event: String): Boolean { + return entry != null && entry.type == type && entry.event == event + } + } + + private val logs: Array + private var nextIndex = 0 + + init { + logs = arrayOfNulls(size) + } + + fun addLog(event: String) { + addLog(TYPE_ONE_OFF, event, 0f) + } + + fun addLog(event: String, extras: Int) { + addLog(TYPE_INTEGER, event, extras.toFloat()) + } + + fun addLog(event: String, extras: Float) { + addLog(TYPE_FLOAT, event, extras) + } + + fun addLog(event: String, extras: Boolean) { + addLog(if (extras) TYPE_BOOL_TRUE else TYPE_BOOL_FALSE, event, 0f) + } + + private fun addLog(type: Int, event: String, extras: Float) { + // Merge the logs if it's a duplicate + val last = (nextIndex + logs.size - 1) % logs.size + val secondLast = (nextIndex + logs.size - 2) % logs.size + if (isEntrySame(logs[last], type, event) && isEntrySame(logs[secondLast], type, event)) { + logs[last]!!.update(type, event, extras) + logs[secondLast]!!.duplicateCount++ + return + } + if (logs[nextIndex] == null) { + logs[nextIndex] = EventEntry() + } + logs[nextIndex]!!.update(type, event, extras) + nextIndex = (nextIndex + 1) % logs.size + } + + fun dump(prefix: String, writer: PrintWriter) { + writer.println("$prefix$name event history:") + val sdf = SimpleDateFormat(" HH:mm:ss.SSSZ ", Locale.US) + val date = Date() + for (i in logs.indices) { + val log = logs[(nextIndex + logs.size - i - 1) % logs.size] ?: continue + date.time = log.time + val msg = StringBuilder(prefix).append(sdf.format(date)).append(log.event) + when (log.type) { + TYPE_BOOL_FALSE -> msg.append(": false") + TYPE_BOOL_TRUE -> msg.append(": true") + TYPE_FLOAT -> msg.append(": ").append(log.extras) + TYPE_INTEGER -> msg.append(": ").append(log.extras.toInt()) + else -> {} + } + if (log.duplicateCount > 0) { + msg.append(" & ").append(log.duplicateCount).append(" similar events") + } + writer.println(msg) + } + } + + /** A single event entry. */ + private class EventEntry { + var type = 0 + var event: String? = null + var extras = 0f + var time: Long = 0 + var duplicateCount = 0 + fun update(type: Int, event: String, extras: Float) { + this.type = type + this.event = event + this.extras = extras + time = System.currentTimeMillis() + duplicateCount = 0 + } + } +} diff --git a/tests/src/com/android/launcher3/testcomponent/BaseTestingActivity.java b/tests/src/com/android/launcher3/testcomponent/BaseTestingActivity.java index d3ce67c81c..81a59b9a45 100644 --- a/tests/src/com/android/launcher3/testcomponent/BaseTestingActivity.java +++ b/tests/src/com/android/launcher3/testcomponent/BaseTestingActivity.java @@ -69,7 +69,10 @@ public class BaseTestingActivity extends Activity implements View.OnClickListene mView.setBackgroundColor(Color.BLUE); setContentView(mView); - registerReceiver(mCommandReceiver, new IntentFilter(mAction + SUFFIX_COMMAND)); + registerReceiver( + mCommandReceiver, + new IntentFilter(mAction + SUFFIX_COMMAND), + RECEIVER_EXPORTED); } protected void addButton(String title, String method) {