Update text
This commit is contained in:
parent
c8af7a7467
commit
bd179ac81c
6 changed files with 50 additions and 29 deletions
|
@ -20,8 +20,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center"
|
||||
|
||||
android:maxLines="1"
|
||||
android:shadowColor="@color/color_myloc_distance"
|
||||
android:shadowRadius="10"
|
||||
|
@ -74,7 +74,7 @@
|
|||
android:layout_width="@dimen/map_address_height"
|
||||
android:layout_height="@dimen/map_address_height"
|
||||
android:background="@drawable/btn_circle_transparent"
|
||||
android:src="@drawable/ic_action_remove_light" />
|
||||
android:src="@drawable/ic_overflow_menu_white" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/waypoint_close"
|
||||
|
|
|
@ -23,6 +23,7 @@ import net.osmand.plus.routing.RouteProvider.RouteService;
|
|||
import net.osmand.plus.voice.CommandPlayer;
|
||||
import net.osmand.router.RouteCalculationProgress;
|
||||
import net.osmand.router.RouteSegmentResult;
|
||||
import net.osmand.router.TurnType;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
|
@ -660,7 +661,7 @@ public class RoutingHelper {
|
|||
return false;
|
||||
}
|
||||
|
||||
public synchronized String getCurrentName(){
|
||||
public synchronized String getCurrentName(TurnType[] next){
|
||||
NextDirectionInfo n = getNextRouteDirectionInfo(new NextDirectionInfo(), false);
|
||||
Location l = lastFixedLocation;
|
||||
float speed = 0;
|
||||
|
@ -672,14 +673,17 @@ public class RoutingHelper {
|
|||
String nm = n.directionInfo.getStreetName();
|
||||
String rf = n.directionInfo.getRef();
|
||||
String dn = n.directionInfo.getDestinationName();
|
||||
return "\u2566 " + formatStreetName(nm, rf, dn);
|
||||
if(next != null) {
|
||||
next[0] = n.directionInfo.getTurnType();
|
||||
}
|
||||
return formatStreetName(nm, rf, dn);
|
||||
}
|
||||
RouteSegmentResult rs = getCurrentSegmentResult();
|
||||
if(rs != null) {
|
||||
String nm = rs.getObject().getName();
|
||||
String rf = rs.getObject().getRef();
|
||||
String dn = rs.getObject().getDestinationName();
|
||||
return "\u21E7 " + formatStreetName(nm, rf, dn);
|
||||
return formatStreetName(nm, rf, dn);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -217,7 +217,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
|||
LatLon ll = settings.getLastKnownMapLocation();
|
||||
currentViewport = new RotatedTileBox.RotatedTileBoxBuilder().
|
||||
setLocation(ll.getLatitude(), ll.getLongitude()).setZoom(settings.getLastKnownMapZoom()).
|
||||
setPixelDimensions(100, 100).build();
|
||||
setPixelDimensions(400, 700).build();
|
||||
currentViewport.setDensity(dm.density);
|
||||
currentViewport.setMapDensity(getSettingsMapDensity());
|
||||
}
|
||||
|
|
|
@ -23,24 +23,18 @@ import net.osmand.plus.routing.RouteDirectionInfo;
|
|||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.ShadowText;
|
||||
import net.osmand.plus.views.controls.MapRouteInfoControl;
|
||||
import net.osmand.plus.views.mapwidgets.NextTurnInfoWidget.TurnDrawable;
|
||||
import net.osmand.router.TurnType;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.Paint.Align;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextPaint;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
|
@ -291,6 +285,7 @@ public class MapInfoWidgetsFactory {
|
|||
private OsmandSettings settings;
|
||||
private View waypointInfoBar;
|
||||
private LocationPointWrapper lastPoint;
|
||||
private TurnDrawable turnDrawable;
|
||||
|
||||
public TopTextView(OsmandApplication app, MapActivity map) {
|
||||
topBar = map.findViewById(R.id.map_top_bar);
|
||||
|
@ -302,6 +297,7 @@ public class MapInfoWidgetsFactory {
|
|||
settings = app.getSettings();
|
||||
waypointHelper = app.getWaypointHelper();
|
||||
updateVisibility(false);
|
||||
turnDrawable = new NextTurnInfoWidget.TurnDrawable(map);
|
||||
}
|
||||
|
||||
public boolean updateVisibility(boolean visible) {
|
||||
|
@ -335,15 +331,17 @@ public class MapInfoWidgetsFactory {
|
|||
|
||||
public boolean updateInfo(DrawSettings d) {
|
||||
String text = null;
|
||||
TurnType[] type = new TurnType[1];
|
||||
if (routingHelper != null && routingHelper.isRouteCalculated()) {
|
||||
if (routingHelper.isFollowingMode()) {
|
||||
text = routingHelper.getCurrentName();
|
||||
text = routingHelper.getCurrentName(type);
|
||||
} else {
|
||||
int di = MapRouteInfoControl.getDirectionInfo();
|
||||
if (di >= 0 && MapRouteInfoControl.isControlVisible() &&
|
||||
di < routingHelper.getRouteDirections().size()) {
|
||||
RouteDirectionInfo next = routingHelper.getRouteDirections().get(di);
|
||||
text = "\u2566 " + RoutingHelper.formatStreetName(next.getStreetName(), next.getRef(), next.getDestinationName());
|
||||
type[0] = next.getTurnType();
|
||||
text = RoutingHelper.formatStreetName(next.getStreetName(), next.getRef(), next.getDestinationName());
|
||||
}
|
||||
}
|
||||
} else if(settings.getApplicationMode() != ApplicationMode.DEFAULT &&
|
||||
|
@ -360,6 +358,14 @@ public class MapInfoWidgetsFactory {
|
|||
} else {
|
||||
updateVisibility(true);
|
||||
updateVisibility(addressText, true);
|
||||
boolean update = turnDrawable.setTurnType(type[0]);
|
||||
if (update) {
|
||||
if (type[0] != null) {
|
||||
addressText.setCompoundDrawables(turnDrawable, null, null, null);
|
||||
} else {
|
||||
addressText.setCompoundDrawables(null, null, null, null);
|
||||
}
|
||||
}
|
||||
if (!text.equals(addressText.getText().toString())) {
|
||||
if (!text.equals("")) {
|
||||
topBar.setContentDescription(text);
|
||||
|
@ -388,7 +394,7 @@ public class MapInfoWidgetsFactory {
|
|||
all.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
map.getMapActions().showWaypointsInDrawer(false);
|
||||
map.getMapActions().showWaypointsDialog(false);
|
||||
}
|
||||
});
|
||||
btnN.setOnClickListener(new View.OnClickListener() {
|
||||
|
|
|
@ -39,11 +39,11 @@ public class NextTurnInfoWidget extends TextInfoWidget {
|
|||
this.horisontalMini = horisontalMini;
|
||||
turnDrawable = new TurnDrawable(activity);
|
||||
if(horisontalMini) {
|
||||
setImageDrawable(turnDrawable);
|
||||
setTopImageDrawable(null);
|
||||
setImageDrawable(turnDrawable, false);
|
||||
setTopImageDrawable(null, true);
|
||||
} else {
|
||||
setTopImageDrawable(turnDrawable);
|
||||
setImageDrawable(null);
|
||||
setImageDrawable(null, false);
|
||||
setTopImageDrawable(turnDrawable, true);
|
||||
}
|
||||
updateVisibility(false);
|
||||
}
|
||||
|
@ -86,9 +86,9 @@ public class NextTurnInfoWidget extends TextInfoWidget {
|
|||
String ds = OsmAndFormatter.getFormattedDistance(deviatePath, app);
|
||||
int ls = ds.lastIndexOf(' ');
|
||||
if (ls == -1) {
|
||||
setText(ds, null);
|
||||
setTextNoUpdateVisibility(ds, null);
|
||||
} else {
|
||||
setText(ds.substring(0, ls), ds.substring(ls + 1));
|
||||
setTextNoUpdateVisibility(ds.substring(0, ls), ds.substring(ls + 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,12 +177,14 @@ public class NextTurnInfoWidget extends TextInfoWidget {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public void setTurnType(TurnType turnType) {
|
||||
public boolean setTurnType(TurnType turnType) {
|
||||
this.turnType = turnType;
|
||||
if(turnType != null) {
|
||||
if(turnType != this.turnType) {
|
||||
TurnPathHelper.calcTurnPath(pathForTurn, turnType, null);
|
||||
onBoundsChange(getBounds());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,21 +36,26 @@ public class TextInfoWidget {
|
|||
}
|
||||
|
||||
public void setImageDrawable(Drawable imageDrawable) {
|
||||
setImageDrawable(imageDrawable, false);
|
||||
}
|
||||
|
||||
|
||||
public void setImageDrawable(Drawable imageDrawable, boolean gone) {
|
||||
if(imageDrawable != null) {
|
||||
imageView.setImageDrawable(imageDrawable);
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
imageView.setVisibility(View.INVISIBLE);
|
||||
imageView.setVisibility(gone ? View.GONE : View.INVISIBLE);
|
||||
}
|
||||
imageView.invalidate();
|
||||
}
|
||||
|
||||
public void setTopImageDrawable(Drawable imageDrawable) {
|
||||
public void setTopImageDrawable(Drawable imageDrawable, boolean gone) {
|
||||
if(imageDrawable != null) {
|
||||
topImageView.setImageDrawable(imageDrawable);
|
||||
topImageView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
topImageView.setVisibility(View.INVISIBLE);
|
||||
topImageView.setVisibility(gone ? View.GONE : View.INVISIBLE);
|
||||
}
|
||||
topImageView.invalidate();
|
||||
}
|
||||
|
@ -80,6 +85,11 @@ public class TextInfoWidget {
|
|||
}
|
||||
|
||||
public void setText(String text, String subtext) {
|
||||
setTextNoUpdateVisibility(text, subtext);
|
||||
updateVisibility(text != null);
|
||||
}
|
||||
|
||||
protected void setTextNoUpdateVisibility(String text, String subtext) {
|
||||
if (text != null) {
|
||||
if (subtext != null) {
|
||||
setContentDescription(text + " " + subtext); //$NON-NLS-1$
|
||||
|
@ -102,7 +112,6 @@ public class TextInfoWidget {
|
|||
} else {
|
||||
smallTextView.setText(subtext);
|
||||
}
|
||||
updateVisibility(text != null);
|
||||
}
|
||||
|
||||
protected boolean updateVisibility(boolean visible) {
|
||||
|
|
Loading…
Reference in a new issue