Fix small issues
This commit is contained in:
parent
6e66378cd4
commit
13081b36e7
5 changed files with 39 additions and 28 deletions
Binary file not shown.
Before Width: | Height: | Size: 3.9 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.1 KiB |
|
@ -111,10 +111,10 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
expand = R.drawable.box_expand_t;
|
||||
}
|
||||
rightStack.setTopDrawable(view.getResources().getDrawable(boxTopR));
|
||||
rightStack.setStackDrawable(view.getResources().getDrawable(boxTop));
|
||||
rightStack.setStackDrawable(boxTop);
|
||||
|
||||
leftStack.setTopDrawable(view.getResources().getDrawable(boxTopL));
|
||||
leftStack.setStackDrawable(view.getResources().getDrawable(boxTop));
|
||||
leftStack.setStackDrawable(boxTop);
|
||||
|
||||
leftStack.setExpandImageDrawable(view.getResources().getDrawable(expand));
|
||||
rightStack.setExpandImageDrawable(view.getResources().getDrawable(expand));
|
||||
|
@ -216,15 +216,14 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
|
||||
private TextInfoControl createSpeedControl(){
|
||||
final TextInfoControl speedControl = new TextInfoControl(map, 3, paintText, paintSubText) {
|
||||
// TODO
|
||||
private float cachedSpeed = 5;
|
||||
private float cachedSpeed = 0;
|
||||
|
||||
@Override
|
||||
public boolean updateInfo() {
|
||||
// draw speed
|
||||
// if (map.getLastKnownLocation() != null && map.getLastKnownLocation().hasSpeed()) {
|
||||
// if (Math.abs(map.getLastKnownLocation().getSpeed() - cachedSpeed) > .3f) {
|
||||
// cachedSpeed = map.getLastKnownLocation().getSpeed();
|
||||
if (map.getLastKnownLocation() != null && map.getLastKnownLocation().hasSpeed()) {
|
||||
if (Math.abs(map.getLastKnownLocation().getSpeed() - cachedSpeed) > .3f) {
|
||||
cachedSpeed = map.getLastKnownLocation().getSpeed();
|
||||
String ds = OsmAndFormatter.getFormattedSpeed(cachedSpeed, map);
|
||||
int ls = ds.lastIndexOf(' ');
|
||||
if (ls == -1) {
|
||||
|
@ -233,13 +232,13 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
setText(ds.substring(0, ls), ds.substring(ls + 1));
|
||||
}
|
||||
return true;
|
||||
// }
|
||||
// } else if (cachedSpeed != 0) {
|
||||
// cachedSpeed = 0;
|
||||
// setText(null, null);
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
}
|
||||
} else if (cachedSpeed != 0) {
|
||||
cachedSpeed = 0;
|
||||
setText(null, null);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
speedControl.setText(null, null);
|
||||
|
@ -288,20 +287,20 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
|
||||
@Override
|
||||
public boolean updateInfo() {
|
||||
int time = 1500;
|
||||
// TODO
|
||||
// if (routeLayer != null && routeLayer.getHelper().isRouterEnabled()) {
|
||||
// boolean followingMode = routeLayer.getHelper().isFollowingMode();
|
||||
// time = routeLayer.getHelper().getLeftTime();
|
||||
int time = 0;
|
||||
if (routeLayer != null && routeLayer.getHelper().isRouterEnabled()) {
|
||||
boolean followingMode = routeLayer.getHelper().isFollowingMode();
|
||||
time = routeLayer.getHelper().getLeftTime();
|
||||
if (time != 0) {
|
||||
if (/*followingMode && */showArrivalTime) {
|
||||
if (followingMode && showArrivalTime) {
|
||||
long toFindTime = time * 1000 + System.currentTimeMillis();
|
||||
if (Math.abs(toFindTime - cachedLeftTime) > 30000) {
|
||||
cachedLeftTime = toFindTime;
|
||||
if (DateFormat.is24HourFormat(map)) {
|
||||
setText(DateFormat.format("kk:mm", toFindTime).toString(), null); //$NON-NLS-1$
|
||||
} else {
|
||||
setText(DateFormat.format("k:mm aa", toFindTime).toString(), null); //$NON-NLS-1$
|
||||
setText(DateFormat.format("k:mm", toFindTime).toString(),
|
||||
DateFormat.format("aa", toFindTime).toString()); //$NON-NLS-1$
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -315,7 +314,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
if (time == 0 && cachedLeftTime != 0) {
|
||||
cachedLeftTime = 0;
|
||||
setText(null, null);
|
||||
|
|
|
@ -23,7 +23,8 @@ public class MapStackControl extends ViewGroup {
|
|||
private boolean isCollapsible = true;
|
||||
|
||||
private Drawable topDrawable;
|
||||
private Drawable stackDrawable;
|
||||
List<Drawable> cacheStackDrawables = new ArrayList<Drawable>();
|
||||
private int stackDrawable;
|
||||
|
||||
public MapStackControl(Context context) {
|
||||
super(context);
|
||||
|
@ -65,8 +66,9 @@ public class MapStackControl extends ViewGroup {
|
|||
this.topDrawable = topDrawable;
|
||||
}
|
||||
|
||||
public void setStackDrawable(Drawable stackDrawable) {
|
||||
public void setStackDrawable(int stackDrawable) {
|
||||
this.stackDrawable = stackDrawable;
|
||||
this.cacheStackDrawables.clear();
|
||||
}
|
||||
|
||||
public void updateInfo() {
|
||||
|
@ -112,6 +114,14 @@ public class MapStackControl extends ViewGroup {
|
|||
public boolean isCollapsible() {
|
||||
return isCollapsible;
|
||||
}
|
||||
|
||||
|
||||
private Drawable getStackDrawable(int i){
|
||||
while(i >= cacheStackDrawables.size()) {
|
||||
cacheStackDrawables.add(getResources().getDrawable(stackDrawable).mutate());
|
||||
}
|
||||
return cacheStackDrawables.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
|
@ -119,10 +129,11 @@ public class MapStackControl extends ViewGroup {
|
|||
int h = 0;
|
||||
int prevBot = 0;
|
||||
boolean first = true;
|
||||
int cacheStack = 0;
|
||||
if (stackViews != null) {
|
||||
for (MapInfoControl c : stackViews) {
|
||||
if (c.getVisibility() != View.GONE) {
|
||||
c.setBackgroundDrawable(first ? topDrawable.mutate() : stackDrawable.mutate());
|
||||
c.setBackgroundDrawable(first ? topDrawable : getStackDrawable(cacheStack++ ));
|
||||
first = false;
|
||||
c.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
|
||||
w = Math.max(w, c.getMeasuredWidth());
|
||||
|
@ -139,7 +150,7 @@ public class MapStackControl extends ViewGroup {
|
|||
if (c.getVisibility() != View.GONE) {
|
||||
isCollapsible = true;
|
||||
if (!isCollapsed) {
|
||||
c.setBackgroundDrawable(first ? topDrawable.mutate() : stackDrawable.mutate());
|
||||
c.setBackgroundDrawable(first ? topDrawable : getStackDrawable(cacheStack++ ));
|
||||
first = false;
|
||||
c.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
|
||||
w = Math.max(w, c.getMeasuredWidth());
|
||||
|
|
|
@ -77,10 +77,11 @@ public class NextTurnInfoControl extends MapInfoControl {
|
|||
st = textPaint.measureText(subtext);
|
||||
}
|
||||
float mt = textPaint.measureText(text);
|
||||
float startX = Math.max((getWWidth() - st - mt) / 2, 2 * scaleCoefficient);
|
||||
drawShadowText(canvas, text,
|
||||
(getWWidth() - st - mt) / 2 - scaleCoefficient, getWHeight() - 5 * scaleCoefficient, textPaint);
|
||||
startX, getWHeight() - 5 * scaleCoefficient, textPaint);
|
||||
if (subtext != null) {
|
||||
drawShadowText(canvas, subtext, (getWWidth() - st - mt) / 2 + 2 * scaleCoefficient + mt, getWHeight() - 5
|
||||
drawShadowText(canvas, subtext, startX + 2 * scaleCoefficient + mt, getWHeight() - 5
|
||||
* scaleCoefficient, subtextPaint);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue