Fixed bug with maprouteinfocontrol dialog showing every time when control created. Fixed layout positioning bug with this dialog

This commit is contained in:
Denis_Bars 2014-08-02 11:50:54 +03:00
parent f2e40be50d
commit 39c6c1ffa8
2 changed files with 29 additions and 29 deletions

View file

@ -26,7 +26,7 @@ public abstract class MapControls {
protected int shadowColor; protected int shadowColor;
private boolean visible; private boolean visible;
private long delayTime; private long delayTime;
protected int gravity = Gravity.BOTTOM | Gravity.RIGHT; protected int gravity = Gravity.BOTTOM | Gravity.RIGHT;
protected int margin; protected int margin;
protected int vmargin; protected int vmargin;
@ -40,19 +40,19 @@ public abstract class MapControls {
this.showUIHandler = showUIHandler; this.showUIHandler = showUIHandler;
this.scaleCoefficient = scaleCoefficient; this.scaleCoefficient = scaleCoefficient;
} }
public void setGravity(int gravity) { public void setGravity(int gravity) {
this.gravity = gravity; this.gravity = gravity;
} }
public void setMargin(int margin) { public void setMargin(int margin) {
this.margin = margin; this.margin = margin;
} }
public void setVerticalMargin(int vmargin) { public void setVerticalMargin(int vmargin) {
this.vmargin = vmargin; this.vmargin = vmargin;
} }
protected ImageButton addImageButton(FrameLayout parent, int stringId, int resourceId) { protected ImageButton addImageButton(FrameLayout parent, int stringId, int resourceId) {
Context ctx = mapActivity; Context ctx = mapActivity;
ImageButton button = new ImageButton(ctx); ImageButton button = new ImageButton(ctx);
@ -73,17 +73,17 @@ public abstract class MapControls {
applyAttributes(ctx, parent, button, stringId, resourceId, extraMargin); applyAttributes(ctx, parent, button, stringId, resourceId, extraMargin);
return button; return button;
} }
public void setNotifyClick(Runnable notifyClick) { public void setNotifyClick(Runnable notifyClick) {
this.notifyClick = notifyClick; this.notifyClick = notifyClick;
} }
protected void notifyClicked() { protected void notifyClicked() {
if(notifyClick != null) { if(notifyClick != null) {
notifyClick.run(); notifyClick.run();
} }
} }
private void applyAttributes(Context ctx, FrameLayout parent, View button, int stringId, int resourceId, private void applyAttributes(Context ctx, FrameLayout parent, View button, int stringId, int resourceId,
int extraMargin) { int extraMargin) {
@ -124,12 +124,12 @@ public abstract class MapControls {
public final void init(FrameLayout layout) { public final void init(FrameLayout layout) {
initControls(layout); initControls(layout);
} }
public final void show(FrameLayout layout) { public final void show(FrameLayout layout) {
visible = true; visible = true;
showControls(layout); showControls(layout);
} }
public final void showWithDelay(final FrameLayout layout, final long delay) { public final void showWithDelay(final FrameLayout layout, final long delay) {
this.delayTime = System.currentTimeMillis() + delay; this.delayTime = System.currentTimeMillis() + delay;
if(!visible) { if(!visible) {
@ -158,25 +158,25 @@ public abstract class MapControls {
} }
}, delay); }, delay);
} }
public final void hide(FrameLayout layout) { public final void hide(FrameLayout layout) {
if(this.delayTime == 0) { if(this.delayTime == 0) {
visible = false; visible = false;
hideControls(layout); hideControls(layout);
} }
} }
public final void forceHide(FrameLayout layout) { public final void forceHide(FrameLayout layout) {
delayTime = 0; delayTime = 0;
visible = false; visible = false;
hideControls(layout); hideControls(layout);
mapActivity.getMapView().refreshMap(); mapActivity.getMapView().refreshMap();
} }
public boolean isVisible() { public boolean isVisible() {
return visible; return visible;
} }
protected boolean isLeft() { protected boolean isLeft() {
return (Gravity.LEFT & gravity) == Gravity.LEFT; return (Gravity.LEFT & gravity) == Gravity.LEFT;
} }
@ -184,23 +184,23 @@ public abstract class MapControls {
public boolean isBottom() { public boolean isBottom() {
return (Gravity.BOTTOM & gravity) == Gravity.BOTTOM; return (Gravity.BOTTOM & gravity) == Gravity.BOTTOM;
} }
protected void initControls(FrameLayout layout) { protected void initControls(FrameLayout layout) {
} }
protected abstract void hideControls(FrameLayout layout); protected abstract void hideControls(FrameLayout layout);
protected abstract void showControls(FrameLayout layout); protected abstract void showControls(FrameLayout layout);
public abstract void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings nightMode); public abstract void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings nightMode);
public boolean onTouchEvent(MotionEvent event, RotatedTileBox tileBox) { public boolean onTouchEvent(MotionEvent event, RotatedTileBox tileBox) {
return false; return false;
} }
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) { public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
return false; return false;
} }
@ -208,4 +208,8 @@ public abstract class MapControls {
public void setExtraVerticalMargin(int extraVerticalMargin) { public void setExtraVerticalMargin(int extraVerticalMargin) {
this.extraVerticalMargin = extraVerticalMargin; this.extraVerticalMargin = extraVerticalMargin;
} }
public int getExtraVerticalMargin() {
return this.extraVerticalMargin;
}
} }

View file

@ -3,6 +3,9 @@ package net.osmand.plus.views.controls;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import android.graphics.Point;
import android.os.SystemClock;
import android.view.*;
import net.osmand.data.FavouritePoint; import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.RotatedTileBox; import net.osmand.data.RotatedTileBox;
@ -31,10 +34,6 @@ import android.graphics.Canvas;
import android.graphics.PointF; import android.graphics.PointF;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Handler; import android.os.Handler;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
@ -98,9 +97,6 @@ public class MapRouteInfoControl extends MapControls implements IRouteInformatio
} }
} }
}); });
if(getTargets().getPointToNavigate() == null) {
showDialog();
}
} }
private Dialog createDialog() { private Dialog createDialog() {
@ -131,7 +127,7 @@ public class MapRouteInfoControl extends MapControls implements IRouteInformatio
lp.width = WindowManager.LayoutParams.WRAP_CONTENT; lp.width = WindowManager.LayoutParams.WRAP_CONTENT;
lp.height = WindowManager.LayoutParams.WRAP_CONTENT; lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
lp.gravity = Gravity.BOTTOM; lp.gravity = Gravity.BOTTOM;
lp.y = (int) (infoButton.getBottom() - infoButton.getTop() + scaleCoefficient * 5); lp.y = (int) (infoButton.getBottom() - infoButton.getTop() + scaleCoefficient * 5 + getExtraVerticalMargin());
dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setAttributes(lp); dialog.getWindow().setAttributes(lp);