Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2014-08-21 00:19:02 +02:00
commit d33a7924e3
8 changed files with 91 additions and 26 deletions

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_selected="true"
android:drawable="@color/sherpafy_selection"/>
<item
android:state_pressed="true"
android:drawable="@color/sherpafy_selection"/>
<item
android:state_focused="true"
android:drawable="@color/sherpafy_selection"/>
<item
android:drawable="@color/color_black" />
</selector>

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_selected="true"
android:drawable="@color/sherpafy_selection"/>
<item
android:state_pressed="true"
android:drawable="@color/sherpafy_selection"/>
<item
android:state_focused="true"
android:drawable="@color/sherpafy_selection"/>
<item
android:drawable="@color/color_transparent" />
</selector>

View file

@ -4,7 +4,7 @@
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="@android:drawable/list_selector_background"
android:background="@drawable/view_transparent_selection"
android:id="@+id/package_delivered_layout">
<ImageView android:id="@+id/waypoint_icon"

View file

@ -9,7 +9,6 @@ import java.util.Map;
import net.osmand.IProgress;
import net.osmand.IndexConstants;
import net.osmand.Location;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LocationPoint;
import net.osmand.plus.activities.DownloadIndexActivity;
import net.osmand.plus.activities.FavouritesActivity;
@ -20,7 +19,6 @@ import net.osmand.plus.activities.PluginsActivity;
import net.osmand.plus.activities.SettingsActivity;
import net.osmand.plus.activities.search.SearchActivity;
import net.osmand.plus.download.DownloadActivityType;
import net.osmand.plus.sherpafy.TourInformation.StageFavorite;
import net.osmand.plus.views.OsmandMapTileView;
import android.app.Activity;
import android.view.Window;
@ -162,4 +160,7 @@ public class OsmAndAppCustomization {
public boolean isWaypointGroupVisible(int waypointType) {
return true;
}
public void showLocationPoint(MapActivity ctx, LocationPoint locationPoint) {
}
}

View file

