Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-09-07 09:38:05 +02:00
commit 935d4ff7e1
9 changed files with 124 additions and 64 deletions

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<nine-patch android:src="@drawable/bottom_shadow" />
</item>
<item>
<shape>
<solid
android:color="@color/bg_color_dark" />
</shape>
</item>
</layer-list>

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<nine-patch android:src="@drawable/bottom_shadow" />
</item>
<item>
<shape>
<solid
android:color="@color/bg_color_light" />
</shape>
</item>
</layer-list>

View file

@ -25,14 +25,13 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:background="@android:color/white"
android:background="?attr/bg_map_context_menu"
android:orientation="vertical">
<LinearLayout
android:id="@+id/context_menu_top_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:orientation="horizontal">
<LinearLayout
@ -43,12 +42,12 @@
<ImageView
android:id="@+id/context_menu_icon_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_marginStart="14dp"
android:layout_marginLeft="14dp"
android:tint="@color/color_unknown"
android:scaleType="center"
android:layout_marginStart="12dp"
android:layout_marginLeft="12dp"
android:src="@drawable/ic_action_building_number"/>
</LinearLayout>
@ -68,6 +67,7 @@
android:layout_marginRight="12dp"
android:text="@string/search_address_building"
android:textSize="@dimen/default_list_text_size_large"
android:textColor="?android:textColorPrimary"
android:textStyle="bold"/>
<TextView
@ -78,7 +78,7 @@
android:layout_marginRight="12dp"
android:layout_marginTop="3dp"
android:text="@string/other_location"
android:textColor="@color/secondary_text_disabled_material_light"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_list_text_size"/>
@ -107,8 +107,7 @@
android:layout_weight="1"
android:scaleType="center"
android:background="?attr/dashboard_button"
android:src="@drawable/map_directions"
android:tint="@color/actionbar_dark_color"/>
android:src="@drawable/map_directions"/>
<View
android:layout_width="1px"
@ -123,8 +122,7 @@
android:layout_weight="1"
android:scaleType="center"
android:background="?attr/dashboard_button"
android:src="@drawable/ic_action_fav_dark"
android:tint="@color/actionbar_dark_color"/>
android:src="@drawable/ic_action_fav_dark"/>
<View
android:layout_width="1px"
@ -139,8 +137,7 @@
android:layout_weight="1"
android:scaleType="center"
android:background="?attr/dashboard_button"
android:src="@drawable/abc_ic_menu_share_mtrl_alpha"
android:tint="@color/actionbar_dark_color"/>
android:src="@drawable/abc_ic_menu_share_mtrl_alpha"/>
<View
android:layout_width="1px"
@ -155,8 +152,7 @@
android:layout_weight="1"
android:scaleType="center"
android:background="?attr/dashboard_button"
android:src="@drawable/ic_action_core_overflow_dark"
android:tint="@color/actionbar_dark_color"/>
android:src="@drawable/ic_action_core_overflow_dark"/>
</LinearLayout>
</LinearLayout>

View file

@ -11,7 +11,8 @@
<attr name="expandable_list_background" format="color"/>
<attr name="bg_color" format="reference" />
<attr name="bg_card" format="reference" />
<attr name="bg_map_context_menu" format="reference" />
<attr name="dashboard_divider" format="reference" />
<attr name="dashboard_button" format="reference" />

View file

@ -66,6 +66,7 @@
<item name="actionBarStyle">@style/Widget.Styled.ActionBarLight</item>
<item name="bg_color">@color/bg_color_light</item>
<item name="bg_card">@drawable/bg_card_light</item>
<item name="bg_map_context_menu">@drawable/bg_map_context_menu_light</item>
<item name="dashboard_divider">@color/dashboard_divider_light</item>
<item name="dashboard_button">@drawable/dashboard_button_light</item>
<item name="search_background">@color/search_background_dark</item>
@ -160,6 +161,7 @@
<item name="actionBarStyle">@style/Widget.Styled.ActionBarDark</item>
<item name="bg_color">@color/bg_color_dark</item>
<item name="bg_card">@drawable/bg_card_dark</item>
<item name="bg_map_context_menu">@drawable/bg_map_context_menu_dark</item>
<item name="dashboard_divider">@color/dashboard_divider_dark</item>
<item name="dashboard_button">@drawable/dashboard_button_dark</item>
<item name="search_background">@color/color_white</item>

