Skip to content

Commit

Permalink
Support following a way in PathCreationActionMode
Browse files Browse the repository at this point in the history
Fixes #1936
  • Loading branch information
simonpoole committed Jan 12, 2024
1 parent a57b912 commit 9fde3fa
Show file tree
Hide file tree
Showing 12 changed files with 1,198 additions and 47 deletions.
15 changes: 14 additions & 1 deletion src/main/java/de/blau/android/DisambiguationMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,19 @@ public void add(int id, @Nullable Type type, @NonNull String text, boolean selec
add(new DisambiguationMenuItem(type, s), listener);
}

/**
* Add a menu item
*
* @param id an id (unused)
* @param the Type of object
* @param text a descriptive text
* @param listener callback when the menu item is selected
*/
public void add(int id, @Nullable Type type, @NonNull String text, @NonNull final OnMenuItemClickListener listener) { // NOSONAR
SpannableString s = new SpannableString(text);
add(new DisambiguationMenuItem(type, s), listener);
}

/**
* Add a menu item
*
Expand All @@ -212,7 +225,7 @@ public void add(int id, @Nullable Type type, @NonNull int textRes, boolean selec
public void add(int id, @Nullable Type type, @NonNull SpannableString text, boolean selected, @NonNull final OnMenuItemClickListener listener) { // NOSONAR
add(new DisambiguationMenuItem(type, text), listener);
}

/**
* Add a menu item
*
Expand Down

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions src/main/java/de/blau/android/util/MathUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package de.blau.android.util;

/**
* Android doesn't have floor mode before API 24
*/
public final class MathUtil {

/**
* Private constructor
*/
private MathUtil() {
// empty
}

/**
* Floor modulus
*
* See Math.floorMod
*
* @param x dividend
* @param y dividor
* @return the floor modulus of x and y
*/
public static int floorMod(int x, int y) {
int r = x / y;
if ((x ^ y) < 0 && (r * y != x)) {
r--;
}
return x - r * y;
}
}
Binary file added src/main/res/drawable-xhdpi/follow_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/res/drawable-xhdpi/follow_light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<attr name="menu_bridge" format="reference" />
<attr name="menu_culvert" format="reference" />
<attr name="menu_steps" format="reference" />
<attr name="menu_follow" format="reference" />
<attr name="alert_dialog" format="reference" />
<attr name="lightbulb_dialog" format="reference" />
<attr name="undolist_undo" format="reference" />
Expand Down
1 change: 1 addition & 0 deletions src/main/res/values/shortcuts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
<string name="shortcut_merge">m</string>
<string name="shortcut_square">s</string>
<string name="shortcut_remove">r</string>
<string name="shortcut_follow">f</string>
</resources>
6 changes: 5 additions & 1 deletion src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,7 @@
<string name="actionmode_nodeselect">Node selected</string>
<string name="actionmode_relationselect">Relation selected</string>
<string name="actionmode_createpath">Creating path</string>
<string name="actionmode_createpath_follow_way">Follow way</string>
<string name="actionmode_multiselect">Multiselect</string>
<string name="actionmode_newnoteselect">New Note selected</string>
<string name="actionmode_add_segment">Add segment</string>
Expand All @@ -1104,11 +1105,15 @@
<string name="actionmode_restriction_split_via">Split \"via\" segment</string>
<string name="actionmode_extract_segment_select">Select segment</string>
<string name="actionmode_extract_segment_set_tags">Set tags</string>
<string name="actionmode_createpath_follow_way_select_end_node">Select end node</string>
<plurals name="actionmode_object_count">
<item quantity="one">1 object</item>
<item quantity="other">%1$d objects</item>
</plurals>
<string name="actionmode_rotateway">Rotate way</string>
<string name="menu_snap">Snap</string>
<string name="menu_follow_way">Follow way</string>
<string name="select_follow_way">Select way to follow</string>
<!-- Simple Action Mode -->
<string name="menu_add_node">Add node</string>
<string name="simple_add_node">Tap the screen position</string>
Expand All @@ -1125,7 +1130,6 @@
<string name="simple_paste">Tap the screen position</string>
<string name="menu_paste_multiple">Paste multiple times</string>
<string name="simple_paste_multiple">Tap the screen position</string>
<string name="menu_snap">Snap</string>
<!-- Preferences -->
<string name="config_backgroundLayer_title">Map background</string>
<string name="config_backgroundLayer_summary">The tile based map background.</string>
Expand Down
2 changes: 2 additions & 0 deletions src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
<item name="menu_bridge">@drawable/bridge_dark</item>
<item name="menu_culvert">@drawable/culvert_dark</item>
<item name="menu_steps">@drawable/steps_dark</item>
<item name="menu_follow">@drawable/follow_dark</item>
<item name="undolist_undo">@drawable/undolist_undo_dark</item>
<item name="undolist_redo">@drawable/undolist_redo_dark</item>
<item name="alert_dialog">@drawable/ic_action_warning_holo_dark</item>
Expand Down Expand Up @@ -263,6 +264,7 @@
<item name="menu_bridge">@drawable/bridge_light</item>
<item name="menu_culvert">@drawable/culvert_light</item>
<item name="menu_steps">@drawable/steps_light</item>
<item name="menu_follow">@drawable/follow_light</item>
<item name="undolist_undo">@drawable/undolist_undo_light</item>
<item name="undolist_redo">@drawable/undolist_redo_light</item>
<item name="alert_dialog">@drawable/ic_action_warning_holo_light</item>
Expand Down
Loading

0 comments on commit 9fde3fa

Please sign in to comment.