mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-18 10:18:20 +00:00
Add Hotseat items to Taskbar
- Currently supports WorkspaceItemInfo (e.g. normal app icons including hotseat predictions and pinned deep shortcuts). - Currently doesn't support Folders, Notification dots, or long press. Some technical details: - Always allow HotseatPredictionController updates given the Hotseat is always showing even when Launcher is stopped. - Represent Taskbar Hotseat items as BubbleTextViews, to allow for normal click handling etc. When the hotseat is updated, we reuse the same BubbleTextViews that were initially inflated, and just reapply the new info. - Add new BubbleTextView iconDisplay for Taskbar, to allow for different treatment such as icon size. Bug: 171917176 Change-Id: I325eb39051f2dc69228b39b5c40ed0cbdad8e200
This commit is contained in:
@@ -26,6 +26,7 @@ import android.animation.Animator;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.Point;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -36,7 +37,9 @@ import com.android.launcher3.QuickstepAppTransitionManagerImpl;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.anim.AlphaUpdateListener;
|
||||
import com.android.launcher3.anim.PendingAnimation;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.states.StateAnimationConfig;
|
||||
import com.android.launcher3.touch.ItemClickHandler;
|
||||
import com.android.quickstep.AnimatedFloat;
|
||||
import com.android.systemui.shared.system.WindowManagerWrapper;
|
||||
|
||||
@@ -55,6 +58,7 @@ public class TaskbarController {
|
||||
private final Point mTaskbarSize;
|
||||
private final TaskbarStateHandler mTaskbarStateHandler;
|
||||
private final TaskbarVisibilityController mTaskbarVisibilityController;
|
||||
private final TaskbarHotseatController mHotseatController;
|
||||
|
||||
// Initialized in init().
|
||||
private WindowManager.LayoutParams mWindowLayoutParams;
|
||||
@@ -64,12 +68,15 @@ public class TaskbarController {
|
||||
mLauncher = launcher;
|
||||
mTaskbarContainerView = taskbarContainerView;
|
||||
mTaskbarView = mTaskbarContainerView.findViewById(R.id.taskbar_view);
|
||||
mTaskbarView.setCallbacks(createTaskbarViewCallbacks());
|
||||
mWindowManager = mLauncher.getWindowManager();
|
||||
mTaskbarSize = new Point(MATCH_PARENT,
|
||||
mLauncher.getResources().getDimensionPixelSize(R.dimen.taskbar_size));
|
||||
mTaskbarStateHandler = mLauncher.getTaskbarStateHandler();
|
||||
mTaskbarVisibilityController = new TaskbarVisibilityController(mLauncher,
|
||||
createTaskbarVisibilityControllerCallbacks());
|
||||
mHotseatController = new TaskbarHotseatController(mLauncher,
|
||||
createTaskbarHotseatControllerCallbacks());
|
||||
}
|
||||
|
||||
private TaskbarVisibilityControllerCallbacks createTaskbarVisibilityControllerCallbacks() {
|
||||
@@ -87,13 +94,33 @@ public class TaskbarController {
|
||||
};
|
||||
}
|
||||
|
||||
private TaskbarViewCallbacks createTaskbarViewCallbacks() {
|
||||
return new TaskbarViewCallbacks() {
|
||||
@Override
|
||||
public View.OnClickListener getItemOnClickListener() {
|
||||
return ItemClickHandler.INSTANCE;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private TaskbarHotseatControllerCallbacks createTaskbarHotseatControllerCallbacks() {
|
||||
return new TaskbarHotseatControllerCallbacks() {
|
||||
@Override
|
||||
public void updateHotseatItems(ItemInfo[] hotseatItemInfos) {
|
||||
mTaskbarView.updateHotseatItems(hotseatItemInfos);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the Taskbar, including adding it to the screen.
|
||||
*/
|
||||
public void init() {
|
||||
mTaskbarView.init(mHotseatController.getNumHotseatIcons());
|
||||
addToWindowManager();
|
||||
mTaskbarStateHandler.setTaskbarCallbacks(createTaskbarStateHandlerCallbacks());
|
||||
mTaskbarVisibilityController.init();
|
||||
mHotseatController.init();
|
||||
}
|
||||
|
||||
private TaskbarStateHandlerCallbacks createTaskbarStateHandlerCallbacks() {
|
||||
@@ -109,9 +136,11 @@ public class TaskbarController {
|
||||
* Removes the Taskbar from the screen, and removes any obsolete listeners etc.
|
||||
*/
|
||||
public void cleanup() {
|
||||
mTaskbarView.cleanup();
|
||||
removeFromWindowManager();
|
||||
mTaskbarStateHandler.setTaskbarCallbacks(null);
|
||||
mTaskbarVisibilityController.cleanup();
|
||||
mHotseatController.cleanup();
|
||||
}
|
||||
|
||||
private void removeFromWindowManager() {
|
||||
@@ -190,6 +219,20 @@ public class TaskbarController {
|
||||
mTaskbarVisibilityController.animateToVisibilityForIme(isImeVisible ? 0 : 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be called when one or more items in the Hotseat have changed.
|
||||
*/
|
||||
public void onHotseatUpdated() {
|
||||
mHotseatController.onHotseatUpdated();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether the given View is in the same window as Taskbar.
|
||||
*/
|
||||
public boolean isViewInTaskbar(View v) {
|
||||
return mTaskbarContainerView.getWindowId().equals(v.getWindowId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains methods that TaskbarStateHandler can call to interface with TaskbarController.
|
||||
*/
|
||||
@@ -205,4 +248,18 @@ public class TaskbarController {
|
||||
void updateTaskbarBackgroundAlpha(float alpha);
|
||||
void updateTaskbarVisibilityAlpha(float alpha);
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains methods that TaskbarView can call to interface with TaskbarController.
|
||||
*/
|
||||
protected interface TaskbarViewCallbacks {
|
||||
View.OnClickListener getItemOnClickListener();
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains methods that TaskbarHotseatController can call to interface with TaskbarController.
|
||||
*/
|
||||
protected interface TaskbarHotseatControllerCallbacks {
|
||||
void updateHotseatItems(ItemInfo[] hotseatItemInfos);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user