summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYour Name <jreck@google.com>2012-11-26 16:33:49 -0800
committerYour Name <jreck@google.com>2012-11-27 15:17:35 -0800
commita314235e093032c2d6cdd1f1d3f6b5c10c3e75a7 (patch)
tree8ca49df903c27a265f2b723ee82f2e37ee74ff31 /src
parent370ec0d435e43763f3e7c4804420bf44d9a39a97 (diff)
downloadandroid_packages_apps_Snap-a314235e093032c2d6cdd1f1d3f6b5c10c3e75a7.tar.gz
android_packages_apps_Snap-a314235e093032c2d6cdd1f1d3f6b5c10c3e75a7.tar.bz2
android_packages_apps_Snap-a314235e093032c2d6cdd1f1d3f6b5c10c3e75a7.zip
Remove orientation compensation
Bug: 7446056 Change-Id: I6f00617c890961e4d56545406bac9682356c0b15
Diffstat (limited to 'src')
-rw-r--r--src/com/android/gallery3d/app/OrientationManager.java100
-rw-r--r--src/com/android/gallery3d/app/PhotoPage.java9
2 files changed, 20 insertions, 89 deletions
diff --git a/src/com/android/gallery3d/app/OrientationManager.java b/src/com/android/gallery3d/app/OrientationManager.java
index 0e033ebe4..0a644ef66 100644
--- a/src/com/android/gallery3d/app/OrientationManager.java
+++ b/src/com/android/gallery3d/app/OrientationManager.java
@@ -27,30 +27,16 @@ import android.view.Surface;
import com.android.gallery3d.ui.OrientationSource;
-import java.util.ArrayList;
-
public class OrientationManager implements OrientationSource {
private static final String TAG = "OrientationManager";
- public interface Listener {
- public void onOrientationCompensationChanged();
- }
-
// Orientation hysteresis amount used in rounding, in degrees
private static final int ORIENTATION_HYSTERESIS = 5;
private Activity mActivity;
- private ArrayList<Listener> mListeners;
private MyOrientationEventListener mOrientationListener;
- // The degrees of the device rotated clockwise from its natural orientation.
- private int mOrientation = OrientationEventListener.ORIENTATION_UNKNOWN;
// If the framework orientation is locked.
private boolean mOrientationLocked = false;
- // The orientation compensation: if the framwork orientation is locked, the
- // device orientation and the framework orientation may be different, so we
- // need to rotate the UI. For example, if this value is 90, the UI
- // components should be rotated 90 degrees counter-clockwise.
- private int mOrientationCompensation = 0;
// This is true if "Settings -> Display -> Rotation Lock" is checked. We
// don't allow the orientation to be unlocked if the value is true.
@@ -58,7 +44,6 @@ public class OrientationManager implements OrientationSource {
public OrientationManager(Activity activity) {
mActivity = activity;
- mListeners = new ArrayList<Listener>();
mOrientationListener = new MyOrientationEventListener(activity);
}
@@ -73,18 +58,6 @@ public class OrientationManager implements OrientationSource {
mOrientationListener.disable();
}
- public void addListener(Listener listener) {
- synchronized (mListeners) {
- mListeners.add(listener);
- }
- }
-
- public void removeListener(Listener listener) {
- synchronized (mListeners) {
- mListeners.remove(listener);
- }
- }
-
////////////////////////////////////////////////////////////////////////////
// Orientation handling
//
@@ -98,15 +71,27 @@ public class OrientationManager implements OrientationSource {
public void lockOrientation() {
if (mOrientationLocked) return;
mOrientationLocked = true;
+ mActivity.setRequestedOrientation(calculateCurrentScreenOrientation());
+ }
+
+ // Unlock the framework orientation, so it can change when the device
+ // rotates.
+ public void unlockOrientation() {
+ if (!mOrientationLocked) return;
+ mOrientationLocked = false;
+ Log.d(TAG, "unlock orientation");
+ mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
+ }
+
+ private int calculateCurrentScreenOrientation() {
int displayRotation = getDisplayRotation();
// Display rotation >= 180 means we need to use the REVERSE landscape/portrait
boolean standard = displayRotation < 180;
if (mActivity.getResources().getConfiguration().orientation
== Configuration.ORIENTATION_LANDSCAPE) {
- Log.d(TAG, "lock orientation to landscape");
- mActivity.setRequestedOrientation(standard
+ return standard
? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
- : ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
+ : ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
} else {
if (displayRotation == 90 || displayRotation == 270) {
// If displayRotation = 90 or 270 then we are on a landscape
@@ -115,53 +100,9 @@ public class OrientationManager implements OrientationSource {
// to flip which portrait we pick as display rotation is counter clockwise
standard = !standard;
}
- Log.d(TAG, "lock orientation to portrait");
- mActivity.setRequestedOrientation(standard
+ return standard
? ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
- : ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
- }
- updateCompensation();
- }
-
- // Unlock the framework orientation, so it can change when the device
- // rotates.
- public void unlockOrientation() {
- if (!mOrientationLocked) return;
- if (mRotationLockedSetting) return;
- mOrientationLocked = false;
- Log.d(TAG, "unlock orientation");
- mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
- disableCompensation();
- }
-
- // Calculate the compensation value and send it to listeners.
- private void updateCompensation() {
- if (mOrientation == OrientationEventListener.ORIENTATION_UNKNOWN) {
- return;
- }
-
- int orientationCompensation =
- (mOrientation + getDisplayRotation(mActivity)) % 360;
-
- if (mOrientationCompensation != orientationCompensation) {
- mOrientationCompensation = orientationCompensation;
- notifyListeners();
- }
- }
-
- // Make the compensation value 0 and send it to listeners.
- private void disableCompensation() {
- if (mOrientationCompensation != 0) {
- mOrientationCompensation = 0;
- notifyListeners();
- }
- }
-
- private void notifyListeners() {
- synchronized (mListeners) {
- for (int i = 0, n = mListeners.size(); i < n; i++) {
- mListeners.get(i).onOrientationCompensationChanged();
- }
+ : ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
}
}
@@ -177,10 +118,7 @@ public class OrientationManager implements OrientationSource {
// the camera then point the camera to floor or sky, we still have
// the correct orientation.
if (orientation == ORIENTATION_UNKNOWN) return;
- mOrientation = roundOrientation(orientation, mOrientation);
- // If the framework orientation is locked, we update the
- // compensation value and notify the listeners.
- if (mOrientationLocked) updateCompensation();
+ orientation = roundOrientation(orientation, 0);
}
}
@@ -191,7 +129,7 @@ public class OrientationManager implements OrientationSource {
@Override
public int getCompensation() {
- return mOrientationCompensation;
+ return 0;
}
private static int roundOrientation(int orientation, int orientationHistory) {
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index cda0f341c..b43cf2a70 100644
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -72,7 +72,7 @@ import com.android.gallery3d.ui.SynchronizedHandler;
import com.android.gallery3d.util.GalleryUtils;
public class PhotoPage extends ActivityState implements
- PhotoView.Listener, OrientationManager.Listener, AppBridge.Server,
+ PhotoView.Listener, AppBridge.Server,
PhotoPageBottomControls.Delegate, GalleryActionBar.OnAlbumModeSelectedListener {
private static final String TAG = "PhotoPage";
@@ -285,7 +285,6 @@ public class PhotoPage extends ActivityState implements
mRootPane.addComponent(mPhotoView);
mApplication = (GalleryApp) ((Activity) mActivity).getApplication();
mOrientationManager = mActivity.getOrientationManager();
- mOrientationManager.addListener(this);
mActivity.getGLRoot().setOrientationSource(mOrientationManager);
mHandler = new SynchronizedHandler(mActivity.getGLRoot()) {
@@ -865,11 +864,6 @@ public class PhotoPage extends ActivityState implements
}
@Override
- public void onOrientationCompensationChanged() {
- mActivity.getGLRoot().requestLayoutContentPane();
- }
-
- @Override
protected void onBackPressed() {
if (mShowDetails) {
hideDetails();
@@ -1424,7 +1418,6 @@ public class PhotoPage extends ActivityState implements
mScreenNailSet = null;
mScreenNailItem = null;
}
- mOrientationManager.removeListener(this);
mActivity.getGLRoot().setOrientationSource(null);
if (mBottomControls != null) mBottomControls.cleanup();