From 199118aa5822caa6e66ac1e3719914d488669107 Mon Sep 17 00:00:00 2001 From: sonora Date: Tue, 6 Jan 2015 00:29:48 +0100 Subject: [PATCH] take a shot at the screen rotation correction --- .../activities/search/SearchPOIActivity.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java index 2bef3c618f..a784bc3137 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java @@ -781,8 +781,24 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa //TODO: Hardy: The arrow direction below is correct only for the default display's standard orientation // i.e. still needs to be corrected for .ROTATION_90/180/170 - // Keep in mind: getRotation was introduced from Android 2.2 - draw.setAngle(mes[1] - a + 180); + //TODO: API<8 use getOrientation() here + int screenOrientation = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation(); + private static final int ORIENTATION_0 = 0; + private static final int ORIENTATION_90 = 3; + private static final int ORIENTATION_270 = 1; + switch (screenOrientation) + { + case ORIENTATION_0: // Portrait + screenOrientation = 0; + break; + case ORIENTATION_90: // Landscape right + screenOrientation = 90; + break; + case ORIENTATION_270: // Landscape left + screenOrientation = 270; + break; + } + draw.setAngle(mes[1] - a + 180 + screenOrientation); draw.setOpenedColor(opened); direction.setImageDrawable(draw);