Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2014-09-05 02:18:36 +02:00
commit 38619fa2af
16 changed files with 4100 additions and 85 deletions

1
.gitignore vendored
View file

@ -1,4 +1,5 @@
*.render.xml
*.template_render.xml
*.map_styles_presets.xml
routing*.xml
rendering_types.xml

View file

@ -1,61 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
<net.osmand.plus.views.OsmandMapTileView
android:id="@+id/MapView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/color_white">
android:layout_height="300dp"
android:contentDescription="@string/map_view"
android:visibility="gone" />
<ImageView
android:id="@+id/Icon"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"/>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
android:background="@color/color_white"
android:orientation="vertical" >
<TextView
android:id="@+id/HeaderText"
android:layout_width="0dp"
<ImageView
android:id="@+id/Icon"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_weight="1"
android:textSize="19sp" />
android:scaleType="centerCrop" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<TextView
android:id="@+id/HeaderText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:textSize="19sp" />
<TextView
android:id="@+id/AdditionalText"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="7dp"
android:textColor="@color/sherpafy_add_text"
android:textSize="16sp" />
</LinearLayout>
<TextView
android:id="@+id/AdditionalText"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="7dp"
android:id="@+id/Text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:singleLine="false"
android:textColor="@color/sherpafy_add_text"
android:textSize="16sp" />
</LinearLayout>
<TextView
android:id="@+id/Text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:singleLine="false"
android:textColor="@color/sherpafy_add_text"
android:textSize="16sp" />
<WebView android:id="@+id/Description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"/>
</LinearLayout>
</ScrollView>
<WebView
android:id="@+id/Description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp" />
</LinearLayout>
</ScrollView>
</LinearLayout>

View file

@ -22,7 +22,7 @@
android:layout_height="0dp"
/>
<android.support.v4.view.ViewPager
<net.osmand.plus.CustomPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="0dp"

View file

@ -0,0 +1,27 @@
package net.osmand.plus;
import net.osmand.plus.views.OsmandMapTileView;
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.View;
public class CustomPager extends ViewPager {
public CustomPager(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CustomPager(Context context) {
super(context);
}
@Override
protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
if (v instanceof OsmandMapTileView) {
return true;
}
return super.canScroll(v, checkV, dx, x, y);
}
}

View file

@ -9,7 +9,6 @@ import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.actionbarsherlock.app.ActionBar;
import net.osmand.Location;
import net.osmand.StateChangedListener;
import net.osmand.access.AccessibilityPlugin;
@ -30,8 +29,8 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.PoiFilter;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.Version;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.Version;
import net.osmand.plus.activities.search.SearchActivity;
import net.osmand.plus.base.FailSafeFuntions;
import net.osmand.plus.base.MapViewTrackingUtilities;

View file

@ -6,9 +6,6 @@ import java.util.List;
import net.osmand.Location;
import net.osmand.PlatformUtil;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
import net.osmand.binary.RouteDataObject;
import net.osmand.data.LatLon;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.GPXUtilities.GPXFile;

View file

