commit
4e62896c0a
5 changed files with 72 additions and 56 deletions
|
@ -11,6 +11,7 @@ import net.osmand.binary.RouteDataBundle;
|
||||||
import net.osmand.binary.StringBundle;
|
import net.osmand.binary.StringBundle;
|
||||||
import net.osmand.binary.StringBundleWriter;
|
import net.osmand.binary.StringBundleWriter;
|
||||||
import net.osmand.binary.StringBundleXmlWriter;
|
import net.osmand.binary.StringBundleXmlWriter;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import org.xmlpull.v1.XmlSerializer;
|
import org.xmlpull.v1.XmlSerializer;
|
||||||
|
|
||||||
|
@ -38,20 +39,22 @@ public class RouteExporter {
|
||||||
RouteDataResources resources = new RouteDataResources(locations);
|
RouteDataResources resources = new RouteDataResources(locations);
|
||||||
final RouteDataBundle bundle = new RouteDataBundle(resources);
|
final RouteDataBundle bundle = new RouteDataBundle(resources);
|
||||||
|
|
||||||
for (RouteSegmentResult sr : route) {
|
if (!Algorithms.isEmpty(route)) {
|
||||||
sr.collectTypes(resources);
|
for (RouteSegmentResult sr : route) {
|
||||||
}
|
sr.collectTypes(resources);
|
||||||
for (RouteSegmentResult sr : route) {
|
}
|
||||||
sr.collectNames(resources);
|
for (RouteSegmentResult sr : route) {
|
||||||
}
|
sr.collectNames(resources);
|
||||||
|
}
|
||||||
|
|
||||||
List<StringBundle> routeItems = new ArrayList<>();
|
List<StringBundle> routeItems = new ArrayList<>();
|
||||||
for (RouteSegmentResult sr : route) {
|
for (RouteSegmentResult sr : route) {
|
||||||
RouteDataBundle itemBundle = new RouteDataBundle(resources);
|
RouteDataBundle itemBundle = new RouteDataBundle(resources);
|
||||||
sr.writeToBundle(itemBundle);
|
sr.writeToBundle(itemBundle);
|
||||||
routeItems.add(itemBundle);
|
routeItems.add(itemBundle);
|
||||||
|
}
|
||||||
|
bundle.putBundleList("route", "segment", routeItems);
|
||||||
}
|
}
|
||||||
bundle.putBundleList("route", "segment", routeItems);
|
|
||||||
|
|
||||||
List<StringBundle> typeList = new ArrayList<>();
|
List<StringBundle> typeList = new ArrayList<>();
|
||||||
Map<RouteTypeRule, Integer> rules = resources.getRules();
|
Map<RouteTypeRule, Integer> rules = resources.getRules();
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
android:id="@+id/ZoomToDownload"
|
android:id="@+id/ZoomToDownload"
|
||||||
style="@style/Widget.Styled.Slider"
|
style="@style/Widget.Styled.Slider"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
android:stepSize="1"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="@dimen/content_padding"
|
android:layout_marginLeft="@dimen/content_padding"
|
||||||
android:layout_marginRight="@dimen/content_padding"
|
android:layout_marginRight="@dimen/content_padding"
|
||||||
|
|
|
@ -51,11 +51,12 @@ public class DownloadTilesDialog {
|
||||||
|
|
||||||
public void openDialog(){
|
public void openDialog(){
|
||||||
BaseMapLayer mainLayer = mapView.getMainLayer();
|
BaseMapLayer mainLayer = mapView.getMainLayer();
|
||||||
if(!(mainLayer instanceof MapTileLayer) || !((MapTileLayer) mainLayer).isVisible()){
|
if (!(mainLayer instanceof MapTileLayer) || !((MapTileLayer) mainLayer).isVisible()) {
|
||||||
Toast.makeText(ctx, R.string.maps_could_not_be_downloaded, Toast.LENGTH_SHORT).show();
|
Toast.makeText(ctx, R.string.maps_could_not_be_downloaded, Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
final ITileSource mapSource = ((MapTileLayer) mainLayer).getMap();
|
final ITileSource mapSource = ((MapTileLayer) mainLayer).getMap();
|
||||||
if(mapSource == null || !mapSource.couldBeDownloadedFromInternet()){
|
if (mapSource == null || !mapSource.couldBeDownloadedFromInternet()) {
|
||||||
Toast.makeText(ctx, R.string.maps_could_not_be_downloaded, Toast.LENGTH_SHORT).show();
|
Toast.makeText(ctx, R.string.maps_could_not_be_downloaded, Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -66,29 +67,28 @@ public class DownloadTilesDialog {
|
||||||
|
|
||||||
// calculate pixel rectangle
|
// calculate pixel rectangle
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
|
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
|
||||||
LayoutInflater inflater = (LayoutInflater)ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
View view = inflater.inflate(R.layout.download_tiles, null);
|
View view = inflater.inflate(R.layout.download_tiles, null);
|
||||||
|
|
||||||
|
((TextView) view.findViewById(R.id.MinZoom)).setText(String.valueOf(zoom));
|
||||||
|
((TextView) view.findViewById(R.id.MaxZoom)).setText(String.valueOf(max));
|
||||||
((TextView)view.findViewById(R.id.MinZoom)).setText(zoom+""); //$NON-NLS-1$
|
|
||||||
((TextView)view.findViewById(R.id.MaxZoom)).setText(max+""); //$NON-NLS-1$
|
|
||||||
final Slider slider = (Slider) view.findViewById(R.id.ZoomToDownload);
|
final Slider slider = (Slider) view.findViewById(R.id.ZoomToDownload);
|
||||||
slider.setValueTo(max - zoom);
|
|
||||||
int progress = (max - zoom) / 2;
|
|
||||||
slider.setValue(progress);
|
|
||||||
|
|
||||||
final TextView downloadText = ((TextView) view.findViewById(R.id.DownloadDescription));
|
final TextView downloadText = ((TextView) view.findViewById(R.id.DownloadDescription));
|
||||||
final String template = ctx.getString(R.string.tiles_to_download_estimated_size);
|
final String template = ctx.getString(R.string.tiles_to_download_estimated_size);
|
||||||
|
|
||||||
|
|
||||||
updateLabel(zoom, rb.getLatLonBounds(), downloadText, template, (int) slider.getValue());
|
updateLabel(zoom, rb.getLatLonBounds(), downloadText, template, (int) slider.getValue());
|
||||||
slider.addOnChangeListener(new Slider.OnChangeListener() {
|
if (max > zoom) {
|
||||||
@Override
|
slider.setValueTo(max - zoom);
|
||||||
public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) {
|
int progress = (max - zoom) / 2;
|
||||||
updateLabel(zoom, rb.getLatLonBounds(), downloadText, template, (int) value);
|
slider.setValue(progress);
|
||||||
}
|
slider.addOnChangeListener(new Slider.OnChangeListener() {
|
||||||
});
|
@Override
|
||||||
|
public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) {
|
||||||
|
updateLabel(zoom, rb.getLatLonBounds(), downloadText, template, (int) value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
builder.setPositiveButton(R.string.shared_string_download, new DialogInterface.OnClickListener(){
|
builder.setPositiveButton(R.string.shared_string_download, new DialogInterface.OnClickListener(){
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -12,6 +12,7 @@ import com.squareup.picasso.Picasso;
|
||||||
|
|
||||||
import net.osmand.PicassoUtils;
|
import net.osmand.PicassoUtils;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -56,19 +57,24 @@ public class ImagesPagerAdapter extends PagerAdapter {
|
||||||
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
|
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||||
|
|
||||||
final String imageUrl = imageUrls.get(position);
|
final String imageUrl = imageUrls.get(position);
|
||||||
Picasso.get().load(imageUrl).into(imageView, new Callback() {
|
if (!Algorithms.isEmpty(imageUrl)) {
|
||||||
@Override
|
Picasso.get().load(imageUrl).into(imageView, new Callback() {
|
||||||
public void onSuccess() {
|
@Override
|
||||||
imageView.setVisibility(View.VISIBLE);
|
public void onSuccess() {
|
||||||
picassoUtils.setResultLoaded(imageUrl, true);
|
imageView.setVisibility(View.VISIBLE);
|
||||||
}
|
picassoUtils.setResultLoaded(imageUrl, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Exception e) {
|
||||||
|
imageView.setVisibility(View.INVISIBLE);
|
||||||
|
picassoUtils.setResultLoaded(imageUrl, false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
imageView.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(Exception e) {
|
|
||||||
imageView.setVisibility(View.INVISIBLE);
|
|
||||||
picassoUtils.setResultLoaded(imageUrl, false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return imageView;
|
return imageView;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,7 +4,6 @@ import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -167,8 +166,9 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
||||||
@Override
|
@Override
|
||||||
public void setCategory(String name, int color) {
|
public void setCategory(String name, int color) {
|
||||||
FavouritesDbHelper helper = getHelper();
|
FavouritesDbHelper helper = getHelper();
|
||||||
if (helper != null) {
|
Context ctx = getContext();
|
||||||
FavoriteGroup group = helper.getGroup(FavoriteGroup.convertDisplayNameToGroupIdName(requireContext(), name));
|
if (helper != null && ctx != null) {
|
||||||
|
FavoriteGroup group = helper.getGroup(FavoriteGroup.convertDisplayNameToGroupIdName(ctx, name));
|
||||||
this.group = group;
|
this.group = group;
|
||||||
super.setCategory(name, group != null ? group.getColor() : 0);
|
super.setCategory(name, group != null ? group.getColor() : 0);
|
||||||
}
|
}
|
||||||
|
@ -176,10 +176,13 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getLastUsedGroup() {
|
protected String getLastUsedGroup() {
|
||||||
OsmandApplication app = requireMyApplication();
|
String lastCategory = "";
|
||||||
String lastCategory = app.getSettings().LAST_FAV_CATEGORY_ENTERED.get();
|
OsmandApplication app = getMyApplication();
|
||||||
if (!Algorithms.isEmpty(lastCategory) && !app.getFavorites().groupExists(lastCategory)) {
|
if (app != null) {
|
||||||
lastCategory = "";
|
lastCategory = app.getSettings().LAST_FAV_CATEGORY_ENTERED.get();
|
||||||
|
if (!Algorithms.isEmpty(lastCategory) && !app.getFavorites().groupExists(lastCategory)) {
|
||||||
|
lastCategory = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return lastCategory;
|
return lastCategory;
|
||||||
}
|
}
|
||||||
|
@ -325,11 +328,14 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
||||||
private void doEditFavorite(FavouritePoint favorite, String name, String category, String description,
|
private void doEditFavorite(FavouritePoint favorite, String name, String category, String description,
|
||||||
@ColorInt int color, BackgroundType backgroundType, @DrawableRes int iconId,
|
@ColorInt int color, BackgroundType backgroundType, @DrawableRes int iconId,
|
||||||
FavouritesDbHelper helper) {
|
FavouritesDbHelper helper) {
|
||||||
requireMyApplication().getSettings().LAST_FAV_CATEGORY_ENTERED.set(category);
|
OsmandApplication app = getMyApplication();
|
||||||
favorite.setColor(color);
|
if (app != null) {
|
||||||
favorite.setBackgroundType(backgroundType);
|
app.getSettings().LAST_FAV_CATEGORY_ENTERED.set(category);
|
||||||
favorite.setIconId(iconId);
|
favorite.setColor(color);
|
||||||
helper.editFavouriteName(favorite, name, category, description);
|
favorite.setBackgroundType(backgroundType);
|
||||||
|
favorite.setIconId(iconId);
|
||||||
|
helper.editFavouriteName(favorite, name, category, description);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doAddFavorite(String name, String category, String description, @ColorInt int color,
|
private void doAddFavorite(String name, String category, String description, @ColorInt int color,
|
||||||
|
|
Loading…
Reference in a new issue