Merge "Push a potential fix for hotseat aggregation" into main

This commit is contained in:
Treehugger Robot
2024-06-05 20:39:11 +00:00
committed by Android (Google) Code Review
4 changed files with 28 additions and 10 deletions

View File

@@ -147,7 +147,8 @@ public abstract class BaseDraggingActivity extends BaseActivity
@Override
public void onDisplayInfoChanged(Context context, Info info, int flags) {
if ((flags & CHANGE_ROTATION) != 0 && mDeviceProfile.updateIsSeascape(this)) {
if ((flags & CHANGE_ROTATION) != 0 && mDeviceProfile.isVerticalBarLayout()) {
mDeviceProfile.updateIsSeascape(this);
reapplyUi();
}
}

View File

@@ -82,6 +82,10 @@ public class Hotseat extends CellLayout implements Insettable {
return mHasVerticalHotseat ? (getCountY() - (rank + 1)) : 0;
}
boolean isHasVerticalHotseat() {
return mHasVerticalHotseat;
}
public void resetLayout(boolean hasVerticalHotseat) {
ActivityContext activityContext = ActivityContext.lookupContext(getContext());
boolean bubbleBarEnabled = activityContext.isBubbleBarEnabled();

View File

@@ -3,6 +3,7 @@ package com.android.launcher3
import android.annotation.TargetApi
import android.os.Build
import android.os.Trace
import android.util.Log
import androidx.annotation.UiThread
import com.android.launcher3.Flags.enableSmartspaceRemovalToggle
import com.android.launcher3.LauncherConstants.TraceEvents
@@ -29,6 +30,8 @@ import com.android.launcher3.widget.PendingAddWidgetInfo
import com.android.launcher3.widget.model.WidgetsListBaseEntry
import java.util.function.Predicate
private const val TAG = "ModelCallbacks"
class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks {
var synchronouslyBoundPages = LIntSet()
@@ -66,6 +69,13 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks {
launcher.workspace.removeAllWorkspaceScreens()
// Avoid clearing the widget update listeners for staying up-to-date with widget info
launcher.appWidgetHolder.clearWidgetViews()
// TODO(b/335141365): Remove this log after the bug is fixed.
Log.d(
TAG,
"startBinding: " +
"hotseat layout was vertical: ${launcher.hotseat?.isHasVerticalHotseat}" +
" and is setting to ${launcher.deviceProfile.isVerticalBarLayout}"
)
launcher.hotseat?.resetLayout(launcher.deviceProfile.isVerticalBarLayout)
TraceHelper.INSTANCE.endSection()
}
@@ -142,7 +152,10 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks {
launcher.viewCache.setCacheSize(R.layout.folder_page, 2)
TraceHelper.INSTANCE.endSection()
launcher.workspace.removeExtraEmptyScreen(/* stripEmptyScreens= */ true)
launcher.workspace.pageIndicator.setPauseScroll(/*pause=*/ false, deviceProfile.isTwoPanels)
launcher.workspace.pageIndicator.setPauseScroll(
/*pause=*/ false,
deviceProfile.isTwoPanels
)
}
/**
@@ -290,8 +303,7 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks {
val widgetsListBaseEntry: WidgetsListBaseEntry =
launcher.popupDataProvider.allWidgets.firstOrNull { item: WidgetsListBaseEntry ->
item.mPkgItem.packageName == BuildConfig.APPLICATION_ID
}
?: return
} ?: return
val info =
PendingAddWidgetInfo(
@@ -315,16 +327,14 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks {
)
val firstScreenPosition = 0
if (
(isFirstPagePinnedItemEnabled &&
!SHOULD_SHOW_FIRST_PAGE_WIDGET) &&
(isFirstPagePinnedItemEnabled && !SHOULD_SHOW_FIRST_PAGE_WIDGET) &&
orderedScreenIds.indexOf(FIRST_SCREEN_ID) != firstScreenPosition
) {
orderedScreenIds.removeValue(FIRST_SCREEN_ID)
orderedScreenIds.add(firstScreenPosition, FIRST_SCREEN_ID)
} else if (
(!isFirstPagePinnedItemEnabled ||
SHOULD_SHOW_FIRST_PAGE_WIDGET)
&& orderedScreenIds.isEmpty
(!isFirstPagePinnedItemEnabled || SHOULD_SHOW_FIRST_PAGE_WIDGET) &&
orderedScreenIds.isEmpty
) {
// If there are no screens, we need to have an empty screen
launcher.workspace.addExtraEmptyScreens()
@@ -380,7 +390,7 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks {
}
orderedScreenIds
.filterNot { screenId ->
isFirstPagePinnedItemEnabled &&
isFirstPagePinnedItemEnabled &&
!SHOULD_SHOW_FIRST_PAGE_WIDGET &&
screenId == WorkspaceLayoutManager.FIRST_SCREEN_ID
}

View File

@@ -58,6 +58,9 @@ public interface WorkspaceLayoutManager {
int screenId = presenterPos.screenId;
x = getHotseat().getCellXFromOrder(screenId);
y = getHotseat().getCellYFromOrder(screenId);
// TODO(b/335141365): Remove this log after the bug is fixed.
Log.d(TAG, "addInScreenFromBind: hotseat inflation with x = " + x
+ " and y = " + y);
}
addInScreen(child, info.container, presenterPos.screenId, x, y, info.spanX, info.spanY);
}