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

Commit b6d56531 authored by Tony Wickham's avatar Tony Wickham Committed by Automerger Merge Worker
Browse files

Merging from ub-launcher3-rvc-qpr-dev @ build 6777894 am: 0486a038

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/12413394

Change-Id: Iefbcc71d3af5867973a7fc41fe6f31dff905946f
parents 096d1790 0486a038
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -66,8 +66,8 @@ public class NavBarToHomeTouchController implements TouchController,
        SingleAxisSwipeDetector.Listener {

    private static final Interpolator PULLBACK_INTERPOLATOR = DEACCEL_3;
    // How much of the overview scrim we can remove during the transition.
    private static final float OVERVIEW_TO_HOME_SCRIM_PROGRESS = 0.5f;
    // The min amount of overview scrim we keep during the transition.
    private static final float OVERVIEW_TO_HOME_SCRIM_MULTIPLIER = 0.5f;

    private final Launcher mLauncher;
    private final SingleAxisSwipeDetector mSwipeDetector;
@@ -163,11 +163,11 @@ public class NavBarToHomeTouchController implements TouchController,
            RecentsView recentsView = mLauncher.getOverviewPanel();
            AnimatorControllerWithResistance.createRecentsResistanceFromOverviewAnim(mLauncher,
                    builder);
            float endScrimAlpha = Utilities.mapRange(OVERVIEW_TO_HOME_SCRIM_PROGRESS,
                    mStartState.getOverviewScrimAlpha(mLauncher),
                    mEndState.getOverviewScrimAlpha(mLauncher));

            builder.setFloat(mLauncher.getDragLayer().getOverviewScrim(),
                    OverviewScrim.SCRIM_PROGRESS, endScrimAlpha, PULLBACK_INTERPOLATOR);
                    OverviewScrim.SCRIM_MULTIPLIER, OVERVIEW_TO_HOME_SCRIM_MULTIPLIER,
                    PULLBACK_INTERPOLATOR);

            if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
                builder.addOnFrameCallback(
                        () -> recentsView.redrawLiveTile(false /* mightNeedToRefill */));
