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

Commit c99cb174 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Moving some state specific logic to subclass of LauncherState

Bug: 67678570
Change-Id: I1316f91c9f19bd572e4a0da67a22fa8921e1dcf9
parent cac86106
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -50,8 +50,6 @@

    <!-- Out of 100, the percent to shrink the workspace during spring loaded mode. -->
    <integer name="config_workspaceSpringLoadShrinkPercentage">90</integer>
    <!-- Out of 100, the percent to shrink the workspace during overview mode. -->
    <integer name="config_workspaceOverviewShrinkPercentage">70</integer>

    <!-- This constant stores the ratio of the all apps button drawable which
         is used for internal (baked-in) padding -->
+1 −1
Original line number Diff line number Diff line
@@ -570,7 +570,7 @@ public class DeviceProfile {
        }
    }

    int getOverviewModeButtonBarHeight() {
    public int getOverviewModeButtonBarHeight() {
        int zoneHeight = (int) (overviewModeIconZoneRatio * availableHeightPx);
        return Utilities.boundToRange(zoneHeight,
                overviewModeMinIconZoneHeightPx,
+10 −50
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

package com.android.launcher3;

import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;

import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_NEXT_FRAME;
import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY;
import static com.android.launcher3.logging.LoggerUtils.newContainerTarget;
@@ -47,7 +50,6 @@ import android.content.IntentFilter;
import android.content.IntentSender;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Point;
@@ -264,10 +266,6 @@ public class Launcher extends BaseActivity

    private PopupDataProvider mPopupDataProvider;

    // Determines how long to wait after a rotation before restoring the screen orientation to
    // match the sensor state.
    private static final int RESTORE_SCREEN_ORIENTATION_DELAY = 500;

    private final ArrayList<Integer> mSynchronouslyBoundPages = new ArrayList<>();

    // We only want to get the SharedPreferences once since it does an FS stat each time we get
@@ -291,18 +289,8 @@ public class Launcher extends BaseActivity

    public ViewGroupFocusHelper mFocusHandler;
    private boolean mRotationEnabled = false;

    private boolean mAppLaunchSuccess;

    @Thunk void setOrientation() {
        if (mRotationEnabled) {
            unlockScreenOrientation(true);
        } else {
            setRequestedOrientation(
                    ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
        }
    }

    private RotationPrefChangeHandler mRotationPrefChangeHandler;

    @Override
@@ -416,7 +404,8 @@ public class Launcher extends BaseActivity

        // On large interfaces, or on devices that a user has specifically enabled screen rotation,
        // we want the screen to auto-rotate based on the current orientation
        setOrientation();
        setRequestedOrientation(mRotationEnabled
                ? SCREEN_ORIENTATION_UNSPECIFIED : SCREEN_ORIENTATION_NOSENSOR);

        setContentView(mLauncherView);

@@ -1896,11 +1885,8 @@ public class Launcher extends BaseActivity
        AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(this);
        if (topView != null) {
            topView.onBackPressed();
        } else if (isInState(LauncherState.ALL_APPS)) {
            ued.logActionCommand(Action.Command.BACK, ContainerType.ALLAPPS);
            showWorkspace(true);
        } else if (isInState(LauncherState.OVERVIEW)) {
            ued.logActionCommand(Action.Command.BACK, ContainerType.OVERVIEW);
        } else if (!isInState(LauncherState.NORMAL)) {
            ued.logActionCommand(Action.Command.BACK, mWorkspace.getState().containerType);
            showWorkspace(true);
        } else {
            // Back button is a no-op here, but give at least some feedback for the button press
@@ -2381,7 +2367,7 @@ public class Launcher extends BaseActivity
        if (!mDragController.isDragging()) {
            if (itemUnderLongClick == null) {
                // User long pressed on empty space
                if (isInState(LauncherState.OVERVIEW)) {
                if (mWorkspace.isPageRearrangeEnabled()) {
                    mWorkspace.startReordering(v);
                    getUserEventDispatcher().logActionOnContainer(Action.Touch.LONGPRESS,
                            Action.Direction.NONE, ContainerType.OVERVIEW);
@@ -2544,15 +2530,6 @@ public class Launcher extends BaseActivity
            return;
        }

        // Lock the orientation:
        if (mRotationEnabled) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
        }

        // Prevent any Un/InstallShortcutReceivers from updating the db while we are
        // in spring loaded mode
        InstallShortcutReceiver.enableInstallQueue(InstallShortcutReceiver.FLAG_DRAG_AND_DROP);

        mStateTransitionAnimation.startAnimationToWorkspace(
                LauncherState.SPRING_LOADED, true /* animated */,
                null /* onCompleteRunnable */);
@@ -2565,13 +2542,6 @@ public class Launcher extends BaseActivity
    public void exitSpringLoadedDragMode(int delay, final Runnable onCompleteRunnable) {
        if (!isInState(LauncherState.SPRING_LOADED)) return;

        // Unlock rotation lock
        unlockScreenOrientation(false);

        // Re-enable any Un/InstallShortcutReceiver and now process any queued items
        InstallShortcutReceiver.disableAndFlushInstallQueue(
                InstallShortcutReceiver.FLAG_DRAG_AND_DROP, this);

        if (mExitSpringLoadedModeRunnable != null) {
            mHandler.removeCallbacks(mExitSpringLoadedModeRunnable);
        }
@@ -3333,18 +3303,8 @@ public class Launcher extends BaseActivity
        mModel.refreshAndBindWidgetsAndShortcuts(packageUser);
    }

    public void unlockScreenOrientation(boolean immediate) {
        if (mRotationEnabled) {
            if (immediate) {
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
            } else {
                mHandler.postDelayed(new Runnable() {
                    public void run() {
                        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
                    }
                }, RESTORE_SCREEN_ORIENTATION_DELAY);
            }
        }
    public boolean isRotationEnabled () {
        return mRotationEnabled;
    }

    private void markAppsViewShown() {
+14 −10
Original line number Diff line number Diff line
@@ -19,9 +19,9 @@ import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_AUTO;
import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS;

import static com.android.launcher3.LauncherAnimUtils.ALL_APPS_TRANSITION_MS;
import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS;
import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_TRANSITION_MS;

import com.android.launcher3.states.OverviewState;
import com.android.launcher3.states.SpringLoadedState;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;

import java.util.Arrays;
@@ -40,19 +40,15 @@ public class LauncherState {

    private static final LauncherState[] sAllStates = new LauncherState[4];

    public static LauncherState NORMAL = new LauncherState(0, ContainerType.WORKSPACE,
    public static final LauncherState NORMAL = new LauncherState(0, ContainerType.WORKSPACE,
            0, FLAG_DO_NOT_RESTORE);

    public static LauncherState ALL_APPS = new LauncherState(1, ContainerType.ALLAPPS,
    public static final LauncherState ALL_APPS = new LauncherState(1, ContainerType.ALLAPPS,
            ALL_APPS_TRANSITION_MS, FLAG_DISABLE_ACCESSIBILITY);

    public static LauncherState SPRING_LOADED = new LauncherState(2, ContainerType.WORKSPACE,
            SPRING_LOADED_TRANSITION_MS,
            FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE | FLAG_DISABLE_ACCESSIBILITY | FLAG_DO_NOT_RESTORE);
    public static final LauncherState SPRING_LOADED = new SpringLoadedState(2);

    public static LauncherState OVERVIEW = new LauncherState(3, ContainerType.OVERVIEW,
            OVERVIEW_TRANSITION_MS,
            FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE | FLAG_HIDE_HOTSEAT | FLAG_DO_NOT_RESTORE);
    public static final LauncherState OVERVIEW = new OverviewState(3);

    public final int ordinal;

@@ -101,4 +97,12 @@ public class LauncherState {
    public static LauncherState[] values() {
        return Arrays.copyOf(sAllStates, sAllStates.length);
    }

    public float[] getWorkspaceScaleAndTranslation(Launcher launcher) {
        return new float[] {1, 0};
    }

    public void onStateEnabled(Launcher launcher) { }

    public void onStateDisabled(Launcher launcher) { }
}
+2 −3
Original line number Diff line number Diff line
@@ -1341,12 +1341,11 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
    /**
     * return true if freescroll has been enabled, false otherwise
     */
    public boolean enableFreeScroll() {
    protected void enableFreeScroll() {
        setEnableFreeScroll(true);
        return true;
    }

    public void disableFreeScroll() {
    protected void disableFreeScroll() {
        setEnableFreeScroll(false);
    }

Loading