Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c113ce9f authored by Federico Baron's avatar Federico Baron Committed by Android (Google) Code Review
Browse files

Merge "Migrate smartspace as a widget and smartspace removal toggle flags to aconfig" into main

parents edfa8480 9d08e0fe
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -253,3 +253,17 @@ flag {
    description: "Enables fallback recents opening inside of a window instead of an activity."
    bug: "292269949"
}

flag {
    name: "enable_smartspace_as_a_widget"
    namespace: "launcher"
    description: "Enables smartspace as a widget"
    bug: "300140279"
}

flag {
    name: "enable_smartspace_removal_toggle"
    namespace: "launcher"
    description: "Enables smartspace removal toggle"
    bug: "303471576"
}
+2 −2
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import static com.android.launcher3.AbstractFloatingView.TYPE_ICON_SURFACE;
import static com.android.launcher3.AbstractFloatingView.TYPE_REBIND_SAFE;
import static com.android.launcher3.AbstractFloatingView.getTopOpenViewWithType;
import static com.android.launcher3.Flags.enableAddAppWidgetViaConfigActivityV2;
import static com.android.launcher3.Flags.enableSmartspaceRemovalToggle;
import static com.android.launcher3.Flags.enableWorkspaceInflation;
import static com.android.launcher3.LauncherAnimUtils.HOTSEAT_SCALE_PROPERTY_FACTORY;
import static com.android.launcher3.LauncherAnimUtils.SCALE_INDEX_WIDGET_TRANSITION;
@@ -66,7 +67,6 @@ import static com.android.launcher3.LauncherState.NO_OFFSET;
import static com.android.launcher3.LauncherState.NO_SCALE;
import static com.android.launcher3.LauncherState.SPRING_LOADED;
import static com.android.launcher3.Utilities.postAsyncCallback;
import static com.android.launcher3.config.FeatureFlags.ENABLE_SMARTSPACE_REMOVAL;
import static com.android.launcher3.config.FeatureFlags.FOLDABLE_SINGLE_PAGE;
import static com.android.launcher3.config.FeatureFlags.MULTI_SELECT_EDIT_MODE;
import static com.android.launcher3.logging.KeyboardStateManager.KeyboardState.HIDE;
@@ -1368,7 +1368,7 @@ public class Launcher extends StatefulActivity<LauncherState>
        // Until the workspace is bound, ensure that we keep the wallpaper offset locked to the
        // default state, otherwise we will update to the wrong offsets in RTL
        mWorkspace.lockWallpaperToDefaultPage();
        if (!ENABLE_SMARTSPACE_REMOVAL.get()) {
        if (!enableSmartspaceRemovalToggle()) {
            mWorkspace.bindAndInitFirstWorkspaceScreen();
        }
        mDragController.addDragListener(mWorkspace);
+2 −2
Original line number Diff line number Diff line
@@ -19,9 +19,9 @@ package com.android.launcher3;
import static android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_RESOURCE_UPDATED;
import static android.content.Context.RECEIVER_EXPORTED;

import static com.android.launcher3.Flags.enableSmartspaceRemovalToggle;
import static com.android.launcher3.LauncherPrefs.ICON_STATE;
import static com.android.launcher3.LauncherPrefs.THEMED_ICONS;
import static com.android.launcher3.config.FeatureFlags.ENABLE_SMARTSPACE_REMOVAL;
import static com.android.launcher3.model.LoaderTask.SMARTSPACE_ON_HOME_SCREEN;
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
import static com.android.launcher3.util.SettingsCache.NOTIFICATION_BADGING_URI;
@@ -126,7 +126,7 @@ public class LauncherAppState implements SafeCloseable {
                .addUserEventListener(mModel::onUserEvent);
        mOnTerminateCallback.add(userChangeListener::close);

        if (ENABLE_SMARTSPACE_REMOVAL.get()) {
        if (enableSmartspaceRemovalToggle()) {
            OnSharedPreferenceChangeListener firstPagePinnedItemListener =
                    new OnSharedPreferenceChangeListener() {
                        @Override
+9 −9
Original line number Diff line number Diff line
@@ -4,11 +4,12 @@ import android.annotation.TargetApi
import android.os.Build
import android.os.Trace
import androidx.annotation.UiThread
import com.android.launcher3.Flags.enableSmartspaceRemovalToggle
import com.android.launcher3.LauncherConstants.TraceEvents
import com.android.launcher3.Utilities.SHOULD_SHOW_FIRST_PAGE_WIDGET
import com.android.launcher3.WorkspaceLayoutManager.FIRST_SCREEN_ID
import com.android.launcher3.allapps.AllAppsStore
import com.android.launcher3.config.FeatureFlags
import com.android.launcher3.config.FeatureFlags.shouldShowFirstPageWidget
import com.android.launcher3.model.BgDataModel
import com.android.launcher3.model.StringCache
import com.android.launcher3.model.data.AppInfo
@@ -34,7 +35,7 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks {
    var pagesToBindSynchronously = LIntSet()

    private var isFirstPagePinnedItemEnabled =
        (BuildConfig.QSB_ON_FIRST_SCREEN && !FeatureFlags.ENABLE_SMARTSPACE_REMOVAL.get())
        (BuildConfig.QSB_ON_FIRST_SCREEN && !enableSmartspaceRemovalToggle())

    var stringCache: StringCache? = null

@@ -314,16 +315,16 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks {
        )
        val firstScreenPosition = 0
        if (
            (FeatureFlags.QSB_ON_FIRST_SCREEN &&
                isFirstPagePinnedItemEnabled &&
                !shouldShowFirstPageWidget()) &&
            (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 (
            (!FeatureFlags.QSB_ON_FIRST_SCREEN && !isFirstPagePinnedItemEnabled ||
                shouldShowFirstPageWidget()) && 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()
@@ -379,9 +380,8 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks {
        }
        orderedScreenIds
            .filterNot { screenId ->
                FeatureFlags.QSB_ON_FIRST_SCREEN &&
                    isFirstPagePinnedItemEnabled &&
                    !FeatureFlags.shouldShowFirstPageWidget() &&
                    !SHOULD_SHOW_FIRST_PAGE_WIDGET &&
                    screenId == WorkspaceLayoutManager.FIRST_SCREEN_ID
            }
            .forEach { screenId ->
+5 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.launcher3;

import static android.graphics.drawable.AdaptiveIconDrawable.getExtraInsetFraction;

import static com.android.launcher3.BuildConfig.WIDGET_ON_FIRST_SCREEN;
import static com.android.launcher3.Flags.enableSmartspaceAsAWidget;
import static com.android.launcher3.icons.BitmapInfo.FLAG_THEMED;
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT;
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT;
@@ -148,6 +150,9 @@ public final class Utilities {
    public static final int TRANSLATE_LEFT = 2;
    public static final int TRANSLATE_RIGHT = 3;

    public static final boolean SHOULD_SHOW_FIRST_PAGE_WIDGET =
            enableSmartspaceAsAWidget() && WIDGET_ON_FIRST_SCREEN;

    @IntDef({TRANSLATE_UP, TRANSLATE_DOWN, TRANSLATE_LEFT, TRANSLATE_RIGHT})
    public @interface AdjustmentDirection{}

Loading