Android编程Froyo2.2版本兑现360度旋转
--- a/frameworks/base/core/java/android/view/WindowOrientationListener.java
+++ b/frameworks/base/core/java/android/view/WindowOrientationListener.java
@@ -124,13 +124,14 @@ public abstract class WindowOrientationListener {
private static final int ROTATION_0 = 0;
private static final int ROTATION_90 = 1;
private static final int ROTATION_270 = 2;
+ private static final int ROTATION_180 = 3;
// Current orientation state
private int mRotation = ROTATION_0;
// Mapping our internal aliases into actual Surface rotation values
private final int[] SURFACE_ROTATIONS = new int[] {Surface.ROTATION_0, Surface.ROTATION_90,
- Surface.ROTATION_270};
+ Surface.ROTATION_270, Surface.ROTATION_180};
// Threshold ranges of orientation angle to transition into other orientation states.
// The first list is for transitions from ROTATION_0, the next for ROTATION_90, etc.
@@ -141,15 +142,18 @@ public abstract class WindowOrientationListener {
// however, we enforce stricter thresholds, pushing the thresholds 15 degrees closer to 180.
private final int[][][] THRESHOLDS = new int[][][] {
{{60, 180}, {180, 300}},
- {{0, 45}, {45, 165}, {330, 360}},
- {{0, 30}, {195, 315}, {315, 360}}
+ {{0, 45}, {45, 165}, {165,225}, {330, 360}},
+ {{0, 30}, {145,195}, {195,315}, {315, 360}},
+ {{0, 45}, {45,165}, {165,225}, {225, 360}}
};
// See THRESHOLDS
private final int[][] ROTATE_TO = new int[][] {
{ROTATION_270, ROTATION_90},
- {ROTATION_0, ROTATION_270, ROTATION_0},
- {ROTATION_0, ROTATION_90, ROTATION_0}
+ {ROTATION_0, ROTATION_270, ROTATION_180, ROTATION_0},
+ {ROTATION_0, ROTATION_180, ROTATION_90, ROTATION_0},
+ {ROTATION_0, ROTATION_270, ROTATION_180, ROTATION_90}
+ //{ROTATION_270, ROTATION_90}
};
// Maximum absolute tilt angle at which to consider orientation changes. Beyond this (i.e.
@@ -159,7 +163,7 @@ public abstract class WindowOrientationListener {
// Additional limits on tilt angle to transition to each new orientation. We ignore all
// vectors with tilt beyond MAX_TILT, but we can set stricter limits on transition to a
// particular orientation here.
- private final int[] MAX_TRANSITION_TILT = new int[] {MAX_TILT, MAX_TILT, MAX_TILT};
+ private final int[] MAX_TRANSITION_TILT = new int[] {MAX_TILT, MAX_TILT, MAX_TILT, MAX_TILT};