From 5613161d114158f0d21733c0a3167400788b6dfc Mon Sep 17 00:00:00 2001 From: vshcherb Date: Wed, 30 Oct 2013 12:19:53 +0100 Subject: [PATCH] Increase delay of showing zoom level button --- .../osmand/plus/views/MapControlsLayer.java | 56 ++++++++++++++----- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index 231aed7184..73e799df86 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -43,7 +43,9 @@ import android.widget.SeekBar; public class MapControlsLayer extends OsmandMapLayer { private static final int SHOW_ZOOM_LEVEL_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_CONTROLS + 1; - private static final int SHOW_ZOOM_LEVEL_DELAY = 4000; + private static final int SHOW_ZOOM_BUTTON_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_CONTROLS + 2; + private static final int SHOW_ZOOM_LEVEL_DELAY = 1000; + private static final int SHOW_ZOOM_LEVEL_BUTTON_DELAY = 2500; private OsmandMapTileView view; @@ -51,6 +53,7 @@ public class MapControlsLayer extends OsmandMapLayer { private Handler showUIHandler; private boolean showZoomLevel = false; + private boolean showZoomLevelButton = false; private int shadowColor = Color.WHITE; @@ -123,9 +126,11 @@ public class MapControlsLayer extends OsmandMapLayer { if(view.isZooming()){ showZoomLevel = true; + showZoomLevelButton = false; showUIHandler.removeMessages(SHOW_ZOOM_LEVEL_MSG_ID); + showUIHandler.removeMessages(SHOW_ZOOM_BUTTON_MSG_ID); } else { - if(showZoomLevel){ + if(showZoomLevel && view.getSettings().SHOW_RULER.get()){ hideZoomLevelInTime(); } } @@ -140,7 +145,7 @@ public class MapControlsLayer extends OsmandMapLayer { } boolean drawZoomLevel = showZoomLevel || !view.getSettings().SHOW_RULER.get(); if (drawZoomLevel) { - drawZoomLevel(canvas, tileBox, view.isZooming()); + drawZoomLevel(canvas, tileBox, !showZoomLevelButton); } else { drawRuler(canvas, tileBox); } @@ -238,21 +243,42 @@ public class MapControlsLayer extends OsmandMapLayer { } private void hideZoomLevelInTime(){ - if (!showUIHandler.hasMessages(SHOW_ZOOM_LEVEL_MSG_ID)) { - Message msg = Message.obtain(showUIHandler, new Runnable() { - @Override - public void run() { - showZoomLevel = false; - view.refreshMap(); - } - - }); - msg.what = SHOW_ZOOM_LEVEL_MSG_ID; - showUIHandler.sendMessageDelayed(msg, SHOW_ZOOM_LEVEL_DELAY); + if (!showUIHandler.hasMessages(SHOW_ZOOM_LEVEL_MSG_ID) && + !showUIHandler.hasMessages(SHOW_ZOOM_BUTTON_MSG_ID)) { + sendMessageToShowZoomLevel(); } } + private void sendMessageToShowZoomLevel() { + Message msg = Message.obtain(showUIHandler, new Runnable() { + @Override + public void run() { + showZoomLevelButton = true; + sendMessageToShowZoomButton(); + view.refreshMap(); + } + + }); + msg.what = SHOW_ZOOM_LEVEL_MSG_ID; + showUIHandler.sendMessageDelayed(msg, SHOW_ZOOM_LEVEL_DELAY); + } + + private void sendMessageToShowZoomButton() { + Message msg = Message.obtain(showUIHandler, new Runnable() { + @Override + public void run() { + showZoomLevelButton = false; + showZoomLevel = false; + view.refreshMap(); + } + + }); + msg.what = SHOW_ZOOM_LEVEL_BUTTON_DELAY; + showUIHandler.sendMessageDelayed(msg, SHOW_ZOOM_LEVEL_BUTTON_DELAY); + } + + @Override public boolean onSingleTap(PointF point, RotatedTileBox tileBox) { if (modeShadow.getBounds().contains((int) point.x, (int) point.y)) { @@ -309,7 +335,7 @@ public class MapControlsLayer extends OsmandMapLayer { Context ctx = view.getContext(); ImageView bottomShadow = new ImageView(ctx); bottomShadow.setBackgroundResource(R.drawable.bottom_shadow); - android.widget.FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, + android.widget.FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, Gravity.BOTTOM); params.setMargins(0, 0, 0, 0); parent.addView(bottomShadow, params);