Merge branch 'master' of https://github.com/Bars107/osmand
This commit is contained in:
commit
9a450fece9
7 changed files with 131 additions and 99 deletions
|
@ -24,7 +24,7 @@
|
||||||
android:layout_marginTop="0dp"
|
android:layout_marginTop="0dp"
|
||||||
android:autoLink="web"
|
android:autoLink="web"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:textSize="18sp"></TextView>
|
android:textSize="18sp"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
android:paddingTop="4dp"
|
android:paddingTop="4dp"
|
||||||
android:paddingBottom="4dp"
|
android:paddingBottom="4dp"
|
||||||
android:paddingRight="8dp"
|
android:paddingRight="8dp"
|
||||||
android:paddingLeft="8dp">
|
android:paddingLeft="12dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
style="@style/ListText.Small"></TextView>
|
style="@style/ListText.Small"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/local_index_size"
|
android:id="@+id/local_index_size"
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
android:gravity="right"
|
android:gravity="right"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
style="@style/ListText.Small"></TextView>
|
style="@style/ListText.Small"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -47,6 +47,6 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:maxLines="25"
|
android:maxLines="25"
|
||||||
style="@style/ListText.Small"></TextView>
|
style="@style/ListText.Small"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -211,7 +211,7 @@ public class OsmandApplication extends Application {
|
||||||
public void onTerminate() {
|
public void onTerminate() {
|
||||||
super.onTerminate();
|
super.onTerminate();
|
||||||
if (routingHelper != null) {
|
if (routingHelper != null) {
|
||||||
routingHelper.getVoiceRouter().onApplicationTerminate(this);
|
routingHelper.getVoiceRouter().onApplicationTerminate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -951,6 +951,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
if(getMyApplication().getLocationProvider().getLocationSimulation().isRouteAnimating()) {
|
if(getMyApplication().getLocationProvider().getLocationSimulation().isRouteAnimating()) {
|
||||||
getMyApplication().getLocationProvider().getLocationSimulation().startStopRouteAnimation(mapActivity);
|
getMyApplication().getLocationProvider().getLocationSimulation().startStopRouteAnimation(mapActivity);
|
||||||
}
|
}
|
||||||
|
routingHelper.getVoiceRouter().interruptRouteCommands();
|
||||||
routingHelper.clearCurrentRoute(null, new ArrayList<LatLon>());
|
routingHelper.clearCurrentRoute(null, new ArrayList<LatLon>());
|
||||||
routingHelper.setRoutePlanningMode(false);
|
routingHelper.setRoutePlanningMode(false);
|
||||||
settings.APPLICATION_MODE.set(settings.DEFAULT_APPLICATION_MODE.get());
|
settings.APPLICATION_MODE.set(settings.DEFAULT_APPLICATION_MODE.get());
|
||||||
|
|
|
@ -1,14 +1,18 @@
|
||||||
package net.osmand.plus.dashboard;
|
package net.osmand.plus.dashboard;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.view.*;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.map.MapTileDownloader.DownloadRequest;
|
import net.osmand.map.MapTileDownloader.DownloadRequest;
|
||||||
import net.osmand.map.MapTileDownloader.IMapDownloaderCallback;
|
import net.osmand.map.MapTileDownloader.IMapDownloaderCallback;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MainMenuActivity;
|
import net.osmand.plus.activities.MainMenuActivity;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.helpers.FontCache;
|
import net.osmand.plus.helpers.FontCache;
|
||||||
|
import net.osmand.plus.render.MapRenderRepositories;
|
||||||
import net.osmand.plus.render.MapVectorLayer;
|
import net.osmand.plus.render.MapVectorLayer;
|
||||||
import net.osmand.plus.resources.ResourceManager;
|
import net.osmand.plus.resources.ResourceManager;
|
||||||
import net.osmand.plus.views.MapTextLayer;
|
import net.osmand.plus.views.MapTextLayer;
|
||||||
|
@ -17,9 +21,6 @@ import net.osmand.plus.views.OsmandMapTileView;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -27,103 +28,122 @@ import android.widget.TextView;
|
||||||
/**
|
/**
|
||||||
* Created by Denis on 24.11.2014.
|
* 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
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
getMyApplication().getResourceManager().getMapTileDownloader().removeDownloaderCallback(this);
|
getMyApplication().getResourceManager().getMapTileDownloader().removeDownloaderCallback(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
getMyApplication().getResourceManager().getMapTileDownloader().addDownloaderCallback(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void startMapActivity() {
|
@Override
|
||||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
}
|
super.onCreate(savedInstanceState);
|
||||||
|
getMyApplication().getResourceManager().getMapTileDownloader().addDownloaderCallback(this);
|
||||||
@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);
|
|
||||||
|
|
||||||
(view.findViewById(R.id.show_map)).setOnClickListener(new View.OnClickListener() {
|
protected void startMapActivity() {
|
||||||
@Override
|
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||||
public void onClick(View view) {
|
}
|
||||||
startMapActivity();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Override
|
||||||
});
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
view.findViewById(R.id.map_image).setOnClickListener(new View.OnClickListener() {
|
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_map_fragment, container, false);
|
||||||
@Override
|
Typeface typeface = FontCache.getRobotoMedium(getActivity());
|
||||||
public void onClick(View v) {
|
((TextView) view.findViewById(R.id.map_text)).setTypeface(typeface);
|
||||||
startMapActivity();
|
((Button) view.findViewById(R.id.show_map)).setTypeface(typeface);
|
||||||
}
|
|
||||||
});
|
|
||||||
setMapImage(view);
|
|
||||||
|
|
||||||
return view;
|
(view.findViewById(R.id.show_map)).setOnClickListener(new View.OnClickListener() {
|
||||||
}
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
private void setMapImage(View view) {
|
startMapActivity();
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
});
|
||||||
public void onResume() {
|
view.findViewById(R.id.map_image).setOnClickListener(new View.OnClickListener() {
|
||||||
super.onResume();
|
@Override
|
||||||
setMapImage(getView());
|
public void onClick(View v) {
|
||||||
|
startMapActivity();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
private void setMapImage(View view) {
|
||||||
public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) {
|
if (view == null) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
return;
|
||||||
view.findViewById(R.id.map_image).setVisibility(View.GONE);
|
}
|
||||||
if(getMyApplication().isApplicationInitializing()) {
|
Bitmap image = getMyApplication().getResourceManager().getRenderer().getBitmap();
|
||||||
getMyApplication().checkApplicationIsBeingInitialized(getActivity(), (TextView) view.findViewById(R.id.ProgressMessage),
|
ImageView map = (ImageView) view.findViewById(R.id.map_image);
|
||||||
(ProgressBar) view.findViewById(R.id.ProgressBar), new Runnable() {
|
if (image != null) {
|
||||||
@Override
|
map.setImageBitmap(image);
|
||||||
public void run() {
|
}
|
||||||
applicationInitialized(view);
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
applicationInitialized(view);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
@Override
|
||||||
public void tileDownloaded(DownloadRequest request) {
|
public void onResume() {
|
||||||
if(request != null && !request.error && request.fileToSave != null){
|
super.onResume();
|
||||||
ResourceManager mgr = getMyApplication().getResourceManager();
|
if (!getMyApplication().isApplicationInitializing()){
|
||||||
mgr.tileDownloaded(request);
|
updateMapImage();
|
||||||
setMapImage(getView());
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -484,7 +484,17 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
if (type == WaypointHelper.POI && btn.isChecked()){
|
if (type == WaypointHelper.POI && btn.isChecked()){
|
||||||
running[0] = position;
|
running[0] = position;
|
||||||
thisAdapter.notifyDataSetInvalidated();
|
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<Object> listAdapter, final int type,
|
private void selectPoi(final int[] running, final ArrayAdapter<Object> listAdapter, final int type,
|
||||||
final boolean enable, Activity ctx) {
|
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;
|
MapActivity map = (MapActivity) ctx;
|
||||||
final PoiFilter[] selected = new PoiFilter[1];
|
final PoiFilter[] selected = new PoiFilter[1];
|
||||||
AlertDialog dlg = map.getMapLayers().selectPOIFilterLayer(map.getMapView(), selected);
|
AlertDialog dlg = map.getMapLayers().selectPOIFilterLayer(map.getMapView(), selected);
|
||||||
|
|
|
@ -793,7 +793,7 @@ public class VoiceRouter {
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
public void onApplicationTerminate(Context ctx) {
|
public void onApplicationTerminate() {
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.clear();
|
player.clear();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue