Rename first page pinned widget to mFirstPagePinnedWidget

mQsb is the name used for the first page pinned widget. This variable name is bad since in some launchers the first page pinned widget is a qsb but sometimes it is a smartspace. Renaming the variable to mFirstPagePinnedWidget is a more accurate name for this variable.

Bug: 251259222
Test: N/A
Change-Id: I6d3c74163995d2267510ee546924917062c4955c
This commit is contained in:
Federico Baron
2022-10-18 13:50:27 -07:00
parent a56f08e677
commit 0abfda8f2f
2 changed files with 30 additions and 26 deletions

View File

@@ -224,8 +224,8 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
// Variables relating to touch disambiguation (scrolling workspace vs. scrolling a widget)
private float mXDown;
private float mYDown;
private View mQsb;
private boolean mIsEventOverQsb;
private View mFirstPagePinnedItem;
private boolean mIsEventOverFirstPagePinnedItem;
final static float START_DAMPING_TOUCH_SLOP_ANGLE = (float) Math.PI / 6;
final static float MAX_SWIPE_ANGLE = (float) Math.PI / 3;
@@ -575,20 +575,22 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
// Add the first page
CellLayout firstPage = insertNewWorkspaceScreen(Workspace.FIRST_SCREEN_ID, getChildCount());
// Always add a QSB on the first screen.
if (mQsb == null) {
// In transposed layout, we add the QSB in the Grid. As workspace does not touch the
// edges, we do not need a full width QSB.
mQsb = LayoutInflater.from(getContext())
// Always add a first page pinned widget on the first screen.
if (mFirstPagePinnedItem == null) {
// In transposed layout, we add the first page pinned widget in the Grid.
// As workspace does not touch the edges, we do not need a full
// width first page pinned widget.
mFirstPagePinnedItem = LayoutInflater.from(getContext())
.inflate(R.layout.search_container_workspace, firstPage, false);
}
int cellHSpan = mLauncher.getDeviceProfile().inv.numSearchContainerColumns;
CellLayoutLayoutParams lp = new CellLayoutLayoutParams(0, 0, cellHSpan, 1);
lp.canReorder = false;
if (!firstPage.addViewToCellLayout(mQsb, 0, R.id.search_container_workspace, lp, true)) {
if (!firstPage.addViewToCellLayout(
mFirstPagePinnedItem, 0, R.id.search_container_workspace, lp, true)) {
Log.e(TAG, "Failed to add to item at (0, 0) to CellLayout");
mQsb = null;
mFirstPagePinnedItem = null;
}
}
@@ -597,9 +599,9 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
// transition animations competing with us changing the scroll when we add pages
disableLayoutTransitions();
// Recycle the QSB widget
if (mQsb != null) {
((ViewGroup) mQsb.getParent()).removeView(mQsb);
// Recycle the first page pinned widget
if (mFirstPagePinnedItem != null) {
((ViewGroup) mFirstPagePinnedItem.getParent()).removeView(mFirstPagePinnedItem);
}
// Remove the pages and clear the screen models
@@ -919,8 +921,8 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
return mScreenOrder;
}
protected View getQsb() {
return mQsb;
protected View getFirstPagePinnedItem() {
return mFirstPagePinnedItem;
}
/**
@@ -1074,20 +1076,22 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
mXDown = ev.getX();
mYDown = ev.getY();
if (mQsb != null) {
if (mFirstPagePinnedItem != null) {
mTempFXY[0] = mXDown + getScrollX();
mTempFXY[1] = mYDown + getScrollY();
Utilities.mapCoordInSelfToDescendant(mQsb, this, mTempFXY);
mIsEventOverQsb = mQsb.getLeft() <= mTempFXY[0] && mQsb.getRight() >= mTempFXY[0]
&& mQsb.getTop() <= mTempFXY[1] && mQsb.getBottom() >= mTempFXY[1];
Utilities.mapCoordInSelfToDescendant(mFirstPagePinnedItem, this, mTempFXY);
mIsEventOverFirstPagePinnedItem = mFirstPagePinnedItem.getLeft() <= mTempFXY[0]
&& mFirstPagePinnedItem.getRight() >= mTempFXY[0]
&& mFirstPagePinnedItem.getTop() <= mTempFXY[1]
&& mFirstPagePinnedItem.getBottom() >= mTempFXY[1];
} else {
mIsEventOverQsb = false;
mIsEventOverFirstPagePinnedItem = false;
}
}
@Override
protected void determineScrollingStart(MotionEvent ev) {
if (!isFinishedSwitchingState() || mIsEventOverQsb) return;
if (!isFinishedSwitchingState() || mIsEventOverFirstPagePinnedItem) return;
float deltaX = ev.getX() - mXDown;
float absDeltaX = Math.abs(deltaX);
@@ -2538,10 +2542,10 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
}
private boolean isDragObjectOverSmartSpace(DragObject dragObject) {
if (mQsb == null) {
if (mFirstPagePinnedItem == null) {
return false;
}
getViewBoundsRelativeToWorkspace(mQsb, mTempRect);
getViewBoundsRelativeToWorkspace(mFirstPagePinnedItem, mTempRect);
return mTempRect.contains(dragObject.x, dragObject.y);
}