diff --git a/OsmAnd/res/layout/expandable_list_item_category.xml b/OsmAnd/res/layout/expandable_list_item_category.xml index 80d958f620..df656e0a8e 100644 --- a/OsmAnd/res/layout/expandable_list_item_category.xml +++ b/OsmAnd/res/layout/expandable_list_item_category.xml @@ -24,7 +24,7 @@ android:layout_marginTop="0dp" android:autoLink="web" android:gravity="center_vertical" - android:textSize="18sp"> + android:textSize="18sp"/> + android:paddingLeft="12dp"> + style="@style/ListText.Small"/> + style="@style/ListText.Small"/> + style="@style/ListText.Small"/> \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index 3968ca0eca..dd3977a80b 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -211,7 +211,7 @@ public class OsmandApplication extends Application { public void onTerminate() { super.onTerminate(); if (routingHelper != null) { - routingHelper.getVoiceRouter().onApplicationTerminate(this); + routingHelper.getVoiceRouter().onApplicationTerminate(); } } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 37cd8de3a9..c888428038 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -951,6 +951,7 @@ public class MapActivityActions implements DialogProvider { if(getMyApplication().getLocationProvider().getLocationSimulation().isRouteAnimating()) { getMyApplication().getLocationProvider().getLocationSimulation().startStopRouteAnimation(mapActivity); } + routingHelper.getVoiceRouter().interruptRouteCommands(); routingHelper.clearCurrentRoute(null, new ArrayList()); routingHelper.setRoutePlanningMode(false); settings.APPLICATION_MODE.set(settings.DEFAULT_APPLICATION_MODE.get()); diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashMapFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashMapFragment.java index 7df80f08f3..62065708cd 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashMapFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashMapFragment.java @@ -1,14 +1,18 @@ package net.osmand.plus.dashboard; +import android.content.Context; import android.graphics.Bitmap; +import android.view.*; import android.widget.ImageView; import net.osmand.data.LatLon; +import net.osmand.data.RotatedTileBox; import net.osmand.map.MapTileDownloader.DownloadRequest; import net.osmand.map.MapTileDownloader.IMapDownloaderCallback; import net.osmand.plus.R; import net.osmand.plus.activities.MainMenuActivity; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.FontCache; +import net.osmand.plus.render.MapRenderRepositories; import net.osmand.plus.render.MapVectorLayer; import net.osmand.plus.resources.ResourceManager; import net.osmand.plus.views.MapTextLayer; @@ -17,9 +21,6 @@ import net.osmand.plus.views.OsmandMapTileView; import android.graphics.Typeface; import android.os.Bundle; import android.support.annotation.Nullable; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; import android.widget.Button; import android.widget.ProgressBar; import android.widget.TextView; @@ -27,103 +28,122 @@ import android.widget.TextView; /** * Created by Denis on 24.11.2014. */ -public class DashMapFragment extends DashBaseFragment implements IMapDownloaderCallback { +public class DashMapFragment extends DashBaseFragment implements IMapDownloaderCallback { - public static final String TAG = "DASH_MAP_FRAGMENT"; + public static final String TAG = "DASH_MAP_FRAGMENT"; - @Override - public void onDestroy() { - super.onDestroy(); - getMyApplication().getResourceManager().getMapTileDownloader().removeDownloaderCallback(this); - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - getMyApplication().getResourceManager().getMapTileDownloader().addDownloaderCallback(this); - } + @Override + public void onDestroy() { + super.onDestroy(); + getMyApplication().getResourceManager().getMapTileDownloader().removeDownloaderCallback(this); + } - protected void startMapActivity() { - MapActivity.launchMapActivityMoveToTop(getActivity()); - } - - @Override - public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - View view = getActivity().getLayoutInflater().inflate(R.layout.dash_map_fragment, container, false); - Typeface typeface = FontCache.getRobotoMedium(getActivity()); - ((TextView) view.findViewById(R.id.map_text)).setTypeface(typeface); - ((Button) view.findViewById(R.id.show_map)).setTypeface(typeface); + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + getMyApplication().getResourceManager().getMapTileDownloader().addDownloaderCallback(this); + } - (view.findViewById(R.id.show_map)).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - startMapActivity(); - } + protected void startMapActivity() { + MapActivity.launchMapActivityMoveToTop(getActivity()); + } - - }); - view.findViewById(R.id.map_image).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - startMapActivity(); - } - }); - setMapImage(view); + @Override + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = getActivity().getLayoutInflater().inflate(R.layout.dash_map_fragment, container, false); + Typeface typeface = FontCache.getRobotoMedium(getActivity()); + ((TextView) view.findViewById(R.id.map_text)).setTypeface(typeface); + ((Button) view.findViewById(R.id.show_map)).setTypeface(typeface); - return view; - } - - private void setMapImage(View view) { - if (view == null) { - return; - } - Bitmap image = getMyApplication().getResourceManager().getRenderer().getBitmap(); - ImageView map = (ImageView) view.findViewById(R.id.map_image); - if (image != null){ - map.setImageBitmap(image); - } - } + (view.findViewById(R.id.show_map)).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + startMapActivity(); + } - @Override - public void onResume() { - super.onResume(); - setMapImage(getView()); + }); + view.findViewById(R.id.map_image).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startMapActivity(); + } + }); - } + return view; + } - @Override - public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - view.findViewById(R.id.map_image).setVisibility(View.GONE); - if(getMyApplication().isApplicationInitializing()) { - getMyApplication().checkApplicationIsBeingInitialized(getActivity(), (TextView) view.findViewById(R.id.ProgressMessage), - (ProgressBar) view.findViewById(R.id.ProgressBar), new Runnable() { - @Override - public void run() { - applicationInitialized(view); - } - }); - } else { - applicationInitialized(view); - } - } + private void setMapImage(View view) { + if (view == null) { + return; + } + Bitmap image = getMyApplication().getResourceManager().getRenderer().getBitmap(); + ImageView map = (ImageView) view.findViewById(R.id.map_image); + if (image != null) { + map.setImageBitmap(image); + } + } - private void applicationInitialized(View view) { - view.findViewById(R.id.loading).setVisibility(View.GONE); - MainMenuActivity dashboardActivity =((MainMenuActivity)getSherlockActivity()); - if (dashboardActivity != null){ - dashboardActivity.updateDownloads(); - view.findViewById(R.id.map_image).setVisibility(View.VISIBLE); - } - } - @Override - public void tileDownloaded(DownloadRequest request) { - if(request != null && !request.error && request.fileToSave != null){ - ResourceManager mgr = getMyApplication().getResourceManager(); - mgr.tileDownloaded(request); - setMapImage(getView()); - } - } + @Override + public void onResume() { + super.onResume(); + if (!getMyApplication().isApplicationInitializing()){ + updateMapImage(); + } + + } + + @Override + public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + view.findViewById(R.id.map_image).setVisibility(View.GONE); + if (getMyApplication().isApplicationInitializing()) { + getMyApplication().checkApplicationIsBeingInitialized(getActivity(), (TextView) view.findViewById(R.id.ProgressMessage), + (ProgressBar) view.findViewById(R.id.ProgressBar), new Runnable() { + @Override + public void run() { + applicationInitialized(view); + } + }); + } else { + applicationInitialized(view); + } + } + + private void applicationInitialized(View view) { + updateMapImage(); + view.findViewById(R.id.loading).setVisibility(View.GONE); + MainMenuActivity dashboardActivity = ((MainMenuActivity) getSherlockActivity()); + if (dashboardActivity != null) { + dashboardActivity.updateDownloads(); + view.findViewById(R.id.map_image).setVisibility(View.VISIBLE); + } + } + + @Override + public void tileDownloaded(DownloadRequest request) { + if (request != null && !request.error && request.fileToSave != null) { + ResourceManager mgr = getMyApplication().getResourceManager(); + mgr.tileDownloaded(request); + } + setMapImage(getView()); + } + + private void updateMapImage() { + MapRenderRepositories repositories = getMyApplication().getResourceManager().getRenderer(); + LatLon lm = getMyApplication().getSettings().getLastKnownMapLocation(); + int zm = getMyApplication().getSettings().getLastKnownMapZoom(); + + WindowManager wm = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE); + Display display = wm.getDefaultDisplay(); + int height = (int) getActivity().getResources().getDimension(R.dimen.dashMapHeight); + int width = display.getWidth(); + + RotatedTileBox rotatedTileBox = new RotatedTileBox.RotatedTileBoxBuilder(). + setZoom(zm).setLocation(lm.getLatitude(), lm.getLongitude()). + setPixelDimensions(width, height).build(); + repositories.loadMap(rotatedTileBox, + getMyApplication().getResourceManager().getMapTileDownloader().getDownloaderCallbacks()); + } } diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java index fcb028834e..2906606c8d 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java @@ -484,7 +484,17 @@ public class WaypointDialogHelper implements OsmAndLocationListener { if (type == WaypointHelper.POI && btn.isChecked()){ running[0] = position; thisAdapter.notifyDataSetInvalidated(); - selectPoi(running, thisAdapter, type, true, ctx); + MapActivity map = (MapActivity) ctx; + final PoiFilter[] selected = new PoiFilter[1]; + AlertDialog dlg = map.getMapLayers().selectPOIFilterLayer(map.getMapView(), selected); + dlg.setOnDismissListener(new OnDismissListener() { + @Override + public void onDismiss(DialogInterface dialog) { + if (selected != null) { + enableType(running, thisAdapter, type, true); + } + } + }); } } }); @@ -493,7 +503,8 @@ public class WaypointDialogHelper implements OsmAndLocationListener { private void selectPoi(final int[] running, final ArrayAdapter listAdapter, final int type, final boolean enable, Activity ctx) { - if (ctx instanceof MapActivity && !PoiFilter.CUSTOM_FILTER_ID.equals(app.getSettings().getPoiFilterForMap())) { + if (ctx instanceof MapActivity && + !PoiFilter.CUSTOM_FILTER_ID.equals(app.getSettings().getPoiFilterForMap())) { MapActivity map = (MapActivity) ctx; final PoiFilter[] selected = new PoiFilter[1]; AlertDialog dlg = map.getMapLayers().selectPOIFilterLayer(map.getMapView(), selected); diff --git a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java index 5f71dc142b..31daa2b40f 100644 --- a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java +++ b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java @@ -793,7 +793,7 @@ public class VoiceRouter { // } //} - public void onApplicationTerminate(Context ctx) { + public void onApplicationTerminate() { if (player != null) { player.clear(); }