From 47ab27b5d1fa32563cbcc62453b26e2d1cce2282 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Fri, 13 Mar 2015 21:47:19 +0100 Subject: [PATCH] Temp fix --- OsmAnd/res/values/strings.xml | 3 + OsmAnd/res/xml/navigation_settings.xml | 5 + .../osmand/plus/activities/MapActivity.java | 8 +- .../SettingsNavigationActivity.java | 20 ++- .../osmand/plus/views/MapControlsLayer.java | 115 ++++++++++++++---- .../views/controls/MapRouteInfoControl.java | 4 - 6 files changed, 123 insertions(+), 32 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 64f426f57f..0dd37df103 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,8 @@ 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 --> + Automatically start navigation after specified interval + Skip route planning Go Action create Action modify @@ -32,6 +34,7 @@ Cancel Dismiss Yes + Not use No On Off diff --git a/OsmAnd/res/xml/navigation_settings.xml b/OsmAnd/res/xml/navigation_settings.xml index 88ca9de0e7..e88306ffb9 100644 --- a/OsmAnd/res/xml/navigation_settings.xml +++ b/OsmAnd/res/xml/navigation_settings.xml @@ -32,5 +32,10 @@ android:key="wake_on_voice_int" android:title="@string/wake_on_voice" android:summary="@string/wake_on_voice_descr" /> + + diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 56896d6c13..22317d1e74 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -160,10 +160,10 @@ public class MapActivity extends AccessibleActivity { if (tn != null) { ((TextView) findViewById(R.id.ProgressMessage)).setText(tn); } - if(event == InitEvents.NATIVE_INITIALIZED) { - setupOpenGLView(); - openGlSetup = true; - } +// if(event == InitEvents.NATIVE_INITIALIZED) { +// setupOpenGLView(); +// openGlSetup = true; +// } if(event == InitEvents.MAPS_INITIALIZED) { mapView.refreshMap(true); } diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java index f0e5706f9e..af798a857c 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java @@ -5,9 +5,14 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import net.osmand.plus.*; +import net.osmand.plus.ApplicationMode; +import net.osmand.plus.DeviceAdminRecv; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings.AutoZoomMap; import net.osmand.plus.OsmandSettings.OsmandPreference; +import net.osmand.plus.R; +import net.osmand.plus.Version; import net.osmand.plus.routing.RouteProvider.RouteService; import net.osmand.router.GeneralRouter; import net.osmand.router.GeneralRouter.RoutingParameter; @@ -184,13 +189,22 @@ public class SettingsNavigationActivity extends SettingsBaseActivity { if (!mode.isDerivedRoutingFrom(ApplicationMode.CAR)) { category.removePreference(speedLimitExceed); } + + Integer[] delayIntervals = new Integer[] { -1, 3, 5, 7, 10, 15, 20 }; + String[] delayIntervalNames = new String[delayIntervals.length]; + for (int i = 0; i < delayIntervals.length; i++) { + if (i == 0) { + delayIntervalNames[i] = getString(R.string.shared_string_not_use); + } else { + delayIntervalNames[i] = delayIntervals[i] + " " + getString(R.string.int_seconds); + } + } + registerListPreference(settings.DELAY_TO_START_NAVIGATION, screen, delayIntervalNames, delayIntervals); profileDialog(); } - - private void prepareRoutingPrefs(PreferenceScreen screen) { PreferenceCategory cat = (PreferenceCategory) screen.findPreference("routing_preferences"); diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index 47fd4ef2a1..a1d6202396 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -19,6 +19,7 @@ import android.graphics.Color; import android.graphics.ColorFilter; import android.graphics.PointF; import android.graphics.drawable.Drawable; +import android.os.Handler; import android.view.Gravity; import android.view.MotionEvent; import android.view.View; @@ -66,10 +67,14 @@ public class MapControlsLayer extends OsmandMapLayer { private MapHudButton routeGoControl; private MapHudButton compassHud; private float cachedRotate = 0; + private static long startCounter; + private Runnable delayStart; + private Handler showUIHandler; public MapControlsLayer(MapActivity activity) { this.mapActivity = activity; settings = activity.getMyApplication().getSettings(); + } @Override @@ -84,6 +89,7 @@ public class MapControlsLayer extends OsmandMapLayer { // TODO // rulerControl = init(new RulerControl(zoomControls, mapActivity, showUIHandler, scaleCoefficient), parent, // rightGravity); + showUIHandler = new Handler(); initTransparencyBar(view, parent); initZooms(); initControls(); @@ -102,10 +108,41 @@ public class MapControlsLayer extends OsmandMapLayer { @Override public void draw(Canvas canvas) { canvas.save(); - canvas.rotate(cachedRotate, canvas.getWidth() / 2, canvas.getHeight() / 2); + canvas.rotate(cachedRotate, getIntrinsicWidth() / 2, getIntrinsicHeight() / 2); original.draw(canvas); canvas.restore(); - + } + + @Override + public int getMinimumHeight() { + return original.getMinimumHeight(); + } + + @Override + public int getMinimumWidth() { + return original.getMinimumWidth(); + } + + @Override + public int getIntrinsicHeight() { + return original.getIntrinsicHeight(); + } + + @Override + public int getIntrinsicWidth() { + return original.getIntrinsicWidth(); + } + + @Override + public void setChangingConfigurations(int configs) { + super.setChangingConfigurations(configs); + original.setChangingConfigurations(configs); + } + + @Override + public void setBounds(int left, int top, int right, int bottom) { + super.setBounds(left, top, right, bottom); + original.setBounds(left, top, right, bottom); } @Override @@ -207,7 +244,12 @@ public class MapControlsLayer extends OsmandMapLayer { @Override public void onClick(View v) { notifyClicked(); - startNavigation(); + RoutingHelper routingHelper = mapActivity.getMyApplication().getRoutingHelper(); + if(!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) { + mapActivity.getMapActions().enterRoutePlanningMode(null, null, false); + } else { + startNavigation(); + } } }); } @@ -318,9 +360,36 @@ public class MapControlsLayer extends OsmandMapLayer { } private void stopCounter() { - // TODO stop counter + startCounter = 0; } + + public void startCounter() { + OsmandSettings settings = mapActivity.getMyApplication().getSettings(); + int del = settings.DELAY_TO_START_NAVIGATION.get(); + if(del <= 0) { + return; + } + if (startCounter <= 0) { + startCounter = System.currentTimeMillis() + del * 1000; + delayStart = new Runnable() { + @Override + public void run() { + if (startCounter > 0) { + if (System.currentTimeMillis() > startCounter) { + startCounter = 0; + startNavigation(); + } else { + mapActivity.refreshMap(); + showUIHandler.postDelayed(delayStart, 1000); + } + } + } + }; + delayStart.run(); + } + + } protected void notifyClicked(MapControls m) { notifyClicked(); @@ -379,16 +448,30 @@ public class MapControlsLayer extends OsmandMapLayer { int vis = showRouteCalculationControls ? View.VISIBLE : View.GONE; if (showRouteCalculationControls) { ((TextView) routeGoControl.iv).setTextColor(textColor); + final String text ; + if (startCounter > 0) { + int get = (int) ((startCounter - System.currentTimeMillis()) / 1000l); + text = mapActivity.getString(R.string.shared_string_go) + " (" + get + ")"; + } else { + text = mapActivity.getString(R.string.shared_string_go) ; + } + ((TextView) routeGoControl.iv).setText(text); } if (routePreparationLayout.getVisibility() != vis) { routePreparationLayout.setVisibility(vis); mapRouteInfoControlDialog.setVisible(showRouteCalculationControls); + if(showRouteCalculationControls) { + if(!mapActivity.getRoutingHelper().isFollowingMode() && !mapActivity.getRoutingHelper().isPauseNavigation()) { + startCounter(); + } + } else { + stopCounter(); + } } float mapRotate = mapActivity.getMapView().getRotate(); if (mapRotate != cachedRotate) { - float c = cachedRotate - mapRotate; cachedRotate = mapRotate; // Aply animation to image view compassHud.iv.invalidate(); @@ -411,26 +494,16 @@ public class MapControlsLayer extends OsmandMapLayer { } public boolean onSingleTap(PointF point, RotatedTileBox tileBox) { - // TODO stop counter & show buttons - // for(MapControls m : allControls) { - // if(m.isVisible() && m.onSingleTap(point, tileBox)){ - // return true; - // } - // } + if(mapRouteInfoControlDialog.onSingleTap(point, tileBox)) { + return true; + } + stopCounter(); return false; } @Override public boolean onTouchEvent(MotionEvent event, RotatedTileBox tileBox) { - // TODO stop counter & show buttons - // if(!mapActivity.getRoutingHelper().isRoutePlanningMode() && mapActivity.getRoutingHelper().isFollowingMode()) - // { - // if(!settings.SHOW_ZOOM_BUTTONS_NAVIGATION.get()) { - // zoomControls.showWithDelay(getParent(), TIMEOUT_TO_SHOW_BUTTONS); - // mapMenuControls.showWithDelay(getParent(), TIMEOUT_TO_SHOW_BUTTONS); - // } - // mapRoutePlanControl.showWithDelay(getParent(), TIMEOUT_TO_SHOW_BUTTONS); - // } + stopCounter(); return false; } @@ -570,7 +643,7 @@ public class MapControlsLayer extends OsmandMapLayer { ((ImageView) iv).setImageDrawable(ctx.getIconsCache().getIcon(resId, nightMode ? resDark : resLight)); } } else if (iv instanceof TextView) { - ((TextView) iv).setCompoundDrawables( + ((TextView) iv).setCompoundDrawablesWithIntrinsicBounds( ctx.getIconsCache().getIcon(resId, nightMode ? resDark : resLight), null, null, null); } } diff --git a/OsmAnd/src/net/osmand/plus/views/controls/MapRouteInfoControl.java b/OsmAnd/src/net/osmand/plus/views/controls/MapRouteInfoControl.java index b8482ffd0a..3ba2641917 100644 --- a/OsmAnd/src/net/osmand/plus/views/controls/MapRouteInfoControl.java +++ b/OsmAnd/src/net/osmand/plus/views/controls/MapRouteInfoControl.java @@ -20,7 +20,6 @@ import net.osmand.plus.routing.RouteDirectionInfo; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener; import net.osmand.plus.views.ContextMenuLayer; -import net.osmand.plus.views.OsmandMapLayer.DrawSettings; import net.osmand.plus.views.OsmandMapTileView; import android.app.AlertDialog; import android.app.AlertDialog.Builder; @@ -28,9 +27,7 @@ import android.app.Dialog; import android.content.DialogInterface; import android.content.DialogInterface.OnDismissListener; import android.content.Intent; -import android.graphics.Canvas; import android.graphics.PointF; -import android.graphics.drawable.Drawable; import android.view.Gravity; import android.view.View; import android.view.Window; @@ -38,7 +35,6 @@ import android.view.WindowManager; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; -import android.widget.FrameLayout; import android.widget.ImageButton; import android.widget.ListView; import android.widget.Spinner;