diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java index cf93a79c54..8585b66554 100644 --- a/src/com/android/launcher3/BaseDraggingActivity.java +++ b/src/com/android/launcher3/BaseDraggingActivity.java @@ -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(); } } diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java index 37737d81a3..854645418a 100644 --- a/src/com/android/launcher3/Hotseat.java +++ b/src/com/android/launcher3/Hotseat.java @@ -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(); diff --git a/src/com/android/launcher3/ModelCallbacks.kt b/src/com/android/launcher3/ModelCallbacks.kt index 7d6d154bde..13062b6b1b 100644 --- a/src/com/android/launcher3/ModelCallbacks.kt +++ b/src/com/android/launcher3/ModelCallbacks.kt @@ -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 } diff --git a/src/com/android/launcher3/WorkspaceLayoutManager.java b/src/com/android/launcher3/WorkspaceLayoutManager.java index 4768773813..f11a88fa10 100644 --- a/src/com/android/launcher3/WorkspaceLayoutManager.java +++ b/src/com/android/launcher3/WorkspaceLayoutManager.java @@ -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); }