Change edit poi controller and refactor
This commit is contained in:
parent
c35632d21f
commit
18e2eaf54f
11 changed files with 178 additions and 138 deletions
|
@ -111,7 +111,7 @@
|
||||||
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
|
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
|
||||||
android:layout_marginEnd="@dimen/context_menu_padding_margin_small"
|
android:layout_marginEnd="@dimen/context_menu_padding_margin_small"
|
||||||
tools:text="Closed till 10:00"
|
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_width="wrap_content"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.mapcontextmenu;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
@ -1135,13 +1136,37 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
||||||
return menuController != null && menuController.displayDistanceDirection();
|
return menuController != null && menuController.displayDistanceDirection();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean displayAdditionalTypeStrInHours() {
|
public String getSubtypeStr() {
|
||||||
return menuController != null && menuController.displayAdditionalTypeStrInHours();
|
if (menuController != null) {
|
||||||
|
return menuController.getSubtypeStr();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTimeStrColor() {
|
public Drawable getSubtypeIcon() {
|
||||||
if (menuController != null) {
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1126,61 +1126,43 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
||||||
}
|
}
|
||||||
line2Str.append(streetStr);
|
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);
|
TextView line3 = (TextView) view.findViewById(R.id.context_menu_line3);
|
||||||
String additionalTypeStr = menu.getAdditionalTypeStr();
|
String subtypeStr = menu.getSubtypeStr();
|
||||||
boolean displayAdditionalTypeStrInHours = menu.displayAdditionalTypeStrInHours();
|
if (TextUtils.isEmpty(subtypeStr)) {
|
||||||
boolean emptyAdditionalTypeStr = TextUtils.isEmpty(additionalTypeStr);
|
|
||||||
if (emptyAdditionalTypeStr || displayAdditionalTypeStrInHours) {
|
|
||||||
line3.setVisibility(View.GONE);
|
line3.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
line3.setVisibility(View.VISIBLE);
|
line3.setVisibility(View.VISIBLE);
|
||||||
line3.setText(additionalTypeStr);
|
line3.setText(subtypeStr);
|
||||||
Drawable icon = menu.getAdditionalLineTypeIcon();
|
Drawable icon = menu.getSubtypeIcon();
|
||||||
line3.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
|
line3.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
|
||||||
line3.setCompoundDrawablePadding(dpToPx(5f));
|
line3.setCompoundDrawablePadding(dpToPx(5f));
|
||||||
}
|
}
|
||||||
|
|
||||||
TextView openingHoursTextView = (TextView) view.findViewById(R.id.opening_hours_text_view);
|
TextView additionalInfoTextView = (TextView) view.findViewById(R.id.additional_info_text_view);
|
||||||
OpeningHoursInfo openingHoursInfo = menu.getOpeningHoursInfo();
|
String additionalInfoStr = menu.getAdditionalInfo();
|
||||||
boolean containsOpeningHours = openingHoursInfo != null && openingHoursInfo.containsInfo();
|
if (!TextUtils.isEmpty(additionalInfoStr)) {
|
||||||
if (containsOpeningHours || (displayAdditionalTypeStrInHours && !emptyAdditionalTypeStr)) {
|
int colorId = menu.getAdditionalInfoColor();
|
||||||
int colorId;
|
int additionalInfoIconRes = menu.getAdditionalInfoIconRes();
|
||||||
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;
|
|
||||||
}
|
|
||||||
if (colorId != 0) {
|
if (colorId != 0) {
|
||||||
openingHoursTextView.setTextColor(ContextCompat.getColor(getContext(), colorId));
|
additionalInfoTextView.setTextColor(ContextCompat.getColor(getContext(), colorId));
|
||||||
Drawable drawable = getIcon(R.drawable.ic_action_opening_hour_16, colorId);
|
if (additionalInfoIconRes != 0) {
|
||||||
openingHoursTextView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
|
Drawable additionalIcon = getIcon(additionalInfoIconRes, colorId);
|
||||||
openingHoursTextView.setCompoundDrawablePadding(dpToPx(8));
|
additionalInfoTextView.setCompoundDrawablesWithIntrinsicBounds(additionalIcon, null, null, null);
|
||||||
|
additionalInfoTextView.setCompoundDrawablePadding(dpToPx(8));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
openingHoursTextView.setText(timeInfo);
|
additionalInfoTextView.setText(additionalInfoStr);
|
||||||
openingHoursTextView.setVisibility(View.VISIBLE);
|
additionalInfoTextView.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
openingHoursTextView.setVisibility(View.GONE);
|
additionalInfoTextView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateCompassVisibility();
|
updateCompassVisibility();
|
||||||
|
|
|
@ -386,10 +386,6 @@ public abstract class MenuController extends BaseMenuController {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean displayAdditionalTypeStrInHours() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLeftIconId() {
|
public int getLeftIconId() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -402,7 +398,7 @@ public abstract class MenuController extends BaseMenuController {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Drawable getAdditionalLineTypeIcon() {
|
public Drawable getSubtypeIcon() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -432,16 +428,20 @@ public abstract class MenuController extends BaseMenuController {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAdditionalTypeStr() {
|
public String getSubtypeStr() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTimeStrColor() {
|
public int getAdditionalInfoColor() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OpeningHoursInfo getOpeningHoursInfo() {
|
public String getAdditionalInfoStr() {
|
||||||
return null;
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAdditionalInfoIconRes() {
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCommonTypeStr() {
|
public String getCommonTypeStr() {
|
||||||
|
|
|
@ -15,12 +15,9 @@ public abstract class MenuTitleController {
|
||||||
protected Drawable leftIcon;
|
protected Drawable leftIcon;
|
||||||
protected String nameStr = "";
|
protected String nameStr = "";
|
||||||
protected String typeStr = "";
|
protected String typeStr = "";
|
||||||
protected String additionalTypeStr = "";
|
|
||||||
protected String commonTypeStr = "";
|
protected String commonTypeStr = "";
|
||||||
protected Drawable secondLineTypeIcon;
|
protected Drawable secondLineTypeIcon;
|
||||||
protected Drawable additionalLineTypeIcon;
|
|
||||||
protected String streetStr = "";
|
protected String streetStr = "";
|
||||||
protected OpeningHoursInfo openingHoursInfo;
|
|
||||||
|
|
||||||
private AddressLookupRequest addressLookupRequest;
|
private AddressLookupRequest addressLookupRequest;
|
||||||
|
|
||||||
|
@ -80,10 +77,6 @@ public abstract class MenuTitleController {
|
||||||
return secondLineTypeIcon;
|
return secondLineTypeIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Drawable getAdditionalLineTypeIcon() {
|
|
||||||
return additionalLineTypeIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTypeStr() {
|
public String getTypeStr() {
|
||||||
MenuController menuController = getMenuController();
|
MenuController menuController = getMenuController();
|
||||||
if (menuController != null && menuController.needTypeStr()) {
|
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() {
|
public String getStreetStr() {
|
||||||
if (needStreetName()) {
|
if (needStreetName()) {
|
||||||
if (searchingAddress()) {
|
if (searchingAddress()) {
|
||||||
|
@ -114,10 +98,6 @@ public abstract class MenuTitleController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public OpeningHoursInfo getOpeningHoursInfo() {
|
|
||||||
return openingHoursInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void initTitle() {
|
protected void initTitle() {
|
||||||
searchAddressStr = PointDescription.getSearchAddressStr(getMapActivity());
|
searchAddressStr = PointDescription.getSearchAddressStr(getMapActivity());
|
||||||
addressNotFoundStr = PointDescription.getAddressNotFoundStr(getMapActivity());
|
addressNotFoundStr = PointDescription.getAddressNotFoundStr(getMapActivity());
|
||||||
|
@ -131,8 +111,6 @@ public abstract class MenuTitleController {
|
||||||
if (needStreetName()) {
|
if (needStreetName()) {
|
||||||
acquireStreetName();
|
acquireStreetName();
|
||||||
}
|
}
|
||||||
|
|
||||||
acquireOpeningHoursInfo();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean needStreetName() {
|
protected boolean needStreetName() {
|
||||||
|
@ -150,13 +128,11 @@ public abstract class MenuTitleController {
|
||||||
leftIconId = 0;
|
leftIconId = 0;
|
||||||
leftIcon = null;
|
leftIcon = null;
|
||||||
secondLineTypeIcon = null;
|
secondLineTypeIcon = null;
|
||||||
additionalLineTypeIcon = null;
|
|
||||||
|
|
||||||
if (menuController != null) {
|
if (menuController != null) {
|
||||||
leftIconId = menuController.getLeftIconId();
|
leftIconId = menuController.getLeftIconId();
|
||||||
leftIcon = menuController.getLeftIcon();
|
leftIcon = menuController.getLeftIcon();
|
||||||
secondLineTypeIcon = menuController.getSecondLineTypeIcon();
|
secondLineTypeIcon = menuController.getSecondLineTypeIcon();
|
||||||
additionalLineTypeIcon = menuController.getAdditionalLineTypeIcon();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +146,6 @@ public abstract class MenuTitleController {
|
||||||
if (menuController != null) {
|
if (menuController != null) {
|
||||||
nameStr = menuController.getNameStr();
|
nameStr = menuController.getNameStr();
|
||||||
typeStr = menuController.getTypeStr();
|
typeStr = menuController.getTypeStr();
|
||||||
additionalTypeStr = menuController.getAdditionalTypeStr();
|
|
||||||
commonTypeStr = menuController.getCommonTypeStr();
|
commonTypeStr = menuController.getCommonTypeStr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,13 +186,6 @@ public abstract class MenuTitleController {
|
||||||
getMapActivity().getMyApplication().getGeocodingLookupService().lookupAddress(addressLookupRequest);
|
getMapActivity().getMyApplication().getGeocodingLookupService().lookupAddress(addressLookupRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void acquireOpeningHoursInfo() {
|
|
||||||
MenuController menuController = getMenuController();
|
|
||||||
if (menuController != null) {
|
|
||||||
openingHoursInfo = menuController.getOpeningHoursInfo();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void onSearchAddressDone() {
|
protected void onSearchAddressDone() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package net.osmand.plus.mapcontextmenu;
|
package net.osmand.plus.mapcontextmenu;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import net.osmand.plus.R;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
public class OpeningHoursInfo {
|
public class OpeningHoursInfo {
|
||||||
|
@ -68,12 +71,20 @@ public class OpeningHoursInfo {
|
||||||
this.openingDay = openingDay;
|
this.openingDay = openingDay;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean containsInfo() {
|
public String getInfo(Context context) {
|
||||||
return opened24_7
|
if (isOpened24_7()) {
|
||||||
|| !Algorithms.isEmpty(openingTime)
|
return context.getString(R.string.shared_string_is_open_24_7);
|
||||||
|| !Algorithms.isEmpty(nearToOpeningTime)
|
} else if (!Algorithms.isEmpty(getNearToOpeningTime())) {
|
||||||
|| !Algorithms.isEmpty(closingTime)
|
return context.getString(R.string.will_be_opened_at) + " " + getNearToOpeningTime();
|
||||||
|| !Algorithms.isEmpty(nearToClosingTime)
|
} else if (!Algorithms.isEmpty(getOpeningTime())) {
|
||||||
|| !Algorithms.isEmpty(openingDay);
|
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 "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ public class AmenityMenuController extends MenuController {
|
||||||
|
|
||||||
private Amenity amenity;
|
private Amenity amenity;
|
||||||
private List<TransportStopRoute> routes = new ArrayList<>();
|
private List<TransportStopRoute> routes = new ArrayList<>();
|
||||||
|
private OpeningHoursInfo openingHoursInfo;
|
||||||
|
|
||||||
private MapMarker marker;
|
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);
|
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
|
@Override
|
||||||
|
@ -145,8 +148,27 @@ public class AmenityMenuController extends MenuController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OpeningHoursInfo getOpeningHoursInfo() {
|
public int getAdditionalInfoColor() {
|
||||||
return processOpeningHours(amenity);
|
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) {
|
public static String getTypeStr(Amenity amenity) {
|
||||||
|
|
|
@ -24,6 +24,7 @@ public class FavouritePointMenuController extends MenuController {
|
||||||
|
|
||||||
private FavouritePoint fav;
|
private FavouritePoint fav;
|
||||||
private MapMarker mapMarker;
|
private MapMarker mapMarker;
|
||||||
|
private OpeningHoursInfo openingHoursInfo;
|
||||||
|
|
||||||
public FavouritePointMenuController(MapActivity mapActivity, PointDescription pointDescription, final FavouritePoint fav) {
|
public FavouritePointMenuController(MapActivity mapActivity, PointDescription pointDescription, final FavouritePoint fav) {
|
||||||
super(new FavouritePointMenuBuilder(mapActivity, fav), pointDescription, mapActivity);
|
super(new FavouritePointMenuBuilder(mapActivity, fav), pointDescription, mapActivity);
|
||||||
|
@ -45,6 +46,11 @@ public class FavouritePointMenuController extends MenuController {
|
||||||
TransportStopController transportStopController = new TransportStopController(getMapActivity(), pointDescription, stop);
|
TransportStopController transportStopController = new TransportStopController(getMapActivity(), pointDescription, stop);
|
||||||
transportStopController.processTransportStop(builder);
|
transportStopController.processTransportStop(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Object originObject = getBuilder().getOriginObject();
|
||||||
|
if (originObject instanceof Amenity) {
|
||||||
|
openingHoursInfo = AmenityMenuController.processOpeningHours((Amenity) originObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -136,11 +142,26 @@ public class FavouritePointMenuController extends MenuController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OpeningHoursInfo getOpeningHoursInfo() {
|
public int getAdditionalInfoColor() {
|
||||||
Object originObject = getBuilder().getOriginObject();
|
if (openingHoursInfo != null) {
|
||||||
if (originObject instanceof Amenity) {
|
return openingHoursInfo.isOpened() ? R.color.ctx_menu_amenity_opened_text_color : R.color.ctx_menu_amenity_closed_text_color;
|
||||||
return AmenityMenuController.processOpeningHours((Amenity) originObject);
|
|
||||||
}
|
}
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,8 +82,8 @@ public class WptPtMenuController extends MenuController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Drawable getAdditionalLineTypeIcon() {
|
public Drawable getSubtypeIcon() {
|
||||||
if (Algorithms.isEmpty(getAdditionalTypeStr())) {
|
if (Algorithms.isEmpty(getSubtypeStr())) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return getIcon(R.drawable.ic_action_group_name_16);
|
return getIcon(R.drawable.ic_action_group_name_16);
|
||||||
|
@ -111,7 +111,7 @@ public class WptPtMenuController extends MenuController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAdditionalTypeStr() {
|
public String getSubtypeStr() {
|
||||||
return wpt.category != null ? wpt.category : "";
|
return wpt.category != null ? wpt.category : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import net.osmand.plus.mapcontextmenu.MenuController;
|
||||||
import net.osmand.plus.osmedit.OsmPoint.Action;
|
import net.osmand.plus.osmedit.OsmPoint.Action;
|
||||||
import net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment;
|
import net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment;
|
||||||
import net.osmand.plus.render.RenderingIcons;
|
import net.osmand.plus.render.RenderingIcons;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -20,7 +21,8 @@ public class EditPOIMenuController extends MenuController {
|
||||||
|
|
||||||
private OsmPoint osmPoint;
|
private OsmPoint osmPoint;
|
||||||
private OsmEditingPlugin plugin;
|
private OsmEditingPlugin plugin;
|
||||||
private String pointTypeStr;
|
private String category;
|
||||||
|
private String actionStr;
|
||||||
|
|
||||||
public EditPOIMenuController(final MapActivity mapActivity, PointDescription pointDescription, OsmPoint osmPoint) {
|
public EditPOIMenuController(final MapActivity mapActivity, PointDescription pointDescription, OsmPoint osmPoint) {
|
||||||
super(new EditPOIMenuBuilder(mapActivity, osmPoint), pointDescription, mapActivity);
|
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.caption = getMapActivity().getString(R.string.shared_string_delete);
|
||||||
rightTitleButtonController.leftIconId = R.drawable.ic_action_delete_dark;
|
rightTitleButtonController.leftIconId = R.drawable.ic_action_delete_dark;
|
||||||
|
|
||||||
|
category = getCategory();
|
||||||
|
|
||||||
if (osmPoint.getGroup() == OsmPoint.Group.POI) {
|
if (osmPoint.getGroup() == OsmPoint.Group.POI) {
|
||||||
if(osmPoint.getAction() == Action.DELETE) {
|
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) {
|
} 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) */{
|
} 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) {
|
} else if (osmPoint.getGroup() == OsmPoint.Group.BUG) {
|
||||||
if(osmPoint.getAction() == Action.DELETE) {
|
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) {
|
} 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) {
|
} 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) */{
|
} 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 {
|
} else {
|
||||||
pointTypeStr = "";
|
actionStr = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean displayAdditionalTypeStrInHours() {
|
public String getTypeStr() {
|
||||||
return true;
|
return category;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -120,29 +123,27 @@ public class EditPOIMenuController extends MenuController {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean needTypeStr() {
|
public boolean needTypeStr() {
|
||||||
return false;
|
return !Algorithms.isEmpty(category);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAdditionalTypeStr() {
|
public String getAdditionalInfoStr() {
|
||||||
return pointTypeStr;
|
return actionStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTimeStrColor() {
|
public int getAdditionalInfoColor() {
|
||||||
if (osmPoint.getAction() == OsmPoint.Action.CREATE) {
|
if (osmPoint.getAction() == Action.DELETE) {
|
||||||
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;
|
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;
|
return R.color.color_osm_edit_modify;
|
||||||
|
} else {
|
||||||
|
return R.color.color_osm_edit_create;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Drawable getAdditionalLineTypeIcon() {
|
public int getAdditionalInfoIconRes() {
|
||||||
if (osmPoint.getGroup() == OsmPoint.Group.POI) {
|
if (osmPoint.getGroup() == OsmPoint.Group.POI) {
|
||||||
OpenstreetmapPoint osmP = (OpenstreetmapPoint) osmPoint;
|
OpenstreetmapPoint osmP = (OpenstreetmapPoint) osmPoint;
|
||||||
int iconResId = 0;
|
int iconResId = 0;
|
||||||
|
@ -165,11 +166,11 @@ public class EditPOIMenuController extends MenuController {
|
||||||
if (iconResId == 0) {
|
if (iconResId == 0) {
|
||||||
iconResId = R.drawable.ic_type_info;
|
iconResId = R.drawable.ic_type_info;
|
||||||
}
|
}
|
||||||
return getIcon(iconResId);
|
return iconResId;
|
||||||
} else if (osmPoint.getGroup() == OsmPoint.Group.BUG) {
|
} else if (osmPoint.getGroup() == OsmPoint.Group.BUG) {
|
||||||
return getIcon(R.drawable.ic_type_bug);
|
return R.drawable.ic_type_bug;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,4 +178,14 @@ public class EditPOIMenuController extends MenuController {
|
||||||
public boolean needStreetName() {
|
public boolean needStreetName() {
|
||||||
return false;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,17 +64,17 @@ public class ParkingPositionMenuController extends MenuController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAdditionalTypeStr() {
|
public int getAdditionalInfoIconRes() {
|
||||||
|
return R.drawable.ic_action_opening_hour_16;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAdditionalInfoStr() {
|
||||||
return parkingLeftDescription;
|
return parkingLeftDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean displayAdditionalTypeStrInHours() {
|
public int getAdditionalInfoColor() {
|
||||||
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;
|
return plugin.getParkingType() ? R.color.ctx_menu_amenity_closed_text_color : isLight() ? R.color.icon_color : R.color.dash_search_icon_dark;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue