Merging update and modify model callbacks

Instead of the dispatcher specifying the type, the UI checks th diff. This
ensures that the UI is updated correctly in all paths

Bug: 390572144
Flag: EXEMPT refactor
Test: Manually verified folder edit path where these callbacks were getting dispatched

Change-Id: Ib73eed5da87a847753a78453a48ab4fc495c1199
This commit is contained in:
Sunny Goyal
2025-04-16 22:48:24 -07:00
parent c562b3ce4e
commit 007cfecf5e
14 changed files with 211 additions and 87 deletions
@@ -38,6 +38,7 @@ import android.view.InputDevice;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import androidx.annotation.LayoutRes;
@@ -51,6 +52,7 @@ import com.android.launcher3.Insettable;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.apppairs.AppPairIcon;
import com.android.launcher3.celllayout.CellInfo;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.folder.PreviewBackground;
import com.android.launcher3.model.data.AppPairInfo;
@@ -570,7 +572,7 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
} else {
hotseatView = inflate(expectedLayoutResId);
}
LayoutParams lp = new LayoutParams(mIconTouchSize, mIconTouchSize);
LayoutParams lp = new TaskbarLayoutParams(mIconTouchSize, mIconTouchSize);
hotseatView.setPadding(mItemPadding, mItemPadding, mItemPadding, mItemPadding);
addView(hotseatView, mNextViewIndex, lp);
} else if (hotseatView instanceof FolderIcon fi) {
@@ -578,6 +580,13 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
fi.getFolder().reapplyItemInfo();
}
if (hotseatView.getLayoutParams() instanceof TaskbarLayoutParams tlp) {
tlp.bindInfo = new CellInfo(hotseatView,
hotseatItemInfo.screenId, hotseatItemInfo.container,
hotseatItemInfo.cellX, hotseatItemInfo.cellY,
hotseatItemInfo.spanX, hotseatItemInfo.spanY);
}
// Apply the Hotseat ItemInfos, or hide the view if there is none for a given index.
if (hotseatView instanceof BubbleTextView btv
&& hotseatItemInfo instanceof WorkspaceItemInfo workspaceInfo) {
@@ -696,7 +705,7 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
if (recentIcon == null) {
// TODO(b/343289567 and b/316004172): support app pairs and desktop mode.
recentIcon = inflate(expectedLayoutResId);
LayoutParams lp = new LayoutParams(mIconTouchSize, mIconTouchSize);
LayoutParams lp = new TaskbarLayoutParams(mIconTouchSize, mIconTouchSize);
recentIcon.setPadding(mItemPadding, mItemPadding, mItemPadding, mItemPadding);
addView(recentIcon, mNextViewIndex, lp);
}
@@ -1130,4 +1139,36 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
return navSpaceNeeded + getIconLayoutWidth();
}
}
@Override
protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) {
return new TaskbarLayoutParams(lp);
}
@Override
public LayoutParams generateLayoutParams(AttributeSet attrs) {
return new TaskbarLayoutParams(getContext(), attrs);
}
@Override
protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
return p instanceof TaskbarLayoutParams;
}
public static class TaskbarLayoutParams extends FrameLayout.LayoutParams {
@Nullable public CellInfo bindInfo;
public TaskbarLayoutParams(Context context, AttributeSet attrs) {
super(context, attrs);
}
public TaskbarLayoutParams(ViewGroup.LayoutParams source) {
super(source);
}
public TaskbarLayoutParams(int width, int height) {
super(width, height);
}
}
}