+10 −2
Original line number Diff line number Diff line
@@ -83,7 +83,15 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
        mDetector = new SingleAxisSwipeDetector(activity, this, dir);
    }

    private boolean canInterceptTouch() {
    private boolean canInterceptTouch(MotionEvent ev) {
        if ((ev.getEdgeFlags() & Utilities.EDGE_NAV_BAR) != 0) {
            // Don't intercept swipes on the nav bar, as user might be trying to go home
            // during a task dismiss animation.
            if (mCurrentAnimation != null) {
                mCurrentAnimation.getAnimationPlayer().end();
            }
            return false;
        }
        if (mCurrentAnimation != null) {
            mCurrentAnimation.forceFinishIfCloseToEnd();
        }
@@ -119,7 +127,7 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
            clearState();
        }
        if (ev.getAction() == MotionEvent.ACTION_DOWN) {
            mNoIntercept = !canInterceptTouch();
            mNoIntercept = !canInterceptTouch(ev);
            if (mNoIntercept) {
                return false;
            }
+42 −6
Original line number Diff line number Diff line
@@ -43,9 +43,13 @@ import android.util.ArrayMap;
import android.util.Log;

import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.WorkerThread;

import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.LauncherProvider;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.R;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.model.data.ItemInfo;
@@ -74,6 +78,9 @@ public final class WellbeingModel {
    private static final int MSG_PACKAGE_REMOVED = 2;
    private static final int MSG_FULL_REFRESH = 3;

    private static final int UNKNOWN_MINIMAL_DEVICE_STATE = 0;
    private static final int IN_MINIMAL_DEVICE = 2;

    // Welbeing contract
    private static final String PATH_ACTIONS = "actions";
    private static final String PATH_MINIMAL_DEVICE = "minimal_device";
@@ -84,6 +91,8 @@ public final class WellbeingModel {
    private static final String EXTRA_MAX_NUM_ACTIONS_SHOWN = "max_num_actions_shown";
    private static final String EXTRA_PACKAGES = "packages";
    private static final String EXTRA_SUCCESS = "success";
    private static final String EXTRA_MINIMAL_DEVICE_STATE = "minimal_device_state";
    private static final String DB_NAME_MINIMAL_DEVICE = "minimal.db";

    public static final MainThreadInitializedObject<WellbeingModel> INSTANCE =
            new MainThreadInitializedObject<>(WellbeingModel::new);
@@ -121,11 +130,12 @@ public final class WellbeingModel {
                    updateWellbeingData();
                } else if (uri.getPath().contains(PATH_MINIMAL_DEVICE)) {
                    // Wellbeing reports that minimal device state or config is changed.
                    updateLauncherModel();
                    updateLauncherModel(context);
                }
            }
        };
        FeatureFlags.ENABLE_MINIMAL_DEVICE.addChangeListener(mContext, this::updateLauncherModel);
        FeatureFlags.ENABLE_MINIMAL_DEVICE.addChangeListener(mContext, () ->
                updateLauncherModel(context));

        if (!TextUtils.isEmpty(mWellbeingProviderPkg)) {
            context.registerReceiver(
@@ -170,7 +180,6 @@ public final class WellbeingModel {
            Log.e(TAG, "Failed to register content observer for " + actionsUri + ": " + e);
            if (mIsInTest) throw new RuntimeException(e);
        }

        updateWellbeingData();
    }

@@ -208,10 +217,34 @@ public final class WellbeingModel {
        mWorkerHandler.sendEmptyMessage(MSG_FULL_REFRESH);
    }

    private void updateLauncherModel() {
        if (!FeatureFlags.ENABLE_MINIMAL_DEVICE.get()) return;
    private void updateLauncherModel(@NonNull final Context context) {
        if (!FeatureFlags.ENABLE_MINIMAL_DEVICE.get()) {
            reloadLauncherInNormalMode(context);
            return;
        }
        runWithMinimalDeviceConfigs((bundle) -> {
            if (bundle.getInt(EXTRA_MINIMAL_DEVICE_STATE, UNKNOWN_MINIMAL_DEVICE_STATE)
                    == IN_MINIMAL_DEVICE) {
                reloadLauncherInMinimalMode(context);
            } else {
                reloadLauncherInNormalMode(context);
            }
        });
    }

    private void reloadLauncherInNormalMode(@NonNull final Context context) {
        LauncherSettings.Settings.call(context.getContentResolver(),
                LauncherSettings.Settings.METHOD_SWITCH_DATABASE,
                InvariantDeviceProfile.INSTANCE.get(context).dbFile);
    }

        // TODO: init Launcher in minimal device / normal mode
    private void reloadLauncherInMinimalMode(@NonNull final Context context) {
        final Bundle extras = new Bundle();
        extras.putString(LauncherProvider.KEY_LAYOUT_PROVIDER_AUTHORITY,
                mWellbeingProviderPkg + ".api");
        LauncherSettings.Settings.call(context.getContentResolver(),
                LauncherSettings.Settings.METHOD_SWITCH_DATABASE,
                DB_NAME_MINIMAL_DEVICE, extras);
    }

    private Uri.Builder apiBuilder() {
@@ -225,6 +258,9 @@ public final class WellbeingModel {
     */
    @WorkerThread
    private void runWithMinimalDeviceConfigs(Consumer<Bundle> consumer) {
        if (!FeatureFlags.ENABLE_MINIMAL_DEVICE.get()) {
            return;
        }
        if (DEBUG || mIsInTest) {
            Log.d(TAG, "runWithMinimalDeviceConfigs() called");
        }
+4 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.launcher3.uioverrides;

import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE_IN_OUT;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.graphics.OverviewScrim.SCRIM_MULTIPLIER;
import static com.android.launcher3.graphics.Scrim.SCRIM_PROGRESS;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_MODAL;
@@ -70,6 +71,7 @@ public abstract class BaseRecentsViewStateController<T extends RecentsView>
        getContentAlphaProperty().set(mRecentsView, state.overviewUi ? 1f : 0);
        OverviewScrim scrim = mLauncher.getDragLayer().getOverviewScrim();
        SCRIM_PROGRESS.set(scrim, state.getOverviewScrimAlpha(mLauncher));
        SCRIM_MULTIPLIER.set(scrim, 1f);
        getTaskModalnessProperty().set(mRecentsView, state.getOverviewModalness());
    }

@@ -108,6 +110,8 @@ public abstract class BaseRecentsViewStateController<T extends RecentsView>
        OverviewScrim scrim = mLauncher.getDragLayer().getOverviewScrim();
        setter.setFloat(scrim, SCRIM_PROGRESS, toState.getOverviewScrimAlpha(mLauncher),
                config.getInterpolator(ANIM_OVERVIEW_SCRIM_FADE, LINEAR));
        setter.setFloat(scrim, SCRIM_MULTIPLIER, 1f,
                config.getInterpolator(ANIM_OVERVIEW_SCRIM_FADE, LINEAR));

        setter.setFloat(
                mRecentsView, getTaskModalnessProperty(),
+47 −6
Original line number Diff line number Diff line
@@ -100,10 +100,12 @@ public class LauncherProvider extends ContentProvider {
    public static final int SCHEMA_VERSION = 28;

    public static final String AUTHORITY = BuildConfig.APPLICATION_ID + ".settings";
    public static final String KEY_LAYOUT_PROVIDER_AUTHORITY = "KEY_LAYOUT_PROVIDER_AUTHORITY";

    static final String EMPTY_DATABASE_CREATED = "EMPTY_DATABASE_CREATED";

    protected DatabaseHelper mOpenHelper;
    protected String mProviderAuthority;

    private long mLastRestoreTimestamp = 0L;

@@ -367,7 +369,8 @@ public class LauncherProvider extends ContentProvider {
            case LauncherSettings.Settings.METHOD_WAS_EMPTY_DB_CREATED : {
                Bundle result = new Bundle();
                result.putBoolean(LauncherSettings.Settings.EXTRA_VALUE,
                        Utilities.getPrefs(getContext()).getBoolean(EMPTY_DATABASE_CREATED, false));
                        Utilities.getPrefs(getContext()).getBoolean(
                                mOpenHelper.getKey(EMPTY_DATABASE_CREATED), false));
                return result;
            }
            case LauncherSettings.Settings.METHOD_DELETE_EMPTY_FOLDERS: {
@@ -437,6 +440,7 @@ public class LauncherProvider extends ContentProvider {
                                            getContext(), true /* forMigration */)));
                    return result;
                }
                return null;
            }
            case LauncherSettings.Settings.METHOD_PREP_FOR_PREVIEW: {
                if (MULTI_DB_GRID_MIRATION_ALGO.get()) {
@@ -450,6 +454,23 @@ public class LauncherProvider extends ContentProvider {
                                    () -> mOpenHelper));
                    return result;
                }
                return null;
            }
            case LauncherSettings.Settings.METHOD_SWITCH_DATABASE: {
                if (TextUtils.equals(arg, mOpenHelper.getDatabaseName())) return null;
                final DatabaseHelper helper = mOpenHelper;
                if (extras == null || !extras.containsKey(KEY_LAYOUT_PROVIDER_AUTHORITY)) {
                    mProviderAuthority = null;
                } else {
                    mProviderAuthority = extras.getString(KEY_LAYOUT_PROVIDER_AUTHORITY);
                }
                mOpenHelper = DatabaseHelper.createDatabaseHelper(
                        getContext(), arg, false /* forMigration */);
                helper.close();
                LauncherAppState app = LauncherAppState.getInstanceNoCreate();
                if (app == null) return null;
                app.getModel().forceReload();
                return null;
            }
        }
        return null;
@@ -492,7 +513,8 @@ public class LauncherProvider extends ContentProvider {
    }

    private void clearFlagEmptyDbCreated() {
        Utilities.getPrefs(getContext()).edit().remove(EMPTY_DATABASE_CREATED).commit();
        Utilities.getPrefs(getContext()).edit()
                .remove(mOpenHelper.getKey(EMPTY_DATABASE_CREATED)).commit();
    }

    /**
@@ -505,7 +527,7 @@ public class LauncherProvider extends ContentProvider {
    synchronized private void loadDefaultFavoritesIfNecessary() {
        SharedPreferences sp = Utilities.getPrefs(getContext());

        if (sp.getBoolean(EMPTY_DATABASE_CREATED, false)) {
        if (sp.getBoolean(mOpenHelper.getKey(EMPTY_DATABASE_CREATED), false)) {
            Log.d(TAG, "loading default workspace");

            AppWidgetHost widgetHost = mOpenHelper.newLauncherWidgetHost();
@@ -553,8 +575,13 @@ public class LauncherProvider extends ContentProvider {
     */
    private AutoInstallsLayout createWorkspaceLoaderFromAppRestriction(AppWidgetHost widgetHost) {
        Context ctx = getContext();
        String authority = Settings.Secure.getString(ctx.getContentResolver(),
        final String authority;
        if (!TextUtils.isEmpty(mProviderAuthority)) {
            authority = mProviderAuthority;
        } else {
            authority = Settings.Secure.getString(ctx.getContentResolver(),
                    "launcher3.layout.provider");
        }
        if (TextUtils.isEmpty(authority)) {
            return null;
        }
@@ -693,12 +720,26 @@ public class LauncherProvider extends ContentProvider {
            }
        }

        /**
         * Re-composite given key in respect to database. If the current db is
         * {@link LauncherFiles#LAUNCHER_DB}, return the key as-is. Otherwise append the db name to
         * given key. e.g. consider key="EMPTY_DATABASE_CREATED", dbName="minimal.db", the returning
         * string will be "EMPTY_DATABASE_CREATED@minimal.db".
         */
        String getKey(final String key) {
            if (TextUtils.equals(getDatabaseName(), LauncherFiles.LAUNCHER_DB)) {
                return key;
            }
            return key + "@" + getDatabaseName();
        }

        /**
         * Overriden in tests.
         */
        protected void onEmptyDbCreated() {
            // Set the flag for empty DB
            Utilities.getPrefs(mContext).edit().putBoolean(EMPTY_DATABASE_CREATED, true).commit();
            Utilities.getPrefs(mContext).edit().putBoolean(getKey(EMPTY_DATABASE_CREATED), true)
                    .commit();
        }

        public long getSerialNumberForUser(UserHandle user) {
Loading