Locking orientation on phones (issue 4967793)

Change-Id: I6b5fe63547f43c408feea75f35dc0a08d06c258c
This commit is contained in:
Adam Cohen
2011-09-15 18:21:21 -07:00
parent c3665faf45
commit 446e940fc8
4 changed files with 25 additions and 14 deletions

View File

@@ -75,7 +75,8 @@
android:clearTaskOnLaunch="true"
android:stateNotNeeded="true"
android:theme="@style/Theme"
android:windowSoftInputMode="adjustPan">
android:windowSoftInputMode="adjustPan"
android:screenOrientation="nosensor">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />

View File

@@ -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();
}

View File

@@ -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,17 +3045,22 @@ public final class Launcher extends Activity
}
return oriMap[(d.getRotation() + indexOffset) % 4];
}
public void lockScreenOrientation() {
public void lockScreenOrientationOnLargeUI() {
if (LauncherApplication.isScreenLarge()) {
setRequestedOrientation(mapConfigurationOriActivityInfoOri(getResources()
.getConfiguration().orientation));
}
public void unlockScreenOrientation() {
}
public void unlockScreenOrientationOnLargeUI() {
if (LauncherApplication.isScreenLarge()) {
mHandler.postDelayed(new Runnable() {
public void run() {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}
}, mRestoreScreenOrientationDelay);
}
}
/* Cling related */
private static final String WORKSPACE_CLING_DISMISSED_KEY = "cling.workspace.dismissed";

View File

@@ -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();
}
/**