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

Commit 43657340 authored by Tracy Zhou's avatar Tracy Zhou Committed by Android (Google) Code Review
Browse files

Merge "Render user's actual workspace in ThemePicker preview (Part 3)" into ub-launcher3-master

parents 6b7fbd22 be13d109
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ public class GridSizeMigrationTaskTest {
        };

        mIdp.numHotseatIcons = 3;
        new GridSizeMigrationTask(mContext, mDb, mValidPackages, 5, 3)
        new GridSizeMigrationTask(mContext, mDb, mValidPackages, false, 5, 3)
                .migrateHotseat();
        // First item is dropped as it has the least weight.
        verifyHotseat(hotseatItems[1], hotseatItems[3], hotseatItems[4]);
@@ -82,7 +82,7 @@ public class GridSizeMigrationTaskTest {
        };

        mIdp.numHotseatIcons = 3;
        new GridSizeMigrationTask(mContext, mDb, mValidPackages, 5, 3)
        new GridSizeMigrationTask(mContext, mDb, mValidPackages, false, 5, 3)
                .migrateHotseat();
        // First item is dropped as it has the least weight.
        verifyHotseat(hotseatItems[1], hotseatItems[3], hotseatItems[4]);
@@ -127,7 +127,7 @@ public class GridSizeMigrationTaskTest {
                {  5,  2, -1,  6},
        }});

        new GridSizeMigrationTask(mContext, mDb, mValidPackages,
        new GridSizeMigrationTask(mContext, mDb, mValidPackages, false,
                new Point(4, 4), new Point(3, 3)).migrateWorkspace();

        // Column 2 and row 2 got removed.
@@ -147,7 +147,7 @@ public class GridSizeMigrationTaskTest {
                {  5,  2, -1,  6},
        }});

        new GridSizeMigrationTask(mContext, mDb, mValidPackages,
        new GridSizeMigrationTask(mContext, mDb, mValidPackages, false,
                new Point(4, 4), new Point(3, 3)).migrateWorkspace();

        // Items in the second column get moved to new screen
@@ -172,7 +172,7 @@ public class GridSizeMigrationTaskTest {
                {  3,  1, -1,  4},
        }});

        new GridSizeMigrationTask(mContext, mDb, mValidPackages,
        new GridSizeMigrationTask(mContext, mDb, mValidPackages, false,
                new Point(4, 4), new Point(3, 3)).migrateWorkspace();

        // Items in the second column of the first screen should get placed on the 3rd
@@ -204,7 +204,7 @@ public class GridSizeMigrationTaskTest {
                {  5,  2, -1,  6},
        }});

        new GridSizeMigrationTask(mContext, mDb, mValidPackages,
        new GridSizeMigrationTask(mContext, mDb, mValidPackages, false,
                new Point(4, 4), new Point(3, 3)).migrateWorkspace();

        // Items in the second column of the first screen should get placed on a new screen.
@@ -235,7 +235,7 @@ public class GridSizeMigrationTaskTest {
                {  5,  2,  7, -1},
        }}, 0);

        new GridSizeMigrationTask(mContext, mDb, mValidPackages,
        new GridSizeMigrationTask(mContext, mDb, mValidPackages, false,
                new Point(4, 4), new Point(3, 4)).migrateWorkspace();

        // Items in the second column of the first screen should get placed on a new screen.
@@ -262,7 +262,7 @@ public class GridSizeMigrationTaskTest {
                {  5,  6,  7, -1},
        }}, 0);

        new GridSizeMigrationTask(mContext, mDb, mValidPackages,
        new GridSizeMigrationTask(mContext, mDb, mValidPackages, false,
                new Point(4, 4), new Point(3, 3)).migrateWorkspace();

        // Items in the second column of the first screen should get placed on a new screen.
@@ -282,7 +282,7 @@ public class GridSizeMigrationTaskTest {
     *            represent the workspace grid.
     */
    private void verifyWorkspace(int[][][] ids) {
        IntArray allScreens = getWorkspaceScreenIds(mDb);
        IntArray allScreens = getWorkspaceScreenIds(mDb, LauncherSettings.Favorites.TABLE_NAME);
        assertEquals(ids.length, allScreens.size());
        int total = 0;

@@ -351,7 +351,7 @@ public class GridSizeMigrationTaskTest {
        private final LinkedList<Point> mPoints;

        public MultiStepMigrationTaskVerifier(int... points) {
            super(null, null, null);
            super(null, null, null, false);

            mPoints = new LinkedList<>();
            for (int i = 0; i < points.length; i += 2) {
+2 −1
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import android.os.Process;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.util.Executors;
import com.android.launcher3.util.LauncherRoboTestRunner;
@@ -91,7 +92,7 @@ public class LoaderCursorTest {
                SCREEN, CELLX, CELLY, RESTORED, INTENT
        });

        mLoaderCursor = new LoaderCursor(mCursor, mApp);
        mLoaderCursor = new LoaderCursor(mCursor, LauncherSettings.Favorites.CONTENT_URI, mApp);
        mLoaderCursor.allUsers.put(0, Process.myUserHandle());
    }

+6 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;

import com.android.launcher3.graphics.IconShape;
import com.android.launcher3.graphics.LauncherPreviewRenderer;
import com.android.launcher3.util.ConfigMonitor;
import com.android.launcher3.util.DefaultDisplay;
import com.android.launcher3.util.DefaultDisplay.Info;
@@ -156,6 +157,11 @@ public class InvariantDeviceProfile {

    @TargetApi(23)
    private InvariantDeviceProfile(Context context) {
        if (context instanceof LauncherPreviewRenderer.PreviewContext) {
            throw new IllegalArgumentException(
                    "PreviewContext is passed into this IDP constructor");
        }

        String gridName = Utilities.getPrefs(context).getBoolean(GRID_OPTIONS_PREFERENCE_KEY, false)
                ? Utilities.getPrefs(context).getString(KEY_IDP_GRID_NAME, null)
                : null;
+32 −18
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ import android.content.pm.LauncherApps;
import android.os.Handler;
import android.util.Log;

import androidx.annotation.Nullable;

import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.icons.IconCache;
import com.android.launcher3.icons.IconProvider;
@@ -55,12 +57,12 @@ public class LauncherAppState {
    private final IconCache mIconCache;
    private final WidgetPreviewLoader mWidgetCache;
    private final InvariantDeviceProfile mInvariantDeviceProfile;
    private final SecureSettingsObserver mNotificationDotsObserver;

    private final InstallSessionTracker mInstallSessionTracker;
    private final SimpleBroadcastReceiver mModelChangeReceiver;
    private final SafeCloseable mCalendarChangeTracker;
    private final SafeCloseable mUserChangeListener;
    private SecureSettingsObserver mNotificationDotsObserver;
    private InstallSessionTracker mInstallSessionTracker;
    private SimpleBroadcastReceiver mModelChangeReceiver;
    private SafeCloseable mCalendarChangeTracker;
    private SafeCloseable mUserChangeListener;

    public static LauncherAppState getInstance(final Context context) {
        return INSTANCE.get(context);
@@ -74,15 +76,8 @@ public class LauncherAppState {
        return mContext;
    }

    private LauncherAppState(Context context) {
        Log.v(Launcher.TAG, "LauncherAppState initiated");
        Preconditions.assertUIThread();
        mContext = context;

        mInvariantDeviceProfile = InvariantDeviceProfile.INSTANCE.get(mContext);
        mIconCache = new IconCache(mContext, mInvariantDeviceProfile);
        mWidgetCache = new WidgetPreviewLoader(mContext, mIconCache);
        mModel = new LauncherModel(this, mIconCache, AppFilter.newInstance(mContext));
    public LauncherAppState(Context context) {
        this(context, LauncherFiles.APP_ICONS_DB);

        mModelChangeReceiver = new SimpleBroadcastReceiver(mModel::onBroadcastIntent);

@@ -123,6 +118,17 @@ public class LauncherAppState {
        }
    }

    public LauncherAppState(Context context, @Nullable String iconCacheFileName) {
        Log.v(Launcher.TAG, "LauncherAppState initiated");
        Preconditions.assertUIThread();
        mContext = context;

        mInvariantDeviceProfile = InvariantDeviceProfile.INSTANCE.get(context);
        mIconCache = new IconCache(mContext, mInvariantDeviceProfile, iconCacheFileName);
        mWidgetCache = new WidgetPreviewLoader(mContext, mIconCache);
        mModel = new LauncherModel(this, mIconCache, AppFilter.newInstance(mContext));
    }

    protected void onNotificationSettingsChanged(boolean areNotificationDotsEnabled) {
        if (areNotificationDotsEnabled) {
            NotificationListener.requestRebind(new ComponentName(
@@ -148,11 +154,19 @@ public class LauncherAppState {
     * Call from Application.onTerminate(), which is not guaranteed to ever be called.
     */
    public void onTerminate() {
        if (mModelChangeReceiver != null) {
            mContext.unregisterReceiver(mModelChangeReceiver);
        }
        mContext.getSystemService(LauncherApps.class).unregisterCallback(mModel);
        if (mInstallSessionTracker != null) {
            mInstallSessionTracker.unregister();
        }
        if (mCalendarChangeTracker != null) {
            mCalendarChangeTracker.close();
        }
        if (mUserChangeListener != null) {
            mUserChangeListener.close();
        }
        CustomWidgetManager.INSTANCE.get(mContext).setWidgetRefreshCallback(null);

        if (mNotificationDotsObserver != null) {
+17 −6
Original line number Diff line number Diff line
@@ -93,15 +93,26 @@ public class LauncherSettings {
        public static final String TABLE_NAME = "favorites";

        /**
         * Backup table created when when the favorites table is modified during grid migration
         * Backup table created when the favorites table is modified during grid migration
         */
        public static final String BACKUP_TABLE_NAME = "favorites_bakup";

        /**
         * The content:// style URL for this table
         * Temporary table used specifically for grid migrations during wallpaper preview
         */
        public static final Uri CONTENT_URI = Uri.parse("content://" +
                LauncherProvider.AUTHORITY + "/" + TABLE_NAME);
        public static final String PREVIEW_TABLE_NAME = "favorites_preview";

        /**
         * The content:// style URL for "favorites" table
         */
        public static final Uri CONTENT_URI = Uri.parse("content://"
                + LauncherProvider.AUTHORITY + "/" + TABLE_NAME);

        /**
         * The content:// style URL for "favorites_preview" table
         */
        public static final Uri PREVIEW_CONTENT_URI = Uri.parse("content://"
                + LauncherProvider.AUTHORITY + "/" + PREVIEW_TABLE_NAME);

        /**
         * The content:// style URL for a given row, identified by its id.
@@ -111,8 +122,8 @@ public class LauncherSettings {
         * @return The unique content URL for the specified row.
         */
        public static Uri getContentUri(int id) {
            return Uri.parse("content://" + LauncherProvider.AUTHORITY +
                    "/" + TABLE_NAME + "/" + id);
            return Uri.parse("content://" + LauncherProvider.AUTHORITY
                    + "/" + TABLE_NAME + "/" + id);
        }

        /**
Loading