Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-09-10 18:15:21 +02:00
commit 9bbc6f2e00
5 changed files with 36 additions and 7 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item> <item>
<nine-patch android:src="@drawable/bg_contextmenu_dots_light" /> <nine-patch android:src="@drawable/bg_contextmenu_dots_dark" />
</item> </item>
<item> <item>
<shape> <shape>

View file

@ -1,5 +1,6 @@
package net.osmand.data; package net.osmand.data;
import java.io.Serializable;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols; import java.text.DecimalFormatSymbols;
import java.util.Locale; import java.util.Locale;
@ -15,7 +16,7 @@ import net.osmand.util.Algorithms;
import android.content.Context; import android.content.Context;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
public class PointDescription { public class PointDescription implements Serializable {
private String type = ""; private String type = "";
private String name = ""; private String name = "";
private String typeName; private String typeName;
@ -23,6 +24,8 @@ public class PointDescription {
private double lat = 0; private double lat = 0;
private double lon = 0; private double lon = 0;
private static final long serialVersionUID = 4078409090417168638L;
public static final String POINT_TYPE_FAVORITE = "favorite"; public static final String POINT_TYPE_FAVORITE = "favorite";
public static final String POINT_TYPE_WPT = "wpt"; public static final String POINT_TYPE_WPT = "wpt";
public static final String POINT_TYPE_POI = "poi"; public static final String POINT_TYPE_POI = "poi";

View file

@ -1,5 +1,6 @@
package net.osmand.plus.mapcontextmenu; package net.osmand.plus.mapcontextmenu;
import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import net.osmand.binary.RouteDataObject; import net.osmand.binary.RouteDataObject;
@ -29,6 +30,9 @@ public class MapContextMenu {
private String foundStreetName; private String foundStreetName;
private static final String KEY_CTX_MENU_OBJECT = "key_ctx_menu_object";
private static final String KEY_CTX_MENU_POINT_DESC = "key_ctx_menu_point_desc";
public boolean isMenuVisible(MapActivity mapActivity) { public boolean isMenuVisible(MapActivity mapActivity) {
return mapActivity.getSupportFragmentManager().findFragmentByTag("MapContextMenuFragment") != null; return mapActivity.getSupportFragmentManager().findFragmentByTag("MapContextMenuFragment") != null;
} }
@ -168,4 +172,19 @@ public class MapContextMenu {
mapActivity.getMapActions().contextMenuPoint(pointDescription.getLat(), pointDescription.getLon(), menuAdapter, object); mapActivity.getMapActions().contextMenuPoint(pointDescription.getLat(), pointDescription.getLon(), menuAdapter, object);
} }
public void saveMenuState(Bundle bundle) {
if (object != null) {
if (object instanceof Amenity)
bundle.putSerializable(KEY_CTX_MENU_OBJECT, (Amenity)object);
}
bundle.putSerializable(KEY_CTX_MENU_POINT_DESC, pointDescription);
}
public void restoreMenuState(Bundle bundle) {
object = bundle.getSerializable(KEY_CTX_MENU_OBJECT);
Object pDescObj = bundle.getSerializable(KEY_CTX_MENU_POINT_DESC);
if (pDescObj != null)
pointDescription = (PointDescription)pDescObj;
}
} }

View file

@ -85,11 +85,20 @@ public class MapContextMenuFragment extends Fragment {
*/ */
} }
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
getCtxMenu().saveMenuState(outState);
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
if (savedInstanceState != null)
getCtxMenu().restoreMenuState(savedInstanceState);
view = inflater.inflate(R.layout.map_context_menu_fragment, container, false); view = inflater.inflate(R.layout.map_context_menu_fragment, container, false);
ViewTreeObserver vto = view.getViewTreeObserver(); ViewTreeObserver vto = view.getViewTreeObserver();
@ -425,7 +434,7 @@ public class MapContextMenuFragment extends Fragment {
} }
private MapContextMenu getCtxMenu() { private MapContextMenu getCtxMenu() {
return ((MapActivity)getActivity()).getContextMenu(); return getMapActivity().getContextMenu();
} }
private MapActivity getMapActivity() { private MapActivity getMapActivity() {

View file

@ -1,8 +1,6 @@
package net.osmand.plus.mapcontextmenu.sections; package net.osmand.plus.mapcontextmenu.sections;
import android.content.res.Resources; import android.content.res.Resources;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.util.Linkify; import android.text.util.Linkify;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
@ -26,7 +24,7 @@ import static android.util.TypedValue.COMPLEX_UNIT_DIP;
public class AmenityInfoMenuBuilder extends MenuBuilder { public class AmenityInfoMenuBuilder extends MenuBuilder {
private static float SHADOW_HEIGHT = 6f; // in dp private static final float SHADOW_HEIGHT = 6f; // in dp
private final Amenity amenity; private final Amenity amenity;
@ -53,7 +51,7 @@ public class AmenityInfoMenuBuilder extends MenuBuilder {
ImageView icon = new ImageView(view.getContext()); ImageView icon = new ImageView(view.getContext());
LinearLayout.LayoutParams llIconParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) ; LinearLayout.LayoutParams llIconParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) ;
llIconParams.setMargins(dpToPx(16f), firstRow ? dpToPx(12f) - dpToPx(SHADOW_HEIGHT) : dpToPx(12f), dpToPx(32f), dpToPx(12f)); llIconParams.setMargins(dpToPx(16f), firstRow ? dpToPx(12f) - dpToPx(SHADOW_HEIGHT / 2f) : dpToPx(12f), dpToPx(32f), dpToPx(12f));
llIconParams.gravity = Gravity.CENTER_VERTICAL; llIconParams.gravity = Gravity.CENTER_VERTICAL;
icon.setLayoutParams(llIconParams); icon.setLayoutParams(llIconParams);
icon.setScaleType(ImageView.ScaleType.CENTER); icon.setScaleType(ImageView.ScaleType.CENTER);