Increase delay of showing zoom level button

This commit is contained in:
vshcherb 2013-10-30 12:19:53 +01:00
parent a25d361ae9
commit 5613161d11

View file

@ -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);