diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2017-10-19 16:15:09 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2017-10-20 13:56:47 -0700 |
commit | c99cb174c3369c8c192efc12d97dd8e9f6d189b9 (patch) | |
tree | e5d112b3fe7fba4c5306242f89fb25ee91874db2 /src/com/android/launcher3/Launcher.java | |
parent | cac861068eeb088ef8524bd39ecba0f2006c02e9 (diff) | |
download | android_packages_apps_Trebuchet-c99cb174c3369c8c192efc12d97dd8e9f6d189b9.tar.gz android_packages_apps_Trebuchet-c99cb174c3369c8c192efc12d97dd8e9f6d189b9.tar.bz2 android_packages_apps_Trebuchet-c99cb174c3369c8c192efc12d97dd8e9f6d189b9.zip |
Moving some state specific logic to subclass of LauncherState
Bug: 67678570
Change-Id: I1316f91c9f19bd572e4a0da67a22fa8921e1dcf9
Diffstat (limited to 'src/com/android/launcher3/Launcher.java')
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 60 |
1 files changed, 10 insertions, 50 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 46eb263c6..b06081b81 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -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() { |