Fix small issues
This commit is contained in:
parent
e826fd0303
commit
0ca6655231
5 changed files with 166 additions and 34 deletions
|
@ -13,14 +13,7 @@
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:textSize="18sp"/>
|
android:textSize="22sp"/>
|
||||||
|
|
||||||
<ImageButton android:id="@+id/all_points"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:visibility="gone"
|
|
||||||
style="@style/Widget.Sherlock.ActionButton"
|
|
||||||
android:src="@drawable/ic_action_core_overflow_dark"/>
|
|
||||||
|
|
||||||
|
<include layout="@layout/check_item_rel"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -9,6 +9,10 @@
|
||||||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||||
-->
|
-->
|
||||||
|
<string name="flat_list_waypoitns">All</string>
|
||||||
|
<string name="waypoints">Waypoints</string>
|
||||||
|
<string name="targets">Targets</string>
|
||||||
|
<string name="way_alarms">Obstacles</string>
|
||||||
<string name="speak_favorites">Announce Favorites</string>
|
<string name="speak_favorites">Announce Favorites</string>
|
||||||
<string name="speak_poi">Announce POI</string>
|
<string name="speak_poi">Announce POI</string>
|
||||||
<string name="download_additional_maps">Download missing maps %1$s (%2$d MB)?</string>
|
<string name="download_additional_maps">Download missing maps %1$s (%2$d MB)?</string>
|
||||||
|
|
|
@ -835,8 +835,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
@Override
|
@Override
|
||||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||||
if (getMyApplication().getWaypointHelper().isRouteCalculated()) {
|
if (getMyApplication().getWaypointHelper().isRouteCalculated()) {
|
||||||
WaypointDialogHelper.showWaypointsDialog(getMyApplication(), mapActivity,
|
WaypointDialogHelper.showWaypointsDialog(getMyApplication(), mapActivity);
|
||||||
getMyApplication().getWaypointHelper().getAllPoints());
|
|
||||||
} else {
|
} else {
|
||||||
openIntermediatePointsDialog();
|
openIntermediatePointsDialog();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,12 +23,14 @@ import android.content.DialogInterface.OnClickListener;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
import android.util.TypedValue;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
@ -46,6 +48,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
public final static boolean OVERLAP_LAYOUT = true; // only true is supported
|
public final static boolean OVERLAP_LAYOUT = true; // only true is supported
|
||||||
private View closePointDialog;
|
private View closePointDialog;
|
||||||
private List<LocationPointWrapper> many = new ArrayList<WaypointHelper.LocationPointWrapper>();
|
private List<LocationPointWrapper> many = new ArrayList<WaypointHelper.LocationPointWrapper>();
|
||||||
|
private static AlertDialog dialog;
|
||||||
|
|
||||||
|
|
||||||
public WaypointDialogHelper(MapActivity mapActivity) {
|
public WaypointDialogHelper(MapActivity mapActivity) {
|
||||||
|
@ -92,7 +95,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
all.setOnClickListener(new View.OnClickListener() {
|
all.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
showWaypointsDialog(app, mapActivity, waypointHelper.getAllPoints());
|
showWaypointsDialog(app, mapActivity);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -130,7 +133,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
int dist = wh.getRouteDistance(ps);
|
int dist = wh.getRouteDistance(ps);
|
||||||
String dd = OsmAndFormatter.getFormattedDistance(dist, app);
|
String dd = OsmAndFormatter.getFormattedDistance(dist, app);
|
||||||
if (ps.deviationDistance > 0) {
|
if (ps.deviationDistance > 0) {
|
||||||
dd += "\n " + OsmAndFormatter.getFormattedDistance(ps.deviationDistance, app);
|
dd += "\n+" + OsmAndFormatter.getFormattedDistance(ps.deviationDistance, app);
|
||||||
}
|
}
|
||||||
textDist.setText(dd);
|
textDist.setText(dd);
|
||||||
text.setText(point.getName(app));
|
text.setText(point.getName(app));
|
||||||
|
@ -187,12 +190,126 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
}.execute(reachedView);
|
}.execute(reachedView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void enableType(OsmandApplication app, MapActivity ctx, int type) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
}
|
||||||
|
|
||||||
public static void showWaypointsDialog(final OsmandApplication app, final MapActivity ctx, final List<LocationPointWrapper> visibleLocationPoints){
|
public static void showWaypointsDialog(final OsmandApplication app,
|
||||||
|
final MapActivity ctx) {
|
||||||
|
final WaypointHelper waypointHelper = app.getWaypointHelper();
|
||||||
|
final List<Object> points = new ArrayList<Object>();
|
||||||
|
for (int i = 0; i < WaypointHelper.MAX; i++) {
|
||||||
|
List<LocationPointWrapper> tp = waypointHelper.getWaypoints(i);
|
||||||
|
points.add(new Integer(i));
|
||||||
|
if (tp != null && tp.size() > 0) {
|
||||||
|
points.addAll(tp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final List<LocationPointWrapper> deletedPoints = new ArrayList<WaypointHelper.LocationPointWrapper>();
|
||||||
|
final ArrayAdapter<Object> listAdapter = new ArrayAdapter<Object>(ctx,
|
||||||
|
R.layout.waypoint_reached, R.id.title, points) {
|
||||||
|
@Override
|
||||||
|
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||||
|
// User super class to create the View
|
||||||
|
View v = convertView;
|
||||||
|
boolean labelView = (getItem(position) instanceof Integer);
|
||||||
|
boolean viewText = v != null && v.findViewById(R.id.info_close) == null;
|
||||||
|
if (v == null || viewText != labelView) {
|
||||||
|
v = ctx.getLayoutInflater().inflate(labelView ? R.layout.waypoint_header : R.layout.waypoint_reached, null);
|
||||||
|
}
|
||||||
|
if (labelView) {
|
||||||
|
final int type = (Integer) getItem(position);
|
||||||
|
CompoundButton btn = (CompoundButton) v.findViewById(R.id.check_item);
|
||||||
|
btn.setVisibility(type == WaypointHelper.TARGETS ? View.GONE : View.VISIBLE);
|
||||||
|
btn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
enableType(app, ctx, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
TextView tv = (TextView) v.findViewById(R.id.header_text);
|
||||||
|
tv.setText(getHeader(ctx, waypointHelper, type));
|
||||||
|
} else {
|
||||||
|
updatePointInfoView(app, ctx, v, (LocationPointWrapper) getItem(position));
|
||||||
|
View remove = v.findViewById(R.id.info_close);
|
||||||
|
((ImageButton) remove).setImageDrawable(ctx.getResources().getDrawable(
|
||||||
|
app.getSettings().isLightContent() ? R.drawable.ic_action_gremove_light
|
||||||
|
: R.drawable.ic_action_gremove_dark));
|
||||||
|
remove.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
LocationPointWrapper point = (LocationPointWrapper) points.get(position);
|
||||||
|
remove(point);
|
||||||
|
deletedPoints.add(point);
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ListView listView = new ListView(ctx);
|
||||||
|
listView.setAdapter(listAdapter);
|
||||||
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
|
if(listAdapter.getItem(i) instanceof LocationPointWrapper) {
|
||||||
|
LocationPointWrapper ps = (LocationPointWrapper) listAdapter.getItem(i);
|
||||||
|
showOnMap(app, ctx, ps.getPoint());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
|
||||||
|
builder.setView(listView);
|
||||||
|
builder.setNeutralButton(R.string.flat_list_waypoitns, new OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
showWaypointsDialogFlat(app, ctx, waypointHelper.getAllPoints());
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setPositiveButton(R.string.default_buttons_ok, new OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
waypointHelper.removeVisibleLocationPoint(deletedPoints);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setNegativeButton(ctx.getString(R.string.default_buttons_cancel), null);
|
||||||
|
dialog = builder.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static String getHeader(final MapActivity ctx, final WaypointHelper waypointHelper, int i) {
|
||||||
|
String str = ctx.getString(R.string.waypoints);
|
||||||
|
switch (i) {
|
||||||
|
case WaypointHelper.TARGETS:
|
||||||
|
str = ctx.getString(R.string.targets);
|
||||||
|
break;
|
||||||
|
case WaypointHelper.ALARMS:
|
||||||
|
str = ctx.getString(R.string.way_alarms);
|
||||||
|
break;
|
||||||
|
case WaypointHelper.FAVORITES:
|
||||||
|
str = ctx.getString(R.string.my_favorites);
|
||||||
|
break;
|
||||||
|
case WaypointHelper.WAYPOINTS:
|
||||||
|
str = ctx.getString(R.string.waypoints);
|
||||||
|
break;
|
||||||
|
case WaypointHelper.POI:
|
||||||
|
str = waypointHelper.getPoiFilter() == null ? ctx.getString(R.string.poi) : waypointHelper
|
||||||
|
.getPoiFilter().getName();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void showWaypointsDialogFlat(final OsmandApplication app, final MapActivity ctx, final List<LocationPointWrapper> points){
|
||||||
final WaypointHelper waypointHelper = app.getWaypointHelper();
|
final WaypointHelper waypointHelper = app.getWaypointHelper();
|
||||||
final List<LocationPointWrapper> deletedPoints = new ArrayList<WaypointHelper.LocationPointWrapper>();
|
final List<LocationPointWrapper> deletedPoints = new ArrayList<WaypointHelper.LocationPointWrapper>();
|
||||||
final ArrayAdapter<LocationPointWrapper> listAdapter = new ArrayAdapter<LocationPointWrapper>(ctx, R.layout.waypoint_reached, R.id.title,
|
final ArrayAdapter<LocationPointWrapper> listAdapter = new ArrayAdapter<LocationPointWrapper>(ctx, R.layout.waypoint_reached, R.id.title,
|
||||||
visibleLocationPoints) {
|
points) {
|
||||||
@Override
|
@Override
|
||||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||||
// User super class to create the View
|
// User super class to create the View
|
||||||
|
@ -208,7 +325,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
remove.setOnClickListener(new View.OnClickListener() {
|
remove.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
LocationPointWrapper point = visibleLocationPoints.get(position);
|
LocationPointWrapper point = points.get(position);
|
||||||
remove(point);
|
remove(point);
|
||||||
deletedPoints.add(point);
|
deletedPoints.add(point);
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
|
@ -238,26 +355,35 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(ctx.getString(R.string.default_buttons_cancel), null);
|
builder.setNegativeButton(ctx.getString(R.string.default_buttons_cancel), null);
|
||||||
builder.show();
|
dialog = builder.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void showOnMap(OsmandApplication app, MapActivity ctx, LocationPoint locationPoint) {
|
private static void showOnMap(OsmandApplication app, MapActivity ctx, LocationPoint locationPoint) {
|
||||||
AnimateDraggingMapThread thread = ctx.getMapView().getAnimatedDraggingThread();
|
AnimateDraggingMapThread thread = ctx.getMapView().getAnimatedDraggingThread();
|
||||||
int fZoom = ctx.getMapView().getZoom() < 15 ? 15 : ctx.getMapView().getZoom();
|
int fZoom = ctx.getMapView().getZoom() < 15 ? 15 : ctx.getMapView().getZoom();
|
||||||
if (thread.isAnimating()) {
|
boolean di = dialog != null && dialog.isShowing();
|
||||||
|
if (thread.isAnimating() && !di) {
|
||||||
ctx.getMapView().setIntZoom(fZoom);
|
ctx.getMapView().setIntZoom(fZoom);
|
||||||
ctx.getMapView().setLatLon(locationPoint.getLatitude(), locationPoint.getLongitude());
|
ctx.getMapView().setLatLon(locationPoint.getLatitude(), locationPoint.getLongitude());
|
||||||
} else if (MapUtils.getDistance(ctx.getMapView().getLatitude(), ctx.getMapView().getLongitude(),
|
} else {
|
||||||
locationPoint.getLatitude(), locationPoint.getLongitude()) < 10) {
|
final double dist = MapUtils.getDistance(ctx.getMapView().getLatitude(), ctx.getMapView().getLongitude(),
|
||||||
|
locationPoint.getLatitude(), locationPoint.getLongitude());
|
||||||
|
double t = 10;
|
||||||
|
if (dist < t || di) {
|
||||||
ctx.getMapLayers().getContextMenuLayer().setSelectedObject(locationPoint);
|
ctx.getMapLayers().getContextMenuLayer().setSelectedObject(locationPoint);
|
||||||
ctx.getMapLayers()
|
ctx.getMapLayers()
|
||||||
.getContextMenuLayer()
|
.getContextMenuLayer()
|
||||||
.setLocation(new LatLon(locationPoint.getLatitude(), locationPoint.getLongitude()),
|
.setLocation(new LatLon(locationPoint.getLatitude(), locationPoint.getLongitude()),
|
||||||
locationPoint.getName(ctx));
|
locationPoint.getName(ctx));
|
||||||
|
}
|
||||||
} else {
|
if (di || dist >= t) {
|
||||||
thread.startMoving(locationPoint.getLatitude(), locationPoint.getLongitude(), fZoom, true);
|
thread.startMoving(locationPoint.getLatitude(), locationPoint.getLongitude(), fZoom, true);
|
||||||
}
|
}
|
||||||
|
if(di) {
|
||||||
|
dialog.dismiss();
|
||||||
|
dialog = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ import android.graphics.drawable.Drawable;
|
||||||
public class WaypointHelper {
|
public class WaypointHelper {
|
||||||
private static final int NOT_ANNOUNCED = 0;
|
private static final int NOT_ANNOUNCED = 0;
|
||||||
private static final int ANNOUNCED_ONCE = 1;
|
private static final int ANNOUNCED_ONCE = 1;
|
||||||
|
private static final int ANNOUNCED_DONE = 2;
|
||||||
|
|
||||||
private int searchDeviationRadius = 500;
|
private int searchDeviationRadius = 500;
|
||||||
private static final int LONG_ANNOUNCE_RADIUS = 500;
|
private static final int LONG_ANNOUNCE_RADIUS = 500;
|
||||||
|
@ -49,10 +50,11 @@ public class WaypointHelper {
|
||||||
OsmandApplication app;
|
OsmandApplication app;
|
||||||
// every time we modify this collection, we change the reference (copy on write list)
|
// every time we modify this collection, we change the reference (copy on write list)
|
||||||
public static final int TARGETS = 0;
|
public static final int TARGETS = 0;
|
||||||
public static final int ALARMS = 1;
|
public static final int WAYPOINTS = 1;
|
||||||
public static final int WAYPOINTS = 2;
|
public static final int POI = 2;
|
||||||
public static final int POI = 3;
|
public static final int FAVORITES = 3;
|
||||||
public static final int FAVORITES = 4;
|
public static final int ALARMS = 4;
|
||||||
|
public static final int MAX = 4;
|
||||||
|
|
||||||
private List<List<LocationPointWrapper>> locationPoints = new ArrayList<List<LocationPointWrapper>>();
|
private List<List<LocationPointWrapper>> locationPoints = new ArrayList<List<LocationPointWrapper>>();
|
||||||
private ConcurrentHashMap<LocationPoint, Integer> locationPointsStates = new ConcurrentHashMap<LocationPoint, Integer>();
|
private ConcurrentHashMap<LocationPoint, Integer> locationPointsStates = new ConcurrentHashMap<LocationPoint, Integer>();
|
||||||
|
@ -69,6 +71,9 @@ public class WaypointHelper {
|
||||||
|
|
||||||
|
|
||||||
public List<LocationPointWrapper> getWaypoints(int type) {
|
public List<LocationPointWrapper> getWaypoints(int type) {
|
||||||
|
if(type == TARGETS) {
|
||||||
|
return getTargets(new ArrayList<WaypointHelper.LocationPointWrapper>());
|
||||||
|
}
|
||||||
if(type >= locationPoints.size()) {
|
if(type >= locationPoints.size()) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
@ -260,11 +265,10 @@ public class WaypointHelper {
|
||||||
double d1 = MapUtils.getDistance(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude(),
|
double d1 = MapUtils.getDistance(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude(),
|
||||||
point.getLatitude(), point.getLongitude());
|
point.getLatitude(), point.getLongitude());
|
||||||
Integer state = locationPointsStates.get(point);
|
Integer state = locationPointsStates.get(point);
|
||||||
System.out.println("!!! " + d1 + " " + point.getName(app));
|
|
||||||
if (state != null && state.intValue() == ANNOUNCED_ONCE
|
if (state != null && state.intValue() == ANNOUNCED_ONCE
|
||||||
&& getVoiceRouter()
|
&& getVoiceRouter()
|
||||||
.isDistanceLess(lastKnownLocation.getSpeed(), d1, SHORT_ANNOUNCE_RADIUS)) {
|
.isDistanceLess(lastKnownLocation.getSpeed(), d1, SHORT_ANNOUNCE_RADIUS)) {
|
||||||
locationPointsStates.remove(point);
|
locationPointsStates.put(point, ANNOUNCED_DONE);
|
||||||
announcePoints.add(point);
|
announcePoints.add(point);
|
||||||
} else if ((state == null || state == NOT_ANNOUNCED)
|
} else if ((state == null || state == NOT_ANNOUNCED)
|
||||||
&& getVoiceRouter()
|
&& getVoiceRouter()
|
||||||
|
@ -326,6 +330,13 @@ public class WaypointHelper {
|
||||||
points.addAll(loc.subList(ps.get(i), loc.size()));
|
points.addAll(loc.subList(ps.get(i), loc.size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
getTargets(points);
|
||||||
|
sortList(points);
|
||||||
|
return points;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected List<LocationPointWrapper> getTargets(List<LocationPointWrapper> points) {
|
||||||
List<TargetPoint> wts = app.getTargetPointsHelper().getIntermediatePointsWithTarget();
|
List<TargetPoint> wts = app.getTargetPointsHelper().getIntermediatePointsWithTarget();
|
||||||
for (int k = 0; k < wts.size(); k++) {
|
for (int k = 0; k < wts.size(); k++) {
|
||||||
final int index = wts.size() - k - 1;
|
final int index = wts.size() - k - 1;
|
||||||
|
@ -338,7 +349,6 @@ public class WaypointHelper {
|
||||||
}
|
}
|
||||||
points.add(new LocationPointWrapper(route, TARGETS, tp, 0, routeIndex));
|
points.add(new LocationPointWrapper(route, TARGETS, tp, 0, routeIndex));
|
||||||
}
|
}
|
||||||
sortList(points);
|
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue