This commit is contained in:
Chumva 2018-09-13 14:03:12 +03:00
parent 6106827f4a
commit 468a0c1620
3 changed files with 47 additions and 31 deletions

View file

@ -1,6 +1,7 @@
package net.osmand.plus.osmedit; package net.osmand.plus.osmedit;
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.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
@ -21,7 +22,7 @@ public class EditPOIMenuController extends MenuController {
private OsmPoint osmPoint; private OsmPoint osmPoint;
private OsmEditingPlugin plugin; private OsmEditingPlugin plugin;
private String category; private String categoryDescr;
private String actionStr; private String actionStr;
public EditPOIMenuController(@NonNull MapActivity mapActivity, @NonNull PointDescription pointDescription, @NonNull OsmPoint osmPoint) { public EditPOIMenuController(@NonNull MapActivity mapActivity, @NonNull PointDescription pointDescription, @NonNull OsmPoint osmPoint) {
@ -80,7 +81,7 @@ public class EditPOIMenuController extends MenuController {
rightTitleButtonController.caption = mapActivity.getString(R.string.shared_string_delete); rightTitleButtonController.caption = mapActivity.getString(R.string.shared_string_delete);
rightTitleButtonController.updateStateListDrawableIcon(R.drawable.ic_action_delete_dark, true); rightTitleButtonController.updateStateListDrawableIcon(R.drawable.ic_action_delete_dark, true);
category = getCategory(); categoryDescr = getCategoryDescr();
if (osmPoint.getGroup() == OsmPoint.Group.POI) { if (osmPoint.getGroup() == OsmPoint.Group.POI) {
if (osmPoint.getAction() == Action.DELETE) { if (osmPoint.getAction() == Action.DELETE) {
@ -108,7 +109,7 @@ public class EditPOIMenuController extends MenuController {
@NonNull @NonNull
@Override @Override
public String getTypeStr() { public String getTypeStr() {
return category; return categoryDescr;
} }
@Override @Override
@ -129,7 +130,7 @@ public class EditPOIMenuController extends MenuController {
@Override @Override
public boolean needTypeStr() { public boolean needTypeStr() {
return !Algorithms.isEmpty(category); return !Algorithms.isEmpty(categoryDescr);
} }
@Override @Override
@ -186,6 +187,16 @@ public class EditPOIMenuController extends MenuController {
} }
} }
@Override
public Drawable getRightIcon() {
int iconResId = getRightIconId();
if (iconResId != 0) {
return getIcon(iconResId, getAdditionalInfoColorId());
} else {
return null;
}
}
@Override @Override
public int getAdditionalInfoIconRes() { public int getAdditionalInfoIconRes() {
if (osmPoint.getAction() == Action.DELETE) { if (osmPoint.getAction() == Action.DELETE) {
@ -202,7 +213,7 @@ public class EditPOIMenuController extends MenuController {
return false; return false;
} }
private String getCategory() { private String getCategoryDescr() {
return OsmEditingPlugin.getCategory(osmPoint, getMapActivity()); return OsmEditingPlugin.getDescription(osmPoint, getMapActivity(), false);
} }
} }

View file

@ -498,6 +498,35 @@ public class OsmEditingPlugin extends OsmandPlugin {
return (osmPoint.getGroup() == OsmPoint.Group.POI ? "POI" : "Bug") + " id: " + osmPoint.getId() + " "; return (osmPoint.getGroup() == OsmPoint.Group.POI ? "POI" : "Bug") + " id: " + osmPoint.getId() + " ";
} }
public static String getDescription(OsmPoint osmPoint, Context context, boolean needPrefix) {
String action = "";
if (osmPoint.getAction() == OsmPoint.Action.CREATE) {
action = context.getString(R.string.shared_string_added);
} else if (osmPoint.getAction() == OsmPoint.Action.MODIFY) {
action = context.getString(R.string.shared_string_edited);
} else if (osmPoint.getAction() == OsmPoint.Action.DELETE) {
action = context.getString(R.string.shared_string_deleted);
} else if (osmPoint.getAction() == OsmPoint.Action.REOPEN) {
action = context.getString(R.string.shared_string_edited);
}
String category = getCategory(osmPoint, context);
String description = "";
if (!Algorithms.isEmpty(action)) {
description += action + "";
}
if (!Algorithms.isEmpty(category)) {
description += category;
}
if (needPrefix) {
String prefix = getPrefix(osmPoint);
description += "" + prefix;
}
return description;
}
@Override @Override
public DashFragmentData getCardFragment() { public DashFragmentData getCardFragment() {
return DashOsmEditsFragment.FRAGMENT_DATA; return DashOsmEditsFragment.FRAGMENT_DATA;

View file

@ -305,31 +305,7 @@ public class OsmEditsAdapter extends ArrayAdapter<Object> {
} }
private String getDescription(OsmPoint point) { private String getDescription(OsmPoint point) {
String action = ""; return OsmEditingPlugin.getDescription(point, getContext(), true);
if (point.getAction() == OsmPoint.Action.CREATE) {
action = getContext().getString(R.string.shared_string_added);
} else if (point.getAction() == OsmPoint.Action.MODIFY) {
action = getContext().getString(R.string.shared_string_edited);
} else if (point.getAction() == OsmPoint.Action.DELETE) {
action = getContext().getString(R.string.shared_string_deleted);
} else if (point.getAction() == OsmPoint.Action.REOPEN) {
action = getContext().getString(R.string.shared_string_edited);
}
String category = getCategory(point);
String prefix = OsmEditingPlugin.getPrefix(point);
String description = "";
if (!Algorithms.isEmpty(action)) {
description += action + "";
}
if (!Algorithms.isEmpty(category)) {
description += category + "";
}
description += prefix;
return description;
} }
private class HeaderViewHolder { private class HeaderViewHolder {