From c9c2a265254a35684bba55de0e43fa7ddb9ba691 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sat, 25 Apr 2015 16:49:43 +0200 Subject: [PATCH 1/5] Update exit --- OsmAnd/AndroidManifest.xml | 1 + .../net/osmand/plus/OsmandApplication.java | 18 +++++++---- .../osmand/plus/activities/ExitActivity.java | 30 +++++++++++++++++++ .../plus/views/PointNavigationLayer.java | 2 +- 4 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/activities/ExitActivity.java diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml index 5fc4817c71..a18b62017b 100644 --- a/OsmAnd/AndroidManifest.xml +++ b/OsmAnd/AndroidManifest.xml @@ -58,6 +58,7 @@ + diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index ac227bc380..4700b49e28 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -18,6 +18,7 @@ import net.osmand.osm.MapPoiTypes; import net.osmand.plus.AppInitializer.AppInitializeListener; import net.osmand.plus.access.AccessibilityMode; import net.osmand.plus.activities.DayNightHelper; +import net.osmand.plus.activities.ExitActivity; import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.activities.SettingsActivity; import net.osmand.plus.api.SQLiteAPI; @@ -395,27 +396,34 @@ public class OsmandApplication extends Application { bld.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - closeApplicationAnyway(activity, true); + closeApplicationAnywayImpl(activity, true); } }); bld.setNegativeButton(R.string.shared_string_no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - closeApplicationAnyway(activity, false); + closeApplicationAnywayImpl(activity, false); } }); bld.show(); } else { - closeApplicationAnyway(activity, true); + closeApplicationAnywayImpl(activity, true); } } - + private void closeApplicationAnyway(final Activity activity, boolean disableService) { + activity.finish(); + Intent newIntent = new Intent(activity, ExitActivity.class); + newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); + newIntent.putExtra(ExitActivity.DISABLE_SERVICE, disableService); + startActivity(newIntent); + } + + public void closeApplicationAnywayImpl(final Activity activity, boolean disableService) { if (appInitializer.isAppInitializing()) { resourceManager.close(); } activity.finish(); - if (getNavigationService() == null) { fullExit(); } else if (disableService) { diff --git a/OsmAnd/src/net/osmand/plus/activities/ExitActivity.java b/OsmAnd/src/net/osmand/plus/activities/ExitActivity.java new file mode 100644 index 0000000000..67beabb1ad --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/activities/ExitActivity.java @@ -0,0 +1,30 @@ +package net.osmand.plus.activities; + +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import android.app.Activity; +import android.os.Bundle; + + +public class ExitActivity extends Activity { + public final static String DISABLE_SERVICE = "DISABLE_SERVICE"; + private boolean dis; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.help_activity); + dis = getIntent().getBooleanExtra(DISABLE_SERVICE, true); + + } + + @Override + protected void onResume() { + super.onResume(); + getMyApplication().closeApplicationAnywayImpl(this, dis); + } + + private OsmandApplication getMyApplication() { + return (OsmandApplication) getApplication(); + } +} diff --git a/OsmAnd/src/net/osmand/plus/views/PointNavigationLayer.java b/OsmAnd/src/net/osmand/plus/views/PointNavigationLayer.java index 905016717d..87fb234be5 100644 --- a/OsmAnd/src/net/osmand/plus/views/PointNavigationLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/PointNavigationLayer.java @@ -92,7 +92,7 @@ public class PointNavigationLayer extends OsmandMapLayer implements IContextMenu int locationY = tb.getPixYFromLatNoRot(ip.getLatitude()); canvas.rotate(-tb.getRotate(), locationX, locationY); canvas.drawBitmap(intermediatePoint, locationX - marginX, locationY - marginY, bitmapPaint); - marginX = intermediatePoint.getWidth() / 5; + marginX = intermediatePoint.getWidth() / 4; canvas.drawText(index + "", locationX + marginX, locationY - 3 * marginY / 5, textPaint); canvas.rotate(tb.getRotate(), locationX, locationY); } From 92ec8bbb4aa7bc9ae7a6ae8b930d42e7c8c89e4b Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sat, 25 Apr 2015 16:49:46 +0200 Subject: [PATCH 2/5] Update exit --- OsmAnd/src/net/osmand/plus/views/PointNavigationLayer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/views/PointNavigationLayer.java b/OsmAnd/src/net/osmand/plus/views/PointNavigationLayer.java index 87fb234be5..844a575e14 100644 --- a/OsmAnd/src/net/osmand/plus/views/PointNavigationLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/PointNavigationLayer.java @@ -92,7 +92,7 @@ public class PointNavigationLayer extends OsmandMapLayer implements IContextMenu int locationY = tb.getPixYFromLatNoRot(ip.getLatitude()); canvas.rotate(-tb.getRotate(), locationX, locationY); canvas.drawBitmap(intermediatePoint, locationX - marginX, locationY - marginY, bitmapPaint); - marginX = intermediatePoint.getWidth() / 4; + marginX = intermediatePoint.getWidth() / 3; canvas.drawText(index + "", locationX + marginX, locationY - 3 * marginY / 5, textPaint); canvas.rotate(tb.getRotate(), locationX, locationY); } From f92438d334400ad363ee921ba508ee22d39cb439 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sat, 25 Apr 2015 18:00:27 +0200 Subject: [PATCH 3/5] Fix using rtept as intermediates recalculation --- OsmAnd/src/net/osmand/plus/GPXUtilities.java | 1 - .../DistanceCalculatorPlugin.java | 1 + .../net/osmand/plus/osmedit/OsmEditsLayer.java | 4 ++-- .../net/osmand/plus/routing/RouteProvider.java | 17 ++++++++++++++--- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/GPXUtilities.java b/OsmAnd/src/net/osmand/plus/GPXUtilities.java index 1371cf726f..4be3a3bb81 100644 --- a/OsmAnd/src/net/osmand/plus/GPXUtilities.java +++ b/OsmAnd/src/net/osmand/plus/GPXUtilities.java @@ -31,7 +31,6 @@ import net.osmand.Location; import net.osmand.PlatformUtil; import net.osmand.data.LocationPoint; import net.osmand.data.PointDescription; -import net.osmand.plus.GPXUtilities.GPXFile; import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; diff --git a/OsmAnd/src/net/osmand/plus/distancecalculator/DistanceCalculatorPlugin.java b/OsmAnd/src/net/osmand/plus/distancecalculator/DistanceCalculatorPlugin.java index 22b0fb8ce7..fee3cb62d3 100644 --- a/OsmAnd/src/net/osmand/plus/distancecalculator/DistanceCalculatorPlugin.java +++ b/OsmAnd/src/net/osmand/plus/distancecalculator/DistanceCalculatorPlugin.java @@ -175,6 +175,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin { measurementPoints.add(new LinkedList()); } else if (id == R.string.distance_measurement_clear_route) { distanceMeasurementMode = 0; + originalGPX = null; measurementPoints.clear(); calculateDistance(); } else if (id == R.string.shared_string_save_as_gpx) { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java index f4cb6cf6f5..cb1fcb649b 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java @@ -52,8 +52,8 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC pointAtUI.setColor(0xa0FF3344); pointAtUI.setStyle(Paint.Style.FILL); - poi = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_pin_origin); - bug = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_pin_destination); + poi = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_pin_poi); + bug = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_pin_poi); paintIcon = new Paint(); diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java index 33b06336aa..1a51cd706f 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java @@ -354,8 +354,7 @@ public class RouteProvider { // get the closest point to start and to end GPXRouteParams gpxParams = routeParams.gpxRoute; if(routeParams.gpxRoute.useIntermediatePointsRTE){ - final List intermediates = gpxParams.points; - return calculateOsmAndRouteWithIntermediatePoints(routeParams, intermediates); + return calculateOsmAndRouteWithIntermediatePoints(routeParams, gpxParams.points); } List gpxRoute ; int[] startI = new int[]{0}; @@ -399,7 +398,19 @@ public class RouteProvider { rp.onlyStartPointChanged = routeParams.onlyStartPointChanged; rp.previousToRecalculate = routeParams.previousToRecalculate; rp.intermediates = new ArrayList(); - for(Location w : intermediates) { + int closest = 0; + double maxDist = Double.POSITIVE_INFINITY; + for (int i = 0; i < intermediates.size(); i++) { + Location loc = intermediates.get(i); + double dist = MapUtils.getDistance(loc.getLatitude(), loc.getLongitude(), rp.start.getLatitude(), + rp.start.getLongitude()); + if (dist <= maxDist) { + closest = i; + maxDist = dist; + } + } + for(int i = closest; i< intermediates.size() ; i++ ){ + Location w = intermediates.get(i); rp.intermediates.add(new LatLon(w.getLatitude(), w.getLongitude())); } return findVectorMapsRoute(rp, false); From e9530dab4afae027f0ed107a090e88cf184d8926 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 27 Apr 2015 16:56:28 +0200 Subject: [PATCH 4/5] Update external storage API for >= 4.4 devices --- OsmAnd/res/layout-land/map_hud_top.xml | 7 +- OsmAnd/res/layout/dash_search_fragment.xml | 18 +- .../res/layout/dash_storage_type_fragment.xml | 119 +++++ OsmAnd/res/layout/map_hud_top.xml | 5 + OsmAnd/res/values/strings.xml | 9 + OsmAnd/res/values/styles.xml | 2 +- .../osmand/plus/OsmAndAppCustomization.java | 5 - .../net/osmand/plus/OsmandApplication.java | 12 +- .../src/net/osmand/plus/OsmandSettings.java | 191 ++++--- .../activities/SettingsGeneralActivity.java | 127 +---- .../activities/ShowRouteInfoActivity.java | 5 +- .../base/SuggestExternalDirectoryDialog.java | 108 ---- .../dashboard/DashChooseAppDirFragment.java | 471 ++++++++++++++++++ .../osmand/plus/dashboard/DashboardOnMap.java | 2 + .../osmand/plus/dialogs/ConfigureMapMenu.java | 10 + .../plus/download/BaseDownloadActivity.java | 70 +-- .../plus/sherpafy/SherpafyCustomization.java | 14 +- .../views/mapwidgets/NextTurnInfoWidget.java | 2 +- 18 files changed, 749 insertions(+), 428 deletions(-) create mode 100644 OsmAnd/res/layout/dash_storage_type_fragment.xml delete mode 100644 OsmAnd/src/net/osmand/plus/base/SuggestExternalDirectoryDialog.java create mode 100644 OsmAnd/src/net/osmand/plus/dashboard/DashChooseAppDirFragment.java diff --git a/OsmAnd/res/layout-land/map_hud_top.xml b/OsmAnd/res/layout-land/map_hud_top.xml index d424d73611..bbd7ccd761 100644 --- a/OsmAnd/res/layout-land/map_hud_top.xml +++ b/OsmAnd/res/layout-land/map_hud_top.xml @@ -51,7 +51,10 @@ + android:layout_marginLeft="5dp" + android:layout_marginRight="5dp" + android:layout_gravity="center" + > @@ -72,6 +76,7 @@ android:layout_gravity="center" android:ellipsize="end" android:maxLines="1" + android:singleLine="true" android:text="Long Street Name" android:textColor="@color/color_black" android:textSize="@dimen/map_widget_text_size" > diff --git a/OsmAnd/res/layout/dash_search_fragment.xml b/OsmAnd/res/layout/dash_search_fragment.xml index 32cad12bc2..5b58df247b 100644 --- a/OsmAnd/res/layout/dash_search_fragment.xml +++ b/OsmAnd/res/layout/dash_search_fragment.xml @@ -40,30 +40,36 @@ android:layout_height="@dimen/dashSearchBtnHeight" android:orientation="horizontal" > -