updated functionality of delivered package
This commit is contained in:
parent
730309fda0
commit
5d63ff5d33
5 changed files with 52 additions and 13 deletions
|
@ -3,20 +3,28 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/color_black">
|
||||
<TextView android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:text="@string/package_delivered"/>
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
<LinearLayout android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
android:orientation="horizontal"
|
||||
android:layout_gravity="center_horizontal">
|
||||
<Button android:id="@+id/delivered_yes"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:text="@string/default_buttons_yes"/>
|
||||
<Button android:id="@+id/delivered_no"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:text="@string/default_buttons_no"/>
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -711,4 +711,8 @@ public class MapActivity extends AccessibleActivity {
|
|||
public void refreshMap() {
|
||||
getMapView().refreshMap();
|
||||
}
|
||||
|
||||
public View getLayout() {
|
||||
return getWindow().getDecorView().findViewById(android.R.id.content);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,7 +192,11 @@ public class RoutePointsActivity extends OsmandListActivity {
|
|||
|
||||
if (point.isVisited()) {
|
||||
holder.image.setImageResource(R.drawable.ic_action_ok_dark);
|
||||
if (point.isDelivered()){
|
||||
holder.name.setTextColor(getResources().getColor(R.color.osmbug_closed));
|
||||
} else {
|
||||
holder.name.setTextColor(getResources().getColor(R.color.color_invalid));
|
||||
}
|
||||
holder.dateOrDistance.setTextColor(getResources().getColor(R.color.color_unknown));
|
||||
holder.dateOrDistance.setText(point.getTime());
|
||||
holder.dateOrDistance.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
|
||||
|
@ -273,7 +277,13 @@ public class RoutePointsActivity extends OsmandListActivity {
|
|||
finish();
|
||||
} else if (menuItem.getItemId() == AS_VISITED_ID) {
|
||||
// inverts selection state of item
|
||||
if (!rp.isVisited()){
|
||||
rp.setDelivered(true);
|
||||
} else if (rp.isDelivered()){
|
||||
rp.setDelivered(false);
|
||||
}
|
||||
plugin.getCurrentRoute().markPoint(rp, !rp.isVisited());
|
||||
|
||||
saveGPXAsync();
|
||||
prepareView();
|
||||
}
|
||||
|
|
|
@ -78,17 +78,17 @@ public class RoutePointsLayer extends OsmandMapLayer implements ContextMenuLaye
|
|||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (itemId == R.string.mark_as_not_visited){
|
||||
plugin.getCurrentRoute().markPoint(point,false);
|
||||
plugin.saveGPXAsync();
|
||||
plugin.getCurrentRoute().saveGPXAsync();
|
||||
} else if (itemId == R.string.mark_as_visited) {
|
||||
plugin.getCurrentRoute().markPoint(point, true);
|
||||
plugin.saveGPXAsync();
|
||||
plugin.getCurrentRoute().saveGPXAsync();
|
||||
} else if (itemId == R.string.mark_as_current){
|
||||
plugin.getCurrentRoute().markPoint(point, false);
|
||||
plugin.getCurrentRoute().navigateToPoint(point);
|
||||
plugin.saveGPXAsync();
|
||||
plugin.getCurrentRoute().saveGPXAsync();
|
||||
} else if (itemId == R.string.navigate_to_next){
|
||||
plugin.getCurrentRoute().navigateToNextPoint();
|
||||
plugin.saveGPXAsync();
|
||||
plugin.getCurrentRoute().saveGPXAsync();
|
||||
}
|
||||
map.refreshMap();
|
||||
}
|
||||
|
|
|
@ -3,9 +3,12 @@ package net.osmand.plus.routepointsnavigation;
|
|||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.content.Context;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
|
@ -45,6 +48,7 @@ public class RoutePointsPlugin extends OsmandPlugin {
|
|||
MapActivity map;
|
||||
|
||||
private View deliveredView;
|
||||
private MapActivity mapActivity;
|
||||
|
||||
private RoutePointsLayer routePointsLayer;
|
||||
|
||||
|
@ -76,6 +80,8 @@ public class RoutePointsPlugin extends OsmandPlugin {
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
currentRoute.navigateToNextPoint(true);
|
||||
FrameLayout layout = (FrameLayout) mapActivity.getLayout();
|
||||
layout.removeView(deliveredView);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -85,6 +91,8 @@ public class RoutePointsPlugin extends OsmandPlugin {
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
currentRoute.navigateToNextPoint(false);
|
||||
FrameLayout layout = (FrameLayout) mapActivity.getLayout();
|
||||
layout.removeView(deliveredView);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -93,8 +101,10 @@ public class RoutePointsPlugin extends OsmandPlugin {
|
|||
@Override
|
||||
public boolean destinationReached() {
|
||||
if (currentRoute != null) {
|
||||
//TODO: add delivered view to map
|
||||
|
||||
FrameLayout layout = (FrameLayout) mapActivity.getLayout();
|
||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
|
||||
params.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
|
||||
layout.addView(deliveredView, params);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -133,6 +143,7 @@ public class RoutePointsPlugin extends OsmandPlugin {
|
|||
@Override
|
||||
public void registerLayers(MapActivity activity) {
|
||||
super.registerLayers(activity);
|
||||
mapActivity = activity;
|
||||
prepareDeliveredView();
|
||||
map = activity;
|
||||
if (routePointsLayer != null) {
|
||||
|
@ -197,6 +208,7 @@ public class RoutePointsPlugin extends OsmandPlugin {
|
|||
int gpxOrder;
|
||||
long visitedTime; // 0 not visited
|
||||
WptPt wpt;
|
||||
boolean delivered;
|
||||
|
||||
public String getName() {
|
||||
return wpt.name;
|
||||
|
@ -214,6 +226,8 @@ public class RoutePointsPlugin extends OsmandPlugin {
|
|||
return visitedTime != 0;
|
||||
}
|
||||
|
||||
public boolean isDelivered() { return delivered;}
|
||||
|
||||
public int getGpxOrder() {
|
||||
return gpxOrder;
|
||||
}
|
||||
|
@ -241,8 +255,9 @@ public class RoutePointsPlugin extends OsmandPlugin {
|
|||
return new LatLon(wpt.lat, wpt.lon);
|
||||
}
|
||||
|
||||
public void setDelivered(boolean delivered) {
|
||||
wpt.getExtensionsToWrite().put(DELIVERED_KEY, String.valueOf(delivered));
|
||||
public void setDelivered(boolean d) {
|
||||
wpt.getExtensionsToWrite().put(DELIVERED_KEY, String.valueOf(d));
|
||||
this.delivered = d;
|
||||
}
|
||||
|
||||
public void setVisitedTime(long currentTimeMillis) {
|
||||
|
@ -256,7 +271,6 @@ public class RoutePointsPlugin extends OsmandPlugin {
|
|||
private GPXUtilities.GPXFile gpx;
|
||||
private List<RoutePoint> currentPoints = new ArrayList<RoutePointsPlugin.RoutePoint>();
|
||||
|
||||
|
||||
public SelectedRouteGpxFile(GPXUtilities.GPXFile gpx) {
|
||||
this.gpx = gpx;
|
||||
parseGPXFile(gpx);
|
||||
|
@ -367,6 +381,9 @@ public class RoutePointsPlugin extends OsmandPlugin {
|
|||
RoutePoint rtp = new RoutePoint();
|
||||
rtp.gpxOrder = i;
|
||||
rtp.wpt = wptPt;
|
||||
String delivered = wptPt.getExtensionsToRead().get(DELIVERED_KEY);
|
||||
rtp.delivered = Boolean.parseBoolean(delivered);
|
||||
|
||||
String time = wptPt.getExtensionsToRead().get(VISITED_KEY);
|
||||
try {
|
||||
rtp.visitedTime = Long.parseLong(time);
|
||||
|
|
Loading…
Reference in a new issue