From d567797a5f47a061dd703e22f96923ab9b475ead Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 20 Dec 2017 17:10:44 +0200 Subject: [PATCH 01/66] Change transport colors --- OsmAnd/res/values/colors.xml | 11 +++++ .../MapContextMenuFragment.java | 2 +- .../TransportStopRouteAdapter.java | 49 ++++++++++++++++++- 3 files changed, 59 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml index dd9eae0d60..f435e29ea2 100644 --- a/OsmAnd/res/values/colors.xml +++ b/OsmAnd/res/values/colors.xml @@ -370,5 +370,16 @@ #ff8800 #d28521 #727272 + + #ff0000 + #f620cb + #920071 + #0000ff + #8c3f01 + #cb6e23 + #009100 + #3880a9 + #53A3BE + #185499 \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index ab48cf98a1..ea91eaf060 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -387,7 +387,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo GridView transportStopRoutesGrid = (GridView) view.findViewById(R.id.transport_stop_routes_grid); List transportStopRoutes = menu.getTransportStopRoutes(); if (transportStopRoutes != null && transportStopRoutes.size() > 0) { - TransportStopRouteAdapter adapter = new TransportStopRouteAdapter(getContext(), transportStopRoutes); + TransportStopRouteAdapter adapter = new TransportStopRouteAdapter(getContext(), transportStopRoutes, nightMode); transportStopRoutesGrid.setAdapter(adapter); transportStopRoutesGrid.setVisibility(View.VISIBLE); } else { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java index fbc1da30a4..84a95d3d0d 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java @@ -1,8 +1,10 @@ package net.osmand.plus.mapcontextmenu; import android.content.Context; +import android.graphics.drawable.GradientDrawable; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.v4.content.ContextCompat; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -16,8 +18,11 @@ import java.util.List; public class TransportStopRouteAdapter extends ArrayAdapter { - public TransportStopRouteAdapter(@NonNull Context context, @NonNull List objects) { + private boolean nightMode; + + public TransportStopRouteAdapter(@NonNull Context context, @NonNull List objects, boolean nightMode) { super(context, 0, objects); + this.nightMode = nightMode; } @NonNull @@ -27,8 +32,48 @@ public class TransportStopRouteAdapter extends ArrayAdapter convertView = LayoutInflater.from(getContext()).inflate(R.layout.transport_stop_route_item, parent, false); } - ((TextView) convertView.findViewById(R.id.transport_stop_route_text)).setText(getItem(position).route.getRef()); + TransportStopRoute transportStopRoute = getItem(position); + if (transportStopRoute != null) { + TextView transportStopRouteTextView = (TextView) convertView.findViewById(R.id.transport_stop_route_text); + transportStopRouteTextView.setText(transportStopRoute.route.getRef()); + GradientDrawable gradientDrawableBg = (GradientDrawable) transportStopRouteTextView.getBackground(); + gradientDrawableBg.setColor(ContextCompat.getColor(getContext(), getColor(transportStopRoute))); + } return convertView; } + + private int getColor(TransportStopRoute route) { + int color; + switch (route.type) { + case BUS: + color = R.color.route_bus_color; + break; + case SHARE_TAXI: + color = R.color.route_share_taxi_color; + break; + case TROLLEYBUS: + color = R.color.route_trolleybus_color; + break; + case TRAM: + color = R.color.route_tram_color; + break; + case TRAIN: + color = nightMode ? R.color.route_train_color_dark : R.color.route_train_color_light; + break; + case LIGHT_RAIL: + color = R.color.route_lightrail_color; + break; + case FUNICULAR: + color = R.color.route_funicular_color; + break; + case FERRY: + color = nightMode ? R.color.route_ferry_color_dark : R.color.route_ferry_color_light; + break; + default: + color = R.color.nav_track; + break; + } + return color; + } } From 24a75dc2bd8cf332498dfb0f231225805e5c70ef Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 20 Dec 2017 17:32:33 +0200 Subject: [PATCH 02/66] Make transport rect clickable --- .../res/layout/transport_stop_route_item.xml | 1 + .../MapContextMenuFragment.java | 19 +++++++++++++++++- .../TransportStopRouteAdapter.java | 20 ++++++++++++++++++- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/layout/transport_stop_route_item.xml b/OsmAnd/res/layout/transport_stop_route_item.xml index 8d186872a8..2e0440c0a8 100644 --- a/OsmAnd/res/layout/transport_stop_route_item.xml +++ b/OsmAnd/res/layout/transport_stop_route_item.xml @@ -7,6 +7,7 @@ android:layout_height="wrap_content"> transportStopRoutes = menu.getTransportStopRoutes(); if (transportStopRoutes != null && transportStopRoutes.size() > 0) { - TransportStopRouteAdapter adapter = new TransportStopRouteAdapter(getContext(), transportStopRoutes, nightMode); + final TransportStopRouteAdapter adapter = new TransportStopRouteAdapter(getContext(), transportStopRoutes, nightMode); + adapter.setListener(new TransportStopRouteAdapter.OnClickListener() { + @Override + public void onClick(int position) { + TransportStopRoute route = adapter.getItem(position); + if (route != null) { + PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE, + route.getDescription(getMapActivity().getMyApplication(), false)); + menu.show(menu.getLatLon(), pd, route); + TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer(); + stopsLayer.setRoute(route.route); + int cz = route.calculateZoom(0, getMapActivity().getMapView().getCurrentRotatedTileBox()); + getMapActivity().changeZoom(cz - getMapActivity().getMapView().getZoom()); + } + } + }); transportStopRoutesGrid.setAdapter(adapter); transportStopRoutesGrid.setVisibility(View.VISIBLE); } else { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java index 84a95d3d0d..3136684905 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java @@ -19,15 +19,20 @@ import java.util.List; public class TransportStopRouteAdapter extends ArrayAdapter { private boolean nightMode; + private OnClickListener listener; public TransportStopRouteAdapter(@NonNull Context context, @NonNull List objects, boolean nightMode) { super(context, 0, objects); this.nightMode = nightMode; } + public void setListener(OnClickListener listener) { + this.listener = listener; + } + @NonNull @Override - public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { + public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) { if (convertView == null) { convertView = LayoutInflater.from(getContext()).inflate(R.layout.transport_stop_route_item, parent, false); } @@ -40,6 +45,15 @@ public class TransportStopRouteAdapter extends ArrayAdapter gradientDrawableBg.setColor(ContextCompat.getColor(getContext(), getColor(transportStopRoute))); } + convertView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (listener != null) { + listener.onClick(position); + } + } + }); + return convertView; } @@ -76,4 +90,8 @@ public class TransportStopRouteAdapter extends ArrayAdapter } return color; } + + public interface OnClickListener { + void onClick(int position); + } } From 5b136fdcdfa0c8ba7a136b38d0c0e10fc80d3bb0 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 20 Dec 2017 17:44:42 +0200 Subject: [PATCH 03/66] Make transport rects colored in bottom view --- .../plus/mapcontextmenu/MenuBuilder.java | 6 +++- .../TransportStopRouteAdapter.java | 36 +------------------ .../controllers/TransportStopController.java | 34 ++++++++++++++++++ 3 files changed, 40 insertions(+), 36 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 49fbd60af8..7a34fc3c43 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -7,6 +7,7 @@ import android.content.res.ColorStateList; import android.content.res.Resources; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; +import android.graphics.drawable.GradientDrawable; import android.net.Uri; import android.os.AsyncTask; import android.support.annotation.NonNull; @@ -726,7 +727,10 @@ public class MenuBuilder { routeDesc.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark)); int drawableResId = r.type == null ? R.drawable.ic_action_polygom_dark : r.type.getResourceId(); ((ImageView) view.findViewById(R.id.route_type_icon)).setImageDrawable(getRowIcon(drawableResId)); - ((TextView) view.findViewById(R.id.route_ref)).setText(r.route.getRef()); + TextView refTextView = (TextView) view.findViewById(R.id.route_ref); + refTextView.setText(r.route.getRef()); + GradientDrawable refBg = (GradientDrawable) refTextView.getBackground(); + refBg.setColor(ContextCompat.getColor(parent.getContext(), r.getColor(!light))); view.setOnClickListener(listener); int typeResId; switch (r.type) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java index 3136684905..f5b66638b6 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java @@ -42,7 +42,7 @@ public class TransportStopRouteAdapter extends ArrayAdapter TextView transportStopRouteTextView = (TextView) convertView.findViewById(R.id.transport_stop_route_text); transportStopRouteTextView.setText(transportStopRoute.route.getRef()); GradientDrawable gradientDrawableBg = (GradientDrawable) transportStopRouteTextView.getBackground(); - gradientDrawableBg.setColor(ContextCompat.getColor(getContext(), getColor(transportStopRoute))); + gradientDrawableBg.setColor(ContextCompat.getColor(getContext(), transportStopRoute.getColor(nightMode))); } convertView.setOnClickListener(new View.OnClickListener() { @@ -57,40 +57,6 @@ public class TransportStopRouteAdapter extends ArrayAdapter return convertView; } - private int getColor(TransportStopRoute route) { - int color; - switch (route.type) { - case BUS: - color = R.color.route_bus_color; - break; - case SHARE_TAXI: - color = R.color.route_share_taxi_color; - break; - case TROLLEYBUS: - color = R.color.route_trolleybus_color; - break; - case TRAM: - color = R.color.route_tram_color; - break; - case TRAIN: - color = nightMode ? R.color.route_train_color_dark : R.color.route_train_color_light; - break; - case LIGHT_RAIL: - color = R.color.route_lightrail_color; - break; - case FUNICULAR: - color = R.color.route_funicular_color; - break; - case FERRY: - color = nightMode ? R.color.route_ferry_color_dark : R.color.route_ferry_color_light; - break; - default: - color = R.color.nav_track; - break; - } - return color; - } - public interface OnClickListener { void onClick(int position); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java index 30b50155d9..17ede9a1bf 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java @@ -264,5 +264,39 @@ public class TransportStopController extends MenuController { } return cp.getZoom(); } + + public int getColor(boolean nightMode) { + int color; + switch (type) { + case BUS: + color = R.color.route_bus_color; + break; + case SHARE_TAXI: + color = R.color.route_share_taxi_color; + break; + case TROLLEYBUS: + color = R.color.route_trolleybus_color; + break; + case TRAM: + color = R.color.route_tram_color; + break; + case TRAIN: + color = nightMode ? R.color.route_train_color_dark : R.color.route_train_color_light; + break; + case LIGHT_RAIL: + color = R.color.route_lightrail_color; + break; + case FUNICULAR: + color = R.color.route_funicular_color; + break; + case FERRY: + color = nightMode ? R.color.route_ferry_color_dark : R.color.route_ferry_color_light; + break; + default: + color = R.color.nav_track; + break; + } + return color; + } } } From 729101faf2042af281b6049aa16597dd1c46cb46 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 20 Dec 2017 18:52:30 +0200 Subject: [PATCH 04/66] Draw coloured transport route on map --- .../net/osmand/plus/TransportStopRoute.java | 81 +++++++++++++++++++ .../plus/mapcontextmenu/MapContextMenu.java | 2 +- .../MapContextMenuFragment.java | 4 +- .../plus/mapcontextmenu/MenuBuilder.java | 4 +- .../plus/mapcontextmenu/MenuController.java | 2 +- .../TransportStopRouteAdapter.java | 2 +- .../controllers/AmenityMenuController.java | 6 +- .../controllers/TransportRouteController.java | 4 +- .../controllers/TransportStopController.java | 78 +----------------- .../plus/views/TransportStopsLayer.java | 31 ++++--- 10 files changed, 111 insertions(+), 103 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/TransportStopRoute.java diff --git a/OsmAnd/src/net/osmand/plus/TransportStopRoute.java b/OsmAnd/src/net/osmand/plus/TransportStopRoute.java new file mode 100644 index 0000000000..e0f7d3fb87 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/TransportStopRoute.java @@ -0,0 +1,81 @@ +package net.osmand.plus; + +import net.osmand.data.RotatedTileBox; +import net.osmand.data.TransportRoute; +import net.osmand.data.TransportStop; +import net.osmand.plus.mapcontextmenu.controllers.TransportStopController; + +import java.util.List; + +public class TransportStopRoute { + public TransportStop refStop; + public TransportStopController.TransportStopType type; + public String desc; + public TransportRoute route; + public TransportStop stop; + public int distance; + public boolean showWholeRoute; + + public String getDescription(OsmandApplication ctx, boolean useDistance) { + if (useDistance && distance > 0) { + String nm = OsmAndFormatter.getFormattedDistance(distance, ctx); + if (refStop != null && !refStop.getName().equals(stop.getName())) { + nm = refStop.getName() + ", " + nm; + } + return desc + " (" + nm + ")"; + } + return desc; + } + + public int calculateZoom(int startPosition, RotatedTileBox currentRotatedTileBox) { + RotatedTileBox cp = currentRotatedTileBox.copy(); + boolean notContains = true; + while (cp.getZoom() > 12 && notContains) { + notContains = false; + List sts = route.getForwardStops(); + for (int i = startPosition; i < sts.size(); i++) { + TransportStop st = sts.get(startPosition); + if (!cp.containsLatLon(st.getLocation())) { + notContains = true; + break; + } + } + cp.setZoom(cp.getZoom() - 1); + } + return cp.getZoom(); + } + + public int getColor(boolean nightMode) { + int color; + switch (type) { + case BUS: + color = R.color.route_bus_color; + break; + case SHARE_TAXI: + color = R.color.route_share_taxi_color; + break; + case TROLLEYBUS: + color = R.color.route_trolleybus_color; + break; + case TRAM: + color = R.color.route_tram_color; + break; + case TRAIN: + color = nightMode ? R.color.route_train_color_dark : R.color.route_train_color_light; + break; + case LIGHT_RAIL: + color = R.color.route_lightrail_color; + break; + case FUNICULAR: + color = R.color.route_funicular_color; + break; + case FERRY: + color = nightMode ? R.color.route_ferry_color_dark : R.color.route_ferry_color_light; + break; + default: + color = R.color.nav_track; + break; + } + return color; + } +} diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index f6f7788041..3e1815179c 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -37,7 +37,7 @@ import net.osmand.plus.mapcontextmenu.MenuController.MenuType; import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController; import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController; import net.osmand.plus.mapcontextmenu.controllers.MapDataMenuController; -import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute; +import net.osmand.plus.TransportStopRoute; import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditor; import net.osmand.plus.mapcontextmenu.editors.PointEditor; import net.osmand.plus.mapcontextmenu.editors.RtePtEditor; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index 567aa99acd..36775029b4 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -46,7 +46,7 @@ import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; import net.osmand.plus.mapcontextmenu.MenuController.MenuState; import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController; import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController; -import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute; +import net.osmand.plus.TransportStopRoute; import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu; import net.osmand.plus.views.AnimateDraggingMapThread; import net.osmand.plus.views.OsmandMapTileView; @@ -399,7 +399,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo route.getDescription(getMapActivity().getMyApplication(), false)); menu.show(menu.getLatLon(), pd, route); TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer(); - stopsLayer.setRoute(route.route); + stopsLayer.setRoute(route); int cz = route.calculateZoom(0, getMapActivity().getMapView().getCurrentRotatedTileBox()); getMapActivity().changeZoom(cz - getMapActivity().getMapView().getZoom()); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 7a34fc3c43..8847d4eac6 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -52,7 +52,7 @@ import net.osmand.plus.mapcontextmenu.builders.cards.CardsRowBuilder; import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard; import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask; import net.osmand.plus.mapcontextmenu.builders.cards.NoImagesCard; -import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute; +import net.osmand.plus.TransportStopRoute; import net.osmand.plus.myplaces.FavoritesActivity; import net.osmand.plus.render.RenderingIcons; import net.osmand.plus.views.TransportStopsLayer; @@ -790,7 +790,7 @@ public class MenuBuilder { r.getDescription(getMapActivity().getMyApplication(), false)); mm.show(latLon, pd, r); TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer(); - stopsLayer.setRoute(r.route); + stopsLayer.setRoute(r); int cz = r.calculateZoom(0, getMapActivity().getMapView().getCurrentRotatedTileBox()); getMapActivity().changeZoom(cz - getMapActivity().getMapView().getZoom()); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index 42b4612988..598a668fce 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -51,7 +51,7 @@ import net.osmand.plus.mapcontextmenu.controllers.RenderedObjectMenuController; import net.osmand.plus.mapcontextmenu.controllers.TargetPointMenuController; import net.osmand.plus.mapcontextmenu.controllers.TransportRouteController; import net.osmand.plus.mapcontextmenu.controllers.TransportStopController; -import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute; +import net.osmand.plus.TransportStopRoute; import net.osmand.plus.mapcontextmenu.controllers.WptPtMenuController; import net.osmand.plus.mapcontextmenu.other.ShareMenu; import net.osmand.plus.mapillary.MapillaryImage; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java index f5b66638b6..b0543ede2d 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java @@ -12,7 +12,7 @@ import android.widget.ArrayAdapter; import android.widget.TextView; import net.osmand.plus.R; -import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute; +import net.osmand.plus.TransportStopRoute; import java.util.List; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java index 862f0090ca..9f64c1dd8c 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java @@ -1,7 +1,5 @@ package net.osmand.plus.mapcontextmenu.controllers; -import android.view.View; - import net.osmand.data.Amenity; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; @@ -14,16 +12,14 @@ import net.osmand.osm.PoiType; import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.mapcontextmenu.MenuController; import net.osmand.plus.mapcontextmenu.OpeningHoursInfo; import net.osmand.plus.mapcontextmenu.builders.AmenityMenuBuilder; -import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute; +import net.osmand.plus.TransportStopRoute; import net.osmand.plus.render.RenderingIcons; import net.osmand.plus.resources.TransportIndexRepository; import net.osmand.plus.views.POIMapLayer; -import net.osmand.plus.views.TransportStopsLayer; import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; import net.osmand.util.OpeningHoursParser; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java index fe4e748fcf..a72f2e3544 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java @@ -12,7 +12,7 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.mapcontextmenu.MenuController; -import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute; +import net.osmand.plus.TransportStopRoute; import net.osmand.plus.views.TransportStopsLayer; import java.util.List; @@ -202,7 +202,7 @@ public class TransportRouteController extends MenuController { TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer(); int cz = transportRoute.calculateZoom(0, getMapActivity().getMapView().getCurrentRotatedTileBox()); getMapActivity().changeZoom(cz - getMapActivity().getMapView().getZoom()); - stopsLayer.setRoute(transportRoute.route); + stopsLayer.setRoute(transportRoute); } private void resetRoute() { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java index 17ede9a1bf..0972367bc4 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java @@ -6,12 +6,10 @@ import android.view.View.OnClickListener; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.QuadRect; -import net.osmand.data.RotatedTileBox; import net.osmand.data.TransportRoute; import net.osmand.data.TransportStop; -import net.osmand.plus.OsmAndFormatter; -import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; +import net.osmand.plus.TransportStopRoute; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.MenuBuilder; @@ -137,7 +135,7 @@ public class TransportStopController extends MenuController { r.getDescription(getMapActivity().getMyApplication(), false)); mm.show(latLon, pd, r); TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer(); - stopsLayer.setRoute(r.route); + stopsLayer.setRoute(r); int cz = r.calculateZoom(0, getMapActivity().getMapView().getCurrentRotatedTileBox()); getMapActivity().changeZoom(cz - getMapActivity().getMapView().getZoom()); } @@ -227,76 +225,4 @@ public class TransportStopController extends MenuController { return false; } - public static class TransportStopRoute { - public TransportStop refStop; - public TransportStopType type; - public String desc; - public TransportRoute route; - public TransportStop stop; - public int distance; - public boolean showWholeRoute; - - public String getDescription(OsmandApplication ctx, boolean useDistance) { - if (useDistance && distance > 0) { - String nm = OsmAndFormatter.getFormattedDistance(distance, ctx); - if (refStop != null && !refStop.getName().equals(stop.getName())) { - nm = refStop.getName() + ", " + nm; - } - return desc + " (" + nm + ")"; - } - return desc; - } - - public int calculateZoom(int startPosition, RotatedTileBox currentRotatedTileBox) { - RotatedTileBox cp = currentRotatedTileBox.copy(); - boolean notContains = true; - while (cp.getZoom() > 12 && notContains) { - notContains = false; - List sts = route.getForwardStops(); - for(int i = startPosition; i < sts.size(); i++) { - TransportStop st = sts.get(startPosition); - if (!cp.containsLatLon(st.getLocation())) { - notContains = true; - break; - } - } - cp.setZoom(cp.getZoom() - 1); - } - return cp.getZoom(); - } - - public int getColor(boolean nightMode) { - int color; - switch (type) { - case BUS: - color = R.color.route_bus_color; - break; - case SHARE_TAXI: - color = R.color.route_share_taxi_color; - break; - case TROLLEYBUS: - color = R.color.route_trolleybus_color; - break; - case TRAM: - color = R.color.route_tram_color; - break; - case TRAIN: - color = nightMode ? R.color.route_train_color_dark : R.color.route_train_color_light; - break; - case LIGHT_RAIL: - color = R.color.route_lightrail_color; - break; - case FUNICULAR: - color = R.color.route_funicular_color; - break; - case FERRY: - color = nightMode ? R.color.route_ferry_color_dark : R.color.route_ferry_color_light; - break; - default: - color = R.color.nav_track; - break; - } - return color; - } - } } diff --git a/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java b/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java index be9959b371..79fbbb89c7 100644 --- a/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java @@ -7,6 +7,7 @@ import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Path; import android.graphics.PointF; +import android.support.v4.content.ContextCompat; import android.util.DisplayMetrics; import android.view.WindowManager; @@ -16,11 +17,11 @@ import net.osmand.data.PointDescription; import net.osmand.data.QuadRect; import net.osmand.data.QuadTree; import net.osmand.data.RotatedTileBox; -import net.osmand.data.TransportRoute; import net.osmand.data.TransportStop; import net.osmand.osm.edit.Node; import net.osmand.osm.edit.Way; import net.osmand.plus.R; +import net.osmand.plus.TransportStopRoute; import net.osmand.plus.activities.MapActivity; import java.util.ArrayList; @@ -38,13 +39,14 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa private final MapActivity mapActivity; private OsmandMapTileView view; + private int cachedColor; private Paint paintIcon; private Bitmap stopBus; private Bitmap stopSmall; private RenderingLineAttributes attrs; private MapLayerData> data; - private TransportRoute route = null; + private TransportStopRoute stopRoute = null; private boolean showTransportStops; private Path path; @@ -67,7 +69,6 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa stopSmall = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_transport_stop_small); attrs = new RenderingLineAttributes("transport_route"); attrs.defaultWidth = (int) (12 * view.getDensity()); - attrs.defaultColor = view.getResources().getColor(R.color.transport_route_line); data = new OsmandMapLayer.MapLayerData>() { { ZOOM_THRESHOLD = 0; @@ -143,12 +144,12 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa } } - public TransportRoute getRoute() { - return route; + public TransportStopRoute getRoute() { + return stopRoute; } - public void setRoute(TransportRoute route) { - this.route = route; + public void setRoute(TransportStopRoute route) { + this.stopRoute = route; } public boolean isShowTransportStops() { @@ -175,18 +176,22 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa } return (int) (r * tb.getDensity()); } - @Override public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tb, DrawSettings settings) { List objects = null; if (tb.getZoom() >= startZoomRoute) { - if (route != null) { - objects = route.getForwardStops(); + if (stopRoute != null) { + objects = stopRoute.route.getForwardStops(); + int color = stopRoute.getColor(settings.isNightMode()); + if (cachedColor != color) { + cachedColor = color; + attrs.paint.setColor(ContextCompat.getColor(mapActivity, cachedColor)); + } attrs.updatePaints(view, settings, tb); try { path.reset(); - List ws = route.getForwardWays(); + List ws = stopRoute.route.getForwardWays(); if (ws != null) { for (Way w : ws) { TIntArrayList tx = new TIntArrayList(); @@ -286,8 +291,8 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa @Override public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List res, boolean unknownLocation) { - if(tileBox.getZoom() >= startZoomRoute && route != null) { - getFromPoint(tileBox, point, res, route.getForwardStops()); + if(tileBox.getZoom() >= startZoomRoute && stopRoute != null) { + getFromPoint(tileBox, point, res, stopRoute.route.getForwardStops()); } else if (tileBox.getZoom() >= startZoom && data.getResults() != null) { getFromPoint(tileBox, point, res, data.getResults()); } From 04b80763749505b774b6d34f5a07dae5d7a78a3c Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 20 Dec 2017 18:56:08 +0200 Subject: [PATCH 05/66] Make route line narrower --- OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java b/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java index 79fbbb89c7..2dee99c725 100644 --- a/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java @@ -68,7 +68,7 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa stopBus = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_transport_stop_bus); stopSmall = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_transport_stop_small); attrs = new RenderingLineAttributes("transport_route"); - attrs.defaultWidth = (int) (12 * view.getDensity()); + attrs.defaultWidth = (int) (6 * view.getDensity()); data = new OsmandMapLayer.MapLayerData>() { { ZOOM_THRESHOLD = 0; From b38f368fb49bc4f3656328c36a8a8312d56bdc88 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Thu, 21 Dec 2017 11:21:21 +0200 Subject: [PATCH 06/66] Change transport item spacing --- OsmAnd/res/layout/ctx_menu_transport_route_layout.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/layout/ctx_menu_transport_route_layout.xml b/OsmAnd/res/layout/ctx_menu_transport_route_layout.xml index ea5082b912..cb81afd6e8 100644 --- a/OsmAnd/res/layout/ctx_menu_transport_route_layout.xml +++ b/OsmAnd/res/layout/ctx_menu_transport_route_layout.xml @@ -8,10 +8,10 @@ android:orientation="horizontal" android:paddingBottom="12dp" android:paddingLeft="16dp" - android:paddingRight="16dp" - android:paddingTop="16dp"> + android:paddingRight="16dp"> Date: Thu, 21 Dec 2017 12:58:55 +0200 Subject: [PATCH 07/66] Get route colors from render.xml --- OsmAnd/res/values/colors.xml | 11 ---- .../plus/mapcontextmenu/MapContextMenu.java | 2 +- .../MapContextMenuFragment.java | 4 +- .../plus/mapcontextmenu/MenuBuilder.java | 4 +- .../plus/mapcontextmenu/MenuController.java | 2 +- .../TransportStopRouteAdapter.java | 13 +++-- .../controllers/AmenityMenuController.java | 5 +- .../controllers/TransportRouteController.java | 2 +- .../controllers/TransportStopController.java | 48 +--------------- .../{ => transport}/TransportStopRoute.java | 57 ++++++++----------- .../plus/transport/TransportStopType.java | 54 ++++++++++++++++++ .../plus/views/TransportStopsLayer.java | 11 +--- 12 files changed, 99 insertions(+), 114 deletions(-) rename OsmAnd/src/net/osmand/plus/{ => transport}/TransportStopRoute.java (56%) create mode 100644 OsmAnd/src/net/osmand/plus/transport/TransportStopType.java diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml index f435e29ea2..dd9eae0d60 100644 --- a/OsmAnd/res/values/colors.xml +++ b/OsmAnd/res/values/colors.xml @@ -370,16 +370,5 @@ #ff8800 #d28521 #727272 - - #ff0000 - #f620cb - #920071 - #0000ff - #8c3f01 - #cb6e23 - #009100 - #3880a9 - #53A3BE - #185499 \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index 3e1815179c..28e11f79bf 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -37,7 +37,7 @@ import net.osmand.plus.mapcontextmenu.MenuController.MenuType; import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController; import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController; import net.osmand.plus.mapcontextmenu.controllers.MapDataMenuController; -import net.osmand.plus.TransportStopRoute; +import net.osmand.plus.transport.TransportStopRoute; import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditor; import net.osmand.plus.mapcontextmenu.editors.PointEditor; import net.osmand.plus.mapcontextmenu.editors.RtePtEditor; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index 36775029b4..b68882032d 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -46,7 +46,7 @@ import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; import net.osmand.plus.mapcontextmenu.MenuController.MenuState; import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController; import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController; -import net.osmand.plus.TransportStopRoute; +import net.osmand.plus.transport.TransportStopRoute; import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu; import net.osmand.plus.views.AnimateDraggingMapThread; import net.osmand.plus.views.OsmandMapTileView; @@ -389,7 +389,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo GridView transportStopRoutesGrid = (GridView) view.findViewById(R.id.transport_stop_routes_grid); List transportStopRoutes = menu.getTransportStopRoutes(); if (transportStopRoutes != null && transportStopRoutes.size() > 0) { - final TransportStopRouteAdapter adapter = new TransportStopRouteAdapter(getContext(), transportStopRoutes, nightMode); + final TransportStopRouteAdapter adapter = new TransportStopRouteAdapter(getMyApplication(), transportStopRoutes, nightMode); adapter.setListener(new TransportStopRouteAdapter.OnClickListener() { @Override public void onClick(int position) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 8847d4eac6..6a628d4e5c 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -52,7 +52,7 @@ import net.osmand.plus.mapcontextmenu.builders.cards.CardsRowBuilder; import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard; import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask; import net.osmand.plus.mapcontextmenu.builders.cards.NoImagesCard; -import net.osmand.plus.TransportStopRoute; +import net.osmand.plus.transport.TransportStopRoute; import net.osmand.plus.myplaces.FavoritesActivity; import net.osmand.plus.render.RenderingIcons; import net.osmand.plus.views.TransportStopsLayer; @@ -730,7 +730,7 @@ public class MenuBuilder { TextView refTextView = (TextView) view.findViewById(R.id.route_ref); refTextView.setText(r.route.getRef()); GradientDrawable refBg = (GradientDrawable) refTextView.getBackground(); - refBg.setColor(ContextCompat.getColor(parent.getContext(), r.getColor(!light))); + refBg.setColor(r.getColor(mapActivity.getMyApplication(), !light)); view.setOnClickListener(listener); int typeResId; switch (r.type) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index 598a668fce..6d6873774b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -51,7 +51,7 @@ import net.osmand.plus.mapcontextmenu.controllers.RenderedObjectMenuController; import net.osmand.plus.mapcontextmenu.controllers.TargetPointMenuController; import net.osmand.plus.mapcontextmenu.controllers.TransportRouteController; import net.osmand.plus.mapcontextmenu.controllers.TransportStopController; -import net.osmand.plus.TransportStopRoute; +import net.osmand.plus.transport.TransportStopRoute; import net.osmand.plus.mapcontextmenu.controllers.WptPtMenuController; import net.osmand.plus.mapcontextmenu.other.ShareMenu; import net.osmand.plus.mapillary.MapillaryImage; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java index b0543ede2d..25fc3bb452 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/TransportStopRouteAdapter.java @@ -1,18 +1,17 @@ package net.osmand.plus.mapcontextmenu; -import android.content.Context; import android.graphics.drawable.GradientDrawable; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import android.support.v4.content.ContextCompat; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; +import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; -import net.osmand.plus.TransportStopRoute; +import net.osmand.plus.transport.TransportStopRoute; import java.util.List; @@ -20,10 +19,12 @@ public class TransportStopRouteAdapter extends ArrayAdapter private boolean nightMode; private OnClickListener listener; + private OsmandApplication app; - public TransportStopRouteAdapter(@NonNull Context context, @NonNull List objects, boolean nightMode) { - super(context, 0, objects); + public TransportStopRouteAdapter(@NonNull OsmandApplication application, @NonNull List objects, boolean nightMode) { + super(application, 0, objects); this.nightMode = nightMode; + this.app = application; } public void setListener(OnClickListener listener) { @@ -42,7 +43,7 @@ public class TransportStopRouteAdapter extends ArrayAdapter TextView transportStopRouteTextView = (TextView) convertView.findViewById(R.id.transport_stop_route_text); transportStopRouteTextView.setText(transportStopRoute.route.getRef()); GradientDrawable gradientDrawableBg = (GradientDrawable) transportStopRouteTextView.getBackground(); - gradientDrawableBg.setColor(ContextCompat.getColor(getContext(), transportStopRoute.getColor(nightMode))); + gradientDrawableBg.setColor(transportStopRoute.getColor(app, nightMode)); } convertView.setOnClickListener(new View.OnClickListener() { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java index 9f64c1dd8c..3709e3600b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java @@ -16,9 +16,10 @@ import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.mapcontextmenu.MenuController; import net.osmand.plus.mapcontextmenu.OpeningHoursInfo; import net.osmand.plus.mapcontextmenu.builders.AmenityMenuBuilder; -import net.osmand.plus.TransportStopRoute; +import net.osmand.plus.transport.TransportStopRoute; import net.osmand.plus.render.RenderingIcons; import net.osmand.plus.resources.TransportIndexRepository; +import net.osmand.plus.transport.TransportStopType; import net.osmand.plus.views.POIMapLayer; import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; @@ -252,7 +253,7 @@ public class AmenityMenuController extends MenuController { if (rts != null) { for (TransportRoute rs : rts) { if (!containsRef(rs)) { - TransportStopController.TransportStopType type = TransportStopController.TransportStopType.findType(rs.getType()); + TransportStopType type = TransportStopType.findType(rs.getType()); TransportStopRoute r = new TransportStopRoute(); r.type = type; r.desc = useEnglishNames ? rs.getEnName(true) : rs.getName(); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java index a72f2e3544..e0eca34040 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java @@ -12,7 +12,7 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.mapcontextmenu.MenuController; -import net.osmand.plus.TransportStopRoute; +import net.osmand.plus.transport.TransportStopRoute; import net.osmand.plus.views.TransportStopsLayer; import java.util.List; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java index 0972367bc4..c30775d1c8 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java @@ -9,12 +9,13 @@ import net.osmand.data.QuadRect; import net.osmand.data.TransportRoute; import net.osmand.data.TransportStop; import net.osmand.plus.R; -import net.osmand.plus.TransportStopRoute; +import net.osmand.plus.transport.TransportStopRoute; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.mapcontextmenu.MenuController; import net.osmand.plus.resources.TransportIndexRepository; +import net.osmand.plus.transport.TransportStopType; import net.osmand.plus.views.TransportStopsLayer; import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; @@ -27,51 +28,6 @@ import java.util.List; public class TransportStopController extends MenuController { - public enum TransportStopType { - BUS(R.drawable.mx_route_bus_ref, R.drawable.mx_route_bus_ref), - FERRY(R.drawable.mx_route_ferry_ref, R.drawable.mx_route_ferry_ref), - FUNICULAR(R.drawable.mx_route_funicular_ref, R.drawable.mx_route_funicular_ref), - LIGHT_RAIL(R.drawable.mx_route_light_rail_ref, R.drawable.mx_route_light_rail_ref), - MONORAIL(R.drawable.mx_route_monorail_ref, R.drawable.mx_route_monorail_ref), - RAILWAY(R.drawable.mx_route_railway_ref, R.drawable.mx_route_railway_ref), - SHARE_TAXI(R.drawable.mx_route_share_taxi_ref, R.drawable.mx_route_share_taxi_ref), - TRAIN(R.drawable.mx_route_train_ref, R.drawable.mx_route_train_ref), - TRAM(R.drawable.mx_route_tram_ref, R.drawable.mx_railway_tram_stop), - TROLLEYBUS(R.drawable.mx_route_trolleybus_ref, R.drawable.mx_route_trolleybus_ref), - SUBWAY(R.drawable.mx_subway_station, R.drawable.mx_subway_station); - - final int resId; - final int topResId; - - TransportStopType(int resId, int topResId) { - this.resId = resId; - this.topResId = topResId; - } - - public int getResourceId() { - return resId; - } - - public int getTopResourceId() { - return topResId; - } - - public boolean isTopType() { - return this == TRAM || this == SUBWAY; - } - - public static TransportStopType findType(String typeName) { - String tName = typeName.toUpperCase(); - for (TransportStopType t : values()) { - if (t.name().equals(tName)) { - return t; - } - } - return null; - } - - } - private TransportStop transportStop; private List routes = new ArrayList<>(); private TransportStopType topType; diff --git a/OsmAnd/src/net/osmand/plus/TransportStopRoute.java b/OsmAnd/src/net/osmand/plus/transport/TransportStopRoute.java similarity index 56% rename from OsmAnd/src/net/osmand/plus/TransportStopRoute.java rename to OsmAnd/src/net/osmand/plus/transport/TransportStopRoute.java index e0f7d3fb87..aee669811e 100644 --- a/OsmAnd/src/net/osmand/plus/TransportStopRoute.java +++ b/OsmAnd/src/net/osmand/plus/transport/TransportStopRoute.java @@ -1,20 +1,26 @@ -package net.osmand.plus; +package net.osmand.plus.transport; import net.osmand.data.RotatedTileBox; import net.osmand.data.TransportRoute; import net.osmand.data.TransportStop; -import net.osmand.plus.mapcontextmenu.controllers.TransportStopController; +import net.osmand.plus.OsmAndFormatter; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.render.RenderingRuleSearchRequest; +import net.osmand.render.RenderingRulesStorage; import java.util.List; public class TransportStopRoute { public TransportStop refStop; - public TransportStopController.TransportStopType type; + public TransportStopType type; public String desc; public TransportRoute route; public TransportStop stop; public int distance; public boolean showWholeRoute; + private int cachedColor; + private boolean cachedNight; public String getDescription(OsmandApplication ctx, boolean useDistance) { if (useDistance && distance > 0) { @@ -45,37 +51,20 @@ public class TransportStopRoute { return cp.getZoom(); } - public int getColor(boolean nightMode) { - int color; - switch (type) { - case BUS: - color = R.color.route_bus_color; - break; - case SHARE_TAXI: - color = R.color.route_share_taxi_color; - break; - case TROLLEYBUS: - color = R.color.route_trolleybus_color; - break; - case TRAM: - color = R.color.route_tram_color; - break; - case TRAIN: - color = nightMode ? R.color.route_train_color_dark : R.color.route_train_color_light; - break; - case LIGHT_RAIL: - color = R.color.route_lightrail_color; - break; - case FUNICULAR: - color = R.color.route_funicular_color; - break; - case FERRY: - color = nightMode ? R.color.route_ferry_color_dark : R.color.route_ferry_color_light; - break; - default: - color = R.color.nav_track; - break; + public int getColor(OsmandApplication ctx, boolean nightMode) { + if (cachedColor == 0 || cachedNight != nightMode) { + cachedColor = ctx.getResources().getColor(R.color.transport_route_line); + cachedNight = nightMode; + RenderingRulesStorage rrs = ctx.getRendererRegistry().getCurrentSelectedRenderer(); + RenderingRuleSearchRequest req = new RenderingRuleSearchRequest(rrs); + req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, nightMode); + String typeStr = type.getTypeStr(); + if (req.searchRenderingAttribute(typeStr)) { + cachedColor = req.getIntPropertyValue(rrs.PROPS.R_ATTR_COLOR_VALUE); + } } - return color; + + return cachedColor; } + } diff --git a/OsmAnd/src/net/osmand/plus/transport/TransportStopType.java b/OsmAnd/src/net/osmand/plus/transport/TransportStopType.java new file mode 100644 index 0000000000..d8273f9090 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/transport/TransportStopType.java @@ -0,0 +1,54 @@ +package net.osmand.plus.transport; + +import net.osmand.plus.R; + +public enum TransportStopType { + BUS(R.drawable.mx_route_bus_ref, R.drawable.mx_route_bus_ref, "routeBusColor"), + FERRY(R.drawable.mx_route_ferry_ref, R.drawable.mx_route_ferry_ref, "routeFerryColor"), + FUNICULAR(R.drawable.mx_route_funicular_ref, R.drawable.mx_route_funicular_ref, "routeFunicularColor"), + LIGHT_RAIL(R.drawable.mx_route_light_rail_ref, R.drawable.mx_route_light_rail_ref, "routeLightrailColor"), + MONORAIL(R.drawable.mx_route_monorail_ref, R.drawable.mx_route_monorail_ref, "routeLightrailColor"), + RAILWAY(R.drawable.mx_route_railway_ref, R.drawable.mx_route_railway_ref, "routeTrainColor"), + SHARE_TAXI(R.drawable.mx_route_share_taxi_ref, R.drawable.mx_route_share_taxi_ref, "routeShareTaxiColor"), + TRAIN(R.drawable.mx_route_train_ref, R.drawable.mx_route_train_ref, "routeTrainColor"), + TRAM(R.drawable.mx_route_tram_ref, R.drawable.mx_railway_tram_stop, "routeTramColor"), + TROLLEYBUS(R.drawable.mx_route_trolleybus_ref, R.drawable.mx_route_trolleybus_ref, "routeTrolleybusColor"), + SUBWAY(R.drawable.mx_subway_station, R.drawable.mx_subway_station, "routeTrainColor"); + + final int resId; + final int topResId; + final String typeStr; + + TransportStopType(int resId, int topResId, String typeStr) { + this.resId = resId; + this.topResId = topResId; + this.typeStr = typeStr; + } + + public int getResourceId() { + return resId; + } + + public int getTopResourceId() { + return topResId; + } + + public String getTypeStr() { + return typeStr; + } + + public boolean isTopType() { + return this == TRAM || this == SUBWAY; + } + + public static TransportStopType findType(String typeName) { + String tName = typeName.toUpperCase(); + for (TransportStopType t : values()) { + if (t.name().equals(tName)) { + return t; + } + } + return null; + } + +} diff --git a/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java b/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java index 2dee99c725..7fd642d9df 100644 --- a/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java @@ -7,7 +7,6 @@ import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Path; import android.graphics.PointF; -import android.support.v4.content.ContextCompat; import android.util.DisplayMetrics; import android.view.WindowManager; @@ -21,7 +20,7 @@ import net.osmand.data.TransportStop; import net.osmand.osm.edit.Node; import net.osmand.osm.edit.Way; import net.osmand.plus.R; -import net.osmand.plus.TransportStopRoute; +import net.osmand.plus.transport.TransportStopRoute; import net.osmand.plus.activities.MapActivity; import java.util.ArrayList; @@ -39,7 +38,6 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa private final MapActivity mapActivity; private OsmandMapTileView view; - private int cachedColor; private Paint paintIcon; private Bitmap stopBus; private Bitmap stopSmall; @@ -183,11 +181,8 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa if (tb.getZoom() >= startZoomRoute) { if (stopRoute != null) { objects = stopRoute.route.getForwardStops(); - int color = stopRoute.getColor(settings.isNightMode()); - if (cachedColor != color) { - cachedColor = color; - attrs.paint.setColor(ContextCompat.getColor(mapActivity, cachedColor)); - } + int color = stopRoute.getColor(mapActivity.getMyApplication(), settings.isNightMode()); + attrs.paint.setColor(color); attrs.updatePaints(view, settings, tb); try { path.reset(); From ca46ae4760029cc2cbfcf747192cb1031d37be67 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Thu, 21 Dec 2017 13:20:54 +0200 Subject: [PATCH 08/66] Change background in multi selection menu --- OsmAnd/res/layout/menu_obj_list_item.xml | 2 +- .../plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/OsmAnd/res/layout/menu_obj_list_item.xml b/OsmAnd/res/layout/menu_obj_list_item.xml index c012235eb6..1f88444361 100644 --- a/OsmAnd/res/layout/menu_obj_list_item.xml +++ b/OsmAnd/res/layout/menu_obj_list_item.xml @@ -8,7 +8,7 @@ Date: Thu, 21 Dec 2017 13:52:45 +0200 Subject: [PATCH 09/66] Fix divider in collapsable view --- .../osmand/plus/mapcontextmenu/MenuBuilder.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 6a628d4e5c..824a28a1d6 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -716,11 +716,7 @@ public class MenuBuilder { ); } - private void buildTransportRouteRow(ViewGroup parent, TransportStopRoute r, OnClickListener listener) { - if (!isFirstRow()) { - buildRowDivider(parent, false); - } - + private void buildTransportRouteRow(ViewGroup parent, TransportStopRoute r, OnClickListener listener, boolean showDivider) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.ctx_menu_transport_route_layout, parent, false); TextView routeDesc = (TextView) view.findViewById(R.id.route_desc); routeDesc.setText(r.getDescription(getMapActivity().getMyApplication(), true)); @@ -775,13 +771,16 @@ public class MenuBuilder { parent.addView(view); - rowBuilt(); + if (showDivider) { + buildRowDivider(parent, false); + } } private CollapsableView getCollapsableTransportStopRoutesView(final Context context, boolean collapsed) { LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, false); - for (final TransportStopRoute r : routes) { + for (int i = 0; i < routes.size(); i++) { + final TransportStopRoute r = routes.get(i); View.OnClickListener listener = new View.OnClickListener() { @Override public void onClick(View arg0) { @@ -795,7 +794,8 @@ public class MenuBuilder { getMapActivity().changeZoom(cz - getMapActivity().getMapView().getZoom()); } }; - buildTransportRouteRow(view, r, listener); + boolean showDivider = i < routes.size() - 1; + buildTransportRouteRow(view, r, listener, showDivider); } return new CollapsableView(view, collapsed); From 95499c39ebb64442fccc54f174a3d05e4a5a7e6d Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Thu, 21 Dec 2017 15:06:18 +0200 Subject: [PATCH 10/66] Create transport item dynamically --- .../ctx_menu_transport_route_layout.xml | 66 --------- .../plus/mapcontextmenu/MenuBuilder.java | 126 ++++++++++-------- .../plus/transport/TransportStopRoute.java | 2 +- .../plus/transport/TransportStopType.java | 53 +++++++- 4 files changed, 122 insertions(+), 125 deletions(-) delete mode 100644 OsmAnd/res/layout/ctx_menu_transport_route_layout.xml diff --git a/OsmAnd/res/layout/ctx_menu_transport_route_layout.xml b/OsmAnd/res/layout/ctx_menu_transport_route_layout.xml deleted file mode 100644 index cb81afd6e8..0000000000 --- a/OsmAnd/res/layout/ctx_menu_transport_route_layout.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 824a28a1d6..ced1596fc4 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -5,6 +5,7 @@ import android.content.Context; import android.content.Intent; import android.content.res.ColorStateList; import android.content.res.Resources; +import android.graphics.Color; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; @@ -716,60 +717,79 @@ public class MenuBuilder { ); } - private void buildTransportRouteRow(ViewGroup parent, TransportStopRoute r, OnClickListener listener, boolean showDivider) { - View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.ctx_menu_transport_route_layout, parent, false); - TextView routeDesc = (TextView) view.findViewById(R.id.route_desc); - routeDesc.setText(r.getDescription(getMapActivity().getMyApplication(), true)); - routeDesc.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark)); - int drawableResId = r.type == null ? R.drawable.ic_action_polygom_dark : r.type.getResourceId(); - ((ImageView) view.findViewById(R.id.route_type_icon)).setImageDrawable(getRowIcon(drawableResId)); - TextView refTextView = (TextView) view.findViewById(R.id.route_ref); - refTextView.setText(r.route.getRef()); - GradientDrawable refBg = (GradientDrawable) refTextView.getBackground(); - refBg.setColor(r.getColor(mapActivity.getMyApplication(), !light)); - view.setOnClickListener(listener); - int typeResId; - switch (r.type) { - case BUS: - typeResId = R.string.poi_route_bus_ref; - break; - case TRAM: - typeResId = R.string.poi_route_tram_ref; - break; - case FERRY: - typeResId = R.string.poi_route_ferry_ref; - break; - case TRAIN: - typeResId = R.string.poi_route_train_ref; - break; - case SHARE_TAXI: - typeResId = R.string.poi_route_share_taxi_ref; - break; - case FUNICULAR: - typeResId = R.string.poi_route_funicular_ref; - break; - case LIGHT_RAIL: - typeResId = R.string.poi_route_light_rail_ref; - break; - case MONORAIL: - typeResId = R.string.poi_route_monorail_ref; - break; - case TROLLEYBUS: - typeResId = R.string.poi_route_trolleybus_ref; - break; - case RAILWAY: - typeResId = R.string.poi_route_railway_ref; - break; - case SUBWAY: - typeResId = R.string.poi_route_subway_ref; - break; - default: - typeResId = R.string.poi_filter_public_transport; - break; - } - ((TextView) view.findViewById(R.id.route_type_text)).setText(typeResId); + private View buildTransportRowItem(View view, TransportStopRoute route, OnClickListener listener) { + LinearLayout baseView = new LinearLayout(view.getContext()); + baseView.setOrientation(LinearLayout.HORIZONTAL); + LinearLayout.LayoutParams llBaseViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); + baseView.setLayoutParams(llBaseViewParams); + baseView.setPadding(dpToPx(16), 0, dpToPx(16), dpToPx(12)); + baseView.setBackgroundResource(resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground)); - parent.addView(view); + TextViewEx transportRect = new TextViewEx(view.getContext()); + LinearLayout.LayoutParams trParams = new LinearLayout.LayoutParams(dpToPx(32), dpToPx(18)); + trParams.setMargins(0, dpToPx(16), 0, 0); + transportRect.setLayoutParams(trParams); + transportRect.setGravity(Gravity.CENTER); + transportRect.setAllCaps(true); + transportRect.setTypeface(FontCache.getRobotoMedium(view.getContext())); + transportRect.setTextColor(Color.WHITE); + transportRect.setTextSize(10); + + GradientDrawable shape = new GradientDrawable(); + shape.setShape(GradientDrawable.RECTANGLE); + shape.setCornerRadius(dpToPx(3)); + shape.setColor(route.getColor(mapActivity.getMyApplication(), !light)); + + transportRect.setBackgroundDrawable(shape); + transportRect.setText(route.route.getRef()); + baseView.addView(transportRect); + + LinearLayout infoView = new LinearLayout(view.getContext()); + infoView.setOrientation(LinearLayout.VERTICAL); + LinearLayout.LayoutParams infoViewLayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + infoViewLayoutParams.setMargins(dpToPx(16), dpToPx(12), dpToPx(16), 0); + infoView.setLayoutParams(infoViewLayoutParams); + baseView.addView(infoView); + + TextView titleView = new TextView(view.getContext()); + LinearLayout.LayoutParams titleParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + titleView.setLayoutParams(titleParams); + titleView.setTextSize(16); + titleView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark)); + titleView.setText(route.getDescription(getMapActivity().getMyApplication(), true)); + infoView.addView(titleView); + + LinearLayout typeView = new LinearLayout(view.getContext()); + typeView.setOrientation(LinearLayout.HORIZONTAL); + LinearLayout.LayoutParams typeViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + typeViewParams.setMargins(0, dpToPx(8), 0, 0); + typeView.setGravity(Gravity.CENTER); + typeView.setLayoutParams(typeViewParams); + infoView.addView(typeView); + + ImageView typeImageView = new ImageView(view.getContext()); + LinearLayout.LayoutParams typeImageParams = new LinearLayout.LayoutParams(dpToPx(16), dpToPx(16)); + typeImageParams.setMargins(dpToPx(4), 0, dpToPx(4), 0); + typeImageView.setLayoutParams(typeImageParams); + int drawableResId = route.type == null ? R.drawable.ic_action_polygom_dark : route.type.getResourceId(); + typeImageView.setImageDrawable(getRowIcon(drawableResId)); + typeView.addView(typeImageView); + + TextView typeTextView = new TextView(view.getContext()); + LinearLayout.LayoutParams typeTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + typeTextView.setLayoutParams(typeTextParams); + typeTextView.setText(route.type.getTypeStrRes()); + typeView.addView(typeTextView); + + baseView.setOnClickListener(listener); + + ((ViewGroup) view).addView(baseView); + + return baseView; + } + + private void buildTransportRouteRow(ViewGroup parent, TransportStopRoute r, OnClickListener listener, boolean showDivider) { + buildTransportRowItem(parent, r, listener); if (showDivider) { buildRowDivider(parent, false); diff --git a/OsmAnd/src/net/osmand/plus/transport/TransportStopRoute.java b/OsmAnd/src/net/osmand/plus/transport/TransportStopRoute.java index aee669811e..ca61058888 100644 --- a/OsmAnd/src/net/osmand/plus/transport/TransportStopRoute.java +++ b/OsmAnd/src/net/osmand/plus/transport/TransportStopRoute.java @@ -58,7 +58,7 @@ public class TransportStopRoute { RenderingRulesStorage rrs = ctx.getRendererRegistry().getCurrentSelectedRenderer(); RenderingRuleSearchRequest req = new RenderingRuleSearchRequest(rrs); req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, nightMode); - String typeStr = type.getTypeStr(); + String typeStr = type.getRendeAttr(); if (req.searchRenderingAttribute(typeStr)) { cachedColor = req.getIntPropertyValue(rrs.PROPS.R_ATTR_COLOR_VALUE); } diff --git a/OsmAnd/src/net/osmand/plus/transport/TransportStopType.java b/OsmAnd/src/net/osmand/plus/transport/TransportStopType.java index d8273f9090..4c7d99b7ad 100644 --- a/OsmAnd/src/net/osmand/plus/transport/TransportStopType.java +++ b/OsmAnd/src/net/osmand/plus/transport/TransportStopType.java @@ -17,12 +17,12 @@ public enum TransportStopType { final int resId; final int topResId; - final String typeStr; + final String renderAttr; - TransportStopType(int resId, int topResId, String typeStr) { + TransportStopType(int resId, int topResId, String renderAttr) { this.resId = resId; this.topResId = topResId; - this.typeStr = typeStr; + this.renderAttr = renderAttr; } public int getResourceId() { @@ -33,8 +33,8 @@ public enum TransportStopType { return topResId; } - public String getTypeStr() { - return typeStr; + public String getRendeAttr() { + return renderAttr; } public boolean isTopType() { @@ -51,4 +51,47 @@ public enum TransportStopType { return null; } + public int getTypeStrRes() { + int typeResId; + switch (this) { + case BUS: + typeResId = R.string.poi_route_bus_ref; + break; + case TRAM: + typeResId = R.string.poi_route_tram_ref; + break; + case FERRY: + typeResId = R.string.poi_route_ferry_ref; + break; + case TRAIN: + typeResId = R.string.poi_route_train_ref; + break; + case SHARE_TAXI: + typeResId = R.string.poi_route_share_taxi_ref; + break; + case FUNICULAR: + typeResId = R.string.poi_route_funicular_ref; + break; + case LIGHT_RAIL: + typeResId = R.string.poi_route_light_rail_ref; + break; + case MONORAIL: + typeResId = R.string.poi_route_monorail_ref; + break; + case TROLLEYBUS: + typeResId = R.string.poi_route_trolleybus_ref; + break; + case RAILWAY: + typeResId = R.string.poi_route_railway_ref; + break; + case SUBWAY: + typeResId = R.string.poi_route_subway_ref; + break; + default: + typeResId = R.string.poi_filter_public_transport; + break; + } + return typeResId; + } + } From 8551969bc9c98333b292f8903b71def0a237caec Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Thu, 21 Dec 2017 15:13:45 +0200 Subject: [PATCH 11/66] Prevent NPE in transport type --- .../plus/mapcontextmenu/MenuBuilder.java | 2 +- .../plus/transport/TransportStopRoute.java | 59 +++++++++++++++++-- .../plus/transport/TransportStopType.java | 43 -------------- 3 files changed, 54 insertions(+), 50 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index ced1596fc4..77a296f88c 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -778,7 +778,7 @@ public class MenuBuilder { TextView typeTextView = new TextView(view.getContext()); LinearLayout.LayoutParams typeTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); typeTextView.setLayoutParams(typeTextParams); - typeTextView.setText(route.type.getTypeStrRes()); + typeTextView.setText(route.getTypeStrRes()); typeView.addView(typeTextView); baseView.setOnClickListener(listener); diff --git a/OsmAnd/src/net/osmand/plus/transport/TransportStopRoute.java b/OsmAnd/src/net/osmand/plus/transport/TransportStopRoute.java index ca61058888..d458b27780 100644 --- a/OsmAnd/src/net/osmand/plus/transport/TransportStopRoute.java +++ b/OsmAnd/src/net/osmand/plus/transport/TransportStopRoute.java @@ -55,16 +55,63 @@ public class TransportStopRoute { if (cachedColor == 0 || cachedNight != nightMode) { cachedColor = ctx.getResources().getColor(R.color.transport_route_line); cachedNight = nightMode; - RenderingRulesStorage rrs = ctx.getRendererRegistry().getCurrentSelectedRenderer(); - RenderingRuleSearchRequest req = new RenderingRuleSearchRequest(rrs); - req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, nightMode); - String typeStr = type.getRendeAttr(); - if (req.searchRenderingAttribute(typeStr)) { - cachedColor = req.getIntPropertyValue(rrs.PROPS.R_ATTR_COLOR_VALUE); + if (type != null) { + RenderingRulesStorage rrs = ctx.getRendererRegistry().getCurrentSelectedRenderer(); + RenderingRuleSearchRequest req = new RenderingRuleSearchRequest(rrs); + req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, nightMode); + String typeStr = type.getRendeAttr(); + if (req.searchRenderingAttribute(typeStr)) { + cachedColor = req.getIntPropertyValue(rrs.PROPS.R_ATTR_COLOR_VALUE); + } } } return cachedColor; } + public int getTypeStrRes() { + int typeResId = R.string.poi_filter_public_transport; + if (type != null) { + switch (type) { + case BUS: + typeResId = R.string.poi_route_bus_ref; + break; + case TRAM: + typeResId = R.string.poi_route_tram_ref; + break; + case FERRY: + typeResId = R.string.poi_route_ferry_ref; + break; + case TRAIN: + typeResId = R.string.poi_route_train_ref; + break; + case SHARE_TAXI: + typeResId = R.string.poi_route_share_taxi_ref; + break; + case FUNICULAR: + typeResId = R.string.poi_route_funicular_ref; + break; + case LIGHT_RAIL: + typeResId = R.string.poi_route_light_rail_ref; + break; + case MONORAIL: + typeResId = R.string.poi_route_monorail_ref; + break; + case TROLLEYBUS: + typeResId = R.string.poi_route_trolleybus_ref; + break; + case RAILWAY: + typeResId = R.string.poi_route_railway_ref; + break; + case SUBWAY: + typeResId = R.string.poi_route_subway_ref; + break; + default: + typeResId = R.string.poi_filter_public_transport; + break; + } + } + return typeResId; + } + } diff --git a/OsmAnd/src/net/osmand/plus/transport/TransportStopType.java b/OsmAnd/src/net/osmand/plus/transport/TransportStopType.java index 4c7d99b7ad..63dfcae17c 100644 --- a/OsmAnd/src/net/osmand/plus/transport/TransportStopType.java +++ b/OsmAnd/src/net/osmand/plus/transport/TransportStopType.java @@ -51,47 +51,4 @@ public enum TransportStopType { return null; } - public int getTypeStrRes() { - int typeResId; - switch (this) { - case BUS: - typeResId = R.string.poi_route_bus_ref; - break; - case TRAM: - typeResId = R.string.poi_route_tram_ref; - break; - case FERRY: - typeResId = R.string.poi_route_ferry_ref; - break; - case TRAIN: - typeResId = R.string.poi_route_train_ref; - break; - case SHARE_TAXI: - typeResId = R.string.poi_route_share_taxi_ref; - break; - case FUNICULAR: - typeResId = R.string.poi_route_funicular_ref; - break; - case LIGHT_RAIL: - typeResId = R.string.poi_route_light_rail_ref; - break; - case MONORAIL: - typeResId = R.string.poi_route_monorail_ref; - break; - case TROLLEYBUS: - typeResId = R.string.poi_route_trolleybus_ref; - break; - case RAILWAY: - typeResId = R.string.poi_route_railway_ref; - break; - case SUBWAY: - typeResId = R.string.poi_route_subway_ref; - break; - default: - typeResId = R.string.poi_filter_public_transport; - break; - } - return typeResId; - } - } From 5b72747dbb35a80a61ae8f7ca7ca1648b6a7923d Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Thu, 21 Dec 2017 15:29:28 +0200 Subject: [PATCH 12/66] Change time icon --- OsmAnd/res/layout/plan_route_info.xml | 2 +- .../net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenu.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/layout/plan_route_info.xml b/OsmAnd/res/layout/plan_route_info.xml index 6a12c401c5..505015148e 100644 --- a/OsmAnd/res/layout/plan_route_info.xml +++ b/OsmAnd/res/layout/plan_route_info.xml @@ -366,7 +366,7 @@ android:layout_marginRight="@dimen/list_content_padding" android:contentDescription="@string/info_button" android:scaleType="center" - android:src="@drawable/ic_action_time"/> + android:src="@drawable/ic_action_time_span"/> Date: Thu, 21 Dec 2017 15:39:01 +0200 Subject: [PATCH 13/66] Change method to find type string --- .../plus/transport/TransportStopRoute.java | 40 +++++++------------ 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/transport/TransportStopRoute.java b/OsmAnd/src/net/osmand/plus/transport/TransportStopRoute.java index d458b27780..2cf17fdad1 100644 --- a/OsmAnd/src/net/osmand/plus/transport/TransportStopRoute.java +++ b/OsmAnd/src/net/osmand/plus/transport/TransportStopRoute.java @@ -70,48 +70,36 @@ public class TransportStopRoute { } public int getTypeStrRes() { - int typeResId = R.string.poi_filter_public_transport; if (type != null) { switch (type) { case BUS: - typeResId = R.string.poi_route_bus_ref; - break; + return R.string.poi_route_bus_ref; case TRAM: - typeResId = R.string.poi_route_tram_ref; - break; + return R.string.poi_route_tram_ref; case FERRY: - typeResId = R.string.poi_route_ferry_ref; - break; + return R.string.poi_route_ferry_ref; case TRAIN: - typeResId = R.string.poi_route_train_ref; - break; + return R.string.poi_route_train_ref; case SHARE_TAXI: - typeResId = R.string.poi_route_share_taxi_ref; - break; + return R.string.poi_route_share_taxi_ref; case FUNICULAR: - typeResId = R.string.poi_route_funicular_ref; - break; + return R.string.poi_route_funicular_ref; case LIGHT_RAIL: - typeResId = R.string.poi_route_light_rail_ref; - break; + return R.string.poi_route_light_rail_ref; case MONORAIL: - typeResId = R.string.poi_route_monorail_ref; - break; + return R.string.poi_route_monorail_ref; case TROLLEYBUS: - typeResId = R.string.poi_route_trolleybus_ref; - break; + return R.string.poi_route_trolleybus_ref; case RAILWAY: - typeResId = R.string.poi_route_railway_ref; - break; + return R.string.poi_route_railway_ref; case SUBWAY: - typeResId = R.string.poi_route_subway_ref; - break; + return R.string.poi_route_subway_ref; default: - typeResId = R.string.poi_filter_public_transport; - break; + return R.string.poi_filter_public_transport; } + } else { + return R.string.poi_filter_public_transport; } - return typeResId; } } From 50a54a244dd5e3db800989d14e89ebcfd9421890 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Thu, 21 Dec 2017 15:48:13 +0200 Subject: [PATCH 14/66] Change font in context menu --- OsmAnd/res/layout/map_context_menu_fragment.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml index 4a2ad7c61d..12cdb7c541 100644 --- a/OsmAnd/res/layout/map_context_menu_fragment.xml +++ b/OsmAnd/res/layout/map_context_menu_fragment.xml @@ -97,13 +97,14 @@ android:layout_height="@dimen/context_menu_sub_info_height" android:orientation="horizontal"> - Date: Thu, 21 Dec 2017 16:28:43 +0200 Subject: [PATCH 15/66] Change edit poi controller (cherry picked from commit 836696f) --- .../plus/osmedit/EditPOIMenuController.java | 64 ++++++++++++++++--- 1 file changed, 56 insertions(+), 8 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java index be90b2bd7a..ab5bf002be 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java @@ -5,13 +5,16 @@ import android.graphics.drawable.Drawable; import android.support.v7.app.AlertDialog; import net.osmand.data.PointDescription; +import net.osmand.osm.PoiType; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.mapcontextmenu.MenuController; import net.osmand.plus.osmedit.OsmPoint.Action; import net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment; -import net.osmand.util.Algorithms; +import net.osmand.plus.render.RenderingIcons; + +import java.util.Map; public class EditPOIMenuController extends MenuController { @@ -94,6 +97,11 @@ public class EditPOIMenuController extends MenuController { } } + @Override + public boolean displayAdditionalTypeStrInHours() { + return true; + } + @Override protected void setObject(Object object) { if (object instanceof OsmPoint) { @@ -112,19 +120,59 @@ public class EditPOIMenuController extends MenuController { @Override public boolean needTypeStr() { - return !Algorithms.isEmpty(pointTypeStr); + return false; } @Override - public Drawable getLeftIcon() { - return getIcon(R.drawable.ic_action_gabout_dark, R.color.created_poi_icon_color); - } - - @Override - public String getTypeStr() { + public String getAdditionalTypeStr() { return pointTypeStr; } + @Override + public int getTimeStrColor() { + if (osmPoint.getAction() == OsmPoint.Action.CREATE) { + return R.color.color_osm_edit_create; + } else if (osmPoint.getAction() == OsmPoint.Action.MODIFY) { + return R.color.color_osm_edit_modify; + } else if (osmPoint.getAction() == OsmPoint.Action.DELETE) { + return R.color.color_osm_edit_delete; + } else { + return R.color.color_osm_edit_modify; + } + } + + @Override + public Drawable getAdditionalLineTypeIcon() { + if (osmPoint.getGroup() == OsmPoint.Group.POI) { + OpenstreetmapPoint osmP = (OpenstreetmapPoint) osmPoint; + int iconResId = 0; + String poiTranslation = osmP.getEntity().getTag(EditPoiData.POI_TYPE_TAG); + if (poiTranslation != null) { + Map poiTypeMap = getMapActivity().getMyApplication().getPoiTypes().getAllTranslatedNames(false); + PoiType poiType = poiTypeMap.get(poiTranslation.toLowerCase()); + if (poiType != null) { + String id = null; + if (RenderingIcons.containsBigIcon(poiType.getIconKeyName())) { + id = poiType.getIconKeyName(); + } else if (RenderingIcons.containsBigIcon(poiType.getOsmTag() + "_" + poiType.getOsmValue())) { + id = poiType.getOsmTag() + "_" + poiType.getOsmValue(); + } + if (id != null) { + iconResId = RenderingIcons.getBigIconResourceId(id); + } + } + } + if (iconResId == 0) { + iconResId = R.drawable.ic_type_info; + } + return getIcon(iconResId); + } else if (osmPoint.getGroup() == OsmPoint.Group.BUG) { + return getIcon(R.drawable.ic_type_bug); + } else { + return null; + } + } + @Override public boolean needStreetName() { return false; From 18e2eaf54f6f6f859d3dcff3da12c40cadf7bafa Mon Sep 17 00:00:00 2001 From: PavelRatushnyi Date: Thu, 21 Dec 2017 19:18:28 +0200 Subject: [PATCH 16/66] Change edit poi controller and refactor --- .../res/layout/map_context_menu_fragment.xml | 2 +- .../plus/mapcontextmenu/MapContextMenu.java | 33 ++++++++-- .../MapContextMenuFragment.java | 66 +++++++------------ .../plus/mapcontextmenu/MenuController.java | 18 ++--- .../mapcontextmenu/MenuTitleController.java | 32 --------- .../plus/mapcontextmenu/OpeningHoursInfo.java | 25 +++++-- .../controllers/AmenityMenuController.java | 26 +++++++- .../FavouritePointMenuController.java | 31 +++++++-- .../controllers/WptPtMenuController.java | 6 +- .../plus/osmedit/EditPOIMenuController.java | 63 ++++++++++-------- .../ParkingPositionMenuController.java | 14 ++-- 11 files changed, 178 insertions(+), 138 deletions(-) diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml index 12cdb7c541..ff429d7ff2 100644 --- a/OsmAnd/res/layout/map_context_menu_fragment.xml +++ b/OsmAnd/res/layout/map_context_menu_fragment.xml @@ -111,7 +111,7 @@ android:layout_marginRight="@dimen/context_menu_padding_margin_small" android:layout_marginEnd="@dimen/context_menu_padding_margin_small" tools:text="Closed till 10:00" - android:id="@+id/opening_hours_text_view" + android:id="@+id/additional_info_text_view" android:layout_width="wrap_content" android:layout_height="wrap_content"/> diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index 28e11f79bf..f67c0d4998 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -3,6 +3,7 @@ package net.osmand.plus.mapcontextmenu; import android.app.Dialog; import android.app.ProgressDialog; import android.content.DialogInterface; +import android.graphics.drawable.Drawable; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; @@ -1135,13 +1136,37 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL return menuController != null && menuController.displayDistanceDirection(); } - public boolean displayAdditionalTypeStrInHours() { - return menuController != null && menuController.displayAdditionalTypeStrInHours(); + public String getSubtypeStr() { + if (menuController != null) { + return menuController.getSubtypeStr(); + } + return ""; } - public int getTimeStrColor() { + public Drawable getSubtypeIcon() { if (menuController != null) { - return menuController.getTimeStrColor(); + return menuController.getSubtypeIcon(); + } + return null; + } + + public int getAdditionalInfoColor() { + if (menuController != null) { + return menuController.getAdditionalInfoColor(); + } + return 0; + } + + public String getAdditionalInfo() { + if (menuController != null) { + return menuController.getAdditionalInfoStr(); + } + return ""; + } + + public int getAdditionalInfoIconRes() { + if (menuController != null) { + return menuController.getAdditionalInfoIconRes(); } return 0; } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index b68882032d..d49e32f9be 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -1126,61 +1126,43 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo } line2Str.append(streetStr); } - line2.setText(line2Str.toString()); + if (!TextUtils.isEmpty(line2Str)) { + line2.setText(line2Str.toString()); + line2.setVisibility(View.VISIBLE); + } else { + line2.setVisibility(View.GONE); + } } TextView line3 = (TextView) view.findViewById(R.id.context_menu_line3); - String additionalTypeStr = menu.getAdditionalTypeStr(); - boolean displayAdditionalTypeStrInHours = menu.displayAdditionalTypeStrInHours(); - boolean emptyAdditionalTypeStr = TextUtils.isEmpty(additionalTypeStr); - if (emptyAdditionalTypeStr || displayAdditionalTypeStrInHours) { + String subtypeStr = menu.getSubtypeStr(); + if (TextUtils.isEmpty(subtypeStr)) { line3.setVisibility(View.GONE); } else { line3.setVisibility(View.VISIBLE); - line3.setText(additionalTypeStr); - Drawable icon = menu.getAdditionalLineTypeIcon(); + line3.setText(subtypeStr); + Drawable icon = menu.getSubtypeIcon(); line3.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null); line3.setCompoundDrawablePadding(dpToPx(5f)); } - TextView openingHoursTextView = (TextView) view.findViewById(R.id.opening_hours_text_view); - OpeningHoursInfo openingHoursInfo = menu.getOpeningHoursInfo(); - boolean containsOpeningHours = openingHoursInfo != null && openingHoursInfo.containsInfo(); - if (containsOpeningHours || (displayAdditionalTypeStrInHours && !emptyAdditionalTypeStr)) { - int colorId; - if (containsOpeningHours) { - colorId = openingHoursInfo.isOpened() ? R.color.ctx_menu_amenity_opened_text_color : R.color.ctx_menu_amenity_closed_text_color; - } else { - colorId = menu.getTimeStrColor(); - } - String timeInfo = ""; - if (containsOpeningHours) { - if (openingHoursInfo.isOpened24_7()) { - timeInfo = getString(R.string.shared_string_is_open_24_7); - } else if (!Algorithms.isEmpty(openingHoursInfo.getNearToOpeningTime())) { - timeInfo = getString(R.string.will_be_opened_at) + " " + openingHoursInfo.getNearToOpeningTime(); - } else if (!Algorithms.isEmpty(openingHoursInfo.getOpeningTime())) { - timeInfo = getString(R.string.opened_from) + " " + openingHoursInfo.getOpeningTime(); - } else if (!Algorithms.isEmpty(openingHoursInfo.getNearToClosingTime())) { - timeInfo = getString(R.string.will_be_closed_at) + " " + openingHoursInfo.getNearToClosingTime(); - } else if (!Algorithms.isEmpty(openingHoursInfo.getClosingTime())) { - timeInfo = getString(R.string.opened_till) + " " + openingHoursInfo.getClosingTime(); - } else if (!Algorithms.isEmpty(openingHoursInfo.getOpeningDay())) { - timeInfo = getString(R.string.will_be_opened_on) + " " + openingHoursInfo.getOpeningDay() + "."; - } - } else { - timeInfo = additionalTypeStr; - } + TextView additionalInfoTextView = (TextView) view.findViewById(R.id.additional_info_text_view); + String additionalInfoStr = menu.getAdditionalInfo(); + if (!TextUtils.isEmpty(additionalInfoStr)) { + int colorId = menu.getAdditionalInfoColor(); + int additionalInfoIconRes = menu.getAdditionalInfoIconRes(); if (colorId != 0) { - openingHoursTextView.setTextColor(ContextCompat.getColor(getContext(), colorId)); - Drawable drawable = getIcon(R.drawable.ic_action_opening_hour_16, colorId); - openingHoursTextView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null); - openingHoursTextView.setCompoundDrawablePadding(dpToPx(8)); + additionalInfoTextView.setTextColor(ContextCompat.getColor(getContext(), colorId)); + if (additionalInfoIconRes != 0) { + Drawable additionalIcon = getIcon(additionalInfoIconRes, colorId); + additionalInfoTextView.setCompoundDrawablesWithIntrinsicBounds(additionalIcon, null, null, null); + additionalInfoTextView.setCompoundDrawablePadding(dpToPx(8)); + } } - openingHoursTextView.setText(timeInfo); - openingHoursTextView.setVisibility(View.VISIBLE); + additionalInfoTextView.setText(additionalInfoStr); + additionalInfoTextView.setVisibility(View.VISIBLE); } else { - openingHoursTextView.setVisibility(View.GONE); + additionalInfoTextView.setVisibility(View.GONE); } } updateCompassVisibility(); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index 6d6873774b..91fdbd450b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -386,10 +386,6 @@ public abstract class MenuController extends BaseMenuController { return false; } - public boolean displayAdditionalTypeStrInHours() { - return false; - } - public int getLeftIconId() { return 0; } @@ -402,7 +398,7 @@ public abstract class MenuController extends BaseMenuController { return null; } - public Drawable getAdditionalLineTypeIcon() { + public Drawable getSubtypeIcon() { return null; } @@ -432,16 +428,20 @@ public abstract class MenuController extends BaseMenuController { return ""; } - public String getAdditionalTypeStr() { + public String getSubtypeStr() { return ""; } - public int getTimeStrColor() { + public int getAdditionalInfoColor() { return 0; } - public OpeningHoursInfo getOpeningHoursInfo() { - return null; + public String getAdditionalInfoStr() { + return ""; + } + + public int getAdditionalInfoIconRes() { + return 0; } public String getCommonTypeStr() { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java index f5c5689798..108aeb78b9 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java @@ -15,12 +15,9 @@ public abstract class MenuTitleController { protected Drawable leftIcon; protected String nameStr = ""; protected String typeStr = ""; - protected String additionalTypeStr = ""; protected String commonTypeStr = ""; protected Drawable secondLineTypeIcon; - protected Drawable additionalLineTypeIcon; protected String streetStr = ""; - protected OpeningHoursInfo openingHoursInfo; private AddressLookupRequest addressLookupRequest; @@ -80,10 +77,6 @@ public abstract class MenuTitleController { return secondLineTypeIcon; } - public Drawable getAdditionalLineTypeIcon() { - return additionalLineTypeIcon; - } - public String getTypeStr() { MenuController menuController = getMenuController(); if (menuController != null && menuController.needTypeStr()) { @@ -93,15 +86,6 @@ public abstract class MenuTitleController { } } - public String getAdditionalTypeStr() { - MenuController menuController = getMenuController(); - if (menuController != null) { - return additionalTypeStr; - } else { - return ""; - } - } - public String getStreetStr() { if (needStreetName()) { if (searchingAddress()) { @@ -114,10 +98,6 @@ public abstract class MenuTitleController { } } - public OpeningHoursInfo getOpeningHoursInfo() { - return openingHoursInfo; - } - protected void initTitle() { searchAddressStr = PointDescription.getSearchAddressStr(getMapActivity()); addressNotFoundStr = PointDescription.getAddressNotFoundStr(getMapActivity()); @@ -131,8 +111,6 @@ public abstract class MenuTitleController { if (needStreetName()) { acquireStreetName(); } - - acquireOpeningHoursInfo(); } protected boolean needStreetName() { @@ -150,13 +128,11 @@ public abstract class MenuTitleController { leftIconId = 0; leftIcon = null; secondLineTypeIcon = null; - additionalLineTypeIcon = null; if (menuController != null) { leftIconId = menuController.getLeftIconId(); leftIcon = menuController.getLeftIcon(); secondLineTypeIcon = menuController.getSecondLineTypeIcon(); - additionalLineTypeIcon = menuController.getAdditionalLineTypeIcon(); } } @@ -170,7 +146,6 @@ public abstract class MenuTitleController { if (menuController != null) { nameStr = menuController.getNameStr(); typeStr = menuController.getTypeStr(); - additionalTypeStr = menuController.getAdditionalTypeStr(); commonTypeStr = menuController.getCommonTypeStr(); } @@ -211,13 +186,6 @@ public abstract class MenuTitleController { getMapActivity().getMyApplication().getGeocodingLookupService().lookupAddress(addressLookupRequest); } - protected void acquireOpeningHoursInfo() { - MenuController menuController = getMenuController(); - if (menuController != null) { - openingHoursInfo = menuController.getOpeningHoursInfo(); - } - } - protected void onSearchAddressDone() { } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/OpeningHoursInfo.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/OpeningHoursInfo.java index 3802a21c52..09db885529 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/OpeningHoursInfo.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/OpeningHoursInfo.java @@ -1,5 +1,8 @@ package net.osmand.plus.mapcontextmenu; +import android.content.Context; + +import net.osmand.plus.R; import net.osmand.util.Algorithms; public class OpeningHoursInfo { @@ -68,12 +71,20 @@ public class OpeningHoursInfo { this.openingDay = openingDay; } - public boolean containsInfo() { - return opened24_7 - || !Algorithms.isEmpty(openingTime) - || !Algorithms.isEmpty(nearToOpeningTime) - || !Algorithms.isEmpty(closingTime) - || !Algorithms.isEmpty(nearToClosingTime) - || !Algorithms.isEmpty(openingDay); + public String getInfo(Context context) { + if (isOpened24_7()) { + return context.getString(R.string.shared_string_is_open_24_7); + } else if (!Algorithms.isEmpty(getNearToOpeningTime())) { + return context.getString(R.string.will_be_opened_at) + " " + getNearToOpeningTime(); + } else if (!Algorithms.isEmpty(getOpeningTime())) { + return context.getString(R.string.opened_from) + " " + getOpeningTime(); + } else if (!Algorithms.isEmpty(getNearToClosingTime())) { + return context.getString(R.string.will_be_closed_at) + " " + getNearToClosingTime(); + } else if (!Algorithms.isEmpty(getClosingTime())) { + return context.getString(R.string.opened_till) + " " + getClosingTime(); + } else if (!Algorithms.isEmpty(getOpeningDay())) { + return context.getString(R.string.will_be_opened_on) + " " + getOpeningDay() + "."; + } + return ""; } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java index 3709e3600b..553ef313a0 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java @@ -36,6 +36,7 @@ public class AmenityMenuController extends MenuController { private Amenity amenity; private List routes = new ArrayList<>(); + private OpeningHoursInfo openingHoursInfo; private MapMarker marker; @@ -76,6 +77,8 @@ public class AmenityMenuController extends MenuController { leftTitleButtonController.leftIcon = getIcon(R.drawable.ic_action_note_dark, isLight() ? R.color.ctx_menu_controller_button_text_color_light_n : R.color.ctx_menu_controller_button_text_color_dark_n); } } + + openingHoursInfo = processOpeningHours(amenity); } @Override @@ -145,8 +148,27 @@ public class AmenityMenuController extends MenuController { } @Override - public OpeningHoursInfo getOpeningHoursInfo() { - return processOpeningHours(amenity); + public int getAdditionalInfoColor() { + if (openingHoursInfo != null) { + return openingHoursInfo.isOpened() ? R.color.ctx_menu_amenity_opened_text_color : R.color.ctx_menu_amenity_closed_text_color; + } + return 0; + } + + @Override + public String getAdditionalInfoStr() { + if (openingHoursInfo != null) { + return openingHoursInfo.getInfo(getMapActivity()); + } + return ""; + } + + @Override + public int getAdditionalInfoIconRes() { + if (openingHoursInfo != null) { + return R.drawable.ic_action_opening_hour_16; + } + return 0; } public static String getTypeStr(Amenity amenity) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java index 12eee1afb4..f122e8d4dd 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java @@ -24,6 +24,7 @@ public class FavouritePointMenuController extends MenuController { private FavouritePoint fav; private MapMarker mapMarker; + private OpeningHoursInfo openingHoursInfo; public FavouritePointMenuController(MapActivity mapActivity, PointDescription pointDescription, final FavouritePoint fav) { super(new FavouritePointMenuBuilder(mapActivity, fav), pointDescription, mapActivity); @@ -45,6 +46,11 @@ public class FavouritePointMenuController extends MenuController { TransportStopController transportStopController = new TransportStopController(getMapActivity(), pointDescription, stop); transportStopController.processTransportStop(builder); } + + Object originObject = getBuilder().getOriginObject(); + if (originObject instanceof Amenity) { + openingHoursInfo = AmenityMenuController.processOpeningHours((Amenity) originObject); + } } @Override @@ -136,11 +142,26 @@ public class FavouritePointMenuController extends MenuController { } @Override - public OpeningHoursInfo getOpeningHoursInfo() { - Object originObject = getBuilder().getOriginObject(); - if (originObject instanceof Amenity) { - return AmenityMenuController.processOpeningHours((Amenity) originObject); + public int getAdditionalInfoColor() { + if (openingHoursInfo != null) { + return openingHoursInfo.isOpened() ? R.color.ctx_menu_amenity_opened_text_color : R.color.ctx_menu_amenity_closed_text_color; } - return null; + return 0; + } + + @Override + public String getAdditionalInfoStr() { + if (openingHoursInfo != null) { + return openingHoursInfo.getInfo(getMapActivity()); + } + return ""; + } + + @Override + public int getAdditionalInfoIconRes() { + if (openingHoursInfo != null) { + return R.drawable.ic_action_opening_hour_16; + } + return 0; } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java index bef7636dc5..1701259c47 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java @@ -82,8 +82,8 @@ public class WptPtMenuController extends MenuController { } @Override - public Drawable getAdditionalLineTypeIcon() { - if (Algorithms.isEmpty(getAdditionalTypeStr())) { + public Drawable getSubtypeIcon() { + if (Algorithms.isEmpty(getSubtypeStr())) { return null; } else { return getIcon(R.drawable.ic_action_group_name_16); @@ -111,7 +111,7 @@ public class WptPtMenuController extends MenuController { } @Override - public String getAdditionalTypeStr() { + public String getSubtypeStr() { return wpt.category != null ? wpt.category : ""; } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java index ab5bf002be..5096886314 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java @@ -13,6 +13,7 @@ import net.osmand.plus.mapcontextmenu.MenuController; import net.osmand.plus.osmedit.OsmPoint.Action; import net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment; import net.osmand.plus.render.RenderingIcons; +import net.osmand.util.Algorithms; import java.util.Map; @@ -20,7 +21,8 @@ public class EditPOIMenuController extends MenuController { private OsmPoint osmPoint; private OsmEditingPlugin plugin; - private String pointTypeStr; + private String category; + private String actionStr; public EditPOIMenuController(final MapActivity mapActivity, PointDescription pointDescription, OsmPoint osmPoint) { super(new EditPOIMenuBuilder(mapActivity, osmPoint), pointDescription, mapActivity); @@ -73,33 +75,34 @@ public class EditPOIMenuController extends MenuController { rightTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_delete); rightTitleButtonController.leftIconId = R.drawable.ic_action_delete_dark; + category = getCategory(); + if (osmPoint.getGroup() == OsmPoint.Group.POI) { if(osmPoint.getAction() == Action.DELETE) { - pointTypeStr = getMapActivity().getString(R.string.osm_edit_deleted_poi); + actionStr = getMapActivity().getString(R.string.osm_edit_deleted_poi); } else if(osmPoint.getAction() == Action.MODIFY) { - pointTypeStr = getMapActivity().getString(R.string.osm_edit_modified_poi); + actionStr = getMapActivity().getString(R.string.osm_edit_modified_poi); } else/* if(osmPoint.getAction() == Action.CREATE) */{ - pointTypeStr = getMapActivity().getString(R.string.osm_edit_created_poi); + actionStr = getMapActivity().getString(R.string.osm_edit_created_poi); } - } else if (osmPoint.getGroup() == OsmPoint.Group.BUG) { if(osmPoint.getAction() == Action.DELETE) { - pointTypeStr = getMapActivity().getString(R.string.osm_edit_removed_note); + actionStr = getMapActivity().getString(R.string.osm_edit_removed_note); } else if(osmPoint.getAction() == Action.MODIFY) { - pointTypeStr = getMapActivity().getString(R.string.osm_edit_commented_note); + actionStr = getMapActivity().getString(R.string.osm_edit_commented_note); } else if(osmPoint.getAction() == Action.REOPEN) { - pointTypeStr = getMapActivity().getString(R.string.osm_edit_reopened_note); + actionStr = getMapActivity().getString(R.string.osm_edit_reopened_note); } else/* if(osmPoint.getAction() == Action.CREATE) */{ - pointTypeStr = getMapActivity().getString(R.string.osm_edit_created_note); + actionStr = getMapActivity().getString(R.string.osm_edit_created_note); } } else { - pointTypeStr = ""; + actionStr = ""; } } @Override - public boolean displayAdditionalTypeStrInHours() { - return true; + public String getTypeStr() { + return category; } @Override @@ -120,29 +123,27 @@ public class EditPOIMenuController extends MenuController { @Override public boolean needTypeStr() { - return false; + return !Algorithms.isEmpty(category); } @Override - public String getAdditionalTypeStr() { - return pointTypeStr; + public String getAdditionalInfoStr() { + return actionStr; } @Override - public int getTimeStrColor() { - if (osmPoint.getAction() == OsmPoint.Action.CREATE) { - return R.color.color_osm_edit_create; - } else if (osmPoint.getAction() == OsmPoint.Action.MODIFY) { - return R.color.color_osm_edit_modify; - } else if (osmPoint.getAction() == OsmPoint.Action.DELETE) { + public int getAdditionalInfoColor() { + if (osmPoint.getAction() == Action.DELETE) { return R.color.color_osm_edit_delete; - } else { + } else if (osmPoint.getAction() == Action.MODIFY || osmPoint.getAction() == Action.REOPEN) { return R.color.color_osm_edit_modify; + } else { + return R.color.color_osm_edit_create; } } @Override - public Drawable getAdditionalLineTypeIcon() { + public int getAdditionalInfoIconRes() { if (osmPoint.getGroup() == OsmPoint.Group.POI) { OpenstreetmapPoint osmP = (OpenstreetmapPoint) osmPoint; int iconResId = 0; @@ -165,11 +166,11 @@ public class EditPOIMenuController extends MenuController { if (iconResId == 0) { iconResId = R.drawable.ic_type_info; } - return getIcon(iconResId); + return iconResId; } else if (osmPoint.getGroup() == OsmPoint.Group.BUG) { - return getIcon(R.drawable.ic_type_bug); + return R.drawable.ic_type_bug; } else { - return null; + return 0; } } @@ -177,4 +178,14 @@ public class EditPOIMenuController extends MenuController { public boolean needStreetName() { return false; } + + private String getCategory() { + String category = ""; + if (osmPoint.getGroup() == OsmPoint.Group.POI) { + category = ((OpenstreetmapPoint) osmPoint).getEntity().getTag(EditPoiData.POI_TYPE_TAG); + } else if (osmPoint.getGroup() == OsmPoint.Group.BUG) { + category = getMapActivity().getString(R.string.osn_bug_name); + } + return category; + } } diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionMenuController.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionMenuController.java index f18a927400..0a0c64f2ec 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionMenuController.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionMenuController.java @@ -64,17 +64,17 @@ public class ParkingPositionMenuController extends MenuController { } @Override - public String getAdditionalTypeStr() { + public int getAdditionalInfoIconRes() { + return R.drawable.ic_action_opening_hour_16; + } + + @Override + public String getAdditionalInfoStr() { return parkingLeftDescription; } @Override - public boolean displayAdditionalTypeStrInHours() { - return true; - } - - @Override - public int getTimeStrColor() { + public int getAdditionalInfoColor() { return plugin.getParkingType() ? R.color.ctx_menu_amenity_closed_text_color : isLight() ? R.color.icon_color : R.color.dash_search_icon_dark; } From de015fde3ea89baaf45e97bb79b108ead9e55547 Mon Sep 17 00:00:00 2001 From: PavelRatushnyi Date: Fri, 22 Dec 2017 10:14:23 +0200 Subject: [PATCH 17/66] Remove unnecessary method --- .../controllers/TransportStopController.java | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java index c30775d1c8..1ea2b94949 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java @@ -81,31 +81,6 @@ public class TransportStopController extends MenuController { return getPointDescription().getTypeName(); } - public void addPlainMenuItems(MenuBuilder builder, final LatLon latLon) { - for (final TransportStopRoute r : routes) { - OnClickListener listener = new OnClickListener() { - @Override - public void onClick(View arg0) { - MapContextMenu mm = getMapActivity().getContextMenu(); - PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE, - r.getDescription(getMapActivity().getMyApplication(), false)); - mm.show(latLon, pd, r); - TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer(); - stopsLayer.setRoute(r); - int cz = r.calculateZoom(0, getMapActivity().getMapView().getCurrentRotatedTileBox()); - getMapActivity().changeZoom(cz - getMapActivity().getMapView().getZoom()); - } - }; - if (r.type == null) { - builder.addPlainMenuItem(R.drawable.ic_action_polygom_dark, r.getDescription(getMapActivity().getMyApplication(), true), - false, false, listener ); - } else { - builder.addPlainMenuItem(r.type.getResourceId(), r.getDescription(getMapActivity().getMyApplication(), true), - false, false, listener); - } - } - } - public void processTransportStop(MenuBuilder builder) { routes.clear(); List reps = getMapActivity().getMyApplication() From d8f0a7e8e1d2debecf059e687cbde58ec90b814e Mon Sep 17 00:00:00 2001 From: PavelRatushnyi Date: Fri, 22 Dec 2017 11:45:19 +0200 Subject: [PATCH 18/66] Change background in route preparation --- OsmAnd/res/layout-land/plan_route_info.xml | 61 ++++++------------- .../res/layout/map_route_prepare_bottom.xml | 6 +- OsmAnd/res/layout/plan_route_info.xml | 60 ++++++------------ OsmAnd/src/net/osmand/AndroidUtils.java | 6 ++ .../activities/actions/AppModeDialog.java | 2 +- .../plus/mapcontextmenu/MenuBuilder.java | 16 ++--- .../builders/AmenityMenuBuilder.java | 3 +- .../other/MapRouteInfoMenu.java | 15 +---- .../other/MapRouteInfoMenuFragment.java | 10 --- .../osmand/plus/views/MapControlsLayer.java | 3 - 10 files changed, 60 insertions(+), 122 deletions(-) diff --git a/OsmAnd/res/layout-land/plan_route_info.xml b/OsmAnd/res/layout-land/plan_route_info.xml index 3ef7ec87a4..ed694f5509 100644 --- a/OsmAnd/res/layout-land/plan_route_info.xml +++ b/OsmAnd/res/layout-land/plan_route_info.xml @@ -49,7 +49,7 @@ android:id="@+id/waypoints" android:layout_width="@dimen/list_item_height" android:layout_height="@dimen/list_item_height" - android:background="?attr/dashboard_button" + android:background="?attr/selectableItemBackground" android:scaleType="center" android:src="@drawable/map_action_waypoints"/> @@ -74,16 +74,19 @@ android:layout_height="wrap_content" android:orientation="vertical"> - - - - - - - - - - + android:layout_height="1dp" + android:background="@color/dashboard_divider_dark" + android:focusable="false"/> - - - + @@ -308,7 +287,7 @@ android:id="@+id/Prev" android:layout_width="@dimen/list_item_height" android:layout_height="@dimen/list_item_height" - android:background="?attr/dashboard_button" + android:background="?attr/selectableItemBackground" android:contentDescription="@string/shared_string_previous" android:scaleType="center" android:src="@drawable/ic_prev"/> @@ -407,7 +386,7 @@ android:layout_width="@dimen/list_item_height" android:layout_height="@dimen/list_item_height" android:layout_marginLeft="5dp" - android:background="?attr/dashboard_button" + android:background="?attr/selectableItemBackground" android:contentDescription="@string/shared_string_next" android:scaleType="center" android:src="@drawable/ic_next"/> diff --git a/OsmAnd/res/layout/map_route_prepare_bottom.xml b/OsmAnd/res/layout/map_route_prepare_bottom.xml index c0d81bab9c..83008eb151 100644 --- a/OsmAnd/res/layout/map_route_prepare_bottom.xml +++ b/OsmAnd/res/layout/map_route_prepare_bottom.xml @@ -18,7 +18,7 @@ android:paddingLeft="@dimen/route_info_buttons_padding_left_right" android:paddingRight="@dimen/route_info_buttons_padding_left_right" android:layout_gravity="center_vertical" - android:background="?attr/dashboard_button" + android:background="?attr/selectableItemBackground" android:src="@drawable/ic_action_test_light" /> @@ -73,16 +73,19 @@ android:layout_height="wrap_content" android:orientation="vertical"> - - - - - - - - - - + android:layout_height="1dp" + android:background="@color/dashboard_divider_dark" + android:focusable="false"/> - - - + @@ -312,7 +292,7 @@ android:id="@+id/Prev" android:layout_width="@dimen/list_item_height" android:layout_height="@dimen/list_item_height" - android:background="?attr/dashboard_button" + android:background="?attr/selectableItemBackground" android:contentDescription="@string/shared_string_previous" android:scaleType="center" android:src="@drawable/ic_prev"/> @@ -411,7 +391,7 @@ android:layout_width="@dimen/list_item_height" android:layout_height="@dimen/list_item_height" android:layout_marginLeft="5dp" - android:background="?attr/dashboard_button" + android:background="?attr/selectableItemBackground" android:contentDescription="@string/shared_string_next" android:scaleType="center" android:src="@drawable/ic_next"/> diff --git a/OsmAnd/src/net/osmand/AndroidUtils.java b/OsmAnd/src/net/osmand/AndroidUtils.java index 04b6e89195..930de97418 100644 --- a/OsmAnd/src/net/osmand/AndroidUtils.java +++ b/OsmAnd/src/net/osmand/AndroidUtils.java @@ -177,6 +177,12 @@ public class AndroidUtils { ); } + public static int resolveAttribute(Context ctx, int attribute) { + TypedValue outValue = new TypedValue(); + ctx.getTheme().resolveAttribute(attribute, outValue, true); + return outValue.resourceId; + } + public static int getStatusBarHeight(Context ctx) { int result = 0; int resourceId = ctx.getResources().getIdentifier("status_bar_height", "dimen", "android"); diff --git a/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java b/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java index 16b39e0e23..d062b09db2 100644 --- a/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java +++ b/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java @@ -88,7 +88,7 @@ public class AppModeDialog { } else { if (useMapTheme) { iv.setImageDrawable(ctx.getIconsCache().getIcon(mode.getSmallIconDark(), R.color.route_info_unchecked_mode_icon_color)); - AndroidUtils.setBackground(ctx, iv, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark); + iv.setBackgroundResource(AndroidUtils.resolveAttribute(ctx, android.R.attr.selectableItemBackground)); } else { iv.setImageDrawable(ctx.getIconsCache().getThemedIcon(mode.getSmallIconDark())); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 77a296f88c..c213597ffd 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -19,7 +19,6 @@ import android.text.TextUtils; import android.text.util.Linkify; import android.util.TypedValue; import android.view.Gravity; -import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; @@ -29,6 +28,7 @@ import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; +import net.osmand.AndroidUtils; import net.osmand.binary.BinaryMapIndexReader; import net.osmand.data.Amenity; import net.osmand.data.FavouritePoint; @@ -466,7 +466,7 @@ public class MenuBuilder { ll.setOrientation(LinearLayout.HORIZONTAL); LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); ll.setLayoutParams(llParams); - ll.setBackgroundResource(resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground)); + ll.setBackgroundResource(AndroidUtils.resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground)); ll.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { @@ -613,7 +613,7 @@ public class MenuBuilder { ll.setOrientation(LinearLayout.HORIZONTAL); LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); ll.setLayoutParams(llParams); - ll.setBackgroundResource(resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground)); + ll.setBackgroundResource(AndroidUtils.resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground)); // Empty LinearLayout llIcon = new LinearLayout(view.getContext()); @@ -634,7 +634,7 @@ public class MenuBuilder { buttonView.setPadding(dpToPx(10f), 0, dpToPx(10f), 0); buttonView.setGravity(Gravity.START | Gravity.CENTER_VERTICAL); //buttonView.setTextSize(view.getResources().getDimension(resolveAttribute(view.getContext(), R.dimen.default_desc_text_size))); - buttonView.setTextColor(view.getResources().getColor(resolveAttribute(view.getContext(), R.attr.contextMenuButtonColor))); + buttonView.setTextColor(view.getResources().getColor(AndroidUtils.resolveAttribute(view.getContext(), R.attr.contextMenuButtonColor))); buttonView.setText(text); if (buttonIcon != null) { @@ -702,12 +702,6 @@ public class MenuBuilder { } } - public int resolveAttribute(Context ctx, int attribute) { - TypedValue outValue = new TypedValue(); - ctx.getTheme().resolveAttribute(attribute, outValue, true); - return outValue.resourceId; - } - public int dpToPx(float dp) { Resources r = app.getResources(); return (int) TypedValue.applyDimension( @@ -723,7 +717,7 @@ public class MenuBuilder { LinearLayout.LayoutParams llBaseViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); baseView.setLayoutParams(llBaseViewParams); baseView.setPadding(dpToPx(16), 0, dpToPx(16), dpToPx(12)); - baseView.setBackgroundResource(resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground)); + baseView.setBackgroundResource(AndroidUtils.resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground)); TextViewEx transportRect = new TextViewEx(view.getContext()); LinearLayout.LayoutParams trParams = new LinearLayout.LayoutParams(dpToPx(32), dpToPx(18)); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java index 8e42c71832..cf0c6129a6 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -19,6 +19,7 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; +import net.osmand.AndroidUtils; import net.osmand.data.Amenity; import net.osmand.data.PointDescription; import net.osmand.osm.AbstractPoiType; @@ -92,7 +93,7 @@ public class AmenityMenuBuilder extends MenuBuilder { ll.setOrientation(LinearLayout.HORIZONTAL); LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); ll.setLayoutParams(llParams); - ll.setBackgroundResource(resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground)); + ll.setBackgroundResource(AndroidUtils.resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground)); ll.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenu.java index aebd43dbaa..49c164ea01 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenu.java @@ -259,24 +259,16 @@ public class MapRouteInfoMenu implements IRouteInformationListener { private void updateViaView(final View parentView) { String via = generateViaDescription(); View viaLayout = parentView.findViewById(R.id.ViaLayout); - View fromLayoutEmptyView = parentView.findViewById(R.id.from_layout_empty_view); - View toLayoutEmptyView = parentView.findViewById(R.id.to_layout_empty_view); - View dividerFromDropDownEmpty = parentView.findViewById(R.id.divider_from_drop_down_empty); + View viaLayoutDivider = parentView.findViewById(R.id.viaLayoutDivider); ImageView swapDirectionView = (ImageView) parentView.findViewById(R.id.swap_direction_image_view); if (via.length() == 0) { viaLayout.setVisibility(View.GONE); - parentView.findViewById(R.id.viaLayoutDivider).setVisibility(View.GONE); - dividerFromDropDownEmpty.setVisibility(View.GONE); - fromLayoutEmptyView.setVisibility(View.VISIBLE); - toLayoutEmptyView.setVisibility(View.VISIBLE); + viaLayoutDivider.setVisibility(View.GONE); swapDirectionView.setVisibility(View.VISIBLE); } else { - fromLayoutEmptyView.setVisibility(View.GONE); - toLayoutEmptyView.setVisibility(View.GONE); swapDirectionView.setVisibility(View.GONE); - dividerFromDropDownEmpty.setVisibility(View.VISIBLE); viaLayout.setVisibility(View.VISIBLE); - parentView.findViewById(R.id.viaLayoutDivider).setVisibility(View.VISIBLE); + viaLayoutDivider.setVisibility(View.VISIBLE); ((TextView) parentView.findViewById(R.id.ViaView)).setText(via); } @@ -294,7 +286,6 @@ public class MapRouteInfoMenu implements IRouteInformationListener { swapDirectionView.setImageDrawable(mapActivity.getMyApplication().getIconsCache().getIcon(R.drawable.ic_action_change_navigation_points, isLight() ? R.color.route_info_control_icon_color_light : R.color.route_info_control_icon_color_dark)); - AndroidUtils.setBackground(mapActivity, swapDirectionView, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark); swapDirectionView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenuFragment.java index f55010cfad..b4e151b190 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapRouteInfoMenuFragment.java @@ -150,8 +150,6 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment { R.color.route_info_divider_light, R.color.route_info_divider_dark); AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerFromDropDown), nightMode, R.color.route_info_divider_light, R.color.route_info_divider_dark); - AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.divider_from_drop_down_empty), nightMode, - R.color.route_info_divider_light, R.color.route_info_divider_dark); AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.viaLayoutDivider), nightMode, R.color.route_info_divider_light, R.color.route_info_divider_dark); AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerToDropDown), nightMode, @@ -170,14 +168,6 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment { AndroidUtils.setTextSecondaryColor(ctx, (TextView) mainView.findViewById(R.id.fromTitle), nightMode); AndroidUtils.setTextPrimaryColor(ctx, (TextView) mainView.findViewById(R.id.InfoTextView), nightMode); - AndroidUtils.setDashButtonBackground(ctx, mainView.findViewById(R.id.FromLayout), nightMode); - AndroidUtils.setDashButtonBackground(ctx, mainView.findViewById(R.id.ViaLayout), nightMode); - AndroidUtils.setDashButtonBackground(ctx, mainView.findViewById(R.id.ToLayout), nightMode); - AndroidUtils.setDashButtonBackground(ctx, mainView.findViewById(R.id.Info), nightMode); - - AndroidUtils.setDashButtonBackground(ctx, mainView.findViewById(R.id.Next), nightMode); - AndroidUtils.setDashButtonBackground(ctx, mainView.findViewById(R.id.Prev), nightMode); - AndroidUtils.setTextPrimaryColor(ctx, (TextView) mainView.findViewById(R.id.DistanceText), nightMode); AndroidUtils.setTextSecondaryColor(ctx, (TextView) mainView.findViewById(R.id.DistanceTitle), nightMode); AndroidUtils.setTextPrimaryColor(ctx, (TextView) mainView.findViewById(R.id.DurationText), nightMode); diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index f3d7b33ee7..580305735c 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -295,7 +295,6 @@ public class MapControlsLayer extends OsmandMapLayer { boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls(); ImageView cancelRouteButton = (ImageView) main.findViewById(R.id.map_cancel_route_button); cancelRouteButton.setImageDrawable(app.getIconsCache().getIcon(R.drawable.map_action_cancel, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light)); - AndroidUtils.setBackground(mapActivity, cancelRouteButton, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark); cancelRouteButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -305,7 +304,6 @@ public class MapControlsLayer extends OsmandMapLayer { ImageView waypointsButton = (ImageView) main.findViewById(R.id.map_waypoints_route_button); waypointsButton.setImageDrawable(app.getIconsCache().getIcon(R.drawable.map_action_flag_dark, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light)); - AndroidUtils.setBackground(mapActivity, waypointsButton, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark); waypointsButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -316,7 +314,6 @@ public class MapControlsLayer extends OsmandMapLayer { ImageView options = (ImageView) main.findViewById(R.id.map_options_route_button); options.setImageDrawable(!routeInfo ? app.getIconsCache().getIcon(R.drawable.map_action_settings, R.color.osmand_orange) : app.getIconsCache().getIcon(R.drawable.map_action_settings, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light)); - AndroidUtils.setBackground(mapActivity, options, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark); options.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { From f44b09fc0c0593942a8f5dd739b05d6a472ae5f8 Mon Sep 17 00:00:00 2001 From: PavelRatushnyi Date: Fri, 22 Dec 2017 15:20:15 +0200 Subject: [PATCH 19/66] Fix icons in osm edits context menu --- .../osmand/plus/osmedit/EditPOIMenuController.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java index 5096886314..0a2de925a2 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java @@ -143,7 +143,7 @@ public class EditPOIMenuController extends MenuController { } @Override - public int getAdditionalInfoIconRes() { + public int getLeftIconId() { if (osmPoint.getGroup() == OsmPoint.Group.POI) { OpenstreetmapPoint osmP = (OpenstreetmapPoint) osmPoint; int iconResId = 0; @@ -174,6 +174,17 @@ public class EditPOIMenuController extends MenuController { } } + @Override + public int getAdditionalInfoIconRes() { + if (osmPoint.getAction() == Action.DELETE) { + return R.drawable.ic_action_type_delete_16; + } else if (osmPoint.getAction() == Action.MODIFY || osmPoint.getAction() == Action.REOPEN) { + return R.drawable.ic_action_type_edit_16; + } else { + return R.drawable.ic_action_type_add_16; + } + } + @Override public boolean needStreetName() { return false; From c0eb827eb520dd4e6856dc5b7c81b05a2ee5c734 Mon Sep 17 00:00:00 2001 From: PavelRatushnyi Date: Tue, 26 Dec 2017 09:09:08 +0200 Subject: [PATCH 20/66] Start changing wikipedia --- .../res/layout/wikipedia_dialog_fragment.xml | 78 ++++++++++++++ .../WikipediaDialogFragment.java | 101 ++++++++++++++++++ .../net/osmand/plus/views/POIMapLayer.java | 14 ++- 3 files changed, 188 insertions(+), 5 deletions(-) create mode 100644 OsmAnd/res/layout/wikipedia_dialog_fragment.xml create mode 100644 OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java diff --git a/OsmAnd/res/layout/wikipedia_dialog_fragment.xml b/OsmAnd/res/layout/wikipedia_dialog_fragment.xml new file mode 100644 index 0000000000..53fb1be62a --- /dev/null +++ b/OsmAnd/res/layout/wikipedia_dialog_fragment.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java new file mode 100644 index 0000000000..33bc455d94 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java @@ -0,0 +1,101 @@ +package net.osmand.plus.mapcontextmenu; + +import android.app.Dialog; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v4.app.DialogFragment; +import android.support.v7.widget.Toolbar; +import android.text.TextUtils; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import net.osmand.data.Amenity; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandSettings; +import net.osmand.plus.R; +import net.osmand.util.Algorithms; + +public class WikipediaDialogFragment extends DialogFragment { + + public static final String PREFERRED_LANGUAGE = "preferred_language"; + + private boolean darkTheme; + private Amenity amenity; + + public void setAmenity(Amenity amenity) { + this.amenity = amenity; + } + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setRetainInstance(true); + OsmandApplication app = getMyApplication(); + darkTheme = app.getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_DARK_THEME; + int themeId = darkTheme ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; + setStyle(STYLE_NO_FRAME, themeId); + } + + @NonNull + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + Dialog dialog = new Dialog(getContext(), getTheme()); + if (!getMyApplication().getSettings().DO_NOT_USE_ANIMATIONS.get()) { + dialog.getWindow().getAttributes().windowAnimations = R.style.Animations_Alpha; + } + return dialog; + } + + @Nullable + @Override + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View mainView = inflater.inflate(R.layout.wikipedia_dialog_fragment, container, false); + + Toolbar toolbar = (Toolbar) mainView.findViewById(R.id.toolbar); + toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back)); + toolbar.setNavigationOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + dismiss(); + } + }); + + String preferredLanguage = ""; + Bundle args = getArguments(); + if (args != null) { + preferredLanguage = args.getString(PREFERRED_LANGUAGE); + } + + if (TextUtils.isEmpty(preferredLanguage)) { + preferredLanguage = getMyApplication().getLanguage(); + } + + final String title = TextUtils.isEmpty(preferredLanguage) ? amenity.getName() : amenity.getName(preferredLanguage); + ((TextView) mainView.findViewById(R.id.title_text_view)).setText(title); + + String langSelected = amenity.getContentLanguage("content", preferredLanguage, "en"); + if (Algorithms.isEmpty(langSelected)) { + langSelected = "en"; + } + + String content = amenity.getDescription(langSelected); + + return mainView; + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + Dialog dialog = getDialog(); + if (dialog != null) { + dialog.setDismissMessage(null); + } + } + + private OsmandApplication getMyApplication() { + return (OsmandApplication) getActivity().getApplication(); + } +} diff --git a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java index 052fddef22..9bad7b4a95 100644 --- a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java @@ -18,6 +18,7 @@ import android.support.v4.content.ContextCompat; import android.support.v4.view.MenuItemCompat; import android.support.v7.widget.PopupMenu; import android.support.v7.widget.Toolbar; +import android.text.Html; import android.text.util.Linkify; import android.util.TypedValue; import android.view.Gravity; @@ -366,6 +367,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon } }); final WebView wv = new WebView(ctx); + final TextView textView = new TextView(ctx); WebSettings settings = wv.getSettings(); settings.setDefaultTextEncodingName("utf-8"); @@ -391,6 +393,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon } } + textView.setText(Html.fromHtml(content)); wv.loadDataWithBaseURL(null, content, "text/html", "UTF-8", null); // wv.loadUrl(OsMoService.SIGN_IN_URL + app.getSettings().OSMO_DEVICE_KEY.get()); //For pinch zooming to work WebView must not be inside ScrollView @@ -400,13 +403,14 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon lp.weight = 1; //ll.addView(scrollView, lp); //scrollView.addView(wv); - ll.addView(wv, lp); +// ll.addView(wv, lp); + ll.addView(textView, lp); ll.addView(bottomBar, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); dialog.setContentView(ll); - wv.setFocusable(true); - wv.setFocusableInTouchMode(true); - wv.requestFocus(View.FOCUS_DOWN); - wv.setOnTouchListener(new View.OnTouchListener() { + textView.setFocusable(true); + textView.setFocusableInTouchMode(true); + textView.requestFocus(View.FOCUS_DOWN); + textView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { From a14b55d0543919e4a42fdd8618f78b1018108aa2 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Tue, 26 Dec 2017 10:34:04 +0200 Subject: [PATCH 21/66] Merge master --- .../plus/mapcontextmenu/MenuBuilder.java | 77 ++++++++++++++++++- .../FavouritePointMenuController.java | 5 +- .../controllers/TransportStopController.java | 11 ++- 3 files changed, 85 insertions(+), 8 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 01230da531..9d9347469c 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -710,8 +710,81 @@ public class MenuBuilder { ); } - private void buildTransportRouteRow(ViewGroup parent, TransportStopRoute r, OnClickListener listener) { - if (!isFirstRow()) { + private View buildTransportRowItem(View view, TransportStopRoute route, OnClickListener listener) { + LinearLayout baseView = new LinearLayout(view.getContext()); + baseView.setOrientation(LinearLayout.HORIZONTAL); + LinearLayout.LayoutParams llBaseViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); + baseView.setLayoutParams(llBaseViewParams); + baseView.setPadding(dpToPx(16), 0, dpToPx(16), dpToPx(12)); + baseView.setBackgroundResource(AndroidUtils.resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground)); + + TextViewEx transportRect = new TextViewEx(view.getContext()); + LinearLayout.LayoutParams trParams = new LinearLayout.LayoutParams(dpToPx(32), dpToPx(18)); + trParams.setMargins(0, dpToPx(16), 0, 0); + transportRect.setLayoutParams(trParams); + transportRect.setGravity(Gravity.CENTER); + transportRect.setAllCaps(true); + transportRect.setTypeface(FontCache.getRobotoMedium(view.getContext())); + transportRect.setTextColor(Color.WHITE); + transportRect.setTextSize(10); + + GradientDrawable shape = new GradientDrawable(); + shape.setShape(GradientDrawable.RECTANGLE); + shape.setCornerRadius(dpToPx(3)); + shape.setColor(route.getColor(mapActivity.getMyApplication(), !light)); + + transportRect.setBackgroundDrawable(shape); + transportRect.setText(route.route.getRef()); + baseView.addView(transportRect); + + LinearLayout infoView = new LinearLayout(view.getContext()); + infoView.setOrientation(LinearLayout.VERTICAL); + LinearLayout.LayoutParams infoViewLayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + infoViewLayoutParams.setMargins(dpToPx(16), dpToPx(12), dpToPx(16), 0); + infoView.setLayoutParams(infoViewLayoutParams); + baseView.addView(infoView); + + TextView titleView = new TextView(view.getContext()); + LinearLayout.LayoutParams titleParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + titleView.setLayoutParams(titleParams); + titleView.setTextSize(16); + titleView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark)); + titleView.setText(route.getDescription(getMapActivity().getMyApplication(), true)); + infoView.addView(titleView); + + LinearLayout typeView = new LinearLayout(view.getContext()); + typeView.setOrientation(LinearLayout.HORIZONTAL); + LinearLayout.LayoutParams typeViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + typeViewParams.setMargins(0, dpToPx(8), 0, 0); + typeView.setGravity(Gravity.CENTER); + typeView.setLayoutParams(typeViewParams); + infoView.addView(typeView); + + ImageView typeImageView = new ImageView(view.getContext()); + LinearLayout.LayoutParams typeImageParams = new LinearLayout.LayoutParams(dpToPx(16), dpToPx(16)); + typeImageParams.setMargins(dpToPx(4), 0, dpToPx(4), 0); + typeImageView.setLayoutParams(typeImageParams); + int drawableResId = route.type == null ? R.drawable.ic_action_polygom_dark : route.type.getResourceId(); + typeImageView.setImageDrawable(getRowIcon(drawableResId)); + typeView.addView(typeImageView); + + TextView typeTextView = new TextView(view.getContext()); + LinearLayout.LayoutParams typeTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + typeTextView.setLayoutParams(typeTextParams); + typeTextView.setText(route.getTypeStrRes()); + typeView.addView(typeTextView); + + baseView.setOnClickListener(listener); + + ((ViewGroup) view).addView(baseView); + + return baseView; + } + + private void buildTransportRouteRow(ViewGroup parent, TransportStopRoute r, OnClickListener listener, boolean showDivider) { + buildTransportRowItem(parent, r, listener); + + if (showDivider) { buildRowDivider(parent); } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java index 701c4d7195..4d2d5b7f98 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java @@ -18,6 +18,7 @@ import net.osmand.plus.mapcontextmenu.OpeningHoursInfo; import net.osmand.plus.mapcontextmenu.builders.FavouritePointMenuBuilder; import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditor; import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragment; +import net.osmand.plus.transport.TransportStopRoute; import net.osmand.util.Algorithms; import java.util.ArrayList; @@ -27,7 +28,7 @@ public class FavouritePointMenuController extends MenuController { private FavouritePoint fav; private MapMarker mapMarker; - private List routes = new ArrayList<>(); + private List routes = new ArrayList<>(); private OpeningHoursInfo openingHoursInfo; public FavouritePointMenuController(MapActivity mapActivity, PointDescription pointDescription, final FavouritePoint fav) { @@ -71,7 +72,7 @@ public class FavouritePointMenuController extends MenuController { } @Override - public List getTransportStopRoutes() { + public List getTransportStopRoutes() { return routes; } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java index deb05a905b..60502b588b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java @@ -36,19 +36,22 @@ public class TransportStopController extends MenuController { PointDescription pointDescription, TransportStop transportStop) { super(new MenuBuilder(mapActivity), pointDescription, mapActivity); this.transportStop = transportStop; - routes = processTransportStop(); - builder.setRoutes(routes); + processRoutes(); } @Override protected void setObject(Object object) { if (object instanceof TransportStop) { this.transportStop = (TransportStop) object; - routes = processTransportStop(); - builder.setRoutes(routes); + processRoutes(); } } + private void processRoutes() { + routes = processTransportStop(); + builder.setRoutes(routes); + } + @Override protected Object getObject() { return transportStop; From 9476bfe3ba4f7cb985ae01554747d72d0411c5fe Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Tue, 26 Dec 2017 15:39:56 +0200 Subject: [PATCH 22/66] Change wikipedia dialog --- .../res/layout/wikipedia_dialog_fragment.xml | 123 +++++----- .../WikipediaDialogFragment.java | 211 ++++++++++++++++-- .../builders/AmenityMenuBuilder.java | 5 +- .../controllers/AmenityMenuController.java | 3 +- 4 files changed, 265 insertions(+), 77 deletions(-) diff --git a/OsmAnd/res/layout/wikipedia_dialog_fragment.xml b/OsmAnd/res/layout/wikipedia_dialog_fragment.xml index 53fb1be62a..4813511f44 100644 --- a/OsmAnd/res/layout/wikipedia_dialog_fragment.xml +++ b/OsmAnd/res/layout/wikipedia_dialog_fragment.xml @@ -1,78 +1,101 @@ - + android:layout_height="wrap_content"> + android:layout_height="wrap_content" + osmand:contentInsetLeft="0dp" + osmand:contentInsetStart="0dp" + osmand:contentInsetRight="0dp" + osmand:contentInsetEnd="0dp"> + android:layout_height="wrap_content"> - + + + + + + + + + + + - - - - - - - - - + android:id="@+id/content" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="@dimen/content_padding"/> + - \ No newline at end of file + + + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java index 33bc455d94..fd523cf1b2 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java @@ -1,38 +1,63 @@ package net.osmand.plus.mapcontextmenu; import android.app.Dialog; +import android.content.Context; +import android.content.Intent; +import android.graphics.drawable.Drawable; +import android.net.Uri; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.design.widget.AppBarLayout; +import android.support.design.widget.CoordinatorLayout; import android.support.v4.app.DialogFragment; -import android.support.v7.widget.Toolbar; +import android.support.v4.content.ContextCompat; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.PopupMenu; +import android.text.Html; import android.text.TextUtils; +import android.util.AttributeSet; +import android.view.Gravity; import android.view.LayoutInflater; +import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageButton; import android.widget.TextView; +import net.osmand.AndroidUtils; import net.osmand.data.Amenity; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; +import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.util.Algorithms; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; + public class WikipediaDialogFragment extends DialogFragment { - public static final String PREFERRED_LANGUAGE = "preferred_language"; + public static final String TAG = "WikipediaDialogFragment"; + private View mainView; private boolean darkTheme; private Amenity amenity; + private String lang; public void setAmenity(Amenity amenity) { this.amenity = amenity; } + public void setLanguage(String lang) { + this.lang = lang; + } + @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setRetainInstance(true); OsmandApplication app = getMyApplication(); darkTheme = app.getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_DARK_THEME; int themeId = darkTheme ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; @@ -52,50 +77,188 @@ public class WikipediaDialogFragment extends DialogFragment { @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - View mainView = inflater.inflate(R.layout.wikipedia_dialog_fragment, container, false); + mainView = inflater.inflate(R.layout.wikipedia_dialog_fragment, container, false); - Toolbar toolbar = (Toolbar) mainView.findViewById(R.id.toolbar); - toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back)); - toolbar.setNavigationOnClickListener(new View.OnClickListener() { + mainView.setBackgroundColor(ContextCompat.getColor(getContext(), darkTheme ? R.color.ctx_menu_bottom_view_bg_dark : R.color.ctx_menu_bottom_view_bg_light)); + + AppBarLayout appBarLayout = (AppBarLayout) mainView.findViewById(R.id.app_bar); + appBarLayout.setBackgroundColor(ContextCompat.getColor(getContext(), darkTheme ? R.color.ctx_menu_buttons_bg_dark: R.color.ctx_menu_buttons_bg_light)); + + int toolbarTextColor = ContextCompat.getColor(getContext(), R.color.dashboard_subheader_text_light); + + ImageButton backButton = (ImageButton) mainView.findViewById(R.id.back_button); + backButton.setImageDrawable(getMyApplication().getIconsCache().getPaintedIcon(R.drawable.ic_arrow_back, toolbarTextColor)); + backButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dismiss(); } }); - String preferredLanguage = ""; - Bundle args = getArguments(); - if (args != null) { - preferredLanguage = args.getString(PREFERRED_LANGUAGE); - } + TextView titleTextView = (TextView) mainView.findViewById(R.id.title_text_view); + titleTextView.setTextColor(toolbarTextColor); - if (TextUtils.isEmpty(preferredLanguage)) { - preferredLanguage = getMyApplication().getLanguage(); - } + final TextView readFullArticleButton = (TextView) mainView.findViewById(R.id.read_full_article); + CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) readFullArticleButton.getLayoutParams(); + params.setBehavior(new CoordinatorLayout.Behavior() { + @Override + public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) { + return dependency instanceof AppBarLayout; + } - final String title = TextUtils.isEmpty(preferredLanguage) ? amenity.getName() : amenity.getName(preferredLanguage); - ((TextView) mainView.findViewById(R.id.title_text_view)).setText(title); + @Override + public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) { + if (dependency instanceof AppBarLayout) { + int readFullArticleButtonHeight = child.getMeasuredHeight(); + if (readFullArticleButtonHeight != 0) { + CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) child.getLayoutParams(); + int viewBottomMargin = lp.bottomMargin; + int distanceToScroll = child.getHeight() + viewBottomMargin; + float ratio = dependency.getY() / readFullArticleButtonHeight; + child.setTranslationY(-distanceToScroll * ratio); + } + } + return true; + } + }); + readFullArticleButton.setLayoutParams(params); + readFullArticleButton.setBackgroundResource(darkTheme ? R.drawable.bt_round_long_night : R.drawable.bt_round_long_day); + int paddingLeft = (int) getResources().getDimension(R.dimen.content_padding_small); + int paddingRight = (int) getResources().getDimension(R.dimen.dialog_content_margin); + readFullArticleButton.setPadding(paddingLeft, 0, paddingRight, 0); + readFullArticleButton.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_world_globe_dark), null, null, null); + readFullArticleButton.setCompoundDrawablePadding(paddingLeft); - String langSelected = amenity.getContentLanguage("content", preferredLanguage, "en"); - if (Algorithms.isEmpty(langSelected)) { - langSelected = "en"; - } - - String content = amenity.getDescription(langSelected); + final TextView selectLanguageTextView = mainView.findViewById(R.id.select_language_text_view); + selectLanguageTextView.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_action_map_language), null, null, null); + selectLanguageTextView.setCompoundDrawablePadding((int) getResources().getDimension(R.dimen.context_menu_padding_margin_small)); return mainView; } + @Override + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { + populateWiki(); + } + @Override public void onDestroyView() { - super.onDestroyView(); Dialog dialog = getDialog(); if (dialog != null) { dialog.setDismissMessage(null); } + super.onDestroyView(); + } + + private void populateWiki() { + if (amenity != null) { + String preferredLanguage = lang; + if (TextUtils.isEmpty(preferredLanguage)) { + preferredLanguage = getMyApplication().getLanguage(); + } + + final String title = TextUtils.isEmpty(preferredLanguage) ? amenity.getName() : amenity.getName(lang); + ((TextView) mainView.findViewById(R.id.title_text_view)).setText(title); + + String lng = amenity.getContentLanguage("content", preferredLanguage, "en"); + if (Algorithms.isEmpty(lng)) { + lng = "en"; + } + + final String langSelected = lng; + + mainView.findViewById(R.id.read_full_article).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + String article = "https://" + langSelected.toLowerCase() + ".wikipedia.org/wiki/" + title.replace(' ', '_'); + Intent i = new Intent(Intent.ACTION_VIEW); + i.setData(Uri.parse(article)); + startActivity(i); + } + }); + + final TextView selectLanguageTextView = mainView.findViewById(R.id.select_language_text_view); + selectLanguageTextView.setText(langSelected); + selectLanguageTextView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + showPopupLangMenu(selectLanguageTextView, langSelected); + } + }); + + String content = amenity.getDescription(langSelected); + + TextView articleTextView = (TextView) mainView.findViewById(R.id.content); + articleTextView.setText(Html.fromHtml(content)); + } + } + + private void showPopupLangMenu(View view, final String langSelected) { + final PopupMenu optionsMenu = new PopupMenu(getContext(), view, Gravity.RIGHT); + Set namesSet = new TreeSet<>(); + namesSet.addAll(amenity.getNames("content", "en")); + namesSet.addAll(amenity.getNames("description", "en")); + + Map names = new HashMap<>(); + for (String n : namesSet) { + names.put(n, FileNameTranslationHelper.getVoiceName(getContext(), n)); + } + String selectedLangName = names.get(langSelected); + if (selectedLangName != null) { + names.remove(langSelected); + } + Map sortedNames = AndroidUtils.sortByValue(names); + + if (selectedLangName != null) { + MenuItem item = optionsMenu.getMenu().add(selectedLangName); + item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + setLanguage(langSelected); + populateWiki(); + return true; + } + }); + } + for (final Map.Entry e : sortedNames.entrySet()) { + MenuItem item = optionsMenu.getMenu().add(e.getValue()); + item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + setLanguage(e.getKey()); + populateWiki(); + return true; + } + }); + } + optionsMenu.show(); + } + + private Drawable getIcon(int resId) { + int colorId = darkTheme ? R.color.ctx_menu_controller_button_text_color_dark_n : R.color.ctx_menu_controller_button_text_color_light_n; + return getMyApplication().getIconsCache().getIcon(resId, colorId); } private OsmandApplication getMyApplication() { return (OsmandApplication) getActivity().getApplication(); } + + public static boolean showInstance(AppCompatActivity activity, Amenity amenity) { + try { + if (!amenity.getType().isWiki()) { + return false; + } + OsmandApplication app = (OsmandApplication) activity.getApplication(); + String lang = app.getSettings().MAP_PREFERRED_LOCALE.get(); + + WikipediaDialogFragment wikipediaDialogFragment = new WikipediaDialogFragment(); + wikipediaDialogFragment.setAmenity(amenity); + wikipediaDialogFragment.setLanguage(lang); + wikipediaDialogFragment.setRetainInstance(true); + wikipediaDialogFragment.show(activity.getSupportFragmentManager(), TAG); + return true; + } catch (RuntimeException e) { + return false; + } + } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java index fb33160461..ec6cba3305 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -32,6 +32,7 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.FontCache; import net.osmand.plus.mapcontextmenu.MenuBuilder; +import net.osmand.plus.mapcontextmenu.WikipediaDialogFragment; import net.osmand.plus.osmedit.OsmEditingPlugin; import net.osmand.plus.views.POIMapLayer; import net.osmand.plus.widgets.TextViewEx; @@ -235,7 +236,7 @@ public class AmenityMenuBuilder extends MenuBuilder { button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - POIMapLayer.showWikipediaDialog(view.getContext(), app, amenity); + WikipediaDialogFragment.showInstance(mapActivity, amenity); } }); button.setAllCaps(true); @@ -285,7 +286,7 @@ public class AmenityMenuBuilder extends MenuBuilder { ll.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - POIMapLayer.showWikipediaDialog(view.getContext(), app, amenity); + WikipediaDialogFragment.showInstance(mapActivity, amenity); } }); } else if (isText && text.length() > 200) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java index 3bf9257b97..be7b689bee 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java @@ -15,6 +15,7 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.mapcontextmenu.MenuController; import net.osmand.plus.mapcontextmenu.OpeningHoursInfo; +import net.osmand.plus.mapcontextmenu.WikipediaDialogFragment; import net.osmand.plus.mapcontextmenu.builders.AmenityMenuBuilder; import net.osmand.plus.transport.TransportStopRoute; import net.osmand.plus.render.RenderingIcons; @@ -69,7 +70,7 @@ public class AmenityMenuController extends MenuController { leftTitleButtonController = new TitleButtonController() { @Override public void buttonPressed() { - POIMapLayer.showWikipediaDialog(mapActivity, mapActivity.getMyApplication(), amenity); + WikipediaDialogFragment.showInstance(mapActivity, amenity); } }; leftTitleButtonController.caption = getMapActivity().getString(R.string.context_menu_read_article); From 787588283e46e54e6ccb970931d0b4056eec6845 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Tue, 26 Dec 2017 15:43:10 +0200 Subject: [PATCH 23/66] Remove unnecessary code --- .../net/osmand/plus/views/POIMapLayer.java | 170 ------------------ 1 file changed, 170 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java index 9bad7b4a95..0d5ccd85be 100644 --- a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java @@ -290,13 +290,6 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon return true; } - public static void showWikipediaDialog(Context ctx, OsmandApplication app, Amenity a) { - String lang = app.getSettings().MAP_PREFERRED_LOCALE.get(); - if (a.getType().isWiki()) { - showWiki(ctx, app, a, lang); - } - } - public static void showDescriptionDialog(Context ctx, OsmandApplication app, String text, String title) { showText(ctx, app, text, title); } @@ -309,125 +302,6 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon ctx.getTheme().resolveAttribute(attr, typedvalueattr, true); return typedvalueattr.resourceId; } - - - @SuppressWarnings("deprecation") - private static void showWiki(final Context ctx, final OsmandApplication app, final Amenity a, final String lang) { - String preferredLang = lang; - if (Algorithms.isEmpty(preferredLang)) { - preferredLang = app.getLanguage(); - } - final Dialog dialog = new Dialog(ctx, - app.getSettings().isLightContent() ? - R.style.OsmandLightTheme : - R.style.OsmandDarkTheme); - final String title = Algorithms.isEmpty(preferredLang) ? a.getName() : a.getName(preferredLang); - LinearLayout ll = new LinearLayout(ctx); - ll.setOrientation(LinearLayout.VERTICAL); - - final Toolbar topBar = new Toolbar(ctx); - topBar.setClickable(true); - Drawable back = app.getIconsCache().getIcon(R.drawable.ic_arrow_back); - topBar.setNavigationIcon(back); - topBar.setNavigationContentDescription(R.string.access_shared_string_navigate_up); - topBar.setTitle(title); - topBar.setBackgroundColor(ContextCompat.getColor(ctx, getResIdFromAttribute(ctx, R.attr.pstsTabBackground))); - topBar.setTitleTextColor(ContextCompat.getColor(ctx, getResIdFromAttribute(ctx, R.attr.pstsTextColor))); - - String lng = a.getContentLanguage("content", preferredLang, "en"); - if (Algorithms.isEmpty(lng)) { - lng = "en"; - } - - final String langSelected = lng; - String content = a.getDescription(langSelected); - final Button bottomBar = new Button(ctx); - bottomBar.setText(R.string.read_full_article); - bottomBar.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - String article = "https://" + langSelected.toLowerCase() + ".wikipedia.org/wiki/" + title.replace(' ', '_'); - Intent i = new Intent(Intent.ACTION_VIEW); - i.setData(Uri.parse(article)); - ctx.startActivity(i); - } - }); - MenuItem mi = topBar.getMenu().add(langSelected.toUpperCase()).setOnMenuItemClickListener(new OnMenuItemClickListener() { - @Override - public boolean onMenuItemClick(final MenuItem item) { - showPopupLangMenu(ctx, topBar, app, a, dialog, langSelected); - return true; - } - }); - MenuItemCompat.setShowAsAction(mi, MenuItem.SHOW_AS_ACTION_ALWAYS); - topBar.setNavigationOnClickListener(new View.OnClickListener() { - @Override - public void onClick(final View v) { - dialog.dismiss(); - } - }); - final WebView wv = new WebView(ctx); - final TextView textView = new TextView(ctx); - WebSettings settings = wv.getSettings(); - settings.setDefaultTextEncodingName("utf-8"); - - settings.setBuiltInZoomControls(true); - settings.setDisplayZoomControls(false); - settings.setSupportZoom(true); - - //Scale web view font size with system font size - float scale = ctx.getResources().getConfiguration().fontScale; - if (android.os.Build.VERSION.SDK_INT >= 14) { - settings.setTextZoom((int) (scale * 100f)); - } else { - if (scale <= 0.7f) { - settings.setTextSize(WebSettings.TextSize.SMALLEST); - } else if (scale <= 0.85f) { - settings.setTextSize(WebSettings.TextSize.SMALLER); - } else if (scale <= 1.0f) { - settings.setTextSize(WebSettings.TextSize.NORMAL); - } else if (scale <= 1.15f) { - settings.setTextSize(WebSettings.TextSize.LARGER); - } else { - settings.setTextSize(WebSettings.TextSize.LARGEST); - } - } - - textView.setText(Html.fromHtml(content)); - wv.loadDataWithBaseURL(null, content, "text/html", "UTF-8", null); -// wv.loadUrl(OsMoService.SIGN_IN_URL + app.getSettings().OSMO_DEVICE_KEY.get()); - //For pinch zooming to work WebView must not be inside ScrollView - //ScrollView scrollView = new ScrollView(ctx); - ll.addView(topBar); - LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0); - lp.weight = 1; - //ll.addView(scrollView, lp); - //scrollView.addView(wv); -// ll.addView(wv, lp); - ll.addView(textView, lp); - ll.addView(bottomBar, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); - dialog.setContentView(ll); - textView.setFocusable(true); - textView.setFocusableInTouchMode(true); - textView.requestFocus(View.FOCUS_DOWN); - textView.setOnTouchListener(new View.OnTouchListener() { - @Override - public boolean onTouch(View v, MotionEvent event) { - switch (event.getAction()) { - case MotionEvent.ACTION_DOWN: - case MotionEvent.ACTION_UP: - if (!v.hasFocus()) { - v.requestFocus(); - } - break; - } - return false; - } - }); - - dialog.setCancelable(true); - dialog.show(); - } private static void showText(final Context ctx, final OsmandApplication app, final String text, String title) { final Dialog dialog = new Dialog(ctx, @@ -475,50 +349,6 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon dialog.show(); } - protected static void showPopupLangMenu(final Context ctx, Toolbar tb, - final OsmandApplication app, final Amenity a, - final Dialog dialog, final String langSelected) { - final PopupMenu optionsMenu = new PopupMenu(ctx, tb, Gravity.RIGHT); - Set namesSet = new TreeSet<>(); - namesSet.addAll(a.getNames("content", "en")); - namesSet.addAll(a.getNames("description", "en")); - - Map names = new HashMap<>(); - for (String n : namesSet) { - names.put(n, FileNameTranslationHelper.getVoiceName(ctx, n)); - } - String selectedLangName = names.get(langSelected); - if (selectedLangName != null) { - names.remove(langSelected); - } - Map sortedNames = AndroidUtils.sortByValue(names); - - if (selectedLangName != null) { - MenuItem item = optionsMenu.getMenu().add(selectedLangName); - item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { - @Override - public boolean onMenuItemClick(MenuItem item) { - dialog.dismiss(); - showWiki(ctx, app, a, langSelected); - return true; - } - }); - } - for (final Map.Entry e : sortedNames.entrySet()) { - MenuItem item = optionsMenu.getMenu().add(e.getValue()); - item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { - @Override - public boolean onMenuItemClick(MenuItem item) { - dialog.dismiss(); - showWiki(ctx, app, a, e.getKey()); - return true; - } - }); - } - optionsMenu.show(); - - } - @Override public PointDescription getObjectName(Object o) { if (o instanceof Amenity) { From 011378b19f11adaacedc7516340f0cb7fd293ca0 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Tue, 26 Dec 2017 15:46:27 +0200 Subject: [PATCH 24/66] Change background in multi selection menu --- .../plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java | 1 - 1 file changed, 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java index 79fe4c1d08..960d74ad35 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java @@ -38,7 +38,6 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter Date: Tue, 26 Dec 2017 15:50:42 +0200 Subject: [PATCH 25/66] Change icons --- .../osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java | 2 +- .../plus/mapcontextmenu/controllers/AmenityMenuController.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java index ec6cba3305..8af8d7f24f 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -241,7 +241,7 @@ public class AmenityMenuBuilder extends MenuBuilder { }); button.setAllCaps(true); button.setText(R.string.context_menu_read_full_article); - Drawable compoundDrawable = app.getIconsCache().getIcon(R.drawable.ic_action_note_dark, light ? R.color.ctx_menu_controller_button_text_color_light_n : R.color.ctx_menu_controller_button_text_color_dark_n); + Drawable compoundDrawable = app.getIconsCache().getIcon(R.drawable.ic_action_read_text, light ? R.color.ctx_menu_controller_button_text_color_light_n : R.color.ctx_menu_controller_button_text_color_dark_n); button.setCompoundDrawablesWithIntrinsicBounds(compoundDrawable, null, null, null); button.setCompoundDrawablePadding(dpToPx(8f)); llText.addView(button); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java index be7b689bee..4a448ca60e 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java @@ -74,7 +74,7 @@ public class AmenityMenuController extends MenuController { } }; leftTitleButtonController.caption = getMapActivity().getString(R.string.context_menu_read_article); - leftTitleButtonController.leftIcon = getIcon(R.drawable.ic_action_note_dark, isLight() ? R.color.ctx_menu_controller_button_text_color_light_n : R.color.ctx_menu_controller_button_text_color_dark_n); + leftTitleButtonController.leftIcon = getIcon(R.drawable.ic_action_read_text, isLight() ? R.color.ctx_menu_controller_button_text_color_light_n : R.color.ctx_menu_controller_button_text_color_dark_n); } openingHoursInfo = processOpeningHours(amenity); From 4e62b6450060ec1bc433cf71163a0f755a4ff1a1 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Tue, 26 Dec 2017 16:21:55 +0200 Subject: [PATCH 26/66] Fix colors --- OsmAnd/res/values/colors.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml index dd9eae0d60..39642f818c 100644 --- a/OsmAnd/res/values/colors.xml +++ b/OsmAnd/res/values/colors.xml @@ -341,7 +341,7 @@ #ffffff #17191a #b3b3b3 - #536dfe + #454a4d #212121 #cccccc #a6a6a6 @@ -349,7 +349,7 @@ #5baf3f #c66545 #f2f2f2 - #536dfe + #222526 #536dfe #d28521 From 2dd4d361c44d3cc9909b3d3876c83b612b1d7831 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 27 Dec 2017 11:34:58 +0200 Subject: [PATCH 27/66] Make wikipedia dark when night mode is active --- .../res/layout/wikipedia_dialog_fragment.xml | 8 ++--- .../WikipediaDialogFragment.java | 31 +++++++++++++------ 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/OsmAnd/res/layout/wikipedia_dialog_fragment.xml b/OsmAnd/res/layout/wikipedia_dialog_fragment.xml index 4813511f44..43821b1e5e 100644 --- a/OsmAnd/res/layout/wikipedia_dialog_fragment.xml +++ b/OsmAnd/res/layout/wikipedia_dialog_fragment.xml @@ -35,7 +35,7 @@ style="@style/Widget.AppCompat.ActionButton" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:src="@drawable/ic_arrow_back"/> + tools:src="@drawable/ic_arrow_back"/> @@ -96,6 +96,6 @@ android:text="@string/read_full_article" android:gravity="center_vertical" android:textAllCaps="true" - android:textColor="?attr/ctx_menu_controller_text_color"/> + tools:textColor="?attr/ctx_menu_controller_text_color"/> \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java index fd523cf1b2..f33b84be19 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java @@ -1,8 +1,8 @@ package net.osmand.plus.mapcontextmenu; import android.app.Dialog; -import android.content.Context; import android.content.Intent; +import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; @@ -16,7 +16,6 @@ import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.PopupMenu; import android.text.Html; import android.text.TextUtils; -import android.util.AttributeSet; import android.view.Gravity; import android.view.LayoutInflater; import android.view.MenuItem; @@ -43,7 +42,7 @@ public class WikipediaDialogFragment extends DialogFragment { public static final String TAG = "WikipediaDialogFragment"; private View mainView; - private boolean darkTheme; + private boolean darkMode; private Amenity amenity; private String lang; @@ -59,8 +58,8 @@ public class WikipediaDialogFragment extends DialogFragment { public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); OsmandApplication app = getMyApplication(); - darkTheme = app.getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_DARK_THEME; - int themeId = darkTheme ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; + darkMode = app.getDaynightHelper().isNightMode(); + int themeId = darkMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; setStyle(STYLE_NO_FRAME, themeId); } @@ -79,10 +78,10 @@ public class WikipediaDialogFragment extends DialogFragment { public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { mainView = inflater.inflate(R.layout.wikipedia_dialog_fragment, container, false); - mainView.setBackgroundColor(ContextCompat.getColor(getContext(), darkTheme ? R.color.ctx_menu_bottom_view_bg_dark : R.color.ctx_menu_bottom_view_bg_light)); + mainView.setBackgroundColor(ContextCompat.getColor(getContext(), darkMode ? R.color.ctx_menu_bottom_view_bg_dark : R.color.ctx_menu_bottom_view_bg_light)); AppBarLayout appBarLayout = (AppBarLayout) mainView.findViewById(R.id.app_bar); - appBarLayout.setBackgroundColor(ContextCompat.getColor(getContext(), darkTheme ? R.color.ctx_menu_buttons_bg_dark: R.color.ctx_menu_buttons_bg_light)); + appBarLayout.setBackgroundColor(ContextCompat.getColor(getContext(), darkMode ? R.color.ctx_menu_buttons_bg_dark: R.color.ctx_menu_buttons_bg_light)); int toolbarTextColor = ContextCompat.getColor(getContext(), R.color.dashboard_subheader_text_light); @@ -98,6 +97,17 @@ public class WikipediaDialogFragment extends DialogFragment { TextView titleTextView = (TextView) mainView.findViewById(R.id.title_text_view); titleTextView.setTextColor(toolbarTextColor); + ColorStateList buttonColorStateList = new ColorStateList( + new int[][]{ + new int[]{android.R.attr.state_pressed}, + new int[]{} + }, + new int[] { + getResources().getColor(darkMode ? R.color.ctx_menu_controller_button_text_color_dark_p : R.color.ctx_menu_controller_button_text_color_light_p), + getResources().getColor(darkMode ? R.color.ctx_menu_controller_button_text_color_dark_n : R.color.ctx_menu_controller_button_text_color_light_n) + } + ); + final TextView readFullArticleButton = (TextView) mainView.findViewById(R.id.read_full_article); CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) readFullArticleButton.getLayoutParams(); params.setBehavior(new CoordinatorLayout.Behavior() { @@ -122,7 +132,8 @@ public class WikipediaDialogFragment extends DialogFragment { } }); readFullArticleButton.setLayoutParams(params); - readFullArticleButton.setBackgroundResource(darkTheme ? R.drawable.bt_round_long_night : R.drawable.bt_round_long_day); + readFullArticleButton.setBackgroundResource(darkMode ? R.drawable.bt_round_long_night : R.drawable.bt_round_long_day); + readFullArticleButton.setTextColor(buttonColorStateList); int paddingLeft = (int) getResources().getDimension(R.dimen.content_padding_small); int paddingRight = (int) getResources().getDimension(R.dimen.dialog_content_margin); readFullArticleButton.setPadding(paddingLeft, 0, paddingRight, 0); @@ -130,8 +141,10 @@ public class WikipediaDialogFragment extends DialogFragment { readFullArticleButton.setCompoundDrawablePadding(paddingLeft); final TextView selectLanguageTextView = mainView.findViewById(R.id.select_language_text_view); + selectLanguageTextView.setTextColor(buttonColorStateList); selectLanguageTextView.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_action_map_language), null, null, null); selectLanguageTextView.setCompoundDrawablePadding((int) getResources().getDimension(R.dimen.context_menu_padding_margin_small)); + selectLanguageTextView.setBackgroundResource(darkMode ? R.drawable.context_menu_controller_bg_dark : R.drawable.context_menu_controller_bg_light); return mainView; } @@ -235,7 +248,7 @@ public class WikipediaDialogFragment extends DialogFragment { } private Drawable getIcon(int resId) { - int colorId = darkTheme ? R.color.ctx_menu_controller_button_text_color_dark_n : R.color.ctx_menu_controller_button_text_color_light_n; + int colorId = darkMode ? R.color.ctx_menu_controller_button_text_color_dark_n : R.color.ctx_menu_controller_button_text_color_light_n; return getMyApplication().getIconsCache().getIcon(resId, colorId); } From bac9180bc06c5ca195c472ce517c505854a3bf33 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 27 Dec 2017 12:14:21 +0200 Subject: [PATCH 28/66] Increase wikipedia article font size --- .../plus/mapcontextmenu/WikipediaDialogFragment.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java index f33b84be19..c52f52e434 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java @@ -15,7 +15,12 @@ import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.PopupMenu; import android.text.Html; +import android.text.Spannable; +import android.text.SpannableString; +import android.text.Spanned; import android.text.TextUtils; +import android.text.style.ForegroundColorSpan; +import android.text.style.RelativeSizeSpan; import android.view.Gravity; import android.view.LayoutInflater; import android.view.MenuItem; @@ -202,7 +207,10 @@ public class WikipediaDialogFragment extends DialogFragment { String content = amenity.getDescription(langSelected); TextView articleTextView = (TextView) mainView.findViewById(R.id.content); - articleTextView.setText(Html.fromHtml(content)); + Spannable spannableContent = new SpannableString(Html.fromHtml(content)); + int length = spannableContent.length(); + spannableContent.setSpan(new RelativeSizeSpan(1.2f), 0, length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + articleTextView.setText(spannableContent); } } From f0f518d5cc4d62a01e2e35ec2902f74c67f2c1ee Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 27 Dec 2017 12:18:35 +0200 Subject: [PATCH 29/66] Change wikipedia title text size --- OsmAnd/res/layout/wikipedia_dialog_fragment.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/res/layout/wikipedia_dialog_fragment.xml b/OsmAnd/res/layout/wikipedia_dialog_fragment.xml index 43821b1e5e..0926fef2ba 100644 --- a/OsmAnd/res/layout/wikipedia_dialog_fragment.xml +++ b/OsmAnd/res/layout/wikipedia_dialog_fragment.xml @@ -66,6 +66,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="@dimen/content_padding" + android:textSize="@dimen/map_button_text_size" tools:text="Title"/> From 02bed4bce0b49404cdfc2bdf1905a32083f84357 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 27 Dec 2017 12:43:54 +0200 Subject: [PATCH 30/66] Change select language wikipedia button bg --- .../res/drawable/wikipedia_select_lang_bg_dark.xml | 5 +++++ .../drawable/wikipedia_select_lang_bg_dark_n.xml | 13 +++++++++++++ .../drawable/wikipedia_select_lang_bg_dark_p.xml | 13 +++++++++++++ .../res/drawable/wikipedia_select_lang_bg_light.xml | 5 +++++ .../drawable/wikipedia_select_lang_bg_light_n.xml | 13 +++++++++++++ .../drawable/wikipedia_select_lang_bg_light_p.xml | 13 +++++++++++++ .../mapcontextmenu/WikipediaDialogFragment.java | 2 +- 7 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 OsmAnd/res/drawable/wikipedia_select_lang_bg_dark.xml create mode 100644 OsmAnd/res/drawable/wikipedia_select_lang_bg_dark_n.xml create mode 100644 OsmAnd/res/drawable/wikipedia_select_lang_bg_dark_p.xml create mode 100644 OsmAnd/res/drawable/wikipedia_select_lang_bg_light.xml create mode 100644 OsmAnd/res/drawable/wikipedia_select_lang_bg_light_n.xml create mode 100644 OsmAnd/res/drawable/wikipedia_select_lang_bg_light_p.xml diff --git a/OsmAnd/res/drawable/wikipedia_select_lang_bg_dark.xml b/OsmAnd/res/drawable/wikipedia_select_lang_bg_dark.xml new file mode 100644 index 0000000000..c990c9567f --- /dev/null +++ b/OsmAnd/res/drawable/wikipedia_select_lang_bg_dark.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/wikipedia_select_lang_bg_dark_n.xml b/OsmAnd/res/drawable/wikipedia_select_lang_bg_dark_n.xml new file mode 100644 index 0000000000..75c6e965c3 --- /dev/null +++ b/OsmAnd/res/drawable/wikipedia_select_lang_bg_dark_n.xml @@ -0,0 +1,13 @@ + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/wikipedia_select_lang_bg_dark_p.xml b/OsmAnd/res/drawable/wikipedia_select_lang_bg_dark_p.xml new file mode 100644 index 0000000000..2cbe3de5a5 --- /dev/null +++ b/OsmAnd/res/drawable/wikipedia_select_lang_bg_dark_p.xml @@ -0,0 +1,13 @@ + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/wikipedia_select_lang_bg_light.xml b/OsmAnd/res/drawable/wikipedia_select_lang_bg_light.xml new file mode 100644 index 0000000000..aa66c087f7 --- /dev/null +++ b/OsmAnd/res/drawable/wikipedia_select_lang_bg_light.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/wikipedia_select_lang_bg_light_n.xml b/OsmAnd/res/drawable/wikipedia_select_lang_bg_light_n.xml new file mode 100644 index 0000000000..12cfbb48c9 --- /dev/null +++ b/OsmAnd/res/drawable/wikipedia_select_lang_bg_light_n.xml @@ -0,0 +1,13 @@ + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/wikipedia_select_lang_bg_light_p.xml b/OsmAnd/res/drawable/wikipedia_select_lang_bg_light_p.xml new file mode 100644 index 0000000000..db337bcee9 --- /dev/null +++ b/OsmAnd/res/drawable/wikipedia_select_lang_bg_light_p.xml @@ -0,0 +1,13 @@ + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java index c52f52e434..7e06f1ba27 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java @@ -149,7 +149,7 @@ public class WikipediaDialogFragment extends DialogFragment { selectLanguageTextView.setTextColor(buttonColorStateList); selectLanguageTextView.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_action_map_language), null, null, null); selectLanguageTextView.setCompoundDrawablePadding((int) getResources().getDimension(R.dimen.context_menu_padding_margin_small)); - selectLanguageTextView.setBackgroundResource(darkMode ? R.drawable.context_menu_controller_bg_dark : R.drawable.context_menu_controller_bg_light); + selectLanguageTextView.setBackgroundResource(darkMode ? R.drawable.wikipedia_select_lang_bg_dark : R.drawable.wikipedia_select_lang_bg_light); return mainView; } From d82f45f41fed7b46097be832be3e199bcd586fd1 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 27 Dec 2017 12:54:17 +0200 Subject: [PATCH 31/66] Styling read full article button --- OsmAnd/res/layout/wikipedia_dialog_fragment.xml | 3 ++- OsmAnd/res/values-large/sizes.xml | 2 ++ OsmAnd/res/values/sizes.xml | 2 ++ .../osmand/plus/mapcontextmenu/WikipediaDialogFragment.java | 4 ++-- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/layout/wikipedia_dialog_fragment.xml b/OsmAnd/res/layout/wikipedia_dialog_fragment.xml index 0926fef2ba..9b37a95707 100644 --- a/OsmAnd/res/layout/wikipedia_dialog_fragment.xml +++ b/OsmAnd/res/layout/wikipedia_dialog_fragment.xml @@ -87,7 +87,8 @@ android:padding="@dimen/content_padding"/> - 78dp + 29dp + \ No newline at end of file diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml index 8f73163ed6..4b9bdbe7da 100644 --- a/OsmAnd/res/values/sizes.xml +++ b/OsmAnd/res/values/sizes.xml @@ -247,4 +247,6 @@ 48dp 52dp + + 19dp \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java index 7e06f1ba27..8cc8337dbb 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java @@ -139,11 +139,11 @@ public class WikipediaDialogFragment extends DialogFragment { readFullArticleButton.setLayoutParams(params); readFullArticleButton.setBackgroundResource(darkMode ? R.drawable.bt_round_long_night : R.drawable.bt_round_long_day); readFullArticleButton.setTextColor(buttonColorStateList); - int paddingLeft = (int) getResources().getDimension(R.dimen.content_padding_small); + int paddingLeft = (int) getResources().getDimension(R.dimen.wikipedia_button_left_padding); int paddingRight = (int) getResources().getDimension(R.dimen.dialog_content_margin); readFullArticleButton.setPadding(paddingLeft, 0, paddingRight, 0); readFullArticleButton.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_world_globe_dark), null, null, null); - readFullArticleButton.setCompoundDrawablePadding(paddingLeft); + readFullArticleButton.setCompoundDrawablePadding((int) getResources().getDimension(R.dimen.content_padding_small)); final TextView selectLanguageTextView = mainView.findViewById(R.id.select_language_text_view); selectLanguageTextView.setTextColor(buttonColorStateList); From 305d877af0002fca1db31fb896bb2d74c2ea8919 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 27 Dec 2017 13:12:40 +0200 Subject: [PATCH 32/66] Fix controller buttons in context menu --- .../res/layout/map_context_menu_fragment.xml | 20 +++++++------- .../MapContextMenuFragment.java | 26 +++++++++++++++++-- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml index ff429d7ff2..1a06c0837a 100644 --- a/OsmAnd/res/layout/map_context_menu_fragment.xml +++ b/OsmAnd/res/layout/map_context_menu_fragment.xml @@ -158,7 +158,7 @@ android:layout_marginLeft="@dimen/context_menu_padding_margin_small" android:layout_marginRight="@dimen/context_menu_padding_margin_small" android:id="@+id/title_button_view" - android:background="?attr/ctx_menu_controller_bg" + tools:background="?attr/ctx_menu_controller_bg" android:layout_width="0dp" android:layout_weight="1" android:layout_height="@dimen/context_menu_controller_height" @@ -175,7 +175,7 @@ android:paddingRight="@dimen/context_menu_button_padding_x" android:textAllCaps="true" android:text="@string/recording_context_menu_play" - android:textColor="?attr/ctx_menu_controller_text_color" + tools:textColor="?attr/ctx_menu_controller_text_color" android:textSize="@dimen/default_desc_text_size"/> @@ -229,7 +229,7 @@ @@ -296,7 +296,7 @@ android:layout_marginLeft="@dimen/context_menu_padding_margin_small" android:layout_marginRight="@dimen/context_menu_padding_margin_small" android:layout_weight="1" - android:background="?attr/ctx_menu_controller_bg"> + tools:background="?attr/ctx_menu_controller_bg"> diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index d49e32f9be..dfec7917a6 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -3,6 +3,7 @@ package net.osmand.plus.mapcontextmenu; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.annotation.TargetApi; +import android.content.res.ColorStateList; import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.os.Build; @@ -150,8 +151,21 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo mapZoom = map.getZoom(); } + ColorStateList buttonColorStateList = new ColorStateList( + new int[][]{ + new int[]{android.R.attr.state_pressed}, + new int[]{} + }, + new int[] { + getResources().getColor(nightMode ? R.color.ctx_menu_controller_button_text_color_dark_p : R.color.ctx_menu_controller_button_text_color_light_p), + getResources().getColor(nightMode ? R.color.ctx_menu_controller_button_text_color_dark_n : R.color.ctx_menu_controller_button_text_color_light_n) + } + ); + // Left title button final View leftTitleButtonView = view.findViewById(R.id.title_button_view); + ((TextView) leftTitleButtonView.findViewById(R.id.title_button)).setTextColor(buttonColorStateList); + leftTitleButtonView.setBackgroundResource(nightMode ? R.drawable.context_menu_controller_bg_dark : R.drawable.context_menu_controller_bg_light); leftTitleButtonView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -164,6 +178,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo // Right title button final View rightTitleButtonView = view.findViewById(R.id.title_button_right_view); + ((TextView) rightTitleButtonView.findViewById(R.id.title_button_right)).setTextColor(buttonColorStateList); + rightTitleButtonView.setBackgroundResource(nightMode ? R.drawable.context_menu_controller_bg_dark : R.drawable.context_menu_controller_bg_light); rightTitleButtonView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -176,6 +192,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo // Left download button final View leftDownloadButtonView = view.findViewById(R.id.download_button_left_view); + ((TextView) leftDownloadButtonView.findViewById(R.id.download_button_left)).setTextColor(buttonColorStateList); + leftDownloadButtonView.setBackgroundResource(nightMode ? R.drawable.context_menu_controller_bg_dark : R.drawable.context_menu_controller_bg_light); leftDownloadButtonView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -188,6 +206,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo // Right download button final View rightDownloadButtonView = (View) view.findViewById(R.id.download_button_right_view); + ((TextView) rightDownloadButtonView.findViewById(R.id.download_button_right)).setTextColor(buttonColorStateList); + rightDownloadButtonView.setBackgroundResource(nightMode ? R.drawable.context_menu_controller_bg_dark : R.drawable.context_menu_controller_bg_light); rightDownloadButtonView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -199,8 +219,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo }); // Bottom title button - final View bottomTitleButton = view.findViewById(R.id.title_button_bottom_view); - bottomTitleButton.setOnClickListener(new View.OnClickListener() { + final View bottomTitleButtonView = view.findViewById(R.id.title_button_bottom_view); + ((TextView) bottomTitleButtonView.findViewById(R.id.title_button_bottom)).setTextColor(buttonColorStateList); + bottomTitleButtonView.setBackgroundResource(nightMode ? R.drawable.context_menu_controller_bg_dark : R.drawable.context_menu_controller_bg_light); + bottomTitleButtonView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { TitleButtonController bottomTitleButtonController = menu.getBottomTitleButtonController(); From 4a126badb5cb77e81552fcd2df69c7f20ce00125 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 27 Dec 2017 15:25:29 +0200 Subject: [PATCH 33/66] Add custom tabs for displaying wikipedia article --- OsmAnd/AndroidManifest.xml | 2 +- OsmAnd/build.gradle | 1 + .../WikipediaDialogFragment.java | 22 ++++++++++++++----- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml index 145d61cedf..fdb7ebdf55 100644 --- a/OsmAnd/AndroidManifest.xml +++ b/OsmAnd/AndroidManifest.xml @@ -40,7 +40,7 @@ + tools:overrideLibrary="com.getkeepsafe.taptargetview, studio.carbonylgroup.textfieldboxes, android.support.customtabs"/> diff --git a/OsmAnd/build.gradle b/OsmAnd/build.gradle index 409fe53919..de30ccf70a 100644 --- a/OsmAnd/build.gradle +++ b/OsmAnd/build.gradle @@ -389,6 +389,7 @@ dependencies { compile 'com.android.support:cardview-v7:26.1.0' compile 'com.android.support:appcompat-v7:26.1.0' compile 'com.android.support:design:26.1.0' + compile 'com.android.support:customtabs:26.1.0' compile fileTree(include: ['*.jar'], exclude: ['QtAndroid-bundled.jar', 'QtAndroidAccessibility-bundled.jar', 'OsmAndCore_android.jar', 'OsmAndCore_wrapper.jar', 'android-support-multidex.jar'], dir: 'libs') legacyCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@jar" qtcoredebugCompile "net.osmand:OsmAndCore_androidNativeDebug:0.1-SNAPSHOT@aar" diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java index 8cc8337dbb..292082ab93 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java @@ -5,9 +5,11 @@ import android.content.Intent; import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.customtabs.CustomTabsIntent; import android.support.design.widget.AppBarLayout; import android.support.design.widget.CoordinatorLayout; import android.support.v4.app.DialogFragment; @@ -17,9 +19,7 @@ import android.support.v7.widget.PopupMenu; import android.text.Html; import android.text.Spannable; import android.text.SpannableString; -import android.text.Spanned; import android.text.TextUtils; -import android.text.style.ForegroundColorSpan; import android.text.style.RelativeSizeSpan; import android.view.Gravity; import android.view.LayoutInflater; @@ -32,7 +32,6 @@ import android.widget.TextView; import net.osmand.AndroidUtils; import net.osmand.data.Amenity; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.util.Algorithms; @@ -189,9 +188,7 @@ public class WikipediaDialogFragment extends DialogFragment { @Override public void onClick(View view) { String article = "https://" + langSelected.toLowerCase() + ".wikipedia.org/wiki/" + title.replace(' ', '_'); - Intent i = new Intent(Intent.ACTION_VIEW); - i.setData(Uri.parse(article)); - startActivity(i); + showFullArticle(Uri.parse(article)); } }); @@ -214,6 +211,19 @@ public class WikipediaDialogFragment extends DialogFragment { } } + private void showFullArticle(Uri uri) { + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH) { + CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder() + .setToolbarColor(ContextCompat.getColor(getContext(), darkMode ? R.color.actionbar_dark_color : R.color.actionbar_light_color)) + .build(); + customTabsIntent.launchUrl(getContext(), uri); + } else { + Intent i = new Intent(Intent.ACTION_VIEW); + i.setData(uri); + startActivity(i); + } + } + private void showPopupLangMenu(View view, final String langSelected) { final PopupMenu optionsMenu = new PopupMenu(getContext(), view, Gravity.RIGHT); Set namesSet = new TreeSet<>(); From 73328e0d6595a06e9fba7a6ec80675e8b2eec9b5 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 27 Dec 2017 15:33:20 +0200 Subject: [PATCH 34/66] Change article text color --- .../osmand/plus/mapcontextmenu/WikipediaDialogFragment.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java index 292082ab93..49c4cacc58 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java @@ -20,6 +20,7 @@ import android.text.Html; import android.text.Spannable; import android.text.SpannableString; import android.text.TextUtils; +import android.text.style.ForegroundColorSpan; import android.text.style.RelativeSizeSpan; import android.view.Gravity; import android.view.LayoutInflater; @@ -207,6 +208,8 @@ public class WikipediaDialogFragment extends DialogFragment { Spannable spannableContent = new SpannableString(Html.fromHtml(content)); int length = spannableContent.length(); spannableContent.setSpan(new RelativeSizeSpan(1.2f), 0, length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + int contentTextColor = ContextCompat.getColor(getContext(), darkMode ? R.color.ctx_menu_bottom_view_text_color_dark : R.color.ctx_menu_bottom_view_text_color_light); + spannableContent.setSpan(new ForegroundColorSpan(contentTextColor), 0, length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); articleTextView.setText(spannableContent); } } From 45a106d89a3d48fc0d1ba5b5c0bdebf576b250d7 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 27 Dec 2017 15:46:22 +0200 Subject: [PATCH 35/66] Display distance in osm edits --- .../src/net/osmand/plus/osmedit/EditPOIMenuController.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java index 0a2de925a2..071b3cd7cd 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java @@ -126,6 +126,11 @@ public class EditPOIMenuController extends MenuController { return !Algorithms.isEmpty(category); } + @Override + public boolean displayDistanceDirection() { + return true; + } + @Override public String getAdditionalInfoStr() { return actionStr; From 16c733d72605a5753972d196c9eb71b275a94a3d Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 27 Dec 2017 17:02:33 +0200 Subject: [PATCH 36/66] Display size in map download controller and change buttons --- .../res/layout/map_context_menu_fragment.xml | 4 +- .../controllers/MapDataMenuController.java | 74 ++++++++++++++----- 2 files changed, 56 insertions(+), 22 deletions(-) diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml index 1a06c0837a..1966edc6b6 100644 --- a/OsmAnd/res/layout/map_context_menu_fragment.xml +++ b/OsmAnd/res/layout/map_context_menu_fragment.xml @@ -271,7 +271,7 @@ android:gravity="center_vertical" android:paddingLeft="@dimen/context_menu_button_padding_x" android:paddingRight="@dimen/context_menu_button_padding_x" - android:text="@string/shared_string_delete" + android:text="@string/shared_string_others" tools:textColor="?attr/ctx_menu_controller_text_color" android:textSize="@dimen/default_desc_text_size"/> @@ -306,7 +306,7 @@ android:gravity="center_vertical" android:paddingLeft="@dimen/context_menu_button_padding_x" android:paddingRight="@dimen/context_menu_button_padding_x" - android:text="@string/shared_string_others" + android:text="@string/shared_string_delete" android:textAllCaps="true" tools:textColor="?attr/ctx_menu_controller_text_color" android:textSize="@dimen/default_desc_text_size" diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java index 4cb6cf67fb..62e5f9ff0f 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java @@ -118,23 +118,6 @@ public class MapDataMenuController extends MenuController { leftDownloadButtonController.leftIconId = R.drawable.ic_action_import; rightDownloadButtonController = new TitleButtonController() { - @Override - public void buttonPressed() { - if (indexItem != null) { - if (backuped) { - deleteItem(indexItem.getBackupFile(app)); - } else { - deleteItem(indexItem.getTargetFile(app)); - } - } else if (localIndexInfo != null) { - deleteItem(new File(localIndexInfo.getPathToData())); - } - } - }; - rightDownloadButtonController.caption = getMapActivity().getString(R.string.shared_string_delete); - rightDownloadButtonController.leftIconId = R.drawable.ic_action_delete_dark; - - bottomTitleButtonController = new TitleButtonController() { @Override public void buttonPressed() { getMapActivity().getContextMenu().close(); @@ -158,7 +141,25 @@ public class MapDataMenuController extends MenuController { mapActivity.getContextMenu().getLatLon(), selectedObjects); } }; - bottomTitleButtonController.caption = getMapActivity().getString(R.string.download_select_map_types); + rightDownloadButtonController.caption = getMapActivity().getString(R.string.download_select_map_types); + rightDownloadButtonController.leftIconId = R.drawable.ic_plugin_srtm; + + bottomTitleButtonController = new TitleButtonController() { + @Override + public void buttonPressed() { + if (indexItem != null) { + if (backuped) { + deleteItem(indexItem.getBackupFile(app)); + } else { + deleteItem(indexItem.getTargetFile(app)); + } + } else if (localIndexInfo != null) { + deleteItem(new File(localIndexInfo.getPathToData())); + } + } + }; + bottomTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_delete); + bottomTitleButtonController.leftIconId = R.drawable.ic_action_delete_dark; titleProgressController = new TitleProgressController() { @Override @@ -178,6 +179,39 @@ public class MapDataMenuController extends MenuController { updateData(); } + @Override + public boolean displayDistanceDirection() { + return true; + } + + @Override + public int getAdditionalInfoColor() { + return R.color.icon_color; + } + + @Override + public String getAdditionalInfoStr() { + double mb = 0; + if (backuped) { + if (localIndexInfo != null) { + mb = localIndexInfo.getSize(); + } else if (indexItem != null) { + mb = indexItem.getArchiveSizeMB(); + } + } else if (indexItem != null) { + mb = indexItem.getArchiveSizeMB(); + } + if (mb != 0) { + return getMapActivity().getString(R.string.file_size_in_mb, mb); + } + return ""; + } + + @Override + public int getAdditionalInfoIconRes() { + return R.drawable.ic_sdcard_16; + } + @Override protected void setObject(Object object) { if (object instanceof DownloadMapObject) { @@ -349,8 +383,8 @@ public class MapDataMenuController extends MenuController { leftDownloadButtonController.visible = false; } - rightDownloadButtonController.visible = downloaded; - bottomTitleButtonController.visible = (otherIndexItems != null && otherIndexItems.size() > 0) + bottomTitleButtonController.visible = downloaded; + rightDownloadButtonController.visible = (otherIndexItems != null && otherIndexItems.size() > 0) || (otherLocalIndexInfos != null && otherLocalIndexInfos.size() > 0); boolean internetConnectionAvailable = From e01319cd82a8119a1b99fea447d4a0174225d566 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 27 Dec 2017 17:07:38 +0200 Subject: [PATCH 37/66] Rename left icon to right icon --- .../AudioVideoNoteMenuController.java | 2 +- .../MapContextMenuFragment.java | 4 ++-- .../plus/mapcontextmenu/MenuController.java | 4 ++-- .../mapcontextmenu/MenuTitleController.java | 20 +++++++++---------- .../controllers/AMapPointMenuController.java | 2 +- .../controllers/AmenityMenuController.java | 9 ++++----- .../FavouritePointMenuController.java | 2 +- .../controllers/GpxItemMenuController.java | 2 +- .../controllers/HistoryMenuController.java | 2 +- .../ImpassibleRoadsMenuController.java | 2 +- .../controllers/MapDataMenuController.java | 2 +- .../controllers/MapMarkerMenuController.java | 2 +- .../controllers/MyLocationMenuController.java | 2 +- .../PointDescriptionMenuController.java | 2 +- .../RenderedObjectMenuController.java | 2 +- .../TargetPointMenuController.java | 2 +- .../controllers/TransportRouteController.java | 2 +- .../controllers/TransportStopController.java | 2 +- .../controllers/WptPtMenuController.java | 2 +- .../other/MultiSelectionArrayAdapter.java | 4 ++-- .../mapillary/MapillaryMenuController.java | 2 +- .../plus/osmedit/EditPOIMenuController.java | 2 +- .../plus/osmedit/OsmBugMenuController.java | 2 +- .../osmand/plus/osmo/OsMoMenuController.java | 2 +- .../ParkingPositionMenuController.java | 2 +- .../osmand/plus/views/ContextMenuLayer.java | 2 +- 26 files changed, 41 insertions(+), 42 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNoteMenuController.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNoteMenuController.java index fef72984e8..e46e4ab81f 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNoteMenuController.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNoteMenuController.java @@ -86,7 +86,7 @@ public class AudioVideoNoteMenuController extends MenuController { } @Override - public Drawable getLeftIcon() { + public Drawable getRightIcon() { if (mRecording.isPhoto()) { return getIcon(R.drawable.ic_action_photo_dark, R.color.audio_video_icon_color); } else if (mRecording.isAudio()) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index dfec7917a6..93225b8ded 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -851,8 +851,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo OsmandApplication app = getMyApplication(); if (app != null && view != null) { final ImageView iconView = (ImageView) view.findViewById(R.id.context_menu_icon_view); - Drawable icon = menu.getLeftIcon(); - int iconId = menu.getLeftIconId(); + Drawable icon = menu.getRightIcon(); + int iconId = menu.getRightIconId(); if (icon != null) { iconView.setImageDrawable(icon); iconView.setVisibility(View.VISIBLE); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index 91fdbd450b..14d8bf65f5 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -386,11 +386,11 @@ public abstract class MenuController extends BaseMenuController { return false; } - public int getLeftIconId() { + public int getRightIconId() { return 0; } - public Drawable getLeftIcon() { + public Drawable getRightIcon() { return null; } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java index 108aeb78b9..4df7f95571 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java @@ -11,8 +11,8 @@ import net.osmand.util.Algorithms; public abstract class MenuTitleController { - protected int leftIconId; - protected Drawable leftIcon; + protected int rightIconId; + protected Drawable rightIcon; protected String nameStr = ""; protected String typeStr = ""; protected String commonTypeStr = ""; @@ -65,12 +65,12 @@ public abstract class MenuTitleController { return !addressNotFoundStr.equals(title) && !searchAddressStr.equals(title); } - public int getLeftIconId() { - return leftIconId; + public int getRightIconId() { + return rightIconId; } - public Drawable getLeftIcon() { - return leftIcon; + public Drawable getRightIcon() { + return rightIcon; } public Drawable getTypeIcon() { @@ -125,13 +125,13 @@ public abstract class MenuTitleController { protected void acquireIcons() { MenuController menuController = getMenuController(); - leftIconId = 0; - leftIcon = null; + rightIconId = 0; + rightIcon = null; secondLineTypeIcon = null; if (menuController != null) { - leftIconId = menuController.getLeftIconId(); - leftIcon = menuController.getLeftIcon(); + rightIconId = menuController.getRightIconId(); + rightIcon = menuController.getRightIcon(); secondLineTypeIcon = menuController.getSecondLineTypeIcon(); } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AMapPointMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AMapPointMenuController.java index 4821d345d9..a5158139e8 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AMapPointMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AMapPointMenuController.java @@ -49,7 +49,7 @@ public class AMapPointMenuController extends MenuController { } @Override - public Drawable getLeftIcon() { + public Drawable getRightIcon() { return getIcon(R.drawable.ic_action_get_my_location); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java index 4a448ca60e..c29722c162 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java @@ -21,7 +21,6 @@ import net.osmand.plus.transport.TransportStopRoute; import net.osmand.plus.render.RenderingIcons; import net.osmand.plus.resources.TransportIndexRepository; import net.osmand.plus.transport.TransportStopType; -import net.osmand.plus.views.POIMapLayer; import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; import net.osmand.util.OpeningHoursParser; @@ -109,11 +108,11 @@ public class AmenityMenuController extends MenuController { } @Override - public int getLeftIconId() { - return getLeftIconId(amenity); + public int getRightIconId() { + return getRightIconId(amenity); } - private static int getLeftIconId(Amenity amenity) { + private static int getRightIconId(Amenity amenity) { String id = null; PoiType st = amenity.getType().getPoiTypeByKeyName(amenity.getSubType()); if (st != null) { @@ -221,7 +220,7 @@ public class AmenityMenuController extends MenuController { public static void addPlainMenuItems(Amenity amenity, String typeStr, MenuBuilder builder) { if (!Algorithms.isEmpty(typeStr)) { - int resId = getLeftIconId(amenity); + int resId = getRightIconId(amenity); if (resId == 0) { PoiCategory pc = amenity.getType(); resId = RenderingIcons.getBigIconResourceId(pc.getIconKeyName()); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java index 4d2d5b7f98..c1ceba5a53 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java @@ -102,7 +102,7 @@ public class FavouritePointMenuController extends MenuController { } @Override - public Drawable getLeftIcon() { + public Drawable getRightIcon() { return FavoriteImageDrawable.getOrCreate(getMapActivity().getMyApplication(), fav.getColor(), false); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/GpxItemMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/GpxItemMenuController.java index cb8fc3407a..ccd28b02fd 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/GpxItemMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/GpxItemMenuController.java @@ -45,7 +45,7 @@ public class GpxItemMenuController extends MenuController { } @Override - public Drawable getLeftIcon() { + public Drawable getRightIcon() { return getIcon(R.drawable.ic_action_polygom_dark, R.color.osmand_orange); } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/HistoryMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/HistoryMenuController.java index 4bdd240adb..b0a4f758e1 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/HistoryMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/HistoryMenuController.java @@ -52,7 +52,7 @@ public class HistoryMenuController extends MenuController { } @Override - public Drawable getLeftIcon() { + public Drawable getRightIcon() { return getIcon(SearchHistoryFragment.getItemIcon(entry.getName())); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/ImpassibleRoadsMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/ImpassibleRoadsMenuController.java index 1d2e6e342a..0877112847 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/ImpassibleRoadsMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/ImpassibleRoadsMenuController.java @@ -53,7 +53,7 @@ public class ImpassibleRoadsMenuController extends MenuController { } @Override - public Drawable getLeftIcon() { + public Drawable getRightIcon() { return ContextCompat.getDrawable(getMapActivity(), R.drawable.map_pin_avoid_road); } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java index 62e5f9ff0f..da0c1b09a6 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java @@ -231,7 +231,7 @@ public class MapDataMenuController extends MenuController { } @Override - public Drawable getLeftIcon() { + public Drawable getRightIcon() { int iconResId; if (getDownloadActivityType() != null) { iconResId = getDownloadActivityType().getIconResource(); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java index ce7d2b33ea..c8247d34e5 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java @@ -89,7 +89,7 @@ public class MapMarkerMenuController extends MenuController { } @Override - public Drawable getLeftIcon() { + public Drawable getRightIcon() { return MapMarkerDialogHelper.getMapMarkerIcon(getMapActivity().getMyApplication(), mapMarker.colorIndex); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MyLocationMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MyLocationMenuController.java index d1f2fc6624..4cb05ddca3 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MyLocationMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MyLocationMenuController.java @@ -42,7 +42,7 @@ public class MyLocationMenuController extends MenuController { } @Override - public Drawable getLeftIcon() { + public Drawable getRightIcon() { ApplicationMode appMode = getMapActivity().getMyApplication().getSettings().getApplicationMode(); return getMapActivity().getResources().getDrawable(appMode.getResourceLocationDay()); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/PointDescriptionMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/PointDescriptionMenuController.java index 8d875706c2..86f2836b8f 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/PointDescriptionMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/PointDescriptionMenuController.java @@ -46,7 +46,7 @@ public class PointDescriptionMenuController extends MenuController { } @Override - public Drawable getLeftIcon() { + public Drawable getRightIcon() { return getIcon(SearchHistoryFragment.getItemIcon(getPointDescription())); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/RenderedObjectMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/RenderedObjectMenuController.java index 3e834bfa46..d9b1ea205b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/RenderedObjectMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/RenderedObjectMenuController.java @@ -49,7 +49,7 @@ public class RenderedObjectMenuController extends MenuController { } @Override - public int getLeftIconId() { + public int getRightIconId() { if (renderedObject.getIconRes() != null && RenderingIcons.containsBigIcon(renderedObject.getIconRes())) { return RenderingIcons.getBigIconResourceId(renderedObject.getIconRes()); } else { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TargetPointMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TargetPointMenuController.java index 5baf0985cb..da14f135d1 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TargetPointMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TargetPointMenuController.java @@ -79,7 +79,7 @@ public class TargetPointMenuController extends MenuController { } @Override - public Drawable getLeftIcon() { + public Drawable getRightIcon() { if (targetPoint.start) { return getIconOrig(R.drawable.list_startpoint); } else if (!targetPoint.intermediate) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java index e0eca34040..9284d30567 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java @@ -61,7 +61,7 @@ public class TransportRouteController extends MenuController { } @Override - public int getLeftIconId() { + public int getRightIconId() { return this.transportRoute.type == null ? R.drawable.mx_public_transport : this.transportRoute.type.getTopResourceId(); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java index 60502b588b..811c1344fe 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java @@ -58,7 +58,7 @@ public class TransportStopController extends MenuController { } @Override - public int getLeftIconId() { + public int getRightIconId() { if (topType == null) { return R.drawable.mx_public_transport; } else { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java index 1701259c47..9fdd42328d 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java @@ -76,7 +76,7 @@ public class WptPtMenuController extends MenuController { } @Override - public Drawable getLeftIcon() { + public Drawable getRightIcon() { return FavoriteImageDrawable.getOrCreate(getMapActivity().getMyApplication(), wpt.getColor(ContextCompat.getColor(getMapActivity(), R.color.gpx_color_point)), false); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java index 960d74ad35..abce00e1de 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java @@ -49,8 +49,8 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter Date: Wed, 27 Dec 2017 17:20:08 +0200 Subject: [PATCH 38/66] Fix text color in amenity menu builder --- .../osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java index 8af8d7f24f..9f460f33a9 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -133,7 +133,7 @@ public class AmenityMenuBuilder extends MenuBuilder { llTextParams.setMargins(icon == null ? dpToPx(16f) : 0, collapsable ? dpToPx(13f) : dpToPx(8f), 0, collapsable ? dpToPx(13f) : dpToPx(8f)); textView.setLayoutParams(llTextParams); textView.setTextSize(16); - textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark)); + textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark)); boolean textDefined = false; if (isPhoneNumber || isUrl) { From 12add8674c1bdf534daac18e5daab5895f2dccc7 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 27 Dec 2017 17:24:01 +0200 Subject: [PATCH 39/66] Fix icon colors after rebuilding context menu --- .../osmand/plus/mapcontextmenu/MapContextMenuFragment.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index 93225b8ded..8637b83204 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -234,8 +234,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo // Progress bar final ImageView progressButton = (ImageView) view.findViewById(R.id.progressButton); - progressButton.setImageDrawable(getIcon(R.drawable.ic_action_remove_dark, - !nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark)); + progressButton.setImageDrawable(getIcon(R.drawable.ic_action_remove_dark, R.color.ctx_menu_buttons_icon_color)); progressButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -945,8 +944,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo OsmandApplication app = getMyApplication(); if (app != null && view != null) { final ImageView buttonFavorite = (ImageView) view.findViewById(R.id.context_menu_fav_image_view); - buttonFavorite.setImageDrawable(getIcon(menu.getFavActionIconId(), - !nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark)); + buttonFavorite.setImageDrawable(getIcon(menu.getFavActionIconId(), R.color.ctx_menu_buttons_icon_color)); String favActionString = getString(menu.getFavActionStringId()); buttonFavorite.setContentDescription(favActionString); ((TextView) view.findViewById(R.id.context_menu_fav_text_view)).setText(favActionString); From 10c7fe2809e36cc9dde4028ce9d09868e36f405e Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 27 Dec 2017 17:25:10 +0200 Subject: [PATCH 40/66] Fix night mode in wikipedia --- .../net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java index 49c4cacc58..6480054f13 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java @@ -63,7 +63,7 @@ public class WikipediaDialogFragment extends DialogFragment { public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); OsmandApplication app = getMyApplication(); - darkMode = app.getDaynightHelper().isNightMode(); + darkMode = app.getDaynightHelper().isNightMode() || !app.getSettings().isLightContent(); int themeId = darkMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; setStyle(STYLE_NO_FRAME, themeId); } From 6b0250d8926fa2174f1f128509715cb292edaeed Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 27 Dec 2017 17:40:00 +0200 Subject: [PATCH 41/66] Change folder icon color --- .../controllers/FavouritePointMenuController.java | 2 +- .../plus/mapcontextmenu/controllers/WptPtMenuController.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java index c1ceba5a53..e0a6ae278d 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java @@ -113,7 +113,7 @@ public class FavouritePointMenuController extends MenuController { @Override public Drawable getSecondLineTypeIcon() { - return getIcon(R.drawable.ic_action_group_name_16); + return getIcon(R.drawable.ic_action_group_name_16, isLight() ? R.color.icon_color : R.color.ctx_menu_bottom_view_icon_dark); } @Override diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java index 9fdd42328d..6290b45571 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java @@ -86,7 +86,7 @@ public class WptPtMenuController extends MenuController { if (Algorithms.isEmpty(getSubtypeStr())) { return null; } else { - return getIcon(R.drawable.ic_action_group_name_16); + return getIcon(R.drawable.ic_action_group_name_16, isLight() ? R.color.icon_color : R.color.ctx_menu_bottom_view_icon_dark); } } From 0fca2bcebce2b27b4dbb83c3fb144c9cbd01209a Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 27 Dec 2017 18:48:49 +0200 Subject: [PATCH 42/66] Start adding previous and next transport stops --- .../controllers/TransportRouteController.java | 97 ++++++++++++++----- 1 file changed, 72 insertions(+), 25 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java index 9284d30567..d6ded8a316 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java @@ -46,6 +46,28 @@ public class TransportRouteController extends MenuController { mapActivity.getContextMenu().closeToolbar(TransportRouteController.this); } }); + + leftTitleButtonController = new TitleButtonController() { + @Override + public void buttonPressed() { + final int previousStop = getPreviousStop(); + if (previousStop != -1) { + showTransportStop(transportRoute.route.getForwardStops().get(previousStop)); + } + } + }; + leftTitleButtonController.caption = mapActivity.getString(R.string.shared_string_previous); + + rightTitleButtonController = new TitleButtonController() { + @Override + public void buttonPressed() { + final int nextStop = getNextStop(); + if (nextStop != -1) { + showTransportStop(transportRoute.route.getForwardStops().get(nextStop)); + } + } + }; + rightTitleButtonController.caption = mapActivity.getString(R.string.shared_string_next); } @Override @@ -121,19 +143,60 @@ public class TransportRouteController extends MenuController { } } + private void showTransportStop(TransportStop stop) { + if (mapContextMenu != null) { + transportRoute.stop = stop; + transportRoute.refStop = stop; + PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE, + transportRoute.getDescription(getMapActivity().getMyApplication(), false)); + + LatLon stopLocation = stop.getLocation(); + if (mapContextMenu.isVisible()) { + mapContextMenu.updateMapCenter(stopLocation); + } else { + mapContextMenu.setMapCenter(stopLocation); + mapContextMenu.setMapPosition(getMapActivity().getMapView().getMapPosition()); + } + mapContextMenu.setCenterMarker(true); + mapContextMenu.setMapZoom(15); + mapContextMenu.showOrUpdate(stopLocation, pd, transportRoute); + } + } + + private int getCurrentStop() { + List stops = transportRoute.route.getForwardStops(); + for (int i = 0; i < stops.size(); i++) { + final TransportStop stop = stops.get(i); + if (stop.getName().equals(transportRoute.stop.getName())) { + return i; + } + } + return -1; + } + + private int getNextStop() { + List stops = transportRoute.route.getForwardStops(); + int currentPos = getCurrentStop(); + if (currentPos != -1 && currentPos + 1 < stops.size()) { + return currentPos + 1; + } + return -1; + } + + private int getPreviousStop() { + int currentPos = getCurrentStop(); + if (currentPos > 0) { + return currentPos - 1; + } + return -1; + } + @Override public void addPlainMenuItems(String typeStr, PointDescription pointDescription, final LatLon latLon) { super.addPlainMenuItems(typeStr, pointDescription, latLon); List stops = transportRoute.route.getForwardStops(); boolean useEnglishNames = getMapActivity().getMyApplication().getSettings().usingEnglishNames(); - int currentStop = -1; - for (int i = 0; i < stops.size(); i++) { - final TransportStop stop = stops.get(i); - if (stop.getName().equals(transportRoute.stop.getName())) { - currentStop = i; - break; - } - } + int currentStop = getCurrentStop(); int defaultIcon = transportRoute.type == null ? R.drawable.mx_route_bus_ref : transportRoute.type.getResourceId(); int startPosition = 0; if (!transportRoute.showWholeRoute) { @@ -158,23 +221,7 @@ public class TransportRouteController extends MenuController { @Override public void onClick(View arg0) { - if (mapContextMenu != null) { - transportRoute.stop = stop; - transportRoute.refStop = stop; - PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE, - transportRoute.getDescription(getMapActivity().getMyApplication(), false)); - - LatLon stopLocation = stop.getLocation(); - if (mapContextMenu.isVisible()) { - mapContextMenu.updateMapCenter(stopLocation); - } else { - mapContextMenu.setMapCenter(stopLocation); - mapContextMenu.setMapPosition(getMapActivity().getMapView().getMapPosition()); - } - mapContextMenu.setCenterMarker(true); - mapContextMenu.setMapZoom(15); - mapContextMenu.showOrUpdate(stopLocation, pd, transportRoute); - } + showTransportStop(stop); /* PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_STOP, getMapActivity().getString(R.string.transport_Stop), name); From f16f6dcaf8e830498f71fa939d6d9c6d56f84d34 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Thu, 28 Dec 2017 11:59:44 +0200 Subject: [PATCH 43/66] Change status bar color in toolbar controller --- OsmAnd/src/net/osmand/plus/activities/MapActivity.java | 5 ++++- .../src/net/osmand/plus/mapcontextmenu/MenuController.java | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 8e805f6056..ecf3a58e25 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -842,9 +842,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven boolean mapControlsVisible = findViewById(R.id.MapHudButtonsOverlay).getVisibility() == View.VISIBLE; boolean night = app.getDaynightHelper().isNightModeForMapControls(); boolean quickSearchTopBar = getTopToolbarController(TopToolbarControllerType.QUICK_SEARCH) != null; + boolean contextMenuTopBar = getTopToolbarController(TopToolbarControllerType.CONTEXT_MENU) != null; boolean mapTopBar = findViewById(R.id.map_top_bar).getVisibility() == View.VISIBLE; boolean markerTopBar = findViewById(R.id.map_markers_top_bar).getVisibility() == View.VISIBLE; - if ((quickSearchTopBar || mapTopBar) && mapControlsVisible) { + if (((quickSearchTopBar || mapTopBar) && mapControlsVisible) || contextMenuTopBar) { colorId = night ? R.color.status_bar_route_dark : R.color.status_bar_route_light; } else if (markerTopBar && mapControlsVisible) { colorId = R.color.status_bar_dark; @@ -1885,11 +1886,13 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven public void showTopToolbar(TopToolbarController controller) { MapInfoLayer mapInfoLayer = getMapLayers().getMapInfoLayer(); mapInfoLayer.addTopToolbarController(controller); + updateStatusBarColor(); } public void hideTopToolbar(TopToolbarController controller) { MapInfoLayer mapInfoLayer = getMapLayers().getMapInfoLayer(); mapInfoLayer.removeTopToolbarController(controller); + updateStatusBarColor(); } public void registerActivityResultListener(ActivityResultListener listener) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index 14d8bf65f5..a5b55f27fd 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -774,6 +774,8 @@ public abstract class MenuController extends BaseMenuController { public ContextMenuToolbarController(MenuController menuController) { super(TopToolbarControllerType.CONTEXT_MENU); this.menuController = menuController; + setBgIds(R.color.actionbar_light_color, R.color.actionbar_dark_color, + R.color.actionbar_light_color, R.color.actionbar_dark_color); } public MenuController getMenuController() { From 073463f64ad3fdc4c0ea954e17ba329030b96496 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Thu, 28 Dec 2017 12:54:34 +0200 Subject: [PATCH 44/66] Fix empty transport stop name --- .../controllers/TransportRouteController.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java index d6ded8a316..aebdb2453f 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java @@ -1,5 +1,6 @@ package net.osmand.plus.mapcontextmenu.controllers; +import android.text.TextUtils; import android.view.View; import android.view.View.OnClickListener; @@ -116,15 +117,21 @@ public class TransportRouteController extends MenuController { @Override public String getTypeStr() { - if (transportRoute.refStop != null) { + if (transportRoute.refStop != null && !TextUtils.isEmpty(transportRoute.refStop.getName())) { return transportRoute.refStop.getName(); - } else if (transportRoute.stop != null) { + } else if (transportRoute.stop != null && !TextUtils.isEmpty(transportRoute.stop.getName())) { return transportRoute.stop.getName(); - } else { + } else if (!TextUtils.isEmpty(getPointDescription().getTypeName())) { return getPointDescription().getTypeName(); + } else { + return getStopType(); } } + private String getStopType() { + return getMapActivity().getString(transportRoute.getTypeStrRes()) + " " + getMapActivity().getString(R.string.transport_Stop).toLowerCase(); + } + @Override public void onShow() { super.onShow(); @@ -215,7 +222,10 @@ public class TransportRouteController extends MenuController { } for (int i = startPosition; i < stops.size(); i++) { final TransportStop stop = stops.get(i); - final String name = useEnglishNames ? stop.getEnName(true) : stop.getName(); + String name = useEnglishNames ? stop.getEnName(true) : stop.getName(); + if (TextUtils.isEmpty(name)) { + name = getStopType(); + } addPlainMenuItem(currentStop == i ? R.drawable.ic_action_marker_dark : defaultIcon, name, false, false, new OnClickListener() { From 39b5b3e0b2c57d4e4e4306b4f5f9ab9cc1dd3ce9 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Thu, 28 Dec 2017 13:35:30 +0200 Subject: [PATCH 45/66] Add previous and next icons --- .../MapContextMenuFragment.java | 29 ++++++++++++------- .../plus/mapcontextmenu/MenuController.java | 16 ++++++++++ .../controllers/TransportRouteController.java | 2 ++ 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index 8637b83204..c0b7ee1f4d 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -14,6 +14,7 @@ import android.support.v4.content.ContextCompat; import android.text.TextUtils; import android.util.TypedValue; import android.view.GestureDetector; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.VelocityTracker; @@ -735,10 +736,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo if (leftTitleButtonController.visible) { leftTitleButtonView.setVisibility(View.VISIBLE); Drawable leftIcon = leftTitleButtonController.getLeftIcon(); - if (leftIcon != null) { - leftTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null); - leftTitleButton.setCompoundDrawablePadding(dpToPx(8f)); - } + Drawable rightIcon = leftTitleButtonController.getRightIcon(); + leftTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, rightIcon, null); + leftTitleButton.setCompoundDrawablePadding(dpToPx(8f)); + ((LinearLayout) leftTitleButtonView).setGravity(rightIcon != null ? Gravity.END : Gravity.START); if (leftTitleButtonController.needRightText) { titleButtonRightText.setText(leftTitleButtonController.rightTextCaption); @@ -762,8 +763,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo rightTitleButtonView.setVisibility(rightTitleButtonController.visible ? View.VISIBLE : View.INVISIBLE); Drawable leftIcon = rightTitleButtonController.getLeftIcon(); - rightTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null); + Drawable rightIcon = rightTitleButtonController.getRightIcon(); + rightTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, rightIcon, null); rightTitleButton.setCompoundDrawablePadding(dpToPx(8f)); + ((LinearLayout) rightTitleButtonView).setGravity(rightIcon != null ? Gravity.END : Gravity.START); } else { rightTitleButtonView.setVisibility(View.INVISIBLE); } @@ -776,8 +779,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo bottomTitleButtonView.setVisibility(bottomTitleButtonController.visible ? View.VISIBLE : View.GONE); Drawable leftIcon = bottomTitleButtonController.getLeftIcon(); - bottomTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null); + Drawable rightIcon = bottomTitleButtonController.getRightIcon(); + bottomTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, rightIcon, null); bottomTitleButton.setCompoundDrawablePadding(dpToPx(8f)); + ((LinearLayout) bottomTitleButtonView).setGravity(rightIcon != null ? Gravity.END : Gravity.START); } else { bottomTitleButtonView.setVisibility(View.GONE); } @@ -798,10 +803,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo leftDownloadButtonView.setVisibility(leftDownloadButtonController.visible ? View.VISIBLE : View.INVISIBLE); Drawable leftIcon = leftDownloadButtonController.getLeftIcon(); - if (leftIcon != null) { - leftDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null); - leftDownloadButton.setCompoundDrawablePadding(dpToPx(8f)); - } + Drawable rightIcon = leftDownloadButtonController.getRightIcon(); + leftDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, rightIcon, null); + leftDownloadButton.setCompoundDrawablePadding(dpToPx(8f)); + ((LinearLayout) leftDownloadButtonView).setGravity(rightIcon != null ? Gravity.END : Gravity.START); } else { leftDownloadButtonView.setVisibility(View.INVISIBLE); } @@ -814,8 +819,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo rightDownloadButtonView.setVisibility(rightDownloadButtonController.visible ? View.VISIBLE : View.INVISIBLE); Drawable leftIcon = rightDownloadButtonController.getLeftIcon(); - rightDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null); + Drawable rightIcon = rightDownloadButtonController.getRightIcon(); + rightDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, rightIcon, null); rightDownloadButton.setCompoundDrawablePadding(dpToPx(8f)); + ((LinearLayout) rightDownloadButtonView).setGravity(rightIcon != null ? Gravity.END : Gravity.START); } else { rightDownloadButtonView.setVisibility(View.INVISIBLE); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index a5b55f27fd..5e2d731f4f 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -531,11 +531,13 @@ public abstract class MenuController extends BaseMenuController { public abstract class TitleButtonController { public String caption = ""; public int leftIconId = 0; + public int rightIconId = 0; public boolean needRightText = false; public String rightTextCaption = ""; public boolean visible = true; public boolean needColorizeIcon = true; public Drawable leftIcon; + public Drawable rightIcon; public Drawable getLeftIcon() { if (leftIcon != null) { @@ -551,6 +553,20 @@ public abstract class MenuController extends BaseMenuController { } } + public Drawable getRightIcon() { + if (rightIcon != null) { + return rightIcon; + } + if (rightIconId != 0) { + if (needColorizeIcon) { + return getIcon(rightIconId, isLight() ? R.color.map_widget_blue : R.color.osmand_orange); + } + return ContextCompat.getDrawable(getMapActivity(), rightIconId); + } else { + return null; + } + } + public abstract void buttonPressed(); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java index aebdb2453f..c018ee5b00 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java @@ -58,6 +58,7 @@ public class TransportRouteController extends MenuController { } }; leftTitleButtonController.caption = mapActivity.getString(R.string.shared_string_previous); + leftTitleButtonController.leftIconId = R.drawable.ic_arrow_back; rightTitleButtonController = new TitleButtonController() { @Override @@ -69,6 +70,7 @@ public class TransportRouteController extends MenuController { } }; rightTitleButtonController.caption = mapActivity.getString(R.string.shared_string_next); + rightTitleButtonController.rightIconId = R.drawable.ic_arrow_forward; } @Override From afcbc5d648bf352d24d5992942f7b9074412ba96 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Thu, 28 Dec 2017 14:57:35 +0200 Subject: [PATCH 46/66] Disable controller buttons --- ...ntext_menu_controller_disabled_bg_dark.xml | 13 +++++ ...text_menu_controller_disabled_bg_light.xml | 13 +++++ OsmAnd/res/values/colors.xml | 2 + .../MapContextMenuFragment.java | 51 +++++++++++-------- .../plus/mapcontextmenu/MenuController.java | 15 +++++- .../controllers/TransportRouteController.java | 18 +++++++ 6 files changed, 88 insertions(+), 24 deletions(-) create mode 100644 OsmAnd/res/drawable/context_menu_controller_disabled_bg_dark.xml create mode 100644 OsmAnd/res/drawable/context_menu_controller_disabled_bg_light.xml diff --git a/OsmAnd/res/drawable/context_menu_controller_disabled_bg_dark.xml b/OsmAnd/res/drawable/context_menu_controller_disabled_bg_dark.xml new file mode 100644 index 0000000000..33274d8ff8 --- /dev/null +++ b/OsmAnd/res/drawable/context_menu_controller_disabled_bg_dark.xml @@ -0,0 +1,13 @@ + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/context_menu_controller_disabled_bg_light.xml b/OsmAnd/res/drawable/context_menu_controller_disabled_bg_light.xml new file mode 100644 index 0000000000..4ac0d70116 --- /dev/null +++ b/OsmAnd/res/drawable/context_menu_controller_disabled_bg_light.xml @@ -0,0 +1,13 @@ + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml index 39642f818c..021609bef7 100644 --- a/OsmAnd/res/values/colors.xml +++ b/OsmAnd/res/values/colors.xml @@ -352,6 +352,8 @@ #222526 #536dfe #d28521 + #b3b3b3 + #666666 #ffffff #17191a diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index c0b7ee1f4d..0e431acecf 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -152,21 +152,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo mapZoom = map.getZoom(); } - ColorStateList buttonColorStateList = new ColorStateList( - new int[][]{ - new int[]{android.R.attr.state_pressed}, - new int[]{} - }, - new int[] { - getResources().getColor(nightMode ? R.color.ctx_menu_controller_button_text_color_dark_p : R.color.ctx_menu_controller_button_text_color_light_p), - getResources().getColor(nightMode ? R.color.ctx_menu_controller_button_text_color_dark_n : R.color.ctx_menu_controller_button_text_color_light_n) - } - ); - // Left title button final View leftTitleButtonView = view.findViewById(R.id.title_button_view); - ((TextView) leftTitleButtonView.findViewById(R.id.title_button)).setTextColor(buttonColorStateList); - leftTitleButtonView.setBackgroundResource(nightMode ? R.drawable.context_menu_controller_bg_dark : R.drawable.context_menu_controller_bg_light); leftTitleButtonView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -179,8 +166,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo // Right title button final View rightTitleButtonView = view.findViewById(R.id.title_button_right_view); - ((TextView) rightTitleButtonView.findViewById(R.id.title_button_right)).setTextColor(buttonColorStateList); - rightTitleButtonView.setBackgroundResource(nightMode ? R.drawable.context_menu_controller_bg_dark : R.drawable.context_menu_controller_bg_light); rightTitleButtonView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -193,8 +178,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo // Left download button final View leftDownloadButtonView = view.findViewById(R.id.download_button_left_view); - ((TextView) leftDownloadButtonView.findViewById(R.id.download_button_left)).setTextColor(buttonColorStateList); - leftDownloadButtonView.setBackgroundResource(nightMode ? R.drawable.context_menu_controller_bg_dark : R.drawable.context_menu_controller_bg_light); leftDownloadButtonView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -207,8 +190,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo // Right download button final View rightDownloadButtonView = (View) view.findViewById(R.id.download_button_right_view); - ((TextView) rightDownloadButtonView.findViewById(R.id.download_button_right)).setTextColor(buttonColorStateList); - rightDownloadButtonView.setBackgroundResource(nightMode ? R.drawable.context_menu_controller_bg_dark : R.drawable.context_menu_controller_bg_light); rightDownloadButtonView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -221,8 +202,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo // Bottom title button final View bottomTitleButtonView = view.findViewById(R.id.title_button_bottom_view); - ((TextView) bottomTitleButtonView.findViewById(R.id.title_button_bottom)).setTextColor(buttonColorStateList); - bottomTitleButtonView.setBackgroundResource(nightMode ? R.drawable.context_menu_controller_bg_dark : R.drawable.context_menu_controller_bg_light); bottomTitleButtonView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -713,7 +692,29 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo origMarkerY = box.getCenterPixelY(); } - private void updateButtonsAndProgress() { + private void enableDisableButtons(View buttonView, TextView button, boolean enabled) { + if (enabled) { + ColorStateList buttonColorStateList = new ColorStateList( + new int[][]{ + new int[]{android.R.attr.state_pressed}, + new int[]{} + }, + new int[] { + getResources().getColor(nightMode ? R.color.ctx_menu_controller_button_text_color_dark_p : R.color.ctx_menu_controller_button_text_color_light_p), + getResources().getColor(nightMode ? R.color.ctx_menu_controller_button_text_color_dark_n : R.color.ctx_menu_controller_button_text_color_light_n) + } + ); + + buttonView.setBackgroundResource(nightMode ? R.drawable.context_menu_controller_bg_dark : R.drawable.context_menu_controller_bg_light); + button.setTextColor(buttonColorStateList); + } else { + buttonView.setBackgroundResource(nightMode ? R.drawable.context_menu_controller_disabled_bg_dark: R.drawable.context_menu_controller_disabled_bg_light); + button.setTextColor(ContextCompat.getColor(getContext(), nightMode ? R.color.ctx_menu_controller_disabled_text_color_dark : R.color.ctx_menu_controller_disabled_text_color_light)); + } + button.setEnabled(enabled); + } + + public void updateButtonsAndProgress() { if (view != null) { TitleButtonController leftTitleButtonController = menu.getLeftTitleButtonController(); TitleButtonController rightTitleButtonController = menu.getRightTitleButtonController(); @@ -732,6 +733,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo final TextView leftTitleButton = (TextView) view.findViewById(R.id.title_button); final TextView titleButtonRightText = (TextView) view.findViewById(R.id.title_button_right_text); if (leftTitleButtonController != null) { + enableDisableButtons(leftTitleButtonView, leftTitleButton, leftTitleButtonController.enabled); leftTitleButton.setText(leftTitleButtonController.caption); if (leftTitleButtonController.visible) { leftTitleButtonView.setVisibility(View.VISIBLE); @@ -759,6 +761,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo final View rightTitleButtonView = view.findViewById(R.id.title_button_right_view); final TextView rightTitleButton = (TextView) view.findViewById(R.id.title_button_right); if (rightTitleButtonController != null) { + enableDisableButtons(rightTitleButtonView, rightTitleButton, rightTitleButtonController.enabled); rightTitleButton.setText(rightTitleButtonController.caption); rightTitleButtonView.setVisibility(rightTitleButtonController.visible ? View.VISIBLE : View.INVISIBLE); @@ -775,6 +778,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo final View bottomTitleButtonView = view.findViewById(R.id.title_button_bottom_view); final TextView bottomTitleButton = (TextView) view.findViewById(R.id.title_button_bottom); if (bottomTitleButtonController != null) { + enableDisableButtons(bottomTitleButtonView, bottomTitleButton, bottomTitleButtonController.enabled); bottomTitleButton.setText(bottomTitleButtonController.caption); bottomTitleButtonView.setVisibility(bottomTitleButtonController.visible ? View.VISIBLE : View.GONE); @@ -799,6 +803,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo final View leftDownloadButtonView = view.findViewById(R.id.download_button_left_view); final TextView leftDownloadButton = (TextView) view.findViewById(R.id.download_button_left); if (leftDownloadButtonController != null) { + enableDisableButtons(leftDownloadButtonView, leftDownloadButton, leftDownloadButtonController.enabled); leftDownloadButton.setText(leftDownloadButtonController.caption); leftDownloadButtonView.setVisibility(leftDownloadButtonController.visible ? View.VISIBLE : View.INVISIBLE); @@ -815,6 +820,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo final View rightDownloadButtonView = view.findViewById(R.id.download_button_right_view); final TextView rightDownloadButton = (TextView) view.findViewById(R.id.download_button_right); if (rightDownloadButtonController != null) { + enableDisableButtons(rightDownloadButtonView, rightDownloadButton, rightDownloadButtonController.enabled); rightDownloadButton.setText(rightDownloadButtonController.caption); rightDownloadButtonView.setVisibility(rightDownloadButtonController.visible ? View.VISIBLE : View.INVISIBLE); @@ -966,6 +972,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo this.initLayout = true; this.centered = true; } + updateButtonsAndProgress(); runLayoutListener(); } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index 5e2d731f4f..6b116ca508 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -538,6 +538,7 @@ public abstract class MenuController extends BaseMenuController { public boolean needColorizeIcon = true; public Drawable leftIcon; public Drawable rightIcon; + public boolean enabled = true; public Drawable getLeftIcon() { if (leftIcon != null) { @@ -545,7 +546,7 @@ public abstract class MenuController extends BaseMenuController { } if (leftIconId != 0) { if (needColorizeIcon) { - return getIcon(leftIconId, isLight() ? R.color.map_widget_blue : R.color.osmand_orange); + return getIcon(leftIconId, getColorRes()); } return ContextCompat.getDrawable(getMapActivity(), leftIconId); } else { @@ -559,7 +560,7 @@ public abstract class MenuController extends BaseMenuController { } if (rightIconId != 0) { if (needColorizeIcon) { - return getIcon(rightIconId, isLight() ? R.color.map_widget_blue : R.color.osmand_orange); + return getIcon(rightIconId, getColorRes()); } return ContextCompat.getDrawable(getMapActivity(), rightIconId); } else { @@ -567,6 +568,16 @@ public abstract class MenuController extends BaseMenuController { } } + private int getColorRes() { + int colorRes; + if (enabled) { + colorRes = isLight() ? R.color.map_widget_blue : R.color.osmand_orange; + } else { + colorRes = isLight() ? R.color.ctx_menu_controller_disabled_text_color_dark : R.color.ctx_menu_controller_disabled_text_color_light; + } + return colorRes; + } + public abstract void buttonPressed(); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java index c018ee5b00..a9c17d4355 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java @@ -152,6 +152,22 @@ public class TransportRouteController extends MenuController { } } + private void updateControllers() { + boolean previousStopEnabled = false; + final int previousStop = getPreviousStop(); + if (previousStop != -1) { + previousStopEnabled = true; + } + leftTitleButtonController.enabled = previousStopEnabled; + + boolean nextStopEnabled = false; + final int nextStop = getNextStop(); + if (nextStop != -1) { + nextStopEnabled = true; + } + rightTitleButtonController.enabled = nextStopEnabled; + } + private void showTransportStop(TransportStop stop) { if (mapContextMenu != null) { transportRoute.stop = stop; @@ -159,6 +175,8 @@ public class TransportRouteController extends MenuController { PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE, transportRoute.getDescription(getMapActivity().getMyApplication(), false)); + updateControllers(); + LatLon stopLocation = stop.getLocation(); if (mapContextMenu.isVisible()) { mapContextMenu.updateMapCenter(stopLocation); From 1f7ba229751fa950d597d2a6ccae4845e562fad3 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Thu, 28 Dec 2017 15:08:44 +0200 Subject: [PATCH 47/66] Change context menu toolbar controller colors --- OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index 6b116ca508..acd816e64e 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -803,6 +803,9 @@ public abstract class MenuController extends BaseMenuController { this.menuController = menuController; setBgIds(R.color.actionbar_light_color, R.color.actionbar_dark_color, R.color.actionbar_light_color, R.color.actionbar_dark_color); + setBackBtnIconClrIds(R.color.color_white, R.color.color_white); + setCloseBtnIconClrIds(R.color.color_white, R.color.color_white); + setTitleTextClrIds(R.color.color_white, R.color.color_white); } public MenuController getMenuController() { From 69bdda4f4790eb25eafa1d9f74a4fedfa853a962 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Fri, 29 Dec 2017 10:38:32 +0200 Subject: [PATCH 48/66] Fix route controllers after rotate --- .../mapcontextmenu/controllers/TransportRouteController.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java index a9c17d4355..371acd5880 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java @@ -71,6 +71,8 @@ public class TransportRouteController extends MenuController { }; rightTitleButtonController.caption = mapActivity.getString(R.string.shared_string_next); rightTitleButtonController.rightIconId = R.drawable.ic_arrow_forward; + + updateControllers(); } @Override From 64e7cf1b8361c2717832da14fab89ba4c1bdd2b1 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Fri, 29 Dec 2017 10:49:40 +0200 Subject: [PATCH 49/66] Fix wikipedia title padding --- OsmAnd/res/layout/wikipedia_dialog_fragment.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/layout/wikipedia_dialog_fragment.xml b/OsmAnd/res/layout/wikipedia_dialog_fragment.xml index 9b37a95707..6164f93d9f 100644 --- a/OsmAnd/res/layout/wikipedia_dialog_fragment.xml +++ b/OsmAnd/res/layout/wikipedia_dialog_fragment.xml @@ -65,7 +65,10 @@ android:id="@+id/title_text_view" android:layout_width="match_parent" android:layout_height="wrap_content" - android:padding="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingTop="@dimen/list_header_padding" + android:paddingBottom="@dimen/list_header_padding" android:textSize="@dimen/map_button_text_size" tools:text="Title"/> From f5f6478a7efc5106154064239f0a5fb3a876648b Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Fri, 29 Dec 2017 10:59:47 +0200 Subject: [PATCH 50/66] Fix wikipedia change lang button stroke --- OsmAnd/res/drawable/wikipedia_select_lang_bg_light_n.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/drawable/wikipedia_select_lang_bg_light_n.xml b/OsmAnd/res/drawable/wikipedia_select_lang_bg_light_n.xml index 12cfbb48c9..8a82c9ac94 100644 --- a/OsmAnd/res/drawable/wikipedia_select_lang_bg_light_n.xml +++ b/OsmAnd/res/drawable/wikipedia_select_lang_bg_light_n.xml @@ -6,7 +6,7 @@ + android:color="@color/ctx_menu_info_divider_light" /> From e4341eb787fd629754dc9c457faace801800e2f8 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Fri, 29 Dec 2017 11:32:01 +0200 Subject: [PATCH 51/66] Fix disabled button color --- OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index acd816e64e..592f3db084 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -573,7 +573,7 @@ public abstract class MenuController extends BaseMenuController { if (enabled) { colorRes = isLight() ? R.color.map_widget_blue : R.color.osmand_orange; } else { - colorRes = isLight() ? R.color.ctx_menu_controller_disabled_text_color_dark : R.color.ctx_menu_controller_disabled_text_color_light; + colorRes = isLight() ? R.color.ctx_menu_controller_disabled_text_color_light : R.color.ctx_menu_controller_disabled_text_color_dark; } return colorRes; } From dd2441c02480e7bedd137aea88c2fac67e08bee0 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Fri, 29 Dec 2017 11:41:09 +0200 Subject: [PATCH 52/66] Change title and type strings in transport route controller --- .../controllers/TransportRouteController.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java index 371acd5880..403b36b5de 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java @@ -121,15 +121,7 @@ public class TransportRouteController extends MenuController { @Override public String getTypeStr() { - if (transportRoute.refStop != null && !TextUtils.isEmpty(transportRoute.refStop.getName())) { - return transportRoute.refStop.getName(); - } else if (transportRoute.stop != null && !TextUtils.isEmpty(transportRoute.stop.getName())) { - return transportRoute.stop.getName(); - } else if (!TextUtils.isEmpty(getPointDescription().getTypeName())) { - return getPointDescription().getTypeName(); - } else { - return getStopType(); - } + return getPointDescription().getName(); } private String getStopType() { @@ -220,6 +212,19 @@ public class TransportRouteController extends MenuController { return -1; } + @Override + public String getNameStr() { + if (transportRoute.refStop != null && !TextUtils.isEmpty(transportRoute.refStop.getName())) { + return transportRoute.refStop.getName(); + } else if (transportRoute.stop != null && !TextUtils.isEmpty(transportRoute.stop.getName())) { + return transportRoute.stop.getName(); + } else if (!TextUtils.isEmpty(getPointDescription().getTypeName())) { + return getPointDescription().getTypeName(); + } else { + return getStopType(); + } + } + @Override public void addPlainMenuItems(String typeStr, PointDescription pointDescription, final LatLon latLon) { super.addPlainMenuItems(typeStr, pointDescription, latLon); From 3faf93db2553937db4894afed00e282f8a579278 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Fri, 29 Dec 2017 12:25:33 +0200 Subject: [PATCH 53/66] Show map size in controller --- .../osmand/plus/mapcontextmenu/MapContextMenu.java | 2 +- .../plus/mapcontextmenu/MapContextMenuFragment.java | 2 +- .../osmand/plus/mapcontextmenu/MenuController.java | 12 +++++++++++- .../controllers/AmenityMenuController.java | 6 +++--- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index f67c0d4998..ca8e8b7ccd 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -598,7 +598,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL historyStack.add(menuData); } if (!(menuController instanceof MapDataMenuController)) { - menuController.buildMapDownloadButton(latLon); + menuController.buildMapDownloadButtonAndSizeInfo(latLon); } return true; } else { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index 0e431acecf..c60648e633 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -1501,7 +1501,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo if (created) { menu.updateData(); updateButtonsAndProgress(); - runLayoutListener(); + refreshTitle(); } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index 592f3db084..68dc0567b7 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -4,6 +4,7 @@ import android.graphics.drawable.Drawable; import android.os.AsyncTask; import android.support.annotation.NonNull; import android.support.v4.content.ContextCompat; +import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.LinearLayout; @@ -433,14 +434,23 @@ public abstract class MenuController extends BaseMenuController { } public int getAdditionalInfoColor() { + if (indexItem != null) { + return R.color.icon_color; + } return 0; } public String getAdditionalInfoStr() { + if (indexItem != null) { + return getMapActivity().getString(R.string.file_size_in_mb, indexItem.getArchiveSizeMB()); + } return ""; } public int getAdditionalInfoIconRes() { + if (indexItem != null) { + return R.drawable.ic_sdcard_16; + } return 0; } @@ -646,7 +656,7 @@ public abstract class MenuController extends BaseMenuController { } } - public void buildMapDownloadButton(final LatLon latLon) { + public void buildMapDownloadButtonAndSizeInfo(final LatLon latLon) { new AsyncTask() { ResourceManager rm; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java index c29722c162..ec3460ba28 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java @@ -150,7 +150,7 @@ public class AmenityMenuController extends MenuController { if (openingHoursInfo != null) { return openingHoursInfo.isOpened() ? R.color.ctx_menu_amenity_opened_text_color : R.color.ctx_menu_amenity_closed_text_color; } - return 0; + return super.getAdditionalInfoColor(); } @Override @@ -158,7 +158,7 @@ public class AmenityMenuController extends MenuController { if (openingHoursInfo != null) { return openingHoursInfo.getInfo(getMapActivity()); } - return ""; + return super.getAdditionalInfoStr(); } @Override @@ -166,7 +166,7 @@ public class AmenityMenuController extends MenuController { if (openingHoursInfo != null) { return R.drawable.ic_action_opening_hour_16; } - return 0; + return super.getAdditionalInfoIconRes(); } public static String getTypeStr(Amenity amenity) { From d98c7c3d3707ad8aaedf69c3a1473ca3ad163fec Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Fri, 29 Dec 2017 12:31:29 +0200 Subject: [PATCH 54/66] Fix updating controllers in route menu --- .../controllers/TransportRouteController.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java index 403b36b5de..18e8a2d07e 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java @@ -71,8 +71,6 @@ public class TransportRouteController extends MenuController { }; rightTitleButtonController.caption = mapActivity.getString(R.string.shared_string_next); rightTitleButtonController.rightIconId = R.drawable.ic_arrow_forward; - - updateControllers(); } @Override @@ -128,6 +126,12 @@ public class TransportRouteController extends MenuController { return getMapActivity().getString(transportRoute.getTypeStrRes()) + " " + getMapActivity().getString(R.string.transport_Stop).toLowerCase(); } + @Override + public void updateData() { + super.updateData(); + updateControllers(); + } + @Override public void onShow() { super.onShow(); From ab81309e1829f7b044bc773d7195f9d11fcf2277 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Fri, 29 Dec 2017 13:47:42 +0200 Subject: [PATCH 55/66] Display map type in context menu --- .../mapcontextmenu/controllers/MapDataMenuController.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java index da0c1b09a6..6028f14f38 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java @@ -253,6 +253,10 @@ public class MapDataMenuController extends MenuController { } else { res = getMapActivity().getString(R.string.shared_string_map); } + DownloadActivityType downloadActivityType = getDownloadActivityType(); + if (downloadActivityType != null) { + res += ", " + downloadActivityType.getString(getMapActivity()); + } if (getMenuType() == MenuType.STANDARD) { res += "\n"; } From 89894b95e473d4d2db231b1685358ce6a1aeb809 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Fri, 29 Dec 2017 14:08:32 +0200 Subject: [PATCH 56/66] Fix showing size after progress downloading --- .../net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index c60648e633..b2510921d7 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -1492,7 +1492,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo boolean progressVisible = menu.getTitleProgressController() != null && menu.getTitleProgressController().visible; updateButtonsAndProgress(); if (wasProgressVisible != progressVisible) { - runLayoutListener(); + refreshTitle(); } } } From b63556acd81babb13522b6b3ed52e79b189cac21 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Fri, 29 Dec 2017 15:55:26 +0200 Subject: [PATCH 57/66] Remove tail from context menu bg --- OsmAnd/res/drawable/bg_map_context_menu_dark.xml | 2 +- OsmAnd/res/drawable/bg_map_context_menu_light.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/drawable/bg_map_context_menu_dark.xml b/OsmAnd/res/drawable/bg_map_context_menu_dark.xml index 1e7add2c05..0ffd43e6ac 100644 --- a/OsmAnd/res/drawable/bg_map_context_menu_dark.xml +++ b/OsmAnd/res/drawable/bg_map_context_menu_dark.xml @@ -1,7 +1,7 @@ - + diff --git a/OsmAnd/res/drawable/bg_map_context_menu_light.xml b/OsmAnd/res/drawable/bg_map_context_menu_light.xml index 60af50f23c..9ea7cda807 100644 --- a/OsmAnd/res/drawable/bg_map_context_menu_light.xml +++ b/OsmAnd/res/drawable/bg_map_context_menu_light.xml @@ -1,7 +1,7 @@ - + From 6c162a6ca885f30277a67f70dc26191eef65fd63 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Fri, 29 Dec 2017 16:09:38 +0200 Subject: [PATCH 58/66] Change main actions padding --- OsmAnd/res/layout/map_context_menu_fragment.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml index 1966edc6b6..4306395700 100644 --- a/OsmAnd/res/layout/map_context_menu_fragment.xml +++ b/OsmAnd/res/layout/map_context_menu_fragment.xml @@ -383,8 +383,8 @@ android:background="?attr/ctx_menu_divider"/> Date: Fri, 29 Dec 2017 16:34:29 +0200 Subject: [PATCH 59/66] Collapse context menu by clicking on details button --- .../MapContextMenuFragment.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index b2510921d7..fe3ce68846 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -530,6 +530,23 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo return view; } + private void toggleDetailsHideButton() { + int menuState = menu.getCurrentMenuState(); + final boolean showShowHideButton = menuState == MenuState.HALF_SCREEN || (!menu.isLandscapeLayout() && menuState == MenuState.FULL_SCREEN); + TextView detailsButton = (TextView) view.findViewById(R.id.context_menu_details_button); + detailsButton.setText(showShowHideButton ? R.string.shared_string_collapse : R.string.description); + detailsButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (showShowHideButton) { + openMenuHeaderOnly(); + } else { + openMenuFullScreen(); + } + } + }); + } + private void deactivate(View view) { view.setEnabled(false); view.setAlpha(0.5f); @@ -564,6 +581,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo changeMenuState(getViewY(), true, true, false); } + public void openMenuHeaderOnly() { + changeMenuState(getViewY(), true, false, true); + } + public void openMenuHalfScreen() { int oldMenuState = menu.getCurrentMenuState(); if (oldMenuState == MenuState.HEADER_ONLY) { @@ -596,6 +617,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo restoreCustomMapRatio(); menu.updateControlsVisibility(true); doBeforeMenuStateChange(oldMenuState, newMenuState); + toggleDetailsHideButton(); } applyPosY(currentY, needCloseMenu, needMapAdjust, oldMenuState, newMenuState, 0); From bedb45e61e517dac7d1bcff251e1c47ae8b2bc87 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Fri, 29 Dec 2017 16:43:01 +0200 Subject: [PATCH 60/66] Navigate in pedestrian mode from transport route controller --- .../net/osmand/plus/mapcontextmenu/MapContextMenu.java | 5 ++++- .../net/osmand/plus/mapcontextmenu/MenuController.java | 4 ++++ .../controllers/TransportRouteController.java | 10 +++++----- .../parkingpoint/ParkingPositionMenuController.java | 5 +++++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index ca8e8b7ccd..a6d14121b6 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -419,7 +419,10 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL } public boolean navigateInPedestrianMode() { - return menuController instanceof ParkingPositionMenuController; + if (menuController != null) { + return menuController.navigateInPedestrianMode(); + } + return false; } public boolean close() { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index 68dc0567b7..a124d885d8 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -403,6 +403,10 @@ public abstract class MenuController extends BaseMenuController { return null; } + public boolean navigateInPedestrianMode() { + return false; + } + public int getFavActionIconId() { return R.drawable.map_action_fav_dark; } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java index 18e8a2d07e..b107f77e7a 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java @@ -80,6 +80,11 @@ public class TransportRouteController extends MenuController { } } + @Override + public boolean navigateInPedestrianMode() { + return true; + } + @Override protected Object getObject() { return transportRoute; @@ -102,11 +107,6 @@ public class TransportRouteController extends MenuController { return false; } - @Override - public boolean navigateButtonVisible() { - return false; - } - @Override public boolean isClosable() { return false; diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionMenuController.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionMenuController.java index 17767ba6cd..61badd42bb 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionMenuController.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionMenuController.java @@ -83,6 +83,11 @@ public class ParkingPositionMenuController extends MenuController { return parkingTitle; } + @Override + public boolean navigateInPedestrianMode() { + return true; + } + @Override public boolean displayDistanceDirection() { return true; From a412f7102e839d9138e9fcbdd33a8f2e23a548f1 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Fri, 29 Dec 2017 17:25:13 +0200 Subject: [PATCH 61/66] Fix night theme in multi selection menu --- OsmAnd/res/drawable/multi_selection_menu_bg_dark.xml | 11 +++++++++++ .../drawable/multi_selection_menu_bg_dark_land.xml | 12 ++++++++++++ .../res/drawable/multi_selection_menu_bg_light.xml | 11 +++++++++++ .../drawable/multi_selection_menu_bg_light_land.xml | 12 ++++++++++++ OsmAnd/res/layout/menu_obj_list_item.xml | 3 ++- OsmAnd/res/layout/menu_obj_selection_fragment.xml | 4 ++-- OsmAnd/res/layout/menu_obj_selection_header.xml | 2 +- OsmAnd/res/values/colors.xml | 5 +++++ .../other/MapMultiSelectionMenuFragment.java | 12 +++++++----- .../other/MultiSelectionArrayAdapter.java | 3 ++- 10 files changed, 65 insertions(+), 10 deletions(-) create mode 100644 OsmAnd/res/drawable/multi_selection_menu_bg_dark.xml create mode 100644 OsmAnd/res/drawable/multi_selection_menu_bg_dark_land.xml create mode 100644 OsmAnd/res/drawable/multi_selection_menu_bg_light.xml create mode 100644 OsmAnd/res/drawable/multi_selection_menu_bg_light_land.xml diff --git a/OsmAnd/res/drawable/multi_selection_menu_bg_dark.xml b/OsmAnd/res/drawable/multi_selection_menu_bg_dark.xml new file mode 100644 index 0000000000..0f3ff4b6b4 --- /dev/null +++ b/OsmAnd/res/drawable/multi_selection_menu_bg_dark.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/multi_selection_menu_bg_dark_land.xml b/OsmAnd/res/drawable/multi_selection_menu_bg_dark_land.xml new file mode 100644 index 0000000000..917a1f9b7a --- /dev/null +++ b/OsmAnd/res/drawable/multi_selection_menu_bg_dark_land.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/multi_selection_menu_bg_light.xml b/OsmAnd/res/drawable/multi_selection_menu_bg_light.xml new file mode 100644 index 0000000000..8c7efd329b --- /dev/null +++ b/OsmAnd/res/drawable/multi_selection_menu_bg_light.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/multi_selection_menu_bg_light_land.xml b/OsmAnd/res/drawable/multi_selection_menu_bg_light_land.xml new file mode 100644 index 0000000000..6fdf50b311 --- /dev/null +++ b/OsmAnd/res/drawable/multi_selection_menu_bg_light_land.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/menu_obj_list_item.xml b/OsmAnd/res/layout/menu_obj_list_item.xml index 1f88444361..04835fdfca 100644 --- a/OsmAnd/res/layout/menu_obj_list_item.xml +++ b/OsmAnd/res/layout/menu_obj_list_item.xml @@ -2,6 +2,7 @@ @@ -64,6 +65,6 @@ android:id="@+id/divider" android:layout_width="match_parent" android:layout_height="1dp" - android:background="?attr/dashboard_divider"/> + tools:background="@color/multi_selection_menu_divider_dark"/> \ No newline at end of file diff --git a/OsmAnd/res/layout/menu_obj_selection_fragment.xml b/OsmAnd/res/layout/menu_obj_selection_fragment.xml index 2412846f31..75aa5be1a7 100644 --- a/OsmAnd/res/layout/menu_obj_selection_fragment.xml +++ b/OsmAnd/res/layout/menu_obj_selection_fragment.xml @@ -26,9 +26,10 @@ android:dividerHeight="0dp"/> + tools:background="@color/multi_selection_menu_divider_dark"/> diff --git a/OsmAnd/res/layout/menu_obj_selection_header.xml b/OsmAnd/res/layout/menu_obj_selection_header.xml index 3941361cf1..7204628004 100644 --- a/OsmAnd/res/layout/menu_obj_selection_header.xml +++ b/OsmAnd/res/layout/menu_obj_selection_header.xml @@ -10,7 +10,7 @@ #d28521 #727272 + #f0f0f0 + #222526 + #2f7af5 + #e69122 + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java index 3ca0063588..83c8792215 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java @@ -4,11 +4,13 @@ import android.os.Build; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; +import android.support.v4.content.ContextCompat; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.widget.ListView; +import android.widget.TextView; import net.osmand.AndroidUtils; import net.osmand.plus.R; @@ -37,10 +39,10 @@ public class MapMultiSelectionMenuFragment extends Fragment implements MultiSele view = inflater.inflate(R.layout.menu_obj_selection_fragment, container, false); if (menu.isLandscapeLayout()) { AndroidUtils.setBackground(view.getContext(), view, !menu.isLight(), - R.drawable.bg_left_menu_light, R.drawable.bg_left_menu_dark); + R.drawable.multi_selection_menu_bg_light_land, R.drawable.multi_selection_menu_bg_dark_land); } else { AndroidUtils.setBackground(view.getContext(), view, !menu.isLight(), - R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark); + R.drawable.multi_selection_menu_bg_light, R.drawable.multi_selection_menu_bg_dark); } ListView listView = (ListView) view.findViewById(R.id.list); @@ -48,9 +50,6 @@ public class MapMultiSelectionMenuFragment extends Fragment implements MultiSele AndroidUtils.addStatusBarPadding21v(getActivity(), listView); } View headerView = inflater.inflate(R.layout.menu_obj_selection_header, listView, false); - if (!menu.isLight()) { - ((TextViewEx) headerView.findViewById(R.id.header_title)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark)); - } headerView.setOnClickListener(null); listView.addHeaderView(headerView); listAdapter = createAdapter(); @@ -59,6 +58,9 @@ public class MapMultiSelectionMenuFragment extends Fragment implements MultiSele runLayoutListener(); + view.findViewById(R.id.divider).setBackgroundColor(ContextCompat.getColor(getContext(), menu.isLight() ? R.color.multi_selection_menu_divider_light : R.color.multi_selection_menu_divider_dark)); + + ((TextView) view.findViewById(R.id.cancel_row_text)).setTextColor(ContextCompat.getColor(getContext(), menu.isLight() ? R.color.multi_selection_menu_close_btn_light : R.color.multi_selection_menu_close_btn_dark)); view.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java index abce00e1de..c98342c0e2 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java @@ -64,7 +64,7 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter Date: Fri, 29 Dec 2017 17:27:54 +0200 Subject: [PATCH 62/66] Fix padding in multi selection menu --- OsmAnd/res/layout/menu_obj_list_item.xml | 6 +++--- OsmAnd/res/values-large/sizes.xml | 3 +++ OsmAnd/res/values/sizes.xml | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/layout/menu_obj_list_item.xml b/OsmAnd/res/layout/menu_obj_list_item.xml index 04835fdfca..43a79d0a21 100644 --- a/OsmAnd/res/layout/menu_obj_list_item.xml +++ b/OsmAnd/res/layout/menu_obj_list_item.xml @@ -19,8 +19,8 @@ @@ -43,7 +43,7 @@ 29dp + 20dp + 23dp + \ No newline at end of file diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml index 4b9bdbe7da..9ccfb7e17e 100644 --- a/OsmAnd/res/values/sizes.xml +++ b/OsmAnd/res/values/sizes.xml @@ -249,4 +249,7 @@ 52dp 19dp + + 13dp + 15dp \ No newline at end of file From 97ae4070a3eff237c8411abb27e0fe4f6aff74ca Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Fri, 29 Dec 2017 18:24:03 +0200 Subject: [PATCH 63/66] Add show button to transport context menu --- .../audionotes/AudioVideoNoteMenuBuilder.java | 2 +- .../plus/mapcontextmenu/MenuBuilder.java | 46 ++++++++++++++----- .../plus/mapcontextmenu/MenuController.java | 6 +-- .../builders/AmenityMenuBuilder.java | 4 +- .../builders/FavouritePointMenuBuilder.java | 2 +- .../builders/GpxItemMenuBuilder.java | 2 +- .../builders/WptPtMenuBuilder.java | 14 +++--- .../FavouritePointMenuController.java | 2 +- .../controllers/MapDataMenuController.java | 16 +++---- .../RenderedObjectMenuController.java | 4 +- .../controllers/TransportRouteController.java | 5 +- .../plus/osmedit/EditPOIMenuBuilder.java | 10 ++-- .../plus/osmedit/OsmBugMenuController.java | 2 +- 13 files changed, 70 insertions(+), 45 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNoteMenuBuilder.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNoteMenuBuilder.java index 1b213df41e..b241fbb808 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNoteMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNoteMenuBuilder.java @@ -42,7 +42,7 @@ public class AudioVideoNoteMenuBuilder extends MenuBuilder { DateFormat dateFormat = android.text.format.DateFormat.getMediumDateFormat(view.getContext()); DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(view.getContext()); Date date = new Date(recording.getFile().lastModified()); - buildRow(view, R.drawable.ic_action_data, dateFormat.format(date) + " — " + timeFormat.format(date), + buildRow(view, R.drawable.ic_action_data, null, dateFormat.format(date) + " — " + timeFormat.format(date), 0, false, null, false, 0, false, null, false); buildPlainMenuItems(view); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 9d9347469c..ff4f0ab3ec 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -101,6 +101,7 @@ public class MenuBuilder { public class PlainMenuItem { private int iconId; + private String buttonText; private String text; private boolean needLinks; private boolean url; @@ -108,10 +109,11 @@ public class MenuBuilder { private CollapsableView collapsableView; private OnClickListener onClickListener; - public PlainMenuItem(int iconId, String text, boolean needLinks, boolean url, + public PlainMenuItem(int iconId, String buttonText, String text, boolean needLinks, boolean url, boolean collapsable, CollapsableView collapsableView, OnClickListener onClickListener) { this.iconId = iconId; + this.buttonText = buttonText; this.text = text; this.needLinks = needLinks; this.url = url; @@ -124,6 +126,10 @@ public class MenuBuilder { return iconId; } + public String getButtonText() { + return buttonText; + } + public String getText() { return text; } @@ -291,7 +297,7 @@ public class MenuBuilder { buildTitleRow(view); } if (showTransportRoutes()) { - buildRow(view, 0, app.getString(R.string.transport_Routes), 0, true, getCollapsableTransportStopRoutesView(view.getContext(), false), + buildRow(view, 0, null, app.getString(R.string.transport_Routes), 0, true, getCollapsableTransportStopRoutesView(view.getContext(), false), false, 0, false, null, true); } buildNearestWikiRow(view); @@ -326,7 +332,7 @@ public class MenuBuilder { protected void buildPlainMenuItems(View view) { for (PlainMenuItem item : plainMenuItems) { - buildRow(view, item.getIconId(), item.getText(), 0, item.collapsable, item.collapsableView, + buildRow(view, item.getIconId(), item.getButtonText(), item.getText(), 0, item.collapsable, item.collapsableView, item.isNeedLinks(), 0, item.isUrl(), item.getOnClickListener(), false); } } @@ -351,14 +357,14 @@ public class MenuBuilder { if (mapContextMenu != null) { String title = mapContextMenu.getTitleStr(); if (title.length() > TITLE_LIMIT) { - buildRow(view, R.drawable.ic_action_note_dark, title, 0, false, null, false, 0, false, null, false); + buildRow(view, R.drawable.ic_action_note_dark, null, title, 0, false, null, false, 0, false, null, false); } } } protected void buildNearestWikiRow(View view) { if (processNearstWiki() && nearestWiki.size() > 0) { - buildRow(view, R.drawable.ic_action_wikipedia, app.getString(R.string.wiki_around) + " (" + nearestWiki.size()+")", 0, + buildRow(view, R.drawable.ic_action_wikipedia, null, app.getString(R.string.wiki_around) + " (" + nearestWiki.size()+")", 0, true, getCollapsableWikiView(view.getContext(), true), false, 0, false, null, false); } @@ -382,7 +388,7 @@ public class MenuBuilder { } } }); - buildRow(view, R.drawable.ic_action_photo_dark, app.getString(R.string.online_photos), 0, true, + buildRow(view, R.drawable.ic_action_photo_dark, null, app.getString(R.string.online_photos), 0, true, collapsableView, false, 1, false, null, false); if (needUpdateOnly && onlinePhotoCards != null) { @@ -439,14 +445,14 @@ public class MenuBuilder { firstRow = false; } - public View buildRow(View view, int iconId, String text, int textColor, + public View buildRow(View view, int iconId, String buttonText, String text, int textColor, boolean collapsable, final CollapsableView collapsableView, boolean needLinks, int textLinesLimit, boolean isUrl, OnClickListener onClickListener, boolean matchWidthDivider) { - return buildRow(view, iconId == 0 ? null : getRowIcon(iconId), text, textColor, null, collapsable, collapsableView, + return buildRow(view, iconId == 0 ? null : getRowIcon(iconId), buttonText, text, textColor, null, collapsable, collapsableView, needLinks, textLinesLimit, isUrl, onClickListener, matchWidthDivider); } - public View buildRow(final View view, Drawable icon, final String text, int textColor, String secondaryText, + public View buildRow(final View view, Drawable icon, final String buttonText, final String text, int textColor, String secondaryText, boolean collapsable, final CollapsableView collapsableView, boolean needLinks, int textLinesLimit, boolean isUrl, OnClickListener onClickListener, boolean matchWidthDivider) { @@ -540,6 +546,20 @@ public class MenuBuilder { llText.addView(textViewSecondary); } + //Button + if (!TextUtils.isEmpty(buttonText)) { + TextViewEx buttonTextView = new TextViewEx(view.getContext()); + LinearLayout.LayoutParams buttonTextViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + buttonTextViewParams.gravity = Gravity.CENTER_VERTICAL; + buttonTextViewParams.setMargins(dpToPx(8), 0, dpToPx(8), 0); + buttonTextView.setLayoutParams(buttonTextViewParams); + buttonTextView.setTypeface(FontCache.getRobotoMedium(view.getContext())); + buttonTextView.setAllCaps(true); + buttonTextView.setTextColor(ContextCompat.getColor(view.getContext(), !light ? R.color.ctx_menu_controller_button_text_color_dark_n : R.color.ctx_menu_controller_button_text_color_light_n)); + buttonTextView.setText(buttonText); + ll.addView(buttonTextView); + } + final ImageView iconViewCollapse = new ImageView(view.getContext()); if (collapsable && collapsableView != null) { // Icon @@ -673,13 +693,17 @@ public class MenuBuilder { } public void addPlainMenuItem(int iconId, String text, boolean needLinks, boolean isUrl, OnClickListener onClickListener) { - plainMenuItems.add(new PlainMenuItem(iconId, text, needLinks, isUrl, false, null, onClickListener)); + plainMenuItems.add(new PlainMenuItem(iconId, text, null, needLinks, isUrl, false, null, onClickListener)); + } + + public void addPlainMenuItem(int iconId, String buttonText, String text, boolean needLinks, boolean isUrl, OnClickListener onClickListener) { + plainMenuItems.add(new PlainMenuItem(iconId, buttonText, text, needLinks, isUrl, false, null, onClickListener)); } public void addPlainMenuItem(int iconId, String text, boolean needLinks, boolean isUrl, boolean collapsable, CollapsableView collapsableView, OnClickListener onClickListener) { - plainMenuItems.add(new PlainMenuItem(iconId, text, needLinks, isUrl, collapsable, collapsableView, onClickListener)); + plainMenuItems.add(new PlainMenuItem(iconId, text, null, needLinks, isUrl, collapsable, collapsableView, onClickListener)); } public void clearPlainMenuItems() { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index a124d885d8..c1a6d78328 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -226,8 +226,8 @@ public abstract class MenuController extends BaseMenuController { return true; } - public void addPlainMenuItem(int iconId, String text, boolean needLinks, boolean isUrl, OnClickListener onClickListener) { - builder.addPlainMenuItem(iconId, text, needLinks, isUrl, onClickListener); + public void addPlainMenuItem(int iconId, String buttonText, String text, boolean needLinks, boolean isUrl, OnClickListener onClickListener) { + builder.addPlainMenuItem(iconId, buttonText, text, needLinks, isUrl, onClickListener); } public void clearPlainMenuItems() { @@ -240,7 +240,7 @@ public abstract class MenuController extends BaseMenuController { protected void addMyLocationToPlainItems(LatLon latLon) { OsmandSettings st = ((OsmandApplication) getMapActivity().getApplicationContext()).getSettings(); - addPlainMenuItem(R.drawable.ic_action_get_my_location, PointDescription.getLocationName(getMapActivity(), + addPlainMenuItem(R.drawable.ic_action_get_my_location, null, PointDescription.getLocationName(getMapActivity(), latLon.getLatitude(), latLon.getLongitude(), true).replaceAll("\n", " "), false, false, null); //if (st.COORDINATES_FORMAT.get() != PointDescription.OLC_FORMAT) // addPlainMenuItem(R.drawable.ic_action_get_my_location, PointDescription.getLocationOlcName( diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java index 9f460f33a9..5d7610e692 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -518,10 +518,10 @@ public class AmenityMenuBuilder extends MenuBuilder { } else { link = "https://www.openstreetmap.org/way/"; } - buildRow(view, R.drawable.ic_action_info_dark, link + (amenity.getId() >> 1), + buildRow(view, R.drawable.ic_action_info_dark, null, link + (amenity.getId() >> 1), 0, false, null, true, 0, true, null, false); } - buildRow(view, R.drawable.ic_action_get_my_location, PointDescription.getLocationName(app, + buildRow(view, R.drawable.ic_action_get_my_location, null, PointDescription.getLocationName(app, amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude(), true) .replaceAll("\n", " "), 0, false, null, false, 0, false, null, false); //if (st.COORDINATES_FORMAT.get() != PointDescription.OLC_FORMAT) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/FavouritePointMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/FavouritePointMenuBuilder.java index 05097d55f2..55056d5279 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/FavouritePointMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/FavouritePointMenuBuilder.java @@ -78,7 +78,7 @@ public class FavouritePointMenuBuilder extends MenuBuilder { int disabledColor = light ? R.color.secondary_text_light : R.color.secondary_text_dark; color = favoriteGroup.visible ? (color | 0xff000000) : view.getResources().getColor(disabledColor); String name = view.getContext().getString(R.string.context_menu_points_of_group); - buildRow(view, app.getIconsCache().getPaintedIcon(R.drawable.ic_action_folder, color), name, 0, null, + buildRow(view, app.getIconsCache().getPaintedIcon(R.drawable.ic_action_folder, color), null, name, 0, null, true, getCollapsableFavouritesView(view.getContext(), true, favoriteGroup, fav), false, 0, false, null, false); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/GpxItemMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/GpxItemMenuBuilder.java index 10d61daf3e..2058c4ca03 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/GpxItemMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/GpxItemMenuBuilder.java @@ -34,7 +34,7 @@ public class GpxItemMenuBuilder extends MenuBuilder { String description = GpxUiHelper.getDescription(app, item.analysis, false); String[] lines = description.split("\n"); for (String line : lines) { - buildRow(view, R.drawable.ic_action_info_dark, line, 0, false, null, false, 0, false, null, false); + buildRow(view, R.drawable.ic_action_info_dark, null, line, 0, false, null, false, 0, false, null, false); } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java index 9553e96d39..ddb18b6278 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java @@ -44,23 +44,23 @@ public class WptPtMenuBuilder extends MenuBuilder { DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(view.getContext()); Date date = new Date(wpt.time); buildRow(view, R.drawable.ic_action_data, - dateFormat.format(date) + " — " + timeFormat.format(date), 0, false, null, false, 0, false, null, false); + null, dateFormat.format(date) + " — " + timeFormat.format(date), 0, false, null, false, 0, false, null, false); } if (wpt.speed > 0) { buildRow(view, R.drawable.ic_action_speed, - OsmAndFormatter.getFormattedSpeed((float)wpt.speed, app), 0, false, null, false, 0, false, null, false); + null, OsmAndFormatter.getFormattedSpeed((float)wpt.speed, app), 0, false, null, false, 0, false, null, false); } if (!Double.isNaN(wpt.ele)) { buildRow(view, R.drawable.ic_action_altitude, - OsmAndFormatter.getFormattedDistance((float) wpt.ele, app), 0, false, null, false, 0, false, null, false); + null, OsmAndFormatter.getFormattedDistance((float) wpt.ele, app), 0, false, null, false, 0, false, null, false); } if (!Double.isNaN(wpt.hdop)) { buildRow(view, R.drawable.ic_action_gps_info, - Algorithms.capitalizeFirstLetterAndLowercase(app.getString(R.string.plugin_distance_point_hdop)) + ": " + (int)wpt.hdop, 0, + null, Algorithms.capitalizeFirstLetterAndLowercase(app.getString(R.string.plugin_distance_point_hdop)) + ": " + (int)wpt.hdop, 0, false, null, false, 0, false, null, false); } if (!Algorithms.isEmpty(wpt.desc)) { - final View row = buildRow(view, R.drawable.ic_action_note_dark, wpt.desc, 0, false, null, true, 10, false, null, false); + final View row = buildRow(view, R.drawable.ic_action_note_dark, null, wpt.desc, 0, false, null, true, 10, false, null, false); row.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -70,7 +70,7 @@ public class WptPtMenuBuilder extends MenuBuilder { }); } if (!Algorithms.isEmpty(wpt.comment)) { - final View rowc = buildRow(view, R.drawable.ic_action_note_dark, wpt.comment, 0, + final View rowc = buildRow(view, R.drawable.ic_action_note_dark, null, wpt.comment, 0, false, null, true, 10, false, null, false); rowc.setOnClickListener(new View.OnClickListener() { @Override @@ -96,7 +96,7 @@ public class WptPtMenuBuilder extends MenuBuilder { File file = new File(gpx.path); String gpxName = file.getName().replace(".gpx", "").replace("/", " ").replace("_", " "); int color = getPointColor(wpt, getFileColor(selectedGpxFile)); - buildRow(view, app.getIconsCache().getPaintedIcon(R.drawable.ic_type_waypoints_group, color), title, 0, gpxName, + buildRow(view, app.getIconsCache().getPaintedIcon(R.drawable.ic_type_waypoints_group, color), null, title, 0, gpxName, true, getCollapsableWaypointsView(view.getContext(), true, gpx, wpt), false, 0, false, null, false); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java index e0a6ae278d..0e1ddda8fa 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/FavouritePointMenuController.java @@ -139,7 +139,7 @@ public class FavouritePointMenuController extends MenuController { @Override public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) { if (!Algorithms.isEmpty(fav.getDescription())) { - addPlainMenuItem(R.drawable.ic_action_note_dark, fav.getDescription(), true, false, null); + addPlainMenuItem(R.drawable.ic_action_note_dark, null, fav.getDescription(), true, false, null); } Object originObject = getBuilder().getOriginObject(); if (originObject != null) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java index 6028f14f38..a0735a80b2 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java @@ -271,16 +271,16 @@ public class MapDataMenuController extends MenuController { @Override public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) { if (indexItem != null) { - addPlainMenuItem(R.drawable.ic_action_info_dark, indexItem.getType().getString(getMapActivity()), false, false, null); + addPlainMenuItem(R.drawable.ic_action_info_dark, null, indexItem.getType().getString(getMapActivity()), false, false, null); StringBuilder sizeStr = new StringBuilder(); sizeStr.append(indexItem.getSizeDescription(getMapActivity())); if (backuped) { sizeStr.append(" — ").append(LocalIndexType.DEACTIVATED.getHumanString(getMapActivity())); } - addPlainMenuItem(R.drawable.ic_action_info_dark, sizeStr.toString(), false, false, null); + addPlainMenuItem(R.drawable.ic_action_info_dark, null, sizeStr.toString(), false, false, null); } else if (localIndexInfo != null) { if (getDownloadActivityType() != null) { - addPlainMenuItem(R.drawable.ic_action_info_dark, getDownloadActivityType().getString(getMapActivity()), false, false, null); + addPlainMenuItem(R.drawable.ic_action_info_dark, null, getDownloadActivityType().getString(getMapActivity()), false, false, null); } StringBuilder sizeStr = new StringBuilder(); if (localIndexInfo.getSize() >= 0) { @@ -297,7 +297,7 @@ public class MapDataMenuController extends MenuController { sizeStr.append(LocalIndexType.DEACTIVATED.getHumanString(getMapActivity())); } } - addPlainMenuItem(R.drawable.ic_action_info_dark, sizeStr.toString(), false, false, null); + addPlainMenuItem(R.drawable.ic_action_info_dark, null, sizeStr.toString(), false, false, null); } if (!Algorithms.isEmpty(mapObject.getWorldRegion().getParams().getWikiLink())) { String[] items = mapObject.getWorldRegion().getParams().getWikiLink().split(":"); @@ -307,7 +307,7 @@ public class MapDataMenuController extends MenuController { } else { url = "https://wikipedia.org/wiki/" + items[0].replace(' ', '_'); } - addPlainMenuItem(R.drawable.ic_world_globe_dark, url, false, true, null); + addPlainMenuItem(R.drawable.ic_world_globe_dark, null, url, false, true, null); } if (!Algorithms.isEmpty(mapObject.getWorldRegion().getParams().getPopulation())) { String population = mapObject.getWorldRegion().getParams().getPopulation(); @@ -321,14 +321,14 @@ public class MapDataMenuController extends MenuController { b.insert(0, population.charAt(i)); k++; } - addPlainMenuItem(R.drawable.ic_action_info_dark, getMapActivity().getResources().getString(R.string.poi_population) + addPlainMenuItem(R.drawable.ic_action_info_dark, null, getMapActivity().getResources().getString(R.string.poi_population) + ": " + b, false, false, null); } if (indexItem != null) { DateFormat dateFormat = android.text.format.DateFormat.getMediumDateFormat(getMapActivity()); - addPlainMenuItem(R.drawable.ic_action_data, indexItem.getRemoteDate(dateFormat), false, false, null); + addPlainMenuItem(R.drawable.ic_action_data, null, indexItem.getRemoteDate(dateFormat), false, false, null); } else if (localIndexInfo != null) { - addPlainMenuItem(R.drawable.ic_action_data, localIndexInfo.getDescription(), false, false, null); + addPlainMenuItem(R.drawable.ic_action_data, null, localIndexInfo.getDescription(), false, false, null); } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/RenderedObjectMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/RenderedObjectMenuController.java index d9b1ea205b..1e0961b2b0 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/RenderedObjectMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/RenderedObjectMenuController.java @@ -95,7 +95,7 @@ public class RenderedObjectMenuController extends MenuController { if (entry.getKey().equalsIgnoreCase("maxheight")) { AbstractPoiType pt = poiTypes.getAnyPoiAdditionalTypeByKey(entry.getKey()); if (pt != null) { - addPlainMenuItem(R.drawable.ic_action_note_dark, pt.getTranslation() + ": " + entry.getValue(), false, false, null); + addPlainMenuItem(R.drawable.ic_action_note_dark, null, pt.getTranslation() + ": " + entry.getValue(), false, false, null); } } } @@ -110,7 +110,7 @@ public class RenderedObjectMenuController extends MenuController { } else { link = "https://www.openstreetmap.org/way/"; } - addPlainMenuItem(R.drawable.ic_action_info_dark, link + (renderedObject.getId() >> 7), true, true, null); + addPlainMenuItem(R.drawable.ic_action_info_dark, null, link + (renderedObject.getId() >> 7), true, true, null); } addMyLocationToPlainItems(latLon); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java index b107f77e7a..0809d7a147 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java @@ -240,7 +240,8 @@ public class TransportRouteController extends MenuController { if (!transportRoute.showWholeRoute) { startPosition = (currentStop == -1 ? 0 : currentStop); if (currentStop > 0) { - addPlainMenuItem(defaultIcon, getMapActivity().getString(R.string.route_stops_before, currentStop), + addPlainMenuItem(defaultIcon, getMapActivity().getString(R.string.shared_string_show), + getMapActivity().getString(R.string.route_stops_before, currentStop), false, false, new OnClickListener() { @Override @@ -258,7 +259,7 @@ public class TransportRouteController extends MenuController { name = getStopType(); } addPlainMenuItem(currentStop == i ? R.drawable.ic_action_marker_dark : defaultIcon, - name, false, false, new OnClickListener() { + null, name, false, false, new OnClickListener() { @Override public void onClick(View arg0) { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuBuilder.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuBuilder.java index 742ba1c410..d4e53c0e68 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuBuilder.java @@ -30,8 +30,8 @@ public class EditPOIMenuBuilder extends MenuBuilder { if (osmPoint instanceof OsmNotesPoint) { OsmNotesPoint notes = (OsmNotesPoint) osmPoint; - buildRow(view, R.drawable.ic_action_note_dark, notes.getText(), 0, false, null, false, 0, false, null, false); - buildRow(view, R.drawable.ic_group, notes.getAuthor(), 0, false, null, false, 0, false, null, false); + buildRow(view, R.drawable.ic_action_note_dark, null, notes.getText(), 0, false, null, false, 0, false, null, false); + buildRow(view, R.drawable.ic_group, null, notes.getAuthor(), 0, false, null, false, 0, false, null, false); } else if (osmPoint instanceof OpenstreetmapPoint) { OpenstreetmapPoint point = (OpenstreetmapPoint) osmPoint; @@ -56,7 +56,7 @@ public class EditPOIMenuBuilder extends MenuBuilder { if (resId == 0) { resId = R.drawable.ic_action_folder_stroke; } - buildRow(view, resId, poiTranslation, 0, false, null, false, 0, false, null, false); + buildRow(view, resId, null, poiTranslation, 0, false, null, false, 0, false, null, false); break; } } @@ -67,11 +67,11 @@ public class EditPOIMenuBuilder extends MenuBuilder { continue; } String text = e.getKey() + "=" + e.getValue(); - buildRow(view, R.drawable.ic_action_info_dark, text, 0, false, null, false, 0, false, null, false); + buildRow(view, R.drawable.ic_action_info_dark, null, text, 0, false, null, false, 0, false, null, false); } } - buildRow(view, R.drawable.ic_action_get_my_location, PointDescription.getLocationName(app, + buildRow(view, R.drawable.ic_action_get_my_location, null, PointDescription.getLocationName(app, osmPoint.getLatitude(), osmPoint.getLongitude(), true) .replaceAll("\n", " "), 0, false, null, false, 0, false, null, false); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugMenuController.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugMenuController.java index 8827ebd024..02df976545 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugMenuController.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugMenuController.java @@ -95,7 +95,7 @@ public class OsmBugMenuController extends MenuController { public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) { super.addPlainMenuItems(typeStr, pointDescription, latLon); for (String description : bug.getCommentDescriptionList()) { - addPlainMenuItem(R.drawable.ic_action_note_dark, description, true, false, null); + addPlainMenuItem(R.drawable.ic_action_note_dark, null, description, true, false, null); } } From 6f804bc4209769b16fad8b062fbd2ec097352739 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Fri, 29 Dec 2017 18:52:48 +0200 Subject: [PATCH 64/66] Fix button text in context menu --- OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index ff4f0ab3ec..7d53141a19 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -693,7 +693,7 @@ public class MenuBuilder { } public void addPlainMenuItem(int iconId, String text, boolean needLinks, boolean isUrl, OnClickListener onClickListener) { - plainMenuItems.add(new PlainMenuItem(iconId, text, null, needLinks, isUrl, false, null, onClickListener)); + plainMenuItems.add(new PlainMenuItem(iconId, null, text, needLinks, isUrl, false, null, onClickListener)); } public void addPlainMenuItem(int iconId, String buttonText, String text, boolean needLinks, boolean isUrl, OnClickListener onClickListener) { @@ -703,7 +703,7 @@ public class MenuBuilder { public void addPlainMenuItem(int iconId, String text, boolean needLinks, boolean isUrl, boolean collapsable, CollapsableView collapsableView, OnClickListener onClickListener) { - plainMenuItems.add(new PlainMenuItem(iconId, text, null, needLinks, isUrl, collapsable, collapsableView, onClickListener)); + plainMenuItems.add(new PlainMenuItem(iconId, null, text, needLinks, isUrl, collapsable, collapsableView, onClickListener)); } public void clearPlainMenuItems() { From a6932c15b6071fc679c3f8843fb719aed6269abc Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Thu, 11 Jan 2018 12:26:52 +0200 Subject: [PATCH 65/66] Add menu controller text color to styles --- OsmAnd/res/values/styles.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values/styles.xml b/OsmAnd/res/values/styles.xml index b3fe484df3..324296db60 100644 --- a/OsmAnd/res/values/styles.xml +++ b/OsmAnd/res/values/styles.xml @@ -132,6 +132,7 @@ @drawable/dashboard_button_light @color/ctx_menu_info_view_bg_light @drawable/context_menu_controller_bg_light + @drawable/context_menu_controller_text_color_light @color/ctx_menu_buttons_divider_light @color/search_background_dark @drawable/ic_action_mode_back @@ -321,6 +322,7 @@ @drawable/dashboard_button_dark @color/ctx_menu_info_view_bg_dark @drawable/context_menu_controller_bg_dark + @drawable/context_menu_controller_text_color_dark @color/ctx_menu_buttons_divider_dark @color/color_white @drawable/switch_ex_background_dark From e6fa541c02a7eea294960bfb2d3e4c955c944e14 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Thu, 11 Jan 2018 13:15:27 +0200 Subject: [PATCH 66/66] Fix strings; extract boilerplate code to AndroidUtils --- OsmAnd/src/net/osmand/AndroidUtils.java | 17 ++++++++++++ .../MapContextMenuFragment.java | 13 +++------- .../plus/mapcontextmenu/MenuBuilder.java | 13 +++------- .../plus/mapcontextmenu/OpeningHoursInfo.java | 10 +++---- .../WikipediaDialogFragment.java | 13 +++------- .../builders/AmenityMenuBuilder.java | 13 +++------- .../CoordinateInputDialogFragment.java | 26 +++++-------------- 7 files changed, 40 insertions(+), 65 deletions(-) diff --git a/OsmAnd/src/net/osmand/AndroidUtils.java b/OsmAnd/src/net/osmand/AndroidUtils.java index 8456023fa7..ba61cd1b36 100644 --- a/OsmAnd/src/net/osmand/AndroidUtils.java +++ b/OsmAnd/src/net/osmand/AndroidUtils.java @@ -4,6 +4,7 @@ package net.osmand; import android.annotation.SuppressLint; import android.app.Activity; import android.content.Context; +import android.content.res.ColorStateList; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.PointF; @@ -11,6 +12,7 @@ import android.graphics.drawable.Drawable; import android.graphics.drawable.StateListDrawable; import android.os.Build; import android.os.IBinder; +import android.support.annotation.ColorRes; import android.support.annotation.DrawableRes; import android.support.v4.content.ContextCompat; import android.text.TextUtils; @@ -118,6 +120,21 @@ public class AndroidUtils { return null; } + public static ColorStateList createColorStateList(Context ctx, boolean night, + @ColorRes int lightNormal, @ColorRes int lightPressed, + @ColorRes int darkNormal, @ColorRes int darkPressed) { + return new ColorStateList( + new int[][]{ + new int[]{android.R.attr.state_pressed}, + new int[]{} + }, + new int[]{ + ContextCompat.getColor(ctx, night ? darkPressed : lightPressed), + ContextCompat.getColor(ctx, night ? darkNormal : lightNormal) + } + ); + } + public static StateListDrawable createStateListDrawable(Context ctx, boolean night, @DrawableRes int lightNormal, @DrawableRes int lightPressed, @DrawableRes int darkNormal, @DrawableRes int darkPressed) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index fe3ce68846..72099d943e 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -716,16 +716,9 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo private void enableDisableButtons(View buttonView, TextView button, boolean enabled) { if (enabled) { - ColorStateList buttonColorStateList = new ColorStateList( - new int[][]{ - new int[]{android.R.attr.state_pressed}, - new int[]{} - }, - new int[] { - getResources().getColor(nightMode ? R.color.ctx_menu_controller_button_text_color_dark_p : R.color.ctx_menu_controller_button_text_color_light_p), - getResources().getColor(nightMode ? R.color.ctx_menu_controller_button_text_color_dark_n : R.color.ctx_menu_controller_button_text_color_light_n) - } - ); + ColorStateList buttonColorStateList = AndroidUtils.createColorStateList(getContext(), nightMode, + R.color.ctx_menu_controller_button_text_color_light_n, R.color.ctx_menu_controller_button_text_color_light_p, + R.color.ctx_menu_controller_button_text_color_dark_n, R.color.ctx_menu_controller_button_text_color_dark_p); buttonView.setBackgroundResource(nightMode ? R.drawable.context_menu_controller_bg_dark : R.drawable.context_menu_controller_bg_light); button.setTextColor(buttonColorStateList); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 7d53141a19..cd43f295ec 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -991,16 +991,9 @@ public class MenuBuilder { int paddingSides = dpToPx(10f); button.setPadding(paddingSides, 0, paddingSides, 0); if (!selected) { - ColorStateList buttonColorStateList = new ColorStateList( - new int[][] { - new int[]{android.R.attr.state_pressed}, - new int[]{} - }, - new int[] { - context.getResources().getColor(light ? R.color.ctx_menu_controller_button_text_color_light_p : R.color.ctx_menu_controller_button_text_color_dark_p), - context.getResources().getColor(light ? R.color.ctx_menu_controller_button_text_color_light_n : R.color.ctx_menu_controller_button_text_color_dark_n) - } - ); + ColorStateList buttonColorStateList = AndroidUtils.createColorStateList(context, !light, + R.color.ctx_menu_controller_button_text_color_light_n, R.color.ctx_menu_controller_button_text_color_light_p, + R.color.ctx_menu_controller_button_text_color_dark_n, R.color.ctx_menu_controller_button_text_color_dark_p); button.setTextColor(buttonColorStateList); } else { button.setTextColor(ContextCompat.getColor(context, light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark)); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/OpeningHoursInfo.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/OpeningHoursInfo.java index 09db885529..34990e86ac 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/OpeningHoursInfo.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/OpeningHoursInfo.java @@ -75,15 +75,15 @@ public class OpeningHoursInfo { if (isOpened24_7()) { return context.getString(R.string.shared_string_is_open_24_7); } else if (!Algorithms.isEmpty(getNearToOpeningTime())) { - return context.getString(R.string.will_be_opened_at) + " " + getNearToOpeningTime(); + return context.getString(R.string.will_open_at) + " " + getNearToOpeningTime(); } else if (!Algorithms.isEmpty(getOpeningTime())) { - return context.getString(R.string.opened_from) + " " + getOpeningTime(); + return context.getString(R.string.open_from) + " " + getOpeningTime(); } else if (!Algorithms.isEmpty(getNearToClosingTime())) { - return context.getString(R.string.will_be_closed_at) + " " + getNearToClosingTime(); + return context.getString(R.string.will_close_at) + " " + getNearToClosingTime(); } else if (!Algorithms.isEmpty(getClosingTime())) { - return context.getString(R.string.opened_till) + " " + getClosingTime(); + return context.getString(R.string.open_till) + " " + getClosingTime(); } else if (!Algorithms.isEmpty(getOpeningDay())) { - return context.getString(R.string.will_be_opened_on) + " " + getOpeningDay() + "."; + return context.getString(R.string.will_open_on) + " " + getOpeningDay() + "."; } return ""; } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java index 6480054f13..0030eedf43 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java @@ -102,16 +102,9 @@ public class WikipediaDialogFragment extends DialogFragment { TextView titleTextView = (TextView) mainView.findViewById(R.id.title_text_view); titleTextView.setTextColor(toolbarTextColor); - ColorStateList buttonColorStateList = new ColorStateList( - new int[][]{ - new int[]{android.R.attr.state_pressed}, - new int[]{} - }, - new int[] { - getResources().getColor(darkMode ? R.color.ctx_menu_controller_button_text_color_dark_p : R.color.ctx_menu_controller_button_text_color_light_p), - getResources().getColor(darkMode ? R.color.ctx_menu_controller_button_text_color_dark_n : R.color.ctx_menu_controller_button_text_color_light_n) - } - ); + ColorStateList buttonColorStateList = AndroidUtils.createColorStateList(getContext(), darkMode, + R.color.ctx_menu_controller_button_text_color_light_n, R.color.ctx_menu_controller_button_text_color_light_p, + R.color.ctx_menu_controller_button_text_color_dark_n, R.color.ctx_menu_controller_button_text_color_dark_p); final TextView readFullArticleButton = (TextView) mainView.findViewById(R.id.read_full_article); CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) readFullArticleButton.getLayoutParams(); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java index 5d7610e692..ce158b58b1 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -219,16 +219,9 @@ public class AmenityMenuBuilder extends MenuBuilder { button.setTextSize(14); int paddingSides = dpToPx(10f); button.setPadding(paddingSides, 0, paddingSides, 0); - ColorStateList buttonColorStateList = new ColorStateList( - new int[][] { - new int[]{android.R.attr.state_pressed}, - new int[]{} - }, - new int[] { - view.getResources().getColor(light ? R.color.ctx_menu_controller_button_text_color_light_p : R.color.ctx_menu_controller_button_text_color_dark_p), - view.getResources().getColor(light ? R.color.ctx_menu_controller_button_text_color_light_n : R.color.ctx_menu_controller_button_text_color_dark_n) - } - ); + ColorStateList buttonColorStateList = AndroidUtils.createColorStateList(view.getContext(), !light, + R.color.ctx_menu_controller_button_text_color_light_n, R.color.ctx_menu_controller_button_text_color_light_p, + R.color.ctx_menu_controller_button_text_color_dark_n, R.color.ctx_menu_controller_button_text_color_dark_p); button.setTextColor(buttonColorStateList); button.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); button.setSingleLine(true); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java index 977fbe466c..bdb13ffa46 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java @@ -754,26 +754,12 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm private class KeyboardAdapter extends ArrayAdapter { - private ColorStateList dividerControlColorStateList = new ColorStateList( - new int[][]{ - new int[]{android.R.attr.state_pressed}, - new int[]{} - }, - new int[] { - getResources().getColor(R.color.keyboard_item_divider_control_color_light_pressed), - getResources().getColor(R.color.keyboard_item_divider_control_color_light) - } - ); - private ColorStateList numberColorStateList = new ColorStateList( - new int[][]{ - new int[]{android.R.attr.state_pressed}, - new int[]{} - }, - new int[] { - getResources().getColor(R.color.keyboard_item_text_color_light_pressed), - getResources().getColor(R.color.keyboard_item_text_color_light) - } - ); + private ColorStateList dividerControlColorStateList = AndroidUtils.createColorStateList(getContext(), false, + R.color.keyboard_item_divider_control_color_light, R.color.keyboard_item_divider_control_color_light_pressed, + 0, 0); + private ColorStateList numberColorStateList = AndroidUtils.createColorStateList(getContext(), false, + R.color.keyboard_item_text_color_light, R.color.keyboard_item_text_color_light_pressed, + 0, 0); KeyboardAdapter(@NonNull Context context, @NonNull Object[] objects) { super(context, 0, objects);