2021-06-08 20:03:43 -07:00
|
|
|
/*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
package com.android.launcher3.taskbar;
|
|
|
|
|
|
2021-06-15 14:49:28 -07:00
|
|
|
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
|
2021-07-16 12:15:35 -10:00
|
|
|
import static com.android.launcher3.Utilities.squaredHypot;
|
2021-06-15 14:49:28 -07:00
|
|
|
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
2021-06-01 16:54:07 -07:00
|
|
|
import static com.android.quickstep.AnimatedFloat.VALUE;
|
2021-06-15 14:49:28 -07:00
|
|
|
|
2022-03-04 16:27:54 +00:00
|
|
|
import android.annotation.NonNull;
|
2021-06-15 14:49:28 -07:00
|
|
|
import android.graphics.Rect;
|
2021-08-27 14:11:53 +01:00
|
|
|
import android.util.FloatProperty;
|
2022-01-31 16:25:22 -08:00
|
|
|
import android.util.Log;
|
2021-07-16 12:15:35 -10:00
|
|
|
import android.view.MotionEvent;
|
2021-06-08 20:03:43 -07:00
|
|
|
import android.view.View;
|
2022-03-04 16:27:54 +00:00
|
|
|
|
|
|
|
|
import androidx.core.view.OneShotPreDrawListener;
|
2021-06-08 20:03:43 -07:00
|
|
|
|
2021-08-27 14:11:53 +01:00
|
|
|
import com.android.launcher3.BubbleTextView;
|
2021-06-15 14:49:28 -07:00
|
|
|
import com.android.launcher3.DeviceProfile;
|
2021-06-23 12:36:18 -07:00
|
|
|
import com.android.launcher3.LauncherAppState;
|
2021-07-16 12:15:35 -10:00
|
|
|
import com.android.launcher3.Utilities;
|
2021-06-15 14:49:28 -07:00
|
|
|
import com.android.launcher3.anim.AnimatorPlaybackController;
|
|
|
|
|
import com.android.launcher3.anim.PendingAnimation;
|
2022-01-31 16:25:22 -08:00
|
|
|
import com.android.launcher3.config.FeatureFlags;
|
2021-08-27 14:11:53 +01:00
|
|
|
import com.android.launcher3.folder.FolderIcon;
|
2021-06-15 14:49:28 -07:00
|
|
|
import com.android.launcher3.model.data.ItemInfo;
|
2022-03-03 23:38:36 +00:00
|
|
|
import com.android.launcher3.util.ItemInfoMatcher;
|
2021-10-19 14:47:23 -07:00
|
|
|
import com.android.launcher3.util.LauncherBindableItemsContainer;
|
2021-06-08 20:03:43 -07:00
|
|
|
import com.android.launcher3.util.MultiValueAlpha;
|
2021-06-01 16:54:07 -07:00
|
|
|
import com.android.quickstep.AnimatedFloat;
|
2021-06-08 20:03:43 -07:00
|
|
|
|
2021-12-15 13:09:39 -08:00
|
|
|
import java.io.PrintWriter;
|
|
|
|
|
|
2021-06-08 20:03:43 -07:00
|
|
|
/**
|
|
|
|
|
* Handles properties/data collection, then passes the results to TaskbarView to render.
|
|
|
|
|
*/
|
2021-12-15 13:09:39 -08:00
|
|
|
public class TaskbarViewController implements TaskbarControllers.LoggableTaskbarController {
|
2022-01-31 16:25:22 -08:00
|
|
|
|
|
|
|
|
private static final String TAG = TaskbarViewController.class.getSimpleName();
|
|
|
|
|
|
2021-06-15 14:49:28 -07:00
|
|
|
private static final Runnable NO_OP = () -> { };
|
2021-06-08 20:03:43 -07:00
|
|
|
|
|
|
|
|
public static final int ALPHA_INDEX_HOME = 0;
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
public static final int ALPHA_INDEX_KEYGUARD = 1;
|
|
|
|
|
public static final int ALPHA_INDEX_STASH = 2;
|
|
|
|
|
public static final int ALPHA_INDEX_RECENTS_DISABLED = 3;
|
|
|
|
|
public static final int ALPHA_INDEX_NOTIFICATION_EXPANDED = 4;
|
|
|
|
|
private static final int NUM_ALPHA_CHANNELS = 5;
|
2021-06-08 20:03:43 -07:00
|
|
|
|
|
|
|
|
private final TaskbarActivityContext mActivity;
|
|
|
|
|
private final TaskbarView mTaskbarView;
|
|
|
|
|
private final MultiValueAlpha mTaskbarIconAlpha;
|
2021-06-01 16:54:07 -07:00
|
|
|
private final AnimatedFloat mTaskbarIconScaleForStash = new AnimatedFloat(this::updateScale);
|
|
|
|
|
private final AnimatedFloat mTaskbarIconTranslationYForHome = new AnimatedFloat(
|
|
|
|
|
this::updateTranslationY);
|
|
|
|
|
private final AnimatedFloat mTaskbarIconTranslationYForStash = new AnimatedFloat(
|
|
|
|
|
this::updateTranslationY);
|
2021-10-12 21:41:13 -07:00
|
|
|
private AnimatedFloat mTaskbarNavButtonTranslationY;
|
2021-06-08 20:03:43 -07:00
|
|
|
|
2021-06-23 12:36:18 -07:00
|
|
|
private final TaskbarModelCallbacks mModelCallbacks;
|
|
|
|
|
|
2021-06-08 20:03:43 -07:00
|
|
|
// Initialized in init.
|
|
|
|
|
private TaskbarControllers mControllers;
|
|
|
|
|
|
2021-06-15 14:49:28 -07:00
|
|
|
// Animation to align icons with Launcher, created lazily. This allows the controller to be
|
|
|
|
|
// active only during the animation and does not need to worry about layout changes.
|
|
|
|
|
private AnimatorPlaybackController mIconAlignControllerLazy = null;
|
|
|
|
|
private Runnable mOnControllerPreCreateCallback = NO_OP;
|
|
|
|
|
|
2021-06-08 20:03:43 -07:00
|
|
|
public TaskbarViewController(TaskbarActivityContext activity, TaskbarView taskbarView) {
|
|
|
|
|
mActivity = activity;
|
|
|
|
|
mTaskbarView = taskbarView;
|
2021-08-26 10:18:04 -07:00
|
|
|
mTaskbarIconAlpha = new MultiValueAlpha(mTaskbarView, NUM_ALPHA_CHANNELS);
|
2021-06-08 20:03:43 -07:00
|
|
|
mTaskbarIconAlpha.setUpdateVisibility(true);
|
2021-06-23 12:36:18 -07:00
|
|
|
mModelCallbacks = new TaskbarModelCallbacks(activity, mTaskbarView);
|
2021-06-08 20:03:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void init(TaskbarControllers controllers) {
|
|
|
|
|
mControllers = controllers;
|
|
|
|
|
mTaskbarView.init(new TaskbarViewCallbacks());
|
|
|
|
|
mTaskbarView.getLayoutParams().height = mActivity.getDeviceProfile().taskbarSize;
|
2021-06-01 16:54:07 -07:00
|
|
|
|
|
|
|
|
mTaskbarIconScaleForStash.updateValue(1f);
|
2021-10-07 15:53:32 -07:00
|
|
|
|
|
|
|
|
mModelCallbacks.init(controllers);
|
2021-10-01 11:31:45 -07:00
|
|
|
if (mActivity.isUserSetupComplete()) {
|
|
|
|
|
// Only load the callbacks if user setup is completed
|
|
|
|
|
LauncherAppState.getInstance(mActivity).getModel().addCallbacksAndLoad(mModelCallbacks);
|
|
|
|
|
}
|
2021-10-12 21:41:13 -07:00
|
|
|
mTaskbarNavButtonTranslationY =
|
|
|
|
|
controllers.navbarButtonsViewController.getTaskbarNavButtonTranslationY();
|
2021-06-23 12:36:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void onDestroy() {
|
|
|
|
|
LauncherAppState.getInstance(mActivity).getModel().removeCallbacks(mModelCallbacks);
|
2021-06-08 20:03:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean areIconsVisible() {
|
|
|
|
|
return mTaskbarView.areIconsVisible();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MultiValueAlpha getTaskbarIconAlpha() {
|
|
|
|
|
return mTaskbarIconAlpha;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Should be called when the IME visibility changes, so we can make Taskbar not steal touches.
|
|
|
|
|
*/
|
|
|
|
|
public void setImeIsVisible(boolean isImeVisible) {
|
|
|
|
|
mTaskbarView.setTouchesEnabled(!isImeVisible);
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-26 10:18:04 -07:00
|
|
|
/**
|
|
|
|
|
* Should be called when the recents button is disabled, so we can hide taskbar icons as well.
|
|
|
|
|
*/
|
|
|
|
|
public void setRecentsButtonDisabled(boolean isDisabled) {
|
|
|
|
|
// TODO: check TaskbarStashController#supportsStashing(), to stash instead of setting alpha.
|
|
|
|
|
mTaskbarIconAlpha.getProperty(ALPHA_INDEX_RECENTS_DISABLED).setValue(isDisabled ? 0 : 1);
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-08 20:03:43 -07:00
|
|
|
/**
|
|
|
|
|
* Sets OnClickListener and OnLongClickListener for the given view.
|
|
|
|
|
*/
|
|
|
|
|
public void setClickAndLongClickListenersForIcon(View icon) {
|
|
|
|
|
mTaskbarView.setClickAndLongClickListenersForIcon(icon);
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-27 14:11:53 +01:00
|
|
|
/**
|
|
|
|
|
* Adds one time pre draw listener to the taskbar view, it is called before
|
|
|
|
|
* drawing a frame and invoked only once
|
|
|
|
|
* @param listener callback that will be invoked before drawing the next frame
|
|
|
|
|
*/
|
2022-03-04 16:27:54 +00:00
|
|
|
public void addOneTimePreDrawListener(@NonNull Runnable listener) {
|
|
|
|
|
OneShotPreDrawListener.add(mTaskbarView, listener);
|
2021-08-27 14:11:53 +01:00
|
|
|
}
|
|
|
|
|
|
2021-06-01 16:54:07 -07:00
|
|
|
public Rect getIconLayoutBounds() {
|
|
|
|
|
return mTaskbarView.getIconLayoutBounds();
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 10:56:31 -07:00
|
|
|
public View[] getIconViews() {
|
|
|
|
|
return mTaskbarView.getIconViews();
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-05 07:06:41 +00:00
|
|
|
public View getAllAppsButtonView() {
|
|
|
|
|
return mTaskbarView.getAllAppsButtonView();
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-01 16:54:07 -07:00
|
|
|
public AnimatedFloat getTaskbarIconScaleForStash() {
|
|
|
|
|
return mTaskbarIconScaleForStash;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public AnimatedFloat getTaskbarIconTranslationYForStash() {
|
|
|
|
|
return mTaskbarIconTranslationYForStash;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Applies scale properties for the entire TaskbarView (rather than individual icons).
|
|
|
|
|
*/
|
|
|
|
|
private void updateScale() {
|
|
|
|
|
float scale = mTaskbarIconScaleForStash.value;
|
|
|
|
|
mTaskbarView.setScaleX(scale);
|
|
|
|
|
mTaskbarView.setScaleY(scale);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateTranslationY() {
|
|
|
|
|
mTaskbarView.setTranslationY(mTaskbarIconTranslationYForHome.value
|
|
|
|
|
+ mTaskbarIconTranslationYForStash.value);
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-15 14:49:28 -07:00
|
|
|
/**
|
|
|
|
|
* Sets the taskbar icon alignment relative to Launcher hotseat icons
|
|
|
|
|
* @param alignmentRatio [0, 1]
|
|
|
|
|
* 0 => not aligned
|
|
|
|
|
* 1 => fully aligned
|
|
|
|
|
*/
|
|
|
|
|
public void setLauncherIconAlignment(float alignmentRatio, DeviceProfile launcherDp) {
|
2022-03-09 07:53:39 +00:00
|
|
|
if (mIconAlignControllerLazy == null) {
|
|
|
|
|
mIconAlignControllerLazy = createIconAlignmentController(launcherDp);
|
|
|
|
|
}
|
2021-06-15 14:49:28 -07:00
|
|
|
mIconAlignControllerLazy.setPlayFraction(alignmentRatio);
|
|
|
|
|
if (alignmentRatio <= 0 || alignmentRatio >= 1) {
|
|
|
|
|
// Cleanup lazy controller so that it is created again in next animation
|
|
|
|
|
mIconAlignControllerLazy = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates an animation for aligning the taskbar icons with the provided Launcher device profile
|
|
|
|
|
*/
|
|
|
|
|
private AnimatorPlaybackController createIconAlignmentController(DeviceProfile launcherDp) {
|
|
|
|
|
mOnControllerPreCreateCallback.run();
|
|
|
|
|
PendingAnimation setter = new PendingAnimation(100);
|
|
|
|
|
Rect hotseatPadding = launcherDp.getHotseatLayoutPadding(mActivity);
|
|
|
|
|
float scaleUp = ((float) launcherDp.iconSizePx) / mActivity.getDeviceProfile().iconSizePx;
|
2022-02-12 19:23:23 +00:00
|
|
|
int borderSpacing = launcherDp.hotseatBorderSpace;
|
2021-12-15 01:10:17 +00:00
|
|
|
int hotseatCellSize = DeviceProfile.calculateCellWidth(
|
|
|
|
|
launcherDp.availableWidthPx - hotseatPadding.left - hotseatPadding.right,
|
|
|
|
|
borderSpacing,
|
|
|
|
|
launcherDp.numShownHotseatIcons);
|
2021-06-15 14:49:28 -07:00
|
|
|
|
|
|
|
|
int offsetY = launcherDp.getTaskbarOffsetY();
|
2021-06-01 16:54:07 -07:00
|
|
|
setter.setFloat(mTaskbarIconTranslationYForHome, VALUE, -offsetY, LINEAR);
|
2021-10-12 21:41:13 -07:00
|
|
|
setter.setFloat(mTaskbarNavButtonTranslationY, VALUE, -offsetY, LINEAR);
|
2021-06-15 14:49:28 -07:00
|
|
|
|
2021-08-13 17:03:55 -07:00
|
|
|
int collapsedHeight = mActivity.getDefaultTaskbarWindowHeight();
|
|
|
|
|
int expandedHeight = Math.max(collapsedHeight,
|
|
|
|
|
mActivity.getDeviceProfile().taskbarSize + offsetY);
|
2021-06-15 14:49:28 -07:00
|
|
|
setter.addOnFrameListener(anim -> mActivity.setTaskbarWindowHeight(
|
|
|
|
|
anim.getAnimatedFraction() > 0 ? expandedHeight : collapsedHeight));
|
|
|
|
|
|
|
|
|
|
int count = mTaskbarView.getChildCount();
|
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
|
View child = mTaskbarView.getChildAt(i);
|
|
|
|
|
|
2022-01-31 16:25:22 -08:00
|
|
|
int positionInHotseat = -1;
|
|
|
|
|
if (FeatureFlags.ENABLE_ALL_APPS_IN_TASKBAR.get() && i == count - 1) {
|
|
|
|
|
// Note that there is no All Apps button in the hotseat, this position is only used
|
|
|
|
|
// as its convenient for animation purposes.
|
2022-02-07 14:06:35 -08:00
|
|
|
positionInHotseat = Utilities.isRtl(child.getResources())
|
|
|
|
|
? -1
|
|
|
|
|
: mActivity.getDeviceProfile().inv.numShownHotseatIcons;
|
2022-01-31 16:25:22 -08:00
|
|
|
|
|
|
|
|
setter.setViewAlpha(child, 0, LINEAR);
|
|
|
|
|
} else if (child.getTag() instanceof ItemInfo) {
|
|
|
|
|
positionInHotseat = ((ItemInfo) child.getTag()).screenId;
|
|
|
|
|
} else {
|
|
|
|
|
Log.w(TAG, "Unsupported view found in createIconAlignmentController, v=" + child);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-15 01:10:17 +00:00
|
|
|
float hotseatIconCenter = hotseatPadding.left
|
2022-01-31 16:25:22 -08:00
|
|
|
+ (hotseatCellSize + borderSpacing) * positionInHotseat
|
2022-02-12 19:23:23 +00:00
|
|
|
+ hotseatCellSize / 2f;
|
2022-01-31 16:25:22 -08:00
|
|
|
|
2022-02-12 19:23:23 +00:00
|
|
|
float childCenter = (child.getLeft() + child.getRight()) / 2f;
|
2021-08-27 14:11:53 +01:00
|
|
|
setter.setFloat(child, ICON_TRANSLATE_X, hotseatIconCenter - childCenter, LINEAR);
|
2022-01-31 16:25:22 -08:00
|
|
|
|
|
|
|
|
setter.setFloat(child, SCALE_PROPERTY, scaleUp, LINEAR);
|
2021-06-15 14:49:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AnimatorPlaybackController controller = setter.createPlaybackController();
|
|
|
|
|
mOnControllerPreCreateCallback = () -> controller.setPlayFraction(0);
|
|
|
|
|
return controller;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-12 21:41:13 -07:00
|
|
|
public void onRotationChanged(DeviceProfile deviceProfile) {
|
|
|
|
|
if (areIconsVisible()) {
|
|
|
|
|
// We only translate on rotation when on home
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
mTaskbarNavButtonTranslationY.updateValue(-deviceProfile.getTaskbarOffsetY());
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-03 23:38:36 +00:00
|
|
|
/**
|
|
|
|
|
* Maps the given operator to all the top-level children of TaskbarView.
|
|
|
|
|
*/
|
|
|
|
|
public void mapOverItems(LauncherBindableItemsContainer.ItemOperator op) {
|
|
|
|
|
mTaskbarView.mapOverItems(op);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the first icon to match the given parameter, in priority from:
|
|
|
|
|
* 1) Icons directly on Taskbar
|
|
|
|
|
* 2) FolderIcon of the Folder containing the given icon
|
|
|
|
|
* 3) All Apps button
|
|
|
|
|
*/
|
|
|
|
|
public View getFirstIconMatch(ItemInfoMatcher matcher) {
|
|
|
|
|
ItemInfoMatcher folderMatcher = ItemInfoMatcher.forFolderMatch(matcher);
|
|
|
|
|
return mTaskbarView.getFirstMatch(matcher, folderMatcher);
|
2021-10-19 14:47:23 -07:00
|
|
|
}
|
|
|
|
|
|
2021-10-18 16:02:21 -07:00
|
|
|
/**
|
|
|
|
|
* Returns whether the given MotionEvent, *in screen coorindates*, is within any Taskbar item's
|
|
|
|
|
* touch bounds.
|
|
|
|
|
*/
|
|
|
|
|
public boolean isEventOverAnyItem(MotionEvent ev) {
|
|
|
|
|
return mTaskbarView.isEventOverAnyItem(ev);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-15 13:09:39 -08:00
|
|
|
@Override
|
|
|
|
|
public void dumpLogs(String prefix, PrintWriter pw) {
|
|
|
|
|
pw.println(prefix + "TaskbarViewController:");
|
|
|
|
|
mModelCallbacks.dumpLogs(prefix + "\t", pw);
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-08 20:03:43 -07:00
|
|
|
/**
|
|
|
|
|
* Callbacks for {@link TaskbarView} to interact with its controller.
|
|
|
|
|
*/
|
|
|
|
|
public class TaskbarViewCallbacks {
|
2021-07-16 12:15:35 -10:00
|
|
|
private final float mSquaredTouchSlop = Utilities.squaredTouchSlop(mActivity);
|
|
|
|
|
|
|
|
|
|
private float mDownX, mDownY;
|
|
|
|
|
private boolean mCanceledStashHint;
|
|
|
|
|
|
2021-06-01 16:54:07 -07:00
|
|
|
public View.OnClickListener getIconOnClickListener() {
|
2021-10-12 12:38:55 -07:00
|
|
|
return mActivity.getItemOnClickListener();
|
2021-06-08 20:03:43 -07:00
|
|
|
}
|
|
|
|
|
|
2022-01-31 16:25:22 -08:00
|
|
|
public View.OnClickListener getAllAppsButtonClickListener() {
|
2022-02-07 22:22:09 -05:00
|
|
|
return v -> mControllers.taskbarAllAppsController.show();
|
2022-01-31 16:25:22 -08:00
|
|
|
}
|
|
|
|
|
|
2021-06-01 16:54:07 -07:00
|
|
|
public View.OnLongClickListener getIconOnLongClickListener() {
|
2021-06-08 20:03:43 -07:00
|
|
|
return mControllers.taskbarDragController::startDragOnLongClick;
|
|
|
|
|
}
|
2021-06-01 16:54:07 -07:00
|
|
|
|
|
|
|
|
public View.OnLongClickListener getBackgroundOnLongClickListener() {
|
2021-10-07 15:49:19 -07:00
|
|
|
return view -> mControllers.taskbarStashController
|
|
|
|
|
.updateAndAnimateIsManuallyStashedInApp(true);
|
2021-06-01 16:54:07 -07:00
|
|
|
}
|
2021-07-16 12:15:35 -10:00
|
|
|
|
2021-08-31 10:41:36 -07:00
|
|
|
/**
|
|
|
|
|
* Get the first chance to handle TaskbarView#onTouchEvent, and return whether we want to
|
|
|
|
|
* consume the touch so TaskbarView treats it as an ACTION_CANCEL.
|
|
|
|
|
*/
|
|
|
|
|
public boolean onTouchEvent(MotionEvent motionEvent) {
|
2021-07-16 12:15:35 -10:00
|
|
|
final float x = motionEvent.getRawX();
|
|
|
|
|
final float y = motionEvent.getRawY();
|
|
|
|
|
switch (motionEvent.getAction()) {
|
|
|
|
|
case MotionEvent.ACTION_DOWN:
|
|
|
|
|
mDownX = x;
|
|
|
|
|
mDownY = y;
|
|
|
|
|
mControllers.taskbarStashController.startStashHint(/* animateForward = */ true);
|
|
|
|
|
mCanceledStashHint = false;
|
|
|
|
|
break;
|
|
|
|
|
case MotionEvent.ACTION_MOVE:
|
|
|
|
|
if (!mCanceledStashHint
|
|
|
|
|
&& squaredHypot(mDownX - x, mDownY - y) > mSquaredTouchSlop) {
|
|
|
|
|
mControllers.taskbarStashController.startStashHint(
|
|
|
|
|
/* animateForward= */ false);
|
|
|
|
|
mCanceledStashHint = true;
|
2021-08-31 10:41:36 -07:00
|
|
|
return true;
|
2021-07-16 12:15:35 -10:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case MotionEvent.ACTION_UP:
|
|
|
|
|
case MotionEvent.ACTION_CANCEL:
|
|
|
|
|
if (!mCanceledStashHint) {
|
|
|
|
|
mControllers.taskbarStashController.startStashHint(
|
|
|
|
|
/* animateForward= */ false);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2021-08-31 10:41:36 -07:00
|
|
|
return false;
|
2021-07-16 12:15:35 -10:00
|
|
|
}
|
2021-06-08 20:03:43 -07:00
|
|
|
}
|
2021-08-27 14:11:53 +01:00
|
|
|
|
|
|
|
|
public static final FloatProperty<View> ICON_TRANSLATE_X =
|
|
|
|
|
new FloatProperty<View>("taskbarAligmentTranslateX") {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setValue(View view, float v) {
|
|
|
|
|
if (view instanceof BubbleTextView) {
|
|
|
|
|
((BubbleTextView) view).setTranslationXForTaskbarAlignmentAnimation(v);
|
|
|
|
|
} else if (view instanceof FolderIcon) {
|
|
|
|
|
((FolderIcon) view).setTranslationForTaskbarAlignmentAnimation(v);
|
|
|
|
|
} else {
|
|
|
|
|
view.setTranslationX(v);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Float get(View view) {
|
|
|
|
|
if (view instanceof BubbleTextView) {
|
|
|
|
|
return ((BubbleTextView) view)
|
|
|
|
|
.getTranslationXForTaskbarAlignmentAnimation();
|
|
|
|
|
} else if (view instanceof FolderIcon) {
|
|
|
|
|
return ((FolderIcon) view).getTranslationXForTaskbarAlignmentAnimation();
|
|
|
|
|
}
|
|
|
|
|
return view.getTranslationX();
|
|
|
|
|
}
|
|
|
|
|
};
|
2021-06-08 20:03:43 -07:00
|
|
|
}
|