From bd2f898a40e0b456e15b22a0323ebfd2604c95b4 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Mon, 18 Dec 2017 13:23:18 +0200 Subject: [PATCH] Change text in parking menu controller --- OsmAnd/res/values/strings.xml | 2 ++ .../plus/mapcontextmenu/MapContextMenu.java | 22 ++++++------- .../MapContextMenuFragment.java | 22 +++++++------ .../plus/mapcontextmenu/MenuController.java | 20 +++++------- .../mapcontextmenu/MenuTitleController.java | 2 +- .../controllers/AmenityMenuController.java | 4 +-- .../controllers/WptPtMenuController.java | 5 --- .../ParkingPositionMenuController.java | 22 ++++++++----- .../parkingpoint/ParkingPositionPlugin.java | 31 ++++++++++++++++--- 9 files changed, 78 insertions(+), 52 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index d4f749372a..c70a834128 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,8 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> + parked at + Pick up till Without time limit Read full article Read article diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index c6425f53d9..31a2f9403f 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -1127,6 +1127,17 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL return menuController != null && menuController.displayDistanceDirection(); } + public boolean displayAdditionalTypeStrInHours() { + return menuController != null && menuController.displayAdditionalTypeStrInHours(); + } + + public int getTimeStrColor() { + if (menuController != null) { + return menuController.getTimeStrColor(); + } + return 0; + } + public boolean isMapDownloaded() { return menuController != null && menuController.isMapDownloaded(); } @@ -1137,17 +1148,6 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL } } - public String getLimitedTimeInfo() { - if (menuController != null) { - return menuController.getLimitedTimeInfo(); - } - return ""; - } - - public boolean isLimitedTime() { - return menuController != null && menuController.isLimitedTime(); - } - public boolean hasCustomAddressLine() { return menuController != null && menuController.hasCustomAddressLine(); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index b1692ccc46..dce8d4afb8 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -1120,7 +1120,9 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo TextView line3 = (TextView) view.findViewById(R.id.context_menu_line3); String additionalTypeStr = menu.getAdditionalTypeStr(); - if (TextUtils.isEmpty(additionalTypeStr)) { + boolean displayAdditionalTypeStrInHours = menu.displayAdditionalTypeStrInHours(); + boolean emptyAdditionalTypeStr = TextUtils.isEmpty(additionalTypeStr); + if (emptyAdditionalTypeStr || displayAdditionalTypeStrInHours) { line3.setVisibility(View.GONE); } else { line3.setVisibility(View.VISIBLE); @@ -1132,17 +1134,14 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo TextView openingHoursTextView = (TextView) view.findViewById(R.id.opening_hours_text_view); OpeningHoursInfo openingHoursInfo = menu.getOpeningHoursInfo(); - String limitedTimeInfo = menu.getLimitedTimeInfo(); boolean containsOpeningHours = openingHoursInfo != null && openingHoursInfo.containsInfo(); - boolean containsLimitedHoursInfo = !TextUtils.isEmpty(limitedTimeInfo); - if (containsOpeningHours || containsLimitedHoursInfo) { + 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.isLimitedTime() ? R.color.ctx_menu_amenity_closed_text_color : !nightMode ? R.color.icon_color : R.color.dash_search_icon_dark; + colorId = menu.getTimeStrColor(); } - openingHoursTextView.setTextColor(ContextCompat.getColor(getContext(), colorId)); String timeInfo = ""; if (containsOpeningHours) { if (openingHoursInfo.isOpened24_7()) { @@ -1159,11 +1158,14 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo timeInfo = getString(R.string.will_be_opened_on) + " " + openingHoursInfo.getOpeningDay() + "."; } } else { - timeInfo = limitedTimeInfo; + timeInfo = additionalTypeStr; + } + 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)); } - Drawable drawable = getIcon(R.drawable.ic_action_opening_hour_16, colorId); - openingHoursTextView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null); - openingHoursTextView.setCompoundDrawablePadding(dpToPx(8)); openingHoursTextView.setText(timeInfo); openingHoursTextView.setVisibility(View.VISIBLE); } else { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index efe69f2f0d..daf04f5904 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -378,10 +378,6 @@ public abstract class MenuController extends BaseMenuController { return true; } - public boolean needAdditionalTypeStr() { - return false; - } - public boolean displayStreetNameInTitle() { return false; } @@ -390,6 +386,10 @@ public abstract class MenuController extends BaseMenuController { return false; } + public boolean displayAdditionalTypeStrInHours() { + return false; + } + public int getLeftIconId() { return 0; } @@ -436,6 +436,10 @@ public abstract class MenuController extends BaseMenuController { return ""; } + public int getTimeStrColor() { + return 0; + } + public OpeningHoursInfo getOpeningHoursInfo() { return null; } @@ -444,14 +448,6 @@ public abstract class MenuController extends BaseMenuController { return ""; } - public String getLimitedTimeInfo() { - return ""; - } - - public boolean isLimitedTime() { - return false; - } - public String getNameStr() { return pointDescription.getName(); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java index d48eefb5f5..f5c5689798 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java @@ -95,7 +95,7 @@ public abstract class MenuTitleController { public String getAdditionalTypeStr() { MenuController menuController = getMenuController(); - if (menuController != null && menuController.needAdditionalTypeStr()) { + if (menuController != null) { return additionalTypeStr; } else { return ""; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java index 8cc7765dda..862f0090ca 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java @@ -42,7 +42,7 @@ public class AmenityMenuController extends MenuController { private MapMarker marker; - public AmenityMenuController(MapActivity mapActivity, PointDescription pointDescription, Amenity amenity) { + public AmenityMenuController(final MapActivity mapActivity, PointDescription pointDescription, final Amenity amenity) { super(new AmenityMenuBuilder(mapActivity, amenity), pointDescription, mapActivity); this.amenity = amenity; if (amenity.getType().getKeyName().equals("transportation")) { @@ -66,7 +66,7 @@ public class AmenityMenuController extends MenuController { MapMarkerMenuController markerMenuController = new MapMarkerMenuController(mapActivity, marker.getPointDescription(mapActivity), marker); leftTitleButtonController = markerMenuController.getLeftTitleButtonController(); - leftSubtitleButtonController = markerMenuController.getLeftSubtitleButtonController(); + rightTitleButtonController = markerMenuController.getRightTitleButtonController(); } else { if (amenity.getType().isWiki()) { leftTitleButtonController = new TitleButtonController() { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java index fb610dedb9..bef7636dc5 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java @@ -95,11 +95,6 @@ public class WptPtMenuController extends MenuController { return mapMarker == null; } - @Override - public boolean needAdditionalTypeStr() { - return true; - } - @Override public String getTypeStr() { GpxSelectionHelper helper = getMapActivity().getMyApplication().getSelectedGpxHelper(); diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionMenuController.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionMenuController.java index e03e916385..f18a927400 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionMenuController.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionMenuController.java @@ -15,6 +15,7 @@ public class ParkingPositionMenuController extends MenuController { private ParkingPositionPlugin plugin; private String parkingStartDescription = ""; private String parkingLeftDescription = ""; + private String parkingTitle = ""; public ParkingPositionMenuController(MapActivity mapActivity, PointDescription pointDescription) { super(new MenuBuilder(mapActivity), pointDescription, mapActivity); @@ -37,6 +38,7 @@ public class ParkingPositionMenuController extends MenuController { private void buildParkingDescription(MapActivity mapActivity) { parkingStartDescription = plugin.getParkingStartDesc(mapActivity); parkingLeftDescription = plugin.getParkingLeftDesc(mapActivity); + parkingTitle = plugin.getParkingTitle(mapActivity); } @Override @@ -62,17 +64,23 @@ public class ParkingPositionMenuController extends MenuController { } @Override - public String getLimitedTimeInfo() { - boolean unlimited = TextUtils.isEmpty(parkingLeftDescription); - if (unlimited) { - return getMapActivity().getString(R.string.without_time_limit); - } + public String getAdditionalTypeStr() { return parkingLeftDescription; } @Override - public boolean isLimitedTime() { - return !TextUtils.isEmpty(parkingLeftDescription); + public boolean displayAdditionalTypeStrInHours() { + return true; + } + + @Override + public int getTimeStrColor() { + return plugin.getParkingType() ? R.color.ctx_menu_amenity_closed_text_color : isLight() ? R.color.icon_color : R.color.dash_search_icon_dark; + } + + @Override + public String getNameStr() { + return parkingTitle; } @Override diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java index 65017e4121..93f6e3ac0b 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java @@ -2,7 +2,6 @@ package net.osmand.plus.parkingpoint; import android.app.Activity; -import android.app.Dialog; import android.content.DialogInterface; import android.content.Intent; import android.support.v7.app.AlertDialog; @@ -11,7 +10,6 @@ import android.text.format.Time; import android.view.View; import android.widget.ArrayAdapter; import android.widget.CheckBox; -import android.widget.ImageButton; import android.widget.TextView; import android.widget.TimePicker; @@ -582,9 +580,32 @@ public class ParkingPositionPlugin extends OsmandPlugin { return timeStringBuilder.toString(); } + public String getParkingTitle(Activity ctx) { + StringBuilder title = new StringBuilder(); + if (getParkingType()) { + title.append(ctx.getString(R.string.pick_up_till)).append(" "); + long endTime = getParkingTime(); + title.append(getFormattedTime(endTime, ctx)); + } else { + title.append(ctx.getString(R.string.osmand_parking_position_name)); + } + return title.toString(); + } + public String getParkingStartDesc(Activity ctx) { - return ctx.getString(R.string.osmand_parking_position_description_add_time) - + " " + getFormattedTime(getStartParkingTime(), ctx); + StringBuilder parkingStartDesc = new StringBuilder(); + String startTime = getFormattedTime(getStartParkingTime(), ctx); + if (getParkingType()) { + parkingStartDesc.append(ctx.getString(R.string.osmand_parking_position_name)); + parkingStartDesc.append(", "); + parkingStartDesc.append(ctx.getString(R.string.parked_at)); + parkingStartDesc.append(" ").append(startTime); + } else { + parkingStartDesc.append(ctx.getString(R.string.osmand_parking_position_description_add_time)); + parkingStartDesc.append(" "); + parkingStartDesc.append(startTime); + } + return parkingStartDesc.toString(); } public String getParkingLeftDesc(Activity ctx) { @@ -599,6 +620,8 @@ public class ParkingPositionPlugin extends OsmandPlugin { } else { descr.append(ctx.getString(R.string.osmand_parking_time_left)); } + } else { + descr.append(ctx.getString(R.string.without_time_limit)); } return descr.toString(); }