Skip to content

Commit

Permalink
Use unified close button where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Feodor0090 committed Aug 30, 2023
1 parent 16c86be commit 8f70e10
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 20 deletions.
8 changes: 3 additions & 5 deletions src/mahomaps/overlays/CacheFailedOverlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

import mahomaps.MahoMapsApp;
import mahomaps.map.Geopoint;
import mahomaps.ui.Button;
import mahomaps.ui.ColumnsContainer;
import mahomaps.ui.CloseButton;
import mahomaps.ui.FillFlowContainer;
import mahomaps.ui.IButtonHandler;
import mahomaps.ui.SimpleText;
Expand All @@ -14,9 +13,8 @@
public class CacheFailedOverlay extends MapOverlay implements IButtonHandler {

public CacheFailedOverlay() {
content = new FillFlowContainer(
new UIElement[] { new SimpleText(MahoMapsApp.text[124]), new SimpleText(MahoMapsApp.text[125]),
new ColumnsContainer(new UIElement[] { new Button(MahoMapsApp.text[38], 0, this) }) });
content = new FillFlowContainer(new UIElement[] { new SimpleText(MahoMapsApp.text[124]),
new SimpleText(MahoMapsApp.text[125]), new CloseButton(this) });
}

public String GetId() {
Expand Down
8 changes: 4 additions & 4 deletions src/mahomaps/overlays/NoApiTokenOverlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import mahomaps.map.Geopoint;
import mahomaps.screens.APIReconnectForm;
import mahomaps.ui.Button;
import mahomaps.ui.ColumnsContainer;
import mahomaps.ui.CloseButton;
import mahomaps.ui.FillFlowContainer;
import mahomaps.ui.IButtonHandler;
import mahomaps.ui.SimpleText;
Expand All @@ -15,9 +15,9 @@
public class NoApiTokenOverlay extends MapOverlay implements IButtonHandler {

public NoApiTokenOverlay() {
content = new FillFlowContainer(new UIElement[] { new SimpleText(MahoMapsApp.text[39]),
new SimpleText(MahoMapsApp.text[40]), new ColumnsContainer(new UIElement[] {
new Button(MahoMapsApp.text[37], 1, this), new Button(MahoMapsApp.text[38], 0, this) }) });
content = new FillFlowContainer(
new UIElement[] { new SimpleText(MahoMapsApp.text[39]), new SimpleText(MahoMapsApp.text[40]),
new Button(MahoMapsApp.text[37], 1, this), new CloseButton(this) });
}

public String GetId() {
Expand Down
18 changes: 13 additions & 5 deletions src/mahomaps/overlays/RouteBuildOverlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,20 @@ public RouteBuildOverlay() {
private void Update() {
v.removeAllElements();
if (a != null && b != null) {
// everything is set
v.addElement(a);
v.addElement(b);
content = new FillFlowContainer(new UIElement[] { new ColumnsContainer(new UIElement[] {
new Button(MahoMapsApp.text[126], 1, this), new Button(MahoMapsApp.text[127], 2, this), new Button(MahoMapsApp.text[128], 3, this)
content = new FillFlowContainer(
new UIElement[] { new ColumnsContainer(new UIElement[] { new Button(MahoMapsApp.text[126], 1, this),
new Button(MahoMapsApp.text[127], 2, this), new Button(MahoMapsApp.text[128], 3, this)

}), new Button(MahoMapsApp.text[118], 0, this) });
} else if (a == null && b == null) {
// nothing is set
content = new FillFlowContainer(new UIElement[] { new SimpleText(MahoMapsApp.text[129]),
new Button(MahoMapsApp.text[118], 0, this) });
} else {
// A or B set but not both
String s;
Button bt;
if (b == null) {
Expand All @@ -51,7 +55,8 @@ private void Update() {
bt = new Button(MahoMapsApp.text[132], 11, this);
v.addElement(b);
}
content = new FillFlowContainer(new UIElement[] { new SimpleText(s), bt, new Button(MahoMapsApp.text[118], 0, this) });
content = new FillFlowContainer(
new UIElement[] { new SimpleText(s), bt, new Button(MahoMapsApp.text[118], 0, this) });
}
}

Expand Down Expand Up @@ -82,8 +87,7 @@ public static RouteBuildOverlay Get() {
}

private static void NotifyNoGeo() {
Alert a = new Alert(MahoMapsApp.text[116], MahoMapsApp.text[117], null,
AlertType.WARNING);
Alert a = new Alert(MahoMapsApp.text[116], MahoMapsApp.text[117], null, AlertType.WARNING);
a.setTimeout(4000);
MahoMapsApp.BringSubScreen(a, MahoMapsApp.GetCanvas());
}
Expand All @@ -100,6 +104,10 @@ public boolean OnPointTap(Geopoint p) {
return false;
}

public boolean CloseButtonImplicit() {
return false;
}

public void OnButtonTap(UIElement sender, int uid) {
MapCanvas m = MahoMapsApp.GetCanvas();
if (uid == 0) {
Expand Down
4 changes: 4 additions & 0 deletions src/mahomaps/overlays/RouteFollowOverlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ public boolean OnPointTap(Geopoint p) {
return false;
}

public boolean CloseButtonImplicit() {
return false;
}

public void OnButtonTap(UIElement sender, int uid) {
if (uid == 0) {
Alert a1 = new Alert("MahoMaps v1", MahoMapsApp.text[112], null, AlertType.WARNING);
Expand Down
9 changes: 8 additions & 1 deletion src/mahomaps/overlays/RouteOverlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import mahomaps.route.RouteTracker;
import mahomaps.screens.MapCanvas;
import mahomaps.ui.Button;
import mahomaps.ui.CloseButton;
import mahomaps.ui.ColumnsContainer;
import mahomaps.ui.FillFlowContainer;
import mahomaps.ui.IButtonHandler;
Expand All @@ -35,6 +36,7 @@ public class RouteOverlay extends MapOverlay implements Runnable, IButtonHandler
private Geopoint b;
private final int method;
Route route;
boolean allowClose = false;

private boolean anchorsShown = false;

Expand All @@ -60,6 +62,10 @@ public boolean OnPointTap(Geopoint p) {
return false;
}

public boolean CloseButtonImplicit() {
return allowClose;
}

public void run() {
try {
route = new Route(MahoMapsApp.api.Route(a, b, method));
Expand Down Expand Up @@ -87,9 +93,10 @@ public void LoadRoute() {
// route field must be non-null here!
ColumnsContainer cols = new ColumnsContainer(new UIElement[] { new Button(MahoMapsApp.text[113], 3, this),
new Button(MahoMapsApp.text[114], 4, this) });
allowClose = true;
content = new FillFlowContainer(
new UIElement[] { new SimpleText(Type(method)), new SimpleText(route.distance + ", " + route.time),
new Button(MahoMapsApp.text[115], 5, this), cols, new Button(MahoMapsApp.text[38], 0, this) });
new Button(MahoMapsApp.text[115], 5, this), cols, new CloseButton(this) });
MahoMapsApp.GetCanvas().line = new Line(a, route.points);
}

Expand Down
3 changes: 3 additions & 0 deletions src/mahomaps/overlays/SearchOverlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ public SearchOverlay(Geopoint around, String query, JSONArray results, SearchScr
this.list = list;

SetNullSelection();
}

public boolean CloseButtonImplicit() {
return false;
}

public void SetNullSelection() {
Expand Down
3 changes: 2 additions & 1 deletion src/mahomaps/overlays/SelectOverlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import mahomaps.screens.BookmarksScreen;
import mahomaps.screens.SearchLoader;
import mahomaps.ui.Button;
import mahomaps.ui.CloseButton;
import mahomaps.ui.ColumnsContainer;
import mahomaps.ui.FillFlowContainer;
import mahomaps.ui.IButtonHandler;
Expand All @@ -31,7 +32,7 @@ public SelectOverlay(final Geopoint p) {
new SimpleText(p.toString()), new Button(MahoMapsApp.text[103], 1, this),
new Button(MahoMapsApp.text[137], 4, this), new ColumnsContainer(new UIElement[] {
new Button(MahoMapsApp.text[104], 2, this), new Button(MahoMapsApp.text[105], 3, this) }),
new Button(MahoMapsApp.text[38], 0, this) });
new CloseButton(this) });
}

public String GetId() {
Expand Down
5 changes: 3 additions & 2 deletions src/mahomaps/overlays/TileCacheForbiddenOverlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import mahomaps.map.Geopoint;
import mahomaps.screens.SettingsScreen;
import mahomaps.ui.Button;
import mahomaps.ui.CloseButton;
import mahomaps.ui.ColumnsContainer;
import mahomaps.ui.FillFlowContainer;
import mahomaps.ui.IButtonHandler;
Expand All @@ -15,8 +16,8 @@
public class TileCacheForbiddenOverlay extends MapOverlay implements IButtonHandler {
public TileCacheForbiddenOverlay() {
content = new FillFlowContainer(new UIElement[] { new SimpleText(MahoMapsApp.text[44]),
new SimpleText(MahoMapsApp.text[45]), new ColumnsContainer(new UIElement[] {
new Button(MahoMapsApp.text[41], 1, this), new Button(MahoMapsApp.text[38], 0, this) }) });
new SimpleText(MahoMapsApp.text[45]), new ColumnsContainer(
new UIElement[] { new Button(MahoMapsApp.text[41], 1, this), new CloseButton(this) }) });
}

public String GetId() {
Expand Down
5 changes: 3 additions & 2 deletions src/mahomaps/overlays/TileDownloadForbiddenOverlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import mahomaps.map.Geopoint;
import mahomaps.screens.SettingsScreen;
import mahomaps.ui.Button;
import mahomaps.ui.CloseButton;
import mahomaps.ui.ColumnsContainer;
import mahomaps.ui.FillFlowContainer;
import mahomaps.ui.IButtonHandler;
Expand All @@ -15,8 +16,8 @@
public class TileDownloadForbiddenOverlay extends MapOverlay implements IButtonHandler {
public TileDownloadForbiddenOverlay() {
content = new FillFlowContainer(new UIElement[] { new SimpleText(MahoMapsApp.text[42]),
new SimpleText(MahoMapsApp.text[43]), new ColumnsContainer(new UIElement[] {
new Button(MahoMapsApp.text[41], 1, this), new Button(MahoMapsApp.text[38], 0, this) }) });
new SimpleText(MahoMapsApp.text[43]), new ColumnsContainer(
new UIElement[] { new Button(MahoMapsApp.text[41], 1, this), new CloseButton(this) }) });
}

public String GetId() {
Expand Down

0 comments on commit 8f70e10

Please sign in to comment.