From 446e940fc8839173de12f1299b8c24f318d53a3f Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Thu, 15 Sep 2011 18:21:21 -0700 Subject: Locking orientation on phones (issue 4967793) Change-Id: I6b5fe63547f43c408feea75f35dc0a08d06c258c --- .../android/launcher2/AppsCustomizePagedView.java | 4 ++-- src/com/android/launcher2/Launcher.java | 28 +++++++++++++++------- src/com/android/launcher2/Workspace.java | 4 ++-- 3 files changed, 23 insertions(+), 13 deletions(-) (limited to 'src/com/android/launcher2') diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index 6640f045f..b208e884f 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -524,7 +524,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } // Start the drag - mLauncher.lockScreenOrientation(); + mLauncher.lockScreenOrientationOnLargeUI(); mLauncher.getWorkspace().onDragStartedWithItemSpans(createItemInfo.spanX, createItemInfo.spanY, b); mDragController.startDrag(image, b, this, createItemInfo, @@ -553,7 +553,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen // drop in Workspace mLauncher.exitSpringLoadedDragMode(); } - mLauncher.unlockScreenOrientation(); + mLauncher.unlockScreenOrientationOnLargeUI(); } diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 28fdb90d3..c3edb9974 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -321,6 +321,11 @@ public final class Launcher extends Activity if (sAppMarketIcon[coi] != null) { updateAppMarketIcon(sAppMarketIcon[coi]); } + + // On large interfaces, we want the screen to auto-rotate based on the current orientation + if (LauncherApplication.isScreenLarge()) { + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); + } } private void checkForLocaleChange() { @@ -3040,16 +3045,21 @@ public final class Launcher extends Activity } return oriMap[(d.getRotation() + indexOffset) % 4]; } - public void lockScreenOrientation() { - setRequestedOrientation(mapConfigurationOriActivityInfoOri(getResources() - .getConfiguration().orientation)); + + public void lockScreenOrientationOnLargeUI() { + if (LauncherApplication.isScreenLarge()) { + setRequestedOrientation(mapConfigurationOriActivityInfoOri(getResources() + .getConfiguration().orientation)); + } } - public void unlockScreenOrientation() { - mHandler.postDelayed(new Runnable() { - public void run() { - setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); - } - }, mRestoreScreenOrientationDelay); + public void unlockScreenOrientationOnLargeUI() { + if (LauncherApplication.isScreenLarge()) { + mHandler.postDelayed(new Runnable() { + public void run() { + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); + } + }, mRestoreScreenOrientationDelay); + } } /* Cling related */ diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 156d57e37..f61f7e7c2 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -315,13 +315,13 @@ public class Workspace extends SmoothPagedView public void onDragStart(DragSource source, Object info, int dragAction) { mIsDragOccuring = true; updateChildrenLayersEnabled(); - mLauncher.lockScreenOrientation(); + mLauncher.lockScreenOrientationOnLargeUI(); } public void onDragEnd() { mIsDragOccuring = false; updateChildrenLayersEnabled(); - mLauncher.unlockScreenOrientation(); + mLauncher.unlockScreenOrientationOnLargeUI(); } /** -- cgit v1.2.3