package net.solutinno.util;

import android.content.Context;
import android.content.pm.ActivityInfo;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.Surface;
import android.view.WindowManager;

public class DisplayHelper
{
    public static DisplayMetrics getDisplayMetrics(Context context) {
        final Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
        DisplayMetrics result = new DisplayMetrics();
        display.getMetrics(result);
        return result;
    }

    public static int getScreenRotation(Context context) {

        final Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();

        switch (display.getRotation()) {
            case Surface.ROTATION_0:
                return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
            case Surface.ROTATION_90:
                return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
            case Surface.ROTATION_180:
                return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
            case Surface.ROTATION_270:
                return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
            default:
                return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
        }
    }
}

@@ -113,27 +113,94 @@
 oid.
-util.DisplayMetrics
+content.res.Configuration;%0Aimport android.util.DisplayMetrics;%0Aimport android.util.Log
 ;%0Aim
@@ -814,429 +814,583 @@
 ();%0A
-%0A        switch (display.getRotation()) %7B%0A            case Surface.ROTATION_0:%0A                return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;%0A            case Surface.ROTATION_90:%0A                return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;%0A            case Surface.ROTATION_180:%0A                return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;%0A            case Surface.ROTATION_270:%0A                return
+        final DisplayMetrics metrics = new DisplayMetrics();%0A        display.getMetrics(metrics);%0A%0A        boolean isPortrait = metrics.widthPixels %3C metrics.heightPixels;%0A%0A        switch (display.getRotation()) %7B%0A            case Surface.ROTATION_0:%0A            case Surface.ROTATION_90:%0A                return isPortrait ? ActivityInfo.SCREEN_ORIENTATION_PORTRAIT : ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;%0A            case Surface.ROTATION_180:%0A            case Surface.ROTATION_270:%0A                return isPortrait ? ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT :
  Act

Change DisplayHelper.getScreenRotation()