Reorganize taskbar controllers

Organize existing properties as follows:
- TaskbarViewController contains properties affecting TaskbarView (though child icons are still supplied by TaskbarHotseatController)
- TaskbarDragLayerController contains properties related to TaskbarDragLayer itself
- Renamed NavbarButtonUiController to NavbarButtonsViewController, following the pattern of TaskbarViewController and TaskbarDragLayerController
- TaskbarControllers contains the different controllers to make it easier to construct, initialize, destroy, and pass them around
- Removed TaskbarIconController as its responsibilities were moved to more specific controllers

Test: compiles and runs, manually tested
Bug: 187353581
Change-Id: Idccd95d47117101bf9617e5532a5b87635d2b8f6
This commit is contained in:
Tony Wickham
2021-06-08 20:03:43 -07:00
parent d897514642
commit 36696d62b0
10 changed files with 419 additions and 249 deletions

View File

@@ -60,6 +60,7 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
private final TaskbarActivityContext mActivityContext;
// Initialized in init.
private TaskbarViewController.TaskbarViewCallbacks mControllerCallbacks;
private View.OnClickListener mIconClickListener;
private View.OnLongClickListener mIconLongClickListener;
@@ -98,9 +99,10 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
mItemPadding = (mIconTouchSize - actualIconSize) / 2;
}
protected void init(OnClickListener clickListener, OnLongClickListener longClickListener) {
mIconClickListener = clickListener;
mIconLongClickListener = longClickListener;
protected void init(TaskbarViewController.TaskbarViewCallbacks callbacks) {
mControllerCallbacks = callbacks;
mIconClickListener = mControllerCallbacks.getOnClickListener();
mIconLongClickListener = mControllerCallbacks.getOnLongClickListener();
int numHotseatIcons = mActivityContext.getDeviceProfile().numShownHotseatIcons;
updateHotseatItems(new ItemInfo[numHotseatIcons]);
@@ -200,11 +202,9 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
&& hotseatItemInfo instanceof WorkspaceItemInfo) {
((BubbleTextView) hotseatView).applyFromWorkspaceItem(
(WorkspaceItemInfo) hotseatItemInfo);
hotseatView.setOnClickListener(mIconClickListener);
hotseatView.setOnLongClickListener(mIconLongClickListener);
setClickAndLongClickListenersForIcon(hotseatView);
} else if (isFolder) {
hotseatView.setOnClickListener(mIconClickListener);
hotseatView.setOnLongClickListener(mIconLongClickListener);
setClickAndLongClickListenersForIcon(hotseatView);
} else {
hotseatView.setOnClickListener(null);
hotseatView.setOnLongClickListener(null);
@@ -214,6 +214,14 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
}
}
/**
* Sets OnClickListener and OnLongClickListener for the given view.
*/
public void setClickAndLongClickListenersForIcon(View icon) {
icon.setOnClickListener(mIconClickListener);
icon.setOnLongClickListener(mIconLongClickListener);
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
int count = getChildCount();