Skip to content

Commit

Permalink
Bookmarks renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
shinovon committed Jun 23, 2023
1 parent a6f691b commit d50e1d0
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/mahomaps/screens/BookmarksScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public class BookmarksScreen extends List implements CommandListener {

private Command from = new Command("Отсюда", Command.ITEM, 0);
private Command to = new Command("Сюда", Command.ITEM, 1);
private Command del = new Command("Удалить", Command.ITEM, 1);
private Command del = new Command("Удалить", Command.ITEM, 2);
private Command rename = new Command("Переименовать", Command.ITEM, 2);

public BookmarksScreen() {
super("Закладки", Choice.IMPLICIT);
Expand All @@ -36,6 +37,7 @@ public BookmarksScreen() {
addCommand(from);
addCommand(to);
addCommand(del);
addCommand(rename);
}
setCommandListener(this);
}
Expand Down Expand Up @@ -109,6 +111,10 @@ private static void Save(JSONArray arr) {

public void commandAction(Command c, Displayable d) {
if (c == MahoMapsApp.back) {
if (d instanceof TextBox) {
MahoMapsApp.BringSubScreen(this);
return;
}
MahoMapsApp.BringMap();
return;
}
Expand All @@ -119,12 +125,27 @@ public void commandAction(Command c, Displayable d) {
if (n == -1)
return;

if (c == MahoMapsApp.ok) {
// будем надеяться что фокус элемента не сбросится пока юзер будет вводить текст
String s = ((TextBox) d).getString();
set(n, s, null);
list.getObject(n).put("name", s);
return;
}
if (c == del) {
list.remove(n);
delete(n);
Save(list);
return;
}
if (c == rename) {
final TextBox tb = new TextBox("Название закладки?", getString(n), 100, 0);
tb.addCommand(MahoMapsApp.back);
tb.addCommand(MahoMapsApp.ok);
tb.setCommandListener(this);
MahoMapsApp.BringSubScreen(tb);
return;
}
JSONObject obj = list.getObject(n);
Geopoint p = new Geopoint(obj.getDouble("lat"), obj.getDouble("lon"));
if (c == SELECT_COMMAND) {
Expand Down

0 comments on commit d50e1d0

Please sign in to comment.