@ -238,7 +238,7 @@ public class MapActivityLayers {
clck.onContextMenuClick(itemId, item, isChecked, dialog);
} else if(itemId == R.string.layer_poi){
if(isChecked){
selectPOIFilterLayer(mapView);
selectPOIFilterLayer(mapView, null);
}
settings.SHOW_POI_OVER_MAP.set(isChecked);
} else if(itemId == R.string.layer_amenity_label){
@ -329,7 +329,7 @@ public class MapActivityLayers {
settingsImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
selectPOIFilterLayer(mapView);
selectPOIFilterLayer(mapView, null);
}
});
} else if (specialItemId == R.string.layer_gpx_layer) {
@ -452,7 +452,7 @@ public class MapActivityLayers {
}
private void selectPOIFilterLayer(final OsmandMapTileView mapView){
public AlertDialog selectPOIFilterLayer(final OsmandMapTileView mapView, final PoiFilter[] selected){
final List<PoiFilter> userDefined = new ArrayList<PoiFilter>();
OsmandApplication app = (OsmandApplication)getApplication();
final PoiFiltersHelper poiFilters = app.getPoiFilters();
@ -521,11 +521,14 @@ public class MapActivityLayers {
}
poiMapLayer.setFilter(f);
mapView.refreshMap();
if(selected != null && selected.length > 0) {
selected[0] = f;
}
}
}
});
builder.show();
return builder.show();
}
public void selectMapLayer(final OsmandMapTileView mapView){

View file

@ -9,6 +9,7 @@ import net.osmand.data.LocationPoint;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.PoiFilter;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
@ -17,11 +18,11 @@ import net.osmand.plus.views.MapControlsLayer;
import net.osmand.util.MapUtils;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Application;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.DialogInterface.OnDismissListener;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Bundle;
@ -38,10 +39,7 @@ import android.widget.CompoundButton;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
/**
@ -81,6 +79,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
}
@SuppressWarnings("deprecation")
public void updateDialog() {
final LocationPointWrapper point = waypointHelper.getMostImportantLocationPoint(many);
if (point == null) {
@ -96,7 +95,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
View all = closePointDialog.findViewById(R.id.all_points);
all.setVisibility(/*many.size() <= 1 ? View.GONE : */View.VISIBLE);
if (created) {
closePointDialog.setBackgroundColor(mapActivity.getResources().getColor(R.color.color_black));
closePointDialog.setBackgroundDrawable(mapActivity.getResources().getDrawable(R.drawable.view_black_selection));
((TextView) closePointDialog.findViewById(R.id.waypoint_text)).setTextColor(Color.WHITE);
all.setOnClickListener(new View.OnClickListener() {
@Override
@ -199,14 +198,14 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
args.putBoolean(WaypointDialogFragment.FLAT_ARG, true);
WaypointDialogFragment wdf = new WaypointDialogFragment();
wdf.setArguments(args);
wdf.show(fragmentActivity.getSupportFragmentManager(), "tag");
fragmentActivity.getSupportFragmentManager().beginTransaction().add(wdf, "tag").commit();
}
public static void showWaypointsDialog(FragmentActivity fragmentActivity) {
Bundle args = new Bundle();
WaypointDialogFragment wdf = new WaypointDialogFragment();
wdf.setArguments(args);
wdf.show(fragmentActivity.getSupportFragmentManager(), "tag");
fragmentActivity.getSupportFragmentManager().beginTransaction().add(wdf, "tag").commit();
}
public static class WaypointDialogFragment extends DialogFragment {
@ -231,6 +230,26 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
return createWaypointsDialog();
}
private void selectPoi(final int[] running, final ArrayAdapter<Object> listAdapter, final int type,
final boolean enable) {
if(getActivity() instanceof MapActivity && !PoiFilter.CUSTOM_FILTER_ID.equals(app.getSettings().getPoiFilterForMap())) {
MapActivity map = (MapActivity) getActivity();
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, listAdapter, type, enable);
}
}
});
} else {
enableType(running, listAdapter, type, enable);
}
}
private void enableType(final int[] running, final ArrayAdapter<Object> listAdapter, final int type,
final boolean enable) {
new AsyncTask<Void, Void, Void>() {
@ -253,7 +272,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
}.execute((Void) null);
}
protected String getHeader(int type) {
protected String getHeader(int type, boolean checked) {
FragmentActivity ctx = getActivity();
String str = ctx.getString(R.string.waypoints);
switch (type) {
@ -270,7 +289,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
str = ctx.getString(R.string.waypoints);
break;
case WaypointHelper.POI:
str = waypointHelper.getPoiFilter() == null ? ctx.getString(R.string.poi) : waypointHelper
str = waypointHelper.getPoiFilter() == null && !checked ? ctx.getString(R.string.poi) : waypointHelper
.getPoiFilter().getName();
break;
}
@ -314,7 +333,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
LocationPointWrapper ps = listAdapter.getItem(i);
showOnMap(app, ctx, ps.getPoint(), getDialog());
showOnMap(app, ctx, ps.getPoint(), WaypointDialogFragment.this);
}
});
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
@ -353,7 +372,8 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
final CompoundButton btn = (CompoundButton) v.findViewById(R.id.check_item);
btn.setVisibility(waypointHelper.isTypeConfigurable(type) ? View.VISIBLE : View.GONE);
btn.setOnCheckedChangeListener(null);
btn.setChecked(waypointHelper.isTypeEnabled(type));
final boolean checked = waypointHelper.isTypeEnabled(type);
btn.setChecked(checked);
btn.setEnabled(running[0] == -1);
v.findViewById(R.id.ProgressBar).setVisibility(position == running[0] ? View.VISIBLE : View.GONE);
btn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@ -362,11 +382,16 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
running[0] = position;
thisAdapter.notifyDataSetInvalidated();
if(type == WaypointHelper.POI && isChecked) {
selectPoi(running, thisAdapter, type, isChecked);
} else {
enableType(running, thisAdapter, type, isChecked);
}
}
});
TextView tv = (TextView) v.findViewById(R.id.header_text);
tv.setText(getHeader(type));
tv.setText(getHeader(type, checked));
} else {
updatePointInfoView(app, ctx, v, (LocationPointWrapper) getItem(position));
View remove = v.findViewById(R.id.info_close);
@ -393,7 +418,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
public void onItemClick(AdapterView<?> adapterView, View view, int item, long l) {
if(listAdapter.getItem(item) instanceof LocationPointWrapper) {
LocationPointWrapper ps = (LocationPointWrapper) listAdapter.getItem(item);
showOnMap(app, ctx, ps.getPoint(), getDialog());
showOnMap(app, ctx, ps.getPoint(), WaypointDialogFragment.this);
}
}
});
@ -434,17 +459,18 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
}
private static void showOnMap(OsmandApplication app, Activity a, LocationPoint locationPoint, Dialog dialog) {
private static void showOnMap(OsmandApplication app, Activity a, LocationPoint locationPoint, DialogFragment dialog) {
if(!(a instanceof MapActivity)) {
return;
}
MapActivity ctx = (MapActivity) a;
AnimateDraggingMapThread thread = ctx.getMapView().getAnimatedDraggingThread();
int fZoom = ctx.getMapView().getZoom() < 15 ? 15 : ctx.getMapView().getZoom();
boolean di = dialog != null && dialog.isShowing();
boolean di = dialog != null;
if (thread.isAnimating() && !di) {
ctx.getMapView().setIntZoom(fZoom);
ctx.getMapView().setLatLon(locationPoint.getLatitude(), locationPoint.getLongitude());
app.getAppCustomization().showLocationPoint(ctx, locationPoint);
} else {
final double dist = MapUtils.getDistance(ctx.getMapView().getLatitude(), ctx.getMapView().getLongitude(),
locationPoint.getLatitude(), locationPoint.getLongitude());
@ -455,13 +481,13 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
.getContextMenuLayer()
.setLocation(new LatLon(locationPoint.getLatitude(), locationPoint.getLongitude()),
locationPoint.getName(ctx));
app.getAppCustomization().showLocationPoint(ctx, locationPoint);
}
if (di || dist >= t) {
thread.startMoving(locationPoint.getLatitude(), locationPoint.getLongitude(), fZoom, true);
}
if(di) {
dialog.dismiss();
dialog = null;
}
}
}

View file

@ -532,7 +532,6 @@ public class RoutingHelper {
private void setNewRoute(RouteCalculationResult res, Location start){
final boolean newRoute = !this.route.isCalculated();
app.getWaypointHelper().setNewRoute(res);
if (isFollowingMode) {
if(lastFixedLocation != null) {
start = lastFixedLocation;
@ -562,7 +561,7 @@ public class RoutingHelper {
voiceRouter.newRouteIsCalculated(newRoute);
}
}
app.getWaypointHelper().setNewRoute(res);
app.runInUIThread(new Runnable() {
@Override
public void run() {

View file

@ -13,6 +13,7 @@ import java.util.TreeSet;
import net.osmand.IProgress;
import net.osmand.IndexConstants;
import net.osmand.Location;
import net.osmand.data.LocationPoint;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.GPXUtilities;
@ -510,4 +511,11 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
waypointType == WaypointHelper.TARGETS ||
waypointType == WaypointHelper.POI;
}
public void showLocationPoint(MapActivity ctx, LocationPoint locationPoint) {
if(locationPoint instanceof StageFavorite && getSelectedStage() != null) {
showFavoriteDialog(ctx, getSelectedStage(), (StageFavorite) locationPoint);
}
}
}