mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 03:08:19 +00:00
Update taskbar to add extra hotseat items instead of recent apps
Removes recents-related code including the divider between it and hotseat. Test: manually on device Fixes: 184366189 Bug: 184789479 Bug: 171917176 Change-Id: I7776c98659ded70f53a49befddcd23c8353c6440
This commit is contained in:
@@ -25,7 +25,6 @@ import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.DragEvent;
|
||||
import android.view.MotionEvent;
|
||||
@@ -47,7 +46,6 @@ import com.android.launcher3.model.data.FolderInfo;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
import com.android.systemui.shared.recents.model.Task;
|
||||
|
||||
/**
|
||||
* Hosts the Taskbar content such as Hotseat and Recent Apps. Drawn on top of other apps.
|
||||
@@ -55,8 +53,6 @@ import com.android.systemui.shared.recents.model.Task;
|
||||
public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconParent, Insettable {
|
||||
|
||||
private final ColorDrawable mBackgroundDrawable;
|
||||
private final int mDividerWidth;
|
||||
private final int mDividerHeight;
|
||||
private final int mIconTouchSize;
|
||||
private final boolean mIsRtl;
|
||||
private final int mTouchSlop;
|
||||
@@ -74,9 +70,6 @@ public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconPa
|
||||
private LayoutTransition mLayoutTransition;
|
||||
private int mHotseatStartIndex;
|
||||
private int mHotseatEndIndex;
|
||||
private View mHotseatRecentsDivider;
|
||||
private int mRecentsStartIndex;
|
||||
private int mRecentsEndIndex;
|
||||
|
||||
// Delegate touches to the closest view if within mIconTouchSize.
|
||||
private boolean mDelegateTargeted;
|
||||
@@ -105,8 +98,6 @@ public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconPa
|
||||
|
||||
Resources resources = getResources();
|
||||
mBackgroundDrawable = (ColorDrawable) getBackground();
|
||||
mDividerWidth = resources.getDimensionPixelSize(R.dimen.taskbar_divider_thickness);
|
||||
mDividerHeight = resources.getDimensionPixelSize(R.dimen.taskbar_divider_height);
|
||||
mIconTouchSize = resources.getDimensionPixelSize(R.dimen.taskbar_icon_touch_size);
|
||||
mIsRtl = Utilities.isRtl(resources);
|
||||
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
|
||||
@@ -119,18 +110,11 @@ public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconPa
|
||||
mItemMarginLeftRight = Math.round(mItemMarginLeftRight * mNonIconScale);
|
||||
}
|
||||
|
||||
protected void init(int numHotseatIcons, int numRecentIcons) {
|
||||
protected void init(int numHotseatIcons) {
|
||||
mHotseatStartIndex = 0;
|
||||
mHotseatEndIndex = mHotseatStartIndex + numHotseatIcons - 1;
|
||||
updateHotseatItems(new ItemInfo[numHotseatIcons]);
|
||||
|
||||
int dividerIndex = mHotseatEndIndex + 1;
|
||||
mHotseatRecentsDivider = addDivider(dividerIndex);
|
||||
|
||||
mRecentsStartIndex = dividerIndex + 1;
|
||||
mRecentsEndIndex = mRecentsStartIndex + numRecentIcons - 1;
|
||||
updateRecentTasks(new Task[numRecentIcons]);
|
||||
|
||||
mLayoutTransition = new LayoutTransition();
|
||||
addUpdateListenerForAllLayoutTransitions(() -> {
|
||||
if (getLayoutTransition() == mLayoutTransition) {
|
||||
@@ -165,7 +149,6 @@ public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconPa
|
||||
endAllLayoutTransitionAnimators();
|
||||
setLayoutTransition(null);
|
||||
removeAllViews();
|
||||
mHotseatRecentsDivider = null;
|
||||
}
|
||||
|
||||
private void endAllLayoutTransitionAnimators() {
|
||||
@@ -248,8 +231,6 @@ public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconPa
|
||||
}
|
||||
updateHotseatItemVisibility(hotseatView);
|
||||
}
|
||||
|
||||
updateHotseatRecentsDividerVisibility();
|
||||
}
|
||||
|
||||
protected void updateHotseatItemsVisibility() {
|
||||
@@ -273,95 +254,6 @@ public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconPa
|
||||
}
|
||||
}
|
||||
|
||||
private View addDivider(int dividerIndex) {
|
||||
View divider = inflate(R.layout.taskbar_divider);
|
||||
LayoutParams lp = new LayoutParams(mDividerWidth, mDividerHeight);
|
||||
lp.setMargins(mItemMarginLeftRight, 0, mItemMarginLeftRight, 0);
|
||||
divider.setScaleX(mNonIconScale);
|
||||
divider.setScaleY(mNonIconScale);
|
||||
addView(divider, dividerIndex, lp);
|
||||
return divider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inflates/binds the Recents items to show in the Taskbar given their Tasks.
|
||||
*/
|
||||
protected void updateRecentTasks(Task[] tasks) {
|
||||
for (int i = 0; i < tasks.length; i++) {
|
||||
Task task = tasks[i];
|
||||
int recentsIndex = mRecentsStartIndex + i;
|
||||
View recentsView = getChildAt(recentsIndex);
|
||||
|
||||
// Inflate empty icon Views.
|
||||
if (recentsView == null) {
|
||||
BubbleTextView btv = (BubbleTextView) inflate(R.layout.taskbar_app_icon);
|
||||
LayoutParams lp = new LayoutParams(btv.getIconSize(), btv.getIconSize());
|
||||
lp.setMargins(mItemMarginLeftRight, 0, mItemMarginLeftRight, 0);
|
||||
recentsView = btv;
|
||||
addView(recentsView, recentsIndex, lp);
|
||||
}
|
||||
|
||||
// Apply the Task, or hide the view if there is none for a given index.
|
||||
if (recentsView instanceof BubbleTextView && task != null) {
|
||||
applyTaskToBubbleTextView((BubbleTextView) recentsView, task);
|
||||
recentsView.setVisibility(VISIBLE);
|
||||
recentsView.setOnClickListener(mControllerCallbacks.getItemOnClickListener());
|
||||
recentsView.setOnLongClickListener(
|
||||
mControllerCallbacks.getItemOnLongClickListener());
|
||||
} else {
|
||||
recentsView.setVisibility(GONE);
|
||||
recentsView.setOnClickListener(null);
|
||||
recentsView.setOnLongClickListener(null);
|
||||
}
|
||||
}
|
||||
|
||||
updateHotseatRecentsDividerVisibility();
|
||||
}
|
||||
|
||||
private void applyTaskToBubbleTextView(BubbleTextView btv, Task task) {
|
||||
if (task.icon != null) {
|
||||
Drawable icon = task.icon.getConstantState().newDrawable().mutate();
|
||||
btv.applyIconAndLabel(icon, task.titleDescription);
|
||||
}
|
||||
btv.setTag(task);
|
||||
}
|
||||
|
||||
protected void updateRecentTaskAtIndex(int taskIndex, Task task) {
|
||||
View taskView = getChildAt(mRecentsStartIndex + taskIndex);
|
||||
if (taskView instanceof BubbleTextView) {
|
||||
applyTaskToBubbleTextView((BubbleTextView) taskView, task);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the divider VISIBLE between the Hotseat and Recents if there is at least one icon in
|
||||
* each, otherwise make it GONE.
|
||||
*/
|
||||
private void updateHotseatRecentsDividerVisibility() {
|
||||
if (mHotseatRecentsDivider == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean hasAtLeastOneHotseatItem = false;
|
||||
for (int i = mHotseatStartIndex; i <= mHotseatEndIndex; i++) {
|
||||
if (getChildAt(i).getVisibility() != GONE) {
|
||||
hasAtLeastOneHotseatItem = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
boolean hasAtLeastOneRecentItem = false;
|
||||
for (int i = mRecentsStartIndex; i <= mRecentsEndIndex; i++) {
|
||||
if (getChildAt(i).getVisibility() != GONE) {
|
||||
hasAtLeastOneRecentItem = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mHotseatRecentsDivider.setVisibility(hasAtLeastOneHotseatItem && hasAtLeastOneRecentItem
|
||||
? VISIBLE : GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
boolean handled = delegateTouchIfNecessary(event);
|
||||
|
||||
Reference in New Issue
Block a user