Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 036bad44 authored by Steve Kondik's avatar Steve Kondik
Browse files

Merge branch 'eclair' of git://github.com/optedoblivion/android_frameworks_base into eclair

parents 5521f501 9a465c64
Loading
Loading
Loading
Loading
+121 −4
Original line number Diff line number Diff line
@@ -145,6 +145,62 @@ public abstract class WindowOrientationListener {
        private static final float LP_LF_LOWER =
            ((float)(LP_UPPER - LP_LOWER))/((float)(PIVOT-PIVOT_LOWER)); 


	// new orientation h4x start here
	// -- optedoblivion

	private static final int LANDSCAPE_LOWER_2 = 125;
	private static final int LP_LOWER_2 = 40;
	private static final int PL_UPPER_2 = 65;
	private static final int PL_LOWER_2 = 90;
	private static final int LP_UPPER_2 = 1;
	private static final int PORTRAIT_LOWER_2 = 300;

	private static final int LP_LOWER_3 = 220;
	private static final int PL_UPPER_3 = 245;
	private static final int LP_UPPER_3 = 181;
	private static final int PL_UPPER_4 = 115;
	private static final int LP_LOWER_4 = 140;
	private static final int LP_UPPER_4 = 179;

        // Internal value used for calculating linear variant
        private static final float PL_LF_UPPER_2 =
            ((float)(PL_UPPER_2-PL_LOWER_2))/((float)(PIVOT_UPPER-PIVOT));
        private static final float PL_LF_LOWER_2 =
            ((float)(PL_UPPER_2-PL_LOWER_2))/((float)(PIVOT-PIVOT_LOWER));
        //  Internal value used for calculating linear variant
        private static final float LP_LF_UPPER_2 =
            ((float)(LP_UPPER_2 - LP_LOWER_2))/((float)(PIVOT_UPPER-PIVOT));
        private static final float LP_LF_LOWER_2 =
            ((float)(LP_UPPER_2 - LP_LOWER_2))/((float)(PIVOT-PIVOT_LOWER)); 

        // Internal value used for calculating linear variant
        private static final float PL_LF_UPPER_3 =
            ((float)(PL_UPPER_3-PL_LOWER))/((float)(PIVOT_UPPER-PIVOT));
        private static final float PL_LF_LOWER_3 =
            ((float)(PL_UPPER_3-PL_LOWER))/((float)(PIVOT-PIVOT_LOWER));
        //  Internal value used for calculating linear variant
        private static final float LP_LF_UPPER_3 =
            ((float)(LP_UPPER_3 - LP_LOWER_3))/((float)(PIVOT_UPPER-PIVOT));
        private static final float LP_LF_LOWER_3 =
            ((float)(LP_UPPER_3 - LP_LOWER_3))/((float)(PIVOT-PIVOT_LOWER)); 

        // Internal value used for calculating linear variant
        private static final float PL_LF_UPPER_4 =
            ((float)(PL_UPPER_4-PL_LOWER_2))/((float)(PIVOT_UPPER-PIVOT));
        private static final float PL_LF_LOWER_4 =
            ((float)(PL_UPPER_4-PL_LOWER_2))/((float)(PIVOT-PIVOT_LOWER));
        //  Internal value used for calculating linear variant
        private static final float LP_LF_UPPER_4 =
            ((float)(LP_UPPER_4 - LP_LOWER_4))/((float)(PIVOT_UPPER-PIVOT));
        private static final float LP_LF_LOWER_4 =
            ((float)(LP_UPPER_4 - LP_LOWER_4))/((float)(PIVOT-PIVOT_LOWER)); 

	// End h4x vars        



        
        public void onSensorChanged(SensorEvent event) {
            float[] values = event.values;
            float X = values[_DATA_X];
@@ -195,7 +251,68 @@ public abstract class WindowOrientationListener {
                    rotation = Surface.ROTATION_90;
                } else if ((orientation >= PL_UPPER) || (orientation <= PORTRAIT_LOWER)) {
                    rotation = Surface.ROTATION_0;
		// Start orientation h4x
		// --optedoblivion
		} else if ((orientation <= PL_LOWER_2) && (orientation >= LP_UPPER_2)){
		    float threshold;
		    float delta = zyangle - PIVOT;
		    if(mSensorRotation == Surface.ROTATION_270) {
			if (delta < 0){
			    threshold = LP_LOWER_2 - (LP_LF_LOWER_2 * delta);
			} else {
                            threshold = LP_LOWER_2 + (LP_LF_UPPER_2 * delta);
                        }
                        rotation = (orientation <= threshold) ? Surface.ROTATION_0 : Surface.ROTATION_270;
		    } else {
		        if (delta < 0){
			    threshold = PL_UPPER_2 + (PL_LF_LOWER_2 * delta);
			} else {
			    threshold = PL_UPPER_2 - (PL_LF_UPPER_2 * delta);
			}
			rotation = (orientation >= threshold) ? Surface.ROTATION_270 : Surface.ROTATION_0; 
	           }
                } else if ((orientation <= LANDSCAPE_LOWER_2) && (orientation > LP_LOWER_2)){
		    rotation = Surface.ROTATION_270;
		} else if ((orientation <= PL_LOWER) && (orientation >= LP_UPPER_3)){
		    float threshold;
                    float delta = zyangle - PIVOT;
		    if(mSensorRotation == Surface.ROTATION_90) {
			if (delta < 0){
			    threshold = LP_LOWER_3 - (LP_LF_LOWER_3 * delta);
			} else {
			    threshold = LP_LOWER_3 + (LP_LF_UPPER_3 * delta);
		        }
			rotation = (orientation <= threshold) ? Surface.ROTATION_180 : Surface.ROTATION_90;
		    } else {
			if(delta < 0){
			    threshold = PL_UPPER_3 + (PL_LF_LOWER_3 * delta);
			} else {
			    threshold = PL_UPPER_3 - (PL_LF_UPPER_3 * delta);
			}
			rotation = (orientation >= threshold) ? Surface.ROTATION_90 : Surface.ROTATION_180;
		    }
		} else if ((orientation <= LP_LOWER_3) && (orientation >= LP_LOWER_4)){
		    rotation = Surface.ROTATION_180;
		} else if ((orientation >= PL_LOWER_2) && (orientation <= LP_UPPER_4)){
		    float threshold;
		    float delta = zyangle - PIVOT;
	   	    if(mSensorRotation == Surface.ROTATION_270){
			if(delta < 0){
			    threshold = LP_LOWER_4 - (LP_LF_LOWER_4 * delta);
			} else {
			    threshold = LP_LOWER_4 + (LP_LF_UPPER_4 * delta);
			}
			rotation = (orientation >= threshold) ? Surface.ROTATION_180 : Surface.ROTATION_270;
		    } else {
			if(delta < 0){
			    threshold = PL_UPPER_4 + (PL_LF_UPPER_4 * delta);
			} else {
			    threshold = PL_UPPER_4 - (PL_LF_UPPER_4 * delta);
			}
			rotation = (orientation <= threshold) ? Surface.ROTATION_270 : Surface.ROTATION_180;
		    }
		}
		// End orientation h4x
                if ((rotation != -1) && (rotation != mSensorRotation)) {
                    mSensorRotation = rotation;
                    onOrientationChanged(mSensorRotation);