@ -60,6 +60,8 @@ import android.view.Window;
import android.widget.TextView;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.app.SherlockFragmentActivity;
public class SherpafyCustomization extends OsmAndAppCustomization {
@ -501,7 +503,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
}
}
public void showFavoriteDialog(MapActivity mapActivity, StageInformation stage, StageFavorite sf) {
public void showFavoriteDialog(SherlockFragmentActivity mapActivity, StageInformation stage, StageFavorite sf) {
Bundle bl = new Bundle();
bl.putInt(SherpafyFavoriteFragment.STAGE_PARAM, stage.getOrder());
bl.putString(SherpafyFavoriteFragment.TOUR_PARAM, stage.getTour().getId());
@ -620,7 +622,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
@Override
public void createLayers(OsmandMapTileView mapView, MapActivity activity) {
mapView.addLayer(new StageFavoritesLayer(app), 4.1f);
mapView.addLayer(new StageFavoritesLayer(app, null), 4.1f);
}
public boolean isWaypointGroupVisible(int waypointType, RouteCalculationResult route) {

View file

@ -127,7 +127,8 @@ public class SherpafyStageFragment extends SherlockFragment {
if (stage != null) {
mTabsAdapter.addTab(tabHost.newTabSpec("INFO").setIndicator(getString(R.string.sherpafy_stage_tab_info)),
SherpafyStageInfoFragment.class);
if (!stage.getItinerary().equals("")) {
if (!stage.getItinerary().equals("") &&
(stage.getGpx() != null || stage.getStartPoint() != null)) {
mTabsAdapter.addTab(
tabHost.newTabSpec("ROUTE").setIndicator(getString(R.string.sherpafy_stage_tab_route)),
SherpafyStageItineraryFragment.class);

View file

@ -4,6 +4,7 @@ import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.sherpafy.TourInformation.StageInformation;
import net.osmand.plus.views.OsmandMapTileView;
import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
@ -24,6 +25,7 @@ public class SherpafyStageInfoFragment extends SherlockFragment {
protected StageInformation stage;
protected TourInformation tour;
private View view;
protected OsmandMapTileView osmandMapTileView;
public SherpafyStageInfoFragment() {
}
@ -64,9 +66,12 @@ public class SherpafyStageInfoFragment extends SherlockFragment {
TextView additional = (TextView) view.findViewById(R.id.AdditionalText);
TextView text = (TextView) view.findViewById(R.id.Text);
TextView header = (TextView) view.findViewById(R.id.HeaderText);
osmandMapTileView = (OsmandMapTileView) view.findViewById(R.id.MapView);
updateView(description, icon, additional, text, header);
return view;
}
protected void updateView(WebView description, ImageView icon, TextView additional, TextView text, TextView header) {

View file

@ -1,16 +1,53 @@
package net.osmand.plus.sherpafy;
import java.util.List;
import net.osmand.data.RotatedTileBox;
import net.osmand.map.MapTileDownloader.DownloadRequest;
import net.osmand.map.MapTileDownloader.IMapDownloaderCallback;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.R;
import net.osmand.plus.render.MapVectorLayer;
import net.osmand.plus.resources.ResourceManager;
import net.osmand.plus.views.GPXLayer;
import net.osmand.plus.views.MapTextLayer;
import android.os.AsyncTask;
import android.view.View;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.TextView;
public class SherpafyStageItineraryFragment extends SherpafyStageInfoFragment {
public class SherpafyStageItineraryFragment extends SherpafyStageInfoFragment implements IMapDownloaderCallback {
private static final boolean HIDE_ITINERARY_IMG = true;
@Override
public void onDestroy() {
super.onDestroy();
app.getResourceManager().getMapTileDownloader().removeDownloaderCallback(this);
}
protected void updateView(WebView description, ImageView icon, TextView additional, TextView text, TextView header) {
if (stage.getItineraryBitmap() != null) {
app.getResourceManager().getMapTileDownloader().addDownloaderCallback(this);
osmandMapTileView.setVisibility(View.VISIBLE);
osmandMapTileView.removeAllLayers();
MapVectorLayer mapVectorLayer = new MapVectorLayer(null);
MapTextLayer mapTextLayer = new MapTextLayer();
mapTextLayer.setAlwaysVisible(true);
// 5.95 all labels
osmandMapTileView.addLayer(mapTextLayer, 5.95f);
osmandMapTileView.addLayer(mapVectorLayer, 0.5f);
final GPXLayer gpxLayer = new GPXLayer();
gpxLayer.setGivenGpx(stage.getGpx());
osmandMapTileView.addLayer(gpxLayer, 0.9f);
osmandMapTileView.addLayer(new StageFavoritesLayer(app, stage), 4.1f);
osmandMapTileView.setMainLayer(mapVectorLayer);
mapVectorLayer.setVisible(true);
calculateLatLon();
if (stage.getItineraryBitmap() != null && !HIDE_ITINERARY_IMG) {
icon.setImageBitmap(stage.getItineraryBitmap());
} else {
icon.setVisibility(View.GONE);
@ -28,7 +65,71 @@ public class SherpafyStageItineraryFragment extends SherpafyStageInfoFragment {
( h == 0 ? "" : h + " " + app.getString(R.string.int_hour) + " ") +
( min == 0 ? "" : min + " " + app.getString(R.string.int_min))+ "<h4/>";
}
description.loadData("<html><body>" + ins + stage.getItinerary() + "</body></html", "text/html; charset=utf-8",
String content = HIDE_ITINERARY_IMG ? "" : stage.getItinerary();
description.loadData("<html><body>" + ins + content + "</body></html", "text/html; charset=utf-8",
"utf-8");
new AsyncTask<Void, Void, Void>() {
private GPXFile gpx;
@Override
protected Void doInBackground(Void... params) {
gpx = GPXUtilities.loadGPXFile(app, stage.gpxFile);
return null;
}
protected void onPostExecute(Void result) {
gpxLayer.setGivenGpx(gpx);
calculateLatLon();
osmandMapTileView.refreshMap();
};
}.execute((Void)null);
}
protected void calculateLatLon() {
WptPt st = stage.getGpx() == null ? null : stage.getGpx().findPointToShow();
double llat = st == null ? stage.getStartPoint().getLatitude() : st.lat;
double llon = st == null ? stage.getStartPoint().getLongitude() : st.lon;
double left = llon, right = llon;
double top = llat, bottom = llat;
if (stage.getGpx() != null) {
for (List<WptPt> list : stage.getGpx().proccessPoints()) {
for (WptPt l : list) {
left = Math.min(left, l.getLongitude());
right = Math.max(right, l.getLongitude());
top = Math.max(top, l.getLatitude());
bottom = Math.min(bottom, l.getLatitude());
}
}
}
osmandMapTileView.setIntZoom(15);
RotatedTileBox tb = new RotatedTileBox(osmandMapTileView.getCurrentRotatedTileBox());
tb.setPixelDimensions(3 * tb.getPixWidth() / 4, 3 * tb.getPixHeight() / 4);
double clat = bottom / 2 + top / 2;
double clon = left / 2 + right / 2;
tb.setLatLonCenter(clat, clon);
while (tb.getZoom() >= 7 && (!tb.containsLatLon(top, left) || !tb.containsLatLon(bottom, right))) {
tb.setZoom(tb.getZoom() - 1);
}
osmandMapTileView.setLatLon(tb.getCenterLatLon().getLatitude(), tb.getCenterLatLon().getLongitude());
osmandMapTileView.setComplexZoom(tb.getZoom(), osmandMapTileView.getSettingsZoomScale());
}
@Override
public void onResume() {
super.onResume();
osmandMapTileView.refreshMap(true);
}
@Override
public void tileDownloaded(DownloadRequest request) {
if(request != null && !request.error && request.fileToSave != null){
ResourceManager mgr = app.getResourceManager();
mgr.tileDownloaded(request);
}
if(request == null || !request.error){
osmandMapTileView.tileDownloaded(request);
}
}
}

View file

@ -4,22 +4,38 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import android.graphics.PointF;
import net.osmand.data.LocationPoint;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.sherpafy.TourInformation.StageFavorite;
import net.osmand.plus.sherpafy.TourInformation.StageInformation;
import net.osmand.plus.views.FavoritesLayer;
import net.osmand.plus.views.OsmandMapTileView;
public class StageFavoritesLayer extends FavoritesLayer {
private OsmandApplication app;
private StageInformation givenStage;
private ArrayList<StageFavorite> cachedFavorites;
public StageFavoritesLayer(OsmandApplication app){
public StageFavoritesLayer(OsmandApplication app, StageInformation givenStage) {
this.app = app;
this.givenStage = givenStage;
if (givenStage != null) {
cachedFavorites = new ArrayList<StageFavorite>();
for (Object o : givenStage.getFavorites()) {
if (o instanceof StageFavorite) {
StageFavorite sf = (StageFavorite) o;
cachedFavorites.add(sf);
}
}
}
}
protected Class<? extends LocationPoint> getFavoriteClass() {
return (Class<? extends LocationPoint>) StageFavorite.class;
}
@ -29,6 +45,10 @@ public class StageFavoritesLayer extends FavoritesLayer {
}
protected List<? extends LocationPoint> getPoints() {
if(cachedFavorites != null) {
return cachedFavorites;
}
List<StageFavorite> fs = ((SherpafyCustomization)app.getAppCustomization()).getWaypoints();
if(fs == null) {
return Collections.emptyList();
@ -42,8 +62,13 @@ public class StageFavoritesLayer extends FavoritesLayer {
getFavoriteFromPoint(tileBox, point, favs);
if (favs.size() > 0){
SherpafyCustomization customization = (SherpafyCustomization) app.getAppCustomization();
customization.showFavoriteDialog(app.getMapActivity(), customization.getSelectedStage(), (StageFavorite)favs.get(0) );
return true;
if (view.getContext() instanceof SherlockFragmentActivity) {
customization
.showFavoriteDialog((SherlockFragmentActivity) view.getContext(),
givenStage != null ? givenStage : customization.getSelectedStage(),
(StageFavorite) favs.get(0));
return true;
}
}
return false;
}

View file

@ -1,25 +1,13 @@
package net.osmand.plus.sherpafy;
import java.util.List;
import java.util.WeakHashMap;
import net.osmand.IProgress;
import net.osmand.data.LatLon;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.activities.DownloadIndexActivity;
import net.osmand.plus.sherpafy.TourInformation.StageFavorite;
import net.osmand.plus.sherpafy.TourInformation.StageInformation;
import net.osmand.util.Algorithms;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;

View file

@ -8,6 +8,7 @@ import net.osmand.access.AccessibleToast;
import net.osmand.data.LatLon;
import net.osmand.data.QuadRect;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
@ -65,6 +66,10 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
private OsmandRenderer osmandRenderer;
private List<List<WptPt>> points;
private GPXFile gpx;
// private Drawable favoriteIcon;
@ -160,16 +165,21 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
@Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
List<SelectedGpxFile> selectedGPXFiles = selectedGpxHelper.getSelectedGPXFiles();
cache.clear();
if (!selectedGPXFiles.isEmpty()) {
drawSelectedFilesSegments(canvas, tileBox, selectedGPXFiles, settings);
canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
drawSelectedFilesSplits(canvas, tileBox, selectedGPXFiles, settings);
drawSelectedFilesPoints(canvas, tileBox, selectedGPXFiles);
}
if(textLayer.isVisible()) {
textLayer.putData(this, cache);
if(points != null) {
updatePaints(0, false, settings, tileBox);
drawSegments(canvas, tileBox, points);
} else {
List<SelectedGpxFile> selectedGPXFiles = selectedGpxHelper.getSelectedGPXFiles();
cache.clear();
if (!selectedGPXFiles.isEmpty()) {
drawSelectedFilesSegments(canvas, tileBox, selectedGPXFiles, settings);
canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
drawSelectedFilesSplits(canvas, tileBox, selectedGPXFiles, settings);
drawSelectedFilesPoints(canvas, tileBox, selectedGPXFiles);
}
if (textLayer != null && textLayer.isVisible()) {
textLayer.putData(this, cache);
}
}
}
@ -440,6 +450,12 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
}
public void setGivenGpx(GPXFile gpx) {
this.gpx = gpx;
this.points = (gpx == null ? null : gpx.proccessPoints());
}
}

View file

@ -24,6 +24,8 @@ public class MapTextLayer extends OsmandMapLayer {
public static final int TEXT_LINES = 3;
private Paint paintTextIcon;
private OsmandMapTileView view;
private boolean alwaysVisible;
public interface MapTextProvider<T> {
@ -47,14 +49,22 @@ public class MapTextLayer extends OsmandMapLayer {
}
}
public boolean isAlwaysVisible() {
return alwaysVisible;
}
public void setAlwaysVisible(boolean alwaysVisible) {
this.alwaysVisible = alwaysVisible;
}
public boolean isVisible() {
return view.getSettings().SHOW_POI_LABEL.get();
return view.getSettings().SHOW_POI_LABEL.get() || isAlwaysVisible();
}
@SuppressWarnings("unchecked")
@Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
if (!view.getSettings().SHOW_POI_LABEL.get()) {
if (!isVisible()) {
return;
}
TIntHashSet set = new TIntHashSet();

View file

@ -272,6 +272,12 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
zOrders.remove(layer);
layer.destroyLayer();
}
public synchronized void removeAllLayers() {
while(layers.size() > 0) {
removeLayer(layers.get(0));
}
}
public List<OsmandMapLayer> getLayers() {
return layers;
@ -356,7 +362,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
}
public float getSettingsZoomScale() {
return settings.getSettingsZoomScale(getDensity());
return getSettings().getSettingsZoomScale(getDensity());
}
public float getZoomScale() {

File diff suppressed because it is too large Load diff