mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-17 09:38:19 +00:00
Moving taskbar lifecycle to TouchInteractionService
> Inflating taskbar views with a non-launcher window context > Removing separate taskbar view in Launcher > Handling taskbar icon clicks directly instead of going via launcher > Fixing some relayouts during show/hide animation Bug: 187353581 Test: Manual Change-Id: Ia7d44acbb770bf0345922234b3daa5cc040a5843
This commit is contained in:
@@ -15,105 +15,83 @@
|
||||
*/
|
||||
package com.android.launcher3.taskbar;
|
||||
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.INVISIBLE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
|
||||
|
||||
import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_BOTTOM_TAPPABLE_ELEMENT;
|
||||
import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_EXTRA_NAVIGATION_BAR;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.app.ActivityOptions;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.inputmethodservice.InputMethodService;
|
||||
import android.view.Gravity;
|
||||
import android.graphics.RectF;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.AbstractFloatingView;
|
||||
import com.android.launcher3.BaseQuickstepLauncher;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.LauncherState;
|
||||
import com.android.launcher3.QuickstepTransitionManager;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.anim.AlphaUpdateListener;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.anim.PendingAnimation;
|
||||
import com.android.launcher3.folder.Folder;
|
||||
import com.android.launcher3.folder.FolderIcon;
|
||||
import com.android.launcher3.model.data.FolderInfo;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.states.StateAnimationConfig;
|
||||
import com.android.launcher3.taskbar.TaskbarNavButtonController.TaskbarButton;
|
||||
import com.android.launcher3.touch.ItemClickHandler;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
import com.android.quickstep.AnimatedFloat;
|
||||
import com.android.quickstep.SysUINavigationMode;
|
||||
import com.android.quickstep.TouchInteractionService.TaskbarOverviewProxyDelegate;
|
||||
import com.android.systemui.shared.recents.model.Task;
|
||||
import com.android.systemui.shared.system.ActivityManagerWrapper;
|
||||
import com.android.systemui.shared.system.WindowManagerWrapper;
|
||||
|
||||
|
||||
/**
|
||||
* Interfaces with Launcher/WindowManager/SystemUI to determine what to show in TaskbarView.
|
||||
* A data source which integrates with a Launcher instance
|
||||
* TODO: Rename to have Launcher prefix
|
||||
*/
|
||||
public class TaskbarController implements TaskbarOverviewProxyDelegate {
|
||||
|
||||
private static final String WINDOW_TITLE = "Taskbar";
|
||||
|
||||
private final TaskbarContainerView mTaskbarContainerView;
|
||||
private final TaskbarView mTaskbarViewInApp;
|
||||
private final TaskbarView mTaskbarViewOnHome;
|
||||
private final ImeBarView mImeBarView;
|
||||
public class TaskbarController extends TaskbarUIController {
|
||||
|
||||
private final BaseQuickstepLauncher mLauncher;
|
||||
private final WindowManager mWindowManager;
|
||||
// Layout width and height of the Taskbar in the default state.
|
||||
private final Point mTaskbarSize;
|
||||
private final TaskbarStateHandler mTaskbarStateHandler;
|
||||
private final TaskbarAnimationController mTaskbarAnimationController;
|
||||
private final TaskbarHotseatController mHotseatController;
|
||||
private final TaskbarDragController mDragController;
|
||||
private final TaskbarNavButtonController mNavButtonController;
|
||||
|
||||
// Initialized in init().
|
||||
private WindowManager.LayoutParams mWindowLayoutParams;
|
||||
private SysUINavigationMode.Mode mNavMode = SysUINavigationMode.Mode.NO_BUTTON;
|
||||
private final SysUINavigationMode.NavigationModeChangeListener mNavigationModeChangeListener =
|
||||
this::onNavModeChanged;
|
||||
private final TaskbarActivityContext mContext;
|
||||
final TaskbarContainerView mTaskbarContainerView;
|
||||
final TaskbarView mTaskbarView;
|
||||
|
||||
private @Nullable Animator mAnimator;
|
||||
private boolean mIsAnimatingToLauncher;
|
||||
|
||||
public TaskbarController(BaseQuickstepLauncher launcher,
|
||||
TaskbarContainerView taskbarContainerView, TaskbarView taskbarViewOnHome) {
|
||||
public TaskbarController(BaseQuickstepLauncher launcher, TaskbarActivityContext context) {
|
||||
mContext = context;
|
||||
mTaskbarContainerView = context.getDragLayer();
|
||||
mTaskbarView = mTaskbarContainerView.findViewById(R.id.taskbar_view);
|
||||
|
||||
mLauncher = launcher;
|
||||
mTaskbarContainerView = taskbarContainerView;
|
||||
mTaskbarContainerView.construct(createTaskbarContainerViewCallbacks());
|
||||
ButtonProvider buttonProvider = new ButtonProvider(launcher);
|
||||
mTaskbarViewInApp = mTaskbarContainerView.findViewById(R.id.taskbar_view);
|
||||
mTaskbarViewInApp.construct(createTaskbarViewCallbacks(), buttonProvider);
|
||||
mTaskbarViewOnHome = taskbarViewOnHome;
|
||||
mTaskbarViewOnHome.construct(createTaskbarViewCallbacks(), buttonProvider);
|
||||
mImeBarView = mTaskbarContainerView.findViewById(R.id.ime_bar_view);
|
||||
mImeBarView.construct(buttonProvider);
|
||||
mNavButtonController = new TaskbarNavButtonController(launcher);
|
||||
mWindowManager = mLauncher.getWindowManager();
|
||||
mTaskbarSize = new Point(MATCH_PARENT, mLauncher.getDeviceProfile().taskbarSize);
|
||||
mTaskbarStateHandler = mLauncher.getTaskbarStateHandler();
|
||||
mTaskbarAnimationController = new TaskbarAnimationController(mLauncher,
|
||||
createTaskbarAnimationControllerCallbacks());
|
||||
mHotseatController = new TaskbarHotseatController(mLauncher,
|
||||
createTaskbarHotseatControllerCallbacks());
|
||||
mDragController = new TaskbarDragController(mLauncher);
|
||||
mHotseatController = new TaskbarHotseatController(
|
||||
mLauncher, mTaskbarView::updateHotseatItems);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate() {
|
||||
mTaskbarStateHandler.setAnimationController(mTaskbarAnimationController);
|
||||
mTaskbarAnimationController.init();
|
||||
mHotseatController.init();
|
||||
setTaskbarViewVisible(!mLauncher.hasBeenResumed());
|
||||
alignRealHotseatWithTaskbar();
|
||||
mLauncher.setTaskbarController(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (mAnimator != null) {
|
||||
// End this first, in case it relies on properties that are about to be cleaned up.
|
||||
mAnimator.end();
|
||||
}
|
||||
mTaskbarStateHandler.setAnimationController(null);
|
||||
mTaskbarAnimationController.cleanup();
|
||||
mHotseatController.cleanup();
|
||||
setTaskbarViewVisible(true);
|
||||
mLauncher.getHotseat().setIconsAlpha(1f);
|
||||
mLauncher.setTaskbarController(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isTaskbarTouchable() {
|
||||
return !mIsAnimatingToLauncher;
|
||||
}
|
||||
|
||||
private TaskbarAnimationControllerCallbacks createTaskbarAnimationControllerCallbacks() {
|
||||
@@ -125,245 +103,34 @@ public class TaskbarController implements TaskbarOverviewProxyDelegate {
|
||||
|
||||
@Override
|
||||
public void updateTaskbarVisibilityAlpha(float alpha) {
|
||||
mTaskbarViewInApp.setAlpha(alpha);
|
||||
mTaskbarViewOnHome.setAlpha(alpha);
|
||||
mTaskbarView.setAlpha(alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateImeBarVisibilityAlpha(float alpha) {
|
||||
if (mNavMode != SysUINavigationMode.Mode.THREE_BUTTONS) {
|
||||
// TODO Remove sysui IME bar for gesture nav as well
|
||||
return;
|
||||
}
|
||||
mImeBarView.setAlpha(alpha);
|
||||
mImeBarView.setVisibility(alpha == 0 ? GONE : VISIBLE);
|
||||
mTaskbarContainerView.updateImeBarVisibilityAlpha(alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTaskbarScale(float scale) {
|
||||
mTaskbarViewInApp.setScaleX(scale);
|
||||
mTaskbarViewInApp.setScaleY(scale);
|
||||
mTaskbarView.setScaleX(scale);
|
||||
mTaskbarView.setScaleY(scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTaskbarTranslationY(float translationY) {
|
||||
if (translationY < 0) {
|
||||
// Resize to accommodate the max translation we'll reach.
|
||||
setTaskbarWindowHeight(mTaskbarSize.y
|
||||
mContext.setTaskbarWindowHeight(mContext.getDeviceProfile().taskbarSize
|
||||
+ mLauncher.getHotseat().getTaskbarOffsetY());
|
||||
} else {
|
||||
setTaskbarWindowHeight(mTaskbarSize.y);
|
||||
mContext.setTaskbarWindowHeight(mContext.getDeviceProfile().taskbarSize);
|
||||
}
|
||||
mTaskbarViewInApp.setTranslationY(translationY);
|
||||
mTaskbarView.setTranslationY(translationY);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private TaskbarContainerViewCallbacks createTaskbarContainerViewCallbacks() {
|
||||
return new TaskbarContainerViewCallbacks() {
|
||||
@Override
|
||||
public void onViewRemoved() {
|
||||
// Ensure no other children present (like Folders, etc)
|
||||
for (int i = 0; i < mTaskbarContainerView.getChildCount(); i++) {
|
||||
View v = mTaskbarContainerView.getChildAt(i);
|
||||
if (!((v instanceof TaskbarView) || (v instanceof ImeBarView))){
|
||||
return;
|
||||
}
|
||||
}
|
||||
setTaskbarWindowFullscreen(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTaskbarTouchable() {
|
||||
return mTaskbarContainerView.getAlpha() > AlphaUpdateListener.ALPHA_CUTOFF_THRESHOLD
|
||||
&& (mTaskbarViewInApp.getVisibility() == VISIBLE
|
||||
|| mImeBarView.getVisibility() == VISIBLE)
|
||||
&& !mIsAnimatingToLauncher;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private TaskbarViewCallbacks createTaskbarViewCallbacks() {
|
||||
return new TaskbarViewCallbacks() {
|
||||
@Override
|
||||
public View.OnClickListener getItemOnClickListener() {
|
||||
return view -> {
|
||||
Object tag = view.getTag();
|
||||
if (tag instanceof Task) {
|
||||
Task task = (Task) tag;
|
||||
ActivityManagerWrapper.getInstance().startActivityFromRecents(task.key,
|
||||
ActivityOptions.makeBasic());
|
||||
} else if (tag instanceof FolderInfo) {
|
||||
FolderIcon folderIcon = (FolderIcon) view;
|
||||
Folder folder = folderIcon.getFolder();
|
||||
|
||||
setTaskbarWindowFullscreen(true);
|
||||
|
||||
mTaskbarContainerView.post(() -> {
|
||||
folder.animateOpen();
|
||||
|
||||
folder.iterateOverItems((itemInfo, itemView) -> {
|
||||
itemView.setOnClickListener(getItemOnClickListener());
|
||||
itemView.setOnLongClickListener(getItemOnLongClickListener());
|
||||
// To play haptic when dragging, like other Taskbar items do.
|
||||
itemView.setHapticFeedbackEnabled(true);
|
||||
return false;
|
||||
});
|
||||
});
|
||||
} else {
|
||||
ItemClickHandler.INSTANCE.onClick(view);
|
||||
}
|
||||
|
||||
AbstractFloatingView.closeAllOpenViews(
|
||||
mTaskbarContainerView.getTaskbarActivityContext());
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public View.OnLongClickListener getItemOnLongClickListener() {
|
||||
return mDragController::startSystemDragOnLongClick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEmptyHotseatViewVisibility(TaskbarView taskbarView) {
|
||||
// When on the home screen, we want the empty hotseat views to take up their full
|
||||
// space so that the others line up with the home screen hotseat.
|
||||
boolean isOnHomeScreen = taskbarView == mTaskbarViewOnHome
|
||||
|| mLauncher.hasBeenResumed() || mIsAnimatingToLauncher;
|
||||
return isOnHomeScreen ? INVISIBLE : GONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getNonIconScale(TaskbarView taskbarView) {
|
||||
return taskbarView == mTaskbarViewOnHome ? getTaskbarScaleOnHome() : 1f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemPositionsChanged(TaskbarView taskbarView) {
|
||||
if (taskbarView == mTaskbarViewOnHome) {
|
||||
alignRealHotseatWithTaskbar();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNavigationButtonClick(@TaskbarButton int buttonType) {
|
||||
mNavButtonController.onButtonClick(buttonType);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private TaskbarHotseatControllerCallbacks createTaskbarHotseatControllerCallbacks() {
|
||||
return new TaskbarHotseatControllerCallbacks() {
|
||||
@Override
|
||||
public void updateHotseatItems(ItemInfo[] hotseatItemInfos) {
|
||||
mTaskbarViewInApp.updateHotseatItems(hotseatItemInfos);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the Taskbar, including adding it to the screen.
|
||||
*/
|
||||
public void init() {
|
||||
mNavMode = SysUINavigationMode.INSTANCE.get(mLauncher)
|
||||
.addModeChangeListener(mNavigationModeChangeListener);
|
||||
mTaskbarViewInApp.init(mHotseatController.getNumHotseatIcons(), mNavMode);
|
||||
mTaskbarViewOnHome.init(mHotseatController.getNumHotseatIcons(), mNavMode);
|
||||
mTaskbarContainerView.init(mTaskbarViewInApp);
|
||||
mImeBarView.init(createTaskbarViewCallbacks());
|
||||
addToWindowManager();
|
||||
mTaskbarStateHandler.setTaskbarCallbacks(createTaskbarStateHandlerCallbacks());
|
||||
mTaskbarAnimationController.init();
|
||||
mHotseatController.init();
|
||||
|
||||
setWhichTaskbarViewIsVisible(mLauncher.hasBeenResumed()
|
||||
? mTaskbarViewOnHome
|
||||
: mTaskbarViewInApp);
|
||||
}
|
||||
|
||||
private TaskbarStateHandlerCallbacks createTaskbarStateHandlerCallbacks() {
|
||||
return new TaskbarStateHandlerCallbacks() {
|
||||
@Override
|
||||
public AnimatedFloat getAlphaTarget() {
|
||||
return mTaskbarAnimationController.getTaskbarVisibilityForLauncherState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnimatedFloat getScaleTarget() {
|
||||
return mTaskbarAnimationController.getTaskbarScaleForLauncherState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnimatedFloat getTranslationYTarget() {
|
||||
return mTaskbarAnimationController.getTaskbarTranslationYForLauncherState();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the Taskbar from the screen, and removes any obsolete listeners etc.
|
||||
*/
|
||||
public void cleanup() {
|
||||
if (mAnimator != null) {
|
||||
// End this first, in case it relies on properties that are about to be cleaned up.
|
||||
mAnimator.end();
|
||||
}
|
||||
|
||||
mTaskbarViewInApp.cleanup();
|
||||
mTaskbarViewOnHome.cleanup();
|
||||
mTaskbarContainerView.cleanup();
|
||||
mImeBarView.cleanup();
|
||||
removeFromWindowManager();
|
||||
mTaskbarStateHandler.setTaskbarCallbacks(null);
|
||||
mTaskbarAnimationController.cleanup();
|
||||
mHotseatController.cleanup();
|
||||
|
||||
setWhichTaskbarViewIsVisible(null);
|
||||
SysUINavigationMode.INSTANCE.get(mLauncher)
|
||||
.removeModeChangeListener(mNavigationModeChangeListener);
|
||||
}
|
||||
|
||||
private void removeFromWindowManager() {
|
||||
mWindowManager.removeViewImmediate(mTaskbarContainerView);
|
||||
}
|
||||
|
||||
private void addToWindowManager() {
|
||||
final int gravity = Gravity.BOTTOM;
|
||||
|
||||
mWindowLayoutParams = new WindowManager.LayoutParams(
|
||||
mTaskbarSize.x,
|
||||
mTaskbarSize.y,
|
||||
TYPE_APPLICATION_OVERLAY,
|
||||
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
|
||||
PixelFormat.TRANSLUCENT);
|
||||
mWindowLayoutParams.setTitle(WINDOW_TITLE);
|
||||
mWindowLayoutParams.packageName = mLauncher.getPackageName();
|
||||
mWindowLayoutParams.gravity = gravity;
|
||||
mWindowLayoutParams.setFitInsetsTypes(0);
|
||||
mWindowLayoutParams.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
|
||||
mWindowLayoutParams.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
|
||||
mWindowLayoutParams.setSystemApplicationOverlay(true);
|
||||
|
||||
WindowManagerWrapper wmWrapper = WindowManagerWrapper.getInstance();
|
||||
wmWrapper.setProvidesInsetsTypes(
|
||||
mWindowLayoutParams,
|
||||
new int[] { ITYPE_EXTRA_NAVIGATION_BAR, ITYPE_BOTTOM_TAPPABLE_ELEMENT }
|
||||
);
|
||||
|
||||
TaskbarContainerView.LayoutParams taskbarLayoutParams =
|
||||
new TaskbarContainerView.LayoutParams(mTaskbarSize.x, mTaskbarSize.y);
|
||||
taskbarLayoutParams.gravity = gravity;
|
||||
mTaskbarViewInApp.setLayoutParams(taskbarLayoutParams);
|
||||
|
||||
mWindowManager.addView(mTaskbarContainerView, mWindowLayoutParams);
|
||||
}
|
||||
|
||||
private void onNavModeChanged(SysUINavigationMode.Mode newMode) {
|
||||
mNavMode = newMode;
|
||||
cleanup();
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be called from onResume() and onPause(), and animates the Taskbar accordingly.
|
||||
*/
|
||||
@@ -401,13 +168,14 @@ public class TaskbarController implements TaskbarOverviewProxyDelegate {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
mIsAnimatingToLauncher = true;
|
||||
mTaskbarViewInApp.updateHotseatItemsVisibility();
|
||||
mTaskbarView.setHolesAllowedInLayout(true);
|
||||
mTaskbarView.updateHotseatItemsVisibility();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mIsAnimatingToLauncher = false;
|
||||
setWhichTaskbarViewIsVisible(mTaskbarViewOnHome);
|
||||
setTaskbarViewVisible(false);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -420,44 +188,21 @@ public class TaskbarController implements TaskbarOverviewProxyDelegate {
|
||||
anim.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
mTaskbarViewInApp.updateHotseatItemsVisibility();
|
||||
setWhichTaskbarViewIsVisible(mTaskbarViewInApp);
|
||||
mTaskbarView.updateHotseatItemsVisibility();
|
||||
setTaskbarViewVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mTaskbarView.setHolesAllowedInLayout(false);
|
||||
}
|
||||
});
|
||||
return anim.buildAnim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be called when the IME visibility changes, so we can hide/show Taskbar accordingly.
|
||||
*/
|
||||
public void setIsImeVisible(boolean isImeVisible) {
|
||||
mTaskbarAnimationController.animateToVisibilityForIme(isImeVisible ? 0 : 1);
|
||||
blockTaskbarTouchesForIme(isImeVisible);
|
||||
}
|
||||
|
||||
/**
|
||||
* When in 3 button nav, the above doesn't get called since we prevent sysui nav bar from
|
||||
* instantiating at all, which is what's responsible for sending sysui state flags over.
|
||||
*
|
||||
* @param vis IME visibility flag
|
||||
* @param backDisposition Used to determine back button behavior for software keyboard
|
||||
* See BACK_DISPOSITION_* constants in {@link InputMethodService}
|
||||
*/
|
||||
public void updateImeStatus(int displayId, int vis, int backDisposition,
|
||||
boolean showImeSwitcher) {
|
||||
if (displayId != mTaskbarContainerView.getContext().getDisplayId() ||
|
||||
mNavMode != SysUINavigationMode.Mode.THREE_BUTTONS) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean imeVisible = (vis & InputMethodService.IME_VISIBLE) != 0;
|
||||
mTaskbarAnimationController.animateToVisibilityForIme(imeVisible ? 0 : 1);
|
||||
mImeBarView.setImeSwitcherVisibility(showImeSwitcher);
|
||||
blockTaskbarTouchesForIme(imeVisible);
|
||||
@Override
|
||||
protected void onImeVisible(TaskbarContainerView containerView, boolean isVisible) {
|
||||
mTaskbarAnimationController.animateToVisibilityForIme(isVisible ? 0 : 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -472,24 +217,17 @@ public class TaskbarController implements TaskbarOverviewProxyDelegate {
|
||||
* @return Whether any Taskbar item could handle the given MotionEvent if given the chance.
|
||||
*/
|
||||
public boolean isEventOverAnyTaskbarItem(MotionEvent ev) {
|
||||
return mTaskbarViewInApp.isEventOverAnyItem(ev);
|
||||
return mTaskbarView.isEventOverAnyItem(ev);
|
||||
}
|
||||
|
||||
public boolean isDraggingItem() {
|
||||
return mTaskbarViewInApp.isDraggingItem() || mTaskbarViewOnHome.isDraggingItem();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether the given View is in the same window as Taskbar.
|
||||
*/
|
||||
public boolean isViewInTaskbar(View v) {
|
||||
return mTaskbarContainerView.isAttachedToWindow()
|
||||
&& mTaskbarContainerView.getWindowId().equals(v.getWindowId());
|
||||
return mTaskbarView.isDraggingItem();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pads the Hotseat to line up exactly with Taskbar's copy of the Hotseat.
|
||||
*/
|
||||
@Override
|
||||
public void alignRealHotseatWithTaskbar() {
|
||||
Rect hotseatBounds = new Rect();
|
||||
DeviceProfile grid = mLauncher.getDeviceProfile();
|
||||
@@ -498,60 +236,28 @@ public class TaskbarController implements TaskbarOverviewProxyDelegate {
|
||||
int hotseatTopDiff = hotseatHeight - grid.taskbarSize - taskbarOffset;
|
||||
int hotseatBottomDiff = taskbarOffset;
|
||||
|
||||
mTaskbarViewOnHome.getHotseatBounds().roundOut(hotseatBounds);
|
||||
RectF hotseatBoundsF = mTaskbarView.getHotseatBounds();
|
||||
Utilities.scaleRectFAboutPivot(hotseatBoundsF, getTaskbarScaleOnHome(),
|
||||
mTaskbarView.getPivotX(), mTaskbarView.getPivotY());
|
||||
hotseatBoundsF.round(hotseatBounds);
|
||||
mLauncher.getHotseat().setPadding(hotseatBounds.left,
|
||||
hotseatBounds.top + hotseatTopDiff,
|
||||
mTaskbarViewOnHome.getWidth() - hotseatBounds.right,
|
||||
mTaskbarViewOnHome.getHeight() - hotseatBounds.bottom + hotseatBottomDiff);
|
||||
}
|
||||
|
||||
private void setWhichTaskbarViewIsVisible(@Nullable TaskbarView visibleTaskbar) {
|
||||
mTaskbarViewInApp.setVisibility(visibleTaskbar == mTaskbarViewInApp
|
||||
? VISIBLE : INVISIBLE);
|
||||
mTaskbarViewOnHome.setVisibility(visibleTaskbar == mTaskbarViewOnHome
|
||||
? VISIBLE : INVISIBLE);
|
||||
mLauncher.getHotseat().setIconsAlpha(visibleTaskbar != mTaskbarViewInApp ? 1f : 0f);
|
||||
}
|
||||
|
||||
private void blockTaskbarTouchesForIme(boolean block) {
|
||||
mTaskbarViewOnHome.setTouchesEnabled(!block);
|
||||
mTaskbarViewInApp.setTouchesEnabled(!block);
|
||||
mTaskbarView.getWidth() - hotseatBounds.right,
|
||||
mTaskbarView.getHeight() - hotseatBounds.bottom + hotseatBottomDiff);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ratio of the taskbar icon size on home vs in an app.
|
||||
*/
|
||||
public float getTaskbarScaleOnHome() {
|
||||
DeviceProfile inAppDp = mTaskbarContainerView.getTaskbarActivityContext()
|
||||
.getDeviceProfile();
|
||||
DeviceProfile onHomeDp = ActivityContext.lookupContext(mTaskbarViewOnHome.getContext())
|
||||
.getDeviceProfile();
|
||||
DeviceProfile inAppDp = mContext.getDeviceProfile();
|
||||
DeviceProfile onHomeDp = mLauncher.getDeviceProfile();
|
||||
return (float) onHomeDp.cellWidthPx / inAppDp.cellWidthPx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the TaskbarContainer to MATCH_PARENT vs original Taskbar size.
|
||||
*/
|
||||
private void setTaskbarWindowFullscreen(boolean fullscreen) {
|
||||
setTaskbarWindowHeight(fullscreen ? MATCH_PARENT : mTaskbarSize.y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the TaskbarContainer height (pass mTaskbarSize.y to reset).
|
||||
*/
|
||||
private void setTaskbarWindowHeight(int height) {
|
||||
mWindowLayoutParams.width = mTaskbarSize.x;
|
||||
mWindowLayoutParams.height = height;
|
||||
mWindowManager.updateViewLayout(mTaskbarContainerView, mWindowLayoutParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains methods that TaskbarStateHandler can call to interface with TaskbarController.
|
||||
*/
|
||||
protected interface TaskbarStateHandlerCallbacks {
|
||||
AnimatedFloat getAlphaTarget();
|
||||
AnimatedFloat getScaleTarget();
|
||||
AnimatedFloat getTranslationYTarget();
|
||||
void setTaskbarViewVisible(boolean isVisible) {
|
||||
mTaskbarView.setIconsVisibility(isVisible);
|
||||
mLauncher.getHotseat().setIconsAlpha(isVisible ? 0f : 1f);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -565,32 +271,4 @@ public class TaskbarController implements TaskbarOverviewProxyDelegate {
|
||||
void updateTaskbarScale(float scale);
|
||||
void updateTaskbarTranslationY(float translationY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains methods that TaskbarContainerView can call to interface with TaskbarController.
|
||||
*/
|
||||
protected interface TaskbarContainerViewCallbacks {
|
||||
void onViewRemoved();
|
||||
boolean isTaskbarTouchable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains methods that TaskbarView can call to interface with TaskbarController.
|
||||
*/
|
||||
protected interface TaskbarViewCallbacks {
|
||||
View.OnClickListener getItemOnClickListener();
|
||||
View.OnLongClickListener getItemOnLongClickListener();
|
||||
int getEmptyHotseatViewVisibility(TaskbarView taskbarView);
|
||||
/** Returns how much to scale non-icon elements such as spacing and dividers. */
|
||||
float getNonIconScale(TaskbarView taskbarView);
|
||||
void onItemPositionsChanged(TaskbarView taskbarView);
|
||||
void onNavigationButtonClick(@TaskbarButton int buttonType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains methods that TaskbarHotseatController can call to interface with TaskbarController.
|
||||
*/
|
||||
protected interface TaskbarHotseatControllerCallbacks {
|
||||
void updateHotseatItems(ItemInfo[] hotseatItemInfos);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user