View file

@ -106,7 +106,7 @@ public class MapActivityActions implements DialogProvider {
new ShareLocation(mapActivity).run();
}
public void showNavigationContextMenuPoint(final double latitude, final double longitude, Object selectedObj) {
public void showNavigationContextMenuPoint(final double latitude, final double longitude) {
final ContextMenuAdapter adapter = new ContextMenuAdapter(mapActivity);
if(!mapActivity.getRoutingHelper().isFollowingMode() && !mapActivity.getRoutingHelper().isRoutePlanningMode()) {

View file

@ -14,6 +14,7 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.render.RenderingIcons;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.OsmandMapLayer;
import net.osmand.util.Algorithms;
public class MapContextMenu {
@ -24,7 +25,6 @@ public class MapContextMenu {
private PointDescription pointDescription;
private Object object;
private ContextMenuAdapter menuAdapter;
private String foundStreetName;
@ -59,14 +59,13 @@ public class MapContextMenu {
}
public void show(PointDescription pointDescription, Object object, ContextMenuAdapter menuAdapter) {
public void show(PointDescription pointDescription, Object object) {
if (isMenuVisible())
hide();
this.pointDescription = pointDescription;
this.object = object;
this.menuAdapter = menuAdapter;
acquireStretName();
@ -92,34 +91,37 @@ public class MapContextMenu {
}
public int getLeftIconId() {
if (object instanceof Amenity) {
String id = null;
Amenity o = (Amenity)object;
PoiType st = o.getType().getPoiTypeByKeyName(o.getSubType());
if (st != null) {
if (RenderingIcons.containsSmallIcon(st.getIconKeyName())) {
id = st.getIconKeyName();
} else if (RenderingIcons.containsSmallIcon(st.getOsmTag() + "_" + st.getOsmValue())) {
id = st.getOsmTag() + "_" + st.getOsmValue();
if (object != null) {
if (object instanceof Amenity) {
String id = null;
Amenity o = (Amenity) object;
PoiType st = o.getType().getPoiTypeByKeyName(o.getSubType());
if (st != null) {
if (RenderingIcons.containsSmallIcon(st.getIconKeyName())) {
id = st.getIconKeyName();
} else if (RenderingIcons.containsSmallIcon(st.getOsmTag() + "_" + st.getOsmValue())) {
id = st.getOsmTag() + "_" + st.getOsmValue();
}
}
}
if (id != null) {
Integer resId = RenderingIcons.getResId(id);
if (resId != null) {
return resId;
if (id != null) {
Integer resId = RenderingIcons.getResId(id);
if (resId != null) {
return resId;
}
}
}
}
return 0;
}
public String getAddressStr() {
String res = null;
if (object instanceof Amenity) {
Amenity amenity = (Amenity) object;
res = OsmAndFormatter.getPoiStringWithoutType(amenity, settings.MAP_PREFERRED_LOCALE.get());
if (object != null) {
if (object instanceof Amenity) {
Amenity amenity = (Amenity) object;
res = OsmAndFormatter.getPoiStringWithoutType(amenity, settings.MAP_PREFERRED_LOCALE.get());
}
}
if (Algorithms.isEmpty(res)) {
@ -132,7 +134,7 @@ public class MapContextMenu {
res = typeName;
}
return Algorithms.isEmpty(res) ? "???" : res;
return Algorithms.isEmpty(res) ? "Address is unknown yet" : res;
}
public String getLocationStr() {
@ -143,11 +145,11 @@ public class MapContextMenu {
}
public void buttonNavigatePressed() {
mapActivity.getMapActions().showNavigationContextMenuPoint(pointDescription.getLat(), pointDescription.getLon(), object);
mapActivity.getMapActions().showNavigationContextMenuPoint(pointDescription.getLat(), pointDescription.getLon());
}
public void buttonFavoritePressed() {
if (object instanceof FavouritePoint) {
if (object != null && object instanceof FavouritePoint) {
mapActivity.getMapActions().editFavoritePoint((FavouritePoint)object);
} else {
mapActivity.getMapActions().addFavouritePoint(pointDescription.getLat(), pointDescription.getLon());
@ -159,6 +161,13 @@ public class MapContextMenu {
}
public void buttonMorePressed() {
final ContextMenuAdapter menuAdapter = new ContextMenuAdapter(mapActivity);
if (object != null) {
for (OsmandMapLayer layer : mapActivity.getMapView().getLayers()) {
layer.populateObjectContextMenu(object, menuAdapter);
}
}
mapActivity.getMapActions().contextMenuPoint(pointDescription.getLat(), pointDescription.getLon(), menuAdapter, object);
}
}

View file

@ -10,14 +10,18 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.DecelerateInterpolator;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import net.osmand.PlatformUtil;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.search.SearchActivity;
import org.apache.commons.logging.Log;
@ -122,6 +126,9 @@ public class MapContextMenuFragment extends Fragment {
}
});
IconsCache iconsCache = getMyApplication().getIconsCache();
boolean light = getMyApplication().getSettings().isLightContent();
int iconId = MapContextMenu.getInstance().getLeftIconId();
final View iconLayout = view.findViewById(R.id.context_menu_icon_layout);
@ -129,7 +136,8 @@ public class MapContextMenuFragment extends Fragment {
if (iconId == 0) {
iconLayout.setVisibility(View.GONE);
} else {
iconView.setImageResource(iconId);
iconView.setImageDrawable(iconsCache.getIcon(iconId,
light ? R.color.icon_color : R.color.icon_color_light));
}
TextView line1 = (TextView) view.findViewById(R.id.context_menu_line1);
@ -139,6 +147,8 @@ public class MapContextMenuFragment extends Fragment {
line2.setText(MapContextMenu.getInstance().getLocationStr());
final ImageButton buttonNavigate = (ImageButton) view.findViewById(R.id.context_menu_route_button);
buttonNavigate.setImageDrawable(iconsCache.getIcon(R.drawable.map_directions,
light ? R.color.actionbar_dark_color : R.color.actionbar_light_color));
buttonNavigate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -147,6 +157,8 @@ public class MapContextMenuFragment extends Fragment {
});
final ImageButton buttonFavorite = (ImageButton) view.findViewById(R.id.context_menu_fav_button);
buttonFavorite.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_fav_dark,
light ? R.color.actionbar_dark_color : R.color.actionbar_light_color));
buttonFavorite.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -155,6 +167,8 @@ public class MapContextMenuFragment extends Fragment {
});
final ImageButton buttonShare = (ImageButton) view.findViewById(R.id.context_menu_share_button);
buttonShare.setImageDrawable(iconsCache.getIcon(R.drawable.abc_ic_menu_share_mtrl_alpha,
light ? R.color.actionbar_dark_color : R.color.actionbar_light_color));
buttonShare.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -163,6 +177,8 @@ public class MapContextMenuFragment extends Fragment {
});
final ImageButton buttonMore = (ImageButton) view.findViewById(R.id.context_menu_more_button);
buttonMore.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_core_overflow_dark,
light ? R.color.actionbar_dark_color : R.color.actionbar_light_color));
buttonMore.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -215,6 +231,13 @@ public class MapContextMenuFragment extends Fragment {
getActivity().getSupportFragmentManager().popBackStack();
}
public OsmandApplication getMyApplication() {
if (getActivity() == null) {
return null;
}
return (OsmandApplication) getActivity().getApplication();
}
public static void showInstance(final MapActivity mapActivity) {
MapContextMenuFragment fragment = new MapContextMenuFragment();
mapActivity.getSupportFragmentManager().beginTransaction()

View file

@ -271,12 +271,20 @@ public class ContextMenuLayer extends OsmandMapLayer {
}
LatLon latLon = selectObjectsForContextMenu(tileBox, point);
if (latLon != null) {
String description = getSelectedObjectDescription();
setLocation(latLon, description);
if (selectedObjects.size() == 1) {
setLocation(null, "");
Object selectedObj = selectedObjects.keySet().iterator().next();
showMapContextMenu(selectedObj, latLon);
} else {
String description = getSelectedObjectDescription();
setLocation(latLon, description);
}
} else {
setLocation(null, "");
final double lat = tileBox.getLatFromPixel((int) point.x, (int) point.y);
final double lon = tileBox.getLonFromPixel((int) point.x, (int) point.y);
setLocation(new LatLon(lat, lon), null);
showMapContextMenu(null, new LatLon(lat, lon));
//setLocation(new LatLon(lat, lon), null);
}
view.refreshMap();
return true;
@ -337,7 +345,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
}
public int pressedInTextView(RotatedTileBox tb, float px, float py) {
if (latLon != null) {
if (latLon != null && textView.getText().length() > 0) {
Rect bs = textView.getBackground().getBounds();
Rect closes = closeButton.getDrawable().getBounds();
int dx = (int) (px - tb.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude()));
@ -429,8 +437,9 @@ public class ContextMenuLayer extends OsmandMapLayer {
LatLon latLon = selectObjectsForContextMenu(tileBox, point);
if (latLon != null) {
if (selectedObjects.size() == 1) {
setLocation(null, "");
Object selectedObj = selectedObjects.keySet().iterator().next();
showMapContextMenu(selectedObj, latLon, null);
showMapContextMenu(selectedObj, latLon);
} else {
String description = getSelectedObjectDescription();
setLocation(latLon, description);
@ -459,33 +468,29 @@ public class ContextMenuLayer extends OsmandMapLayer {
@Override
public void onClick(DialogInterface dialog, int which) {
Object selectedObj = s.get(which);
for (OsmandMapLayer layer : view.getLayers()) {
layer.populateObjectContextMenu(selectedObj, menuAdapter);
}
showMapContextMenu(selectedObj, l, menuAdapter);
//activity.getMapActions().contextMenuPoint(l.getLatitude(), l.getLongitude(), menuAdapter, selectedObj);
showMapContextMenu(selectedObj, l);
}
});
builder.show();
} else {
Object selectedObj = selectedObjects.keySet().iterator().next();
for (OsmandMapLayer layer : view.getLayers()) {
layer.populateObjectContextMenu(selectedObj, menuAdapter);
}
showMapContextMenu(selectedObj, l, menuAdapter);
//activity.getMapActions().contextMenuPoint(l.getLatitude(), l.getLongitude(), menuAdapter, selectedObj);
showMapContextMenu(selectedObj, l);
}
}
private void showMapContextMenu(Object obj, LatLon latLon, final ContextMenuAdapter menuAdapter) {
PointDescription pointDescription = selectedObjects.get(obj).getObjectName(obj);
pointDescription.setLat(latLon.getLatitude());
pointDescription.setLon(latLon.getLongitude());
private void showMapContextMenu(Object obj, LatLon latLon) {
PointDescription pointDescription;
if (obj != null) {
pointDescription = selectedObjects.get(obj).getObjectName(obj);
pointDescription.setLat(latLon.getLatitude());
pointDescription.setLon(latLon.getLongitude());
} else {
pointDescription = new PointDescription(latLon.getLatitude(), latLon.getLongitude());
}
this.latLon = latLon;
showMapContextMenuMarker();
MapContextMenu.getInstance().show(pointDescription, obj, menuAdapter);
MapContextMenu.getInstance().show(pointDescription, obj);
}