Skip to content

Commit

Permalink
Configurable place titles
Browse files Browse the repository at this point in the history
  • Loading branch information
andreynovikov committed Feb 13, 2024
1 parent f4dcb7f commit 7417572
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 4 deletions.
5 changes: 5 additions & 0 deletions app/src/main/java/mobi/maptrek/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class Configuration {
private static final String PREF_BITMAP_MAP_TRANSPARENCY = "bitmap_map_transparency";
private static final String PREF_EXCEPTION_SIZE = "exception_size";
public static final String PREF_ZOOM_BUTTONS_VISIBLE = "zoom_buttons_visible";
public static final String PREF_PLACE_TITLES = "place_titles";
public static final String PREF_ACCESSIBILITY_BADGES = "accessibility_badges";
public static final String PREF_CONFIRM_EXIT = "confirm_exit";
public static final String PREF_SPEED_UNIT = "speed_unit";
Expand Down Expand Up @@ -430,6 +431,10 @@ public static boolean getZoomButtonsVisible() {
return loadBoolean(PREF_ZOOM_BUTTONS_VISIBLE, false);
}

public static boolean getPlaceTitlesEnabled() {
return loadBoolean(PREF_PLACE_TITLES, true);
}

public static boolean getAccessibilityBadgesEnabled() {
return loadBoolean(PREF_ACCESSIBILITY_BADGES, true);
}
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/mobi/maptrek/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ public void onChildViewRemoved(View parent, View child) {
Bitmap bitmap = new AndroidBitmap(MarkerFactory.getMarkerSymbol(this));
MarkerSymbol symbol = new MarkerSymbol(bitmap, MarkerItem.HotspotPlace.BOTTOM_CENTER);
mMarkerLayer = new ItemizedLayer<>(mMap, new ArrayList<>(), symbol, MapTrek.density, this);
mMarkerLayer.setTitlesEnabled(Configuration.getPlaceTitlesEnabled());
layers.add(mMarkerLayer, MAP_3D_DATA);

mapIndexViewModel = new ViewModelProvider(this).get(MapIndexViewModel.class);
Expand Down Expand Up @@ -4532,6 +4533,12 @@ public void onConfigurationChanged(Configuration.ChangedEvent event) {
mViews.coordinatorLayout.findViewById(R.id.mapZoomHolder).setVisibility(visible ? View.VISIBLE : View.GONE);
break;
}
case Configuration.PREF_PLACE_TITLES: {
mMarkerLayer.setTitlesEnabled(Configuration.getPlaceTitlesEnabled());
mMarkerLayer.updateItems();
mMap.updateMap();
break;
}
case Configuration.PREF_ACCESSIBILITY_BADGES: {
Tags.accessibility = Configuration.getAccessibilityBadgesEnabled();
mMap.clearMap();
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/mobi/maptrek/layers/marker/MarkerLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,7 @@ public Item getFocus() {
return mFocusedItem;
}

public void setTitlesEnabled(boolean titlesEnabled) {
mMarkerRenderer.setTitlesEnabled(titlesEnabled);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class MarkerRenderer extends BucketRenderer {
private final MarkerLayer<MarkerItem> mMarkerLayer;
private final Point mMapPoint = new Point();
private final float mScale;
private boolean mTitlesEnabled;

private int mShaderProgram;
private int hVertexPosition;
Expand Down Expand Up @@ -99,6 +100,11 @@ public String toString() {
mMarkerLayer = markerLayer;
mDefaultMarker = defaultSymbol;
mScale = scale;
mTitlesEnabled = true;
}

public void setTitlesEnabled(boolean titlesEnabled) {
mTitlesEnabled = titlesEnabled;
}

@Override
Expand Down Expand Up @@ -210,7 +216,7 @@ else if (it.x < -flip)
s.billboard = marker.isBillboard();
mSymbolBucket.pushSymbol(s);

if (it.item.title != null) {
if (mTitlesEnabled && it.item.title != null) {
float dy = -s.offset.y * bitmap.getHeight() - 10 * mScale * CanvasAdapter.textScale;
long k = (((long) dy) << 32) | (it.item.color & 0xffffffffL);
TextStyle textStyle = textStyles.get(k);
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/bools.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="def_place_titles">true</bool>
<bool name="def_zoom_buttons_visible">false</bool>
<bool name="def_accessibility_badges">true</bool>
<bool name="def_confirm_exit">false</bool>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@
<string name="pref_unit_precision_title">Extra precision</string>
<string name="pref_advanced">Advanced</string>
<string name="pref_hillshades_transparency">Hillshades transparency</string>
<string name="pref_place_titles_title">Place titles</string>
<string name="pref_accessibility_badges_title">Accessibility badges</string>
<string name="pref_confirm_exit_title">Exit confirmation</string>

Expand Down
11 changes: 8 additions & 3 deletions app/src/main/res/xml/preferences_general.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@
app:seekBarIncrement="10"
app:showSeekBarValue="true" />
<CheckBoxPreference
android:defaultValue="@bool/def_zoom_buttons_visible"
android:key="zoom_buttons_visible"
android:title="@string/pref_zoom_buttons_visible_title"
android:defaultValue="@bool/def_place_titles"
android:key="place_titles"
android:title="@string/pref_place_titles_title"
app:iconSpaceReserved="false" />
<CheckBoxPreference
android:defaultValue="@bool/def_accessibility_badges"
android:key="accessibility_badges"
android:title="@string/pref_accessibility_badges_title"
app:iconSpaceReserved="false" />
<CheckBoxPreference
android:defaultValue="@bool/def_zoom_buttons_visible"
android:key="zoom_buttons_visible"
android:title="@string/pref_zoom_buttons_visible_title"
app:iconSpaceReserved="false" />
<CheckBoxPreference
android:defaultValue="@bool/def_confirm_exit"
android:key="confirm_exit"
Expand Down

0 comments on commit 7417572

Please sign in to comment.