Skip to content

Commit 6798bf2

Browse files
authored
Merge pull request #491 from miltonials/fix-351-display-map-design
Fix #351. UI: Display map design
2 parents e9747f8 + 52435c8 commit 6798bf2

File tree

8 files changed

+89
-20
lines changed

8 files changed

+89
-20
lines changed

app/src/main/java/net/osmtracker/activity/DisplayTrackMap.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.osmdroid.config.Configuration;
2828
import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
2929
import org.osmdroid.util.GeoPoint;
30+
import org.osmdroid.views.CustomZoomButtonsController;
3031
import org.osmdroid.views.MapView;
3132
import org.osmdroid.views.overlay.Polyline;
3233
import org.osmdroid.views.overlay.ScaleBarOverlay;
@@ -85,6 +86,16 @@ public class DisplayTrackMap extends Activity {
8586
*/
8687
private static final int DEFAULT_ZOOM = 16;
8788

89+
/**
90+
* Default zoom level for center with zoom
91+
*/
92+
private static final double CENTER_DEFAULT_ZOOM_LEVEL = 18;
93+
94+
/**
95+
* Animation duration in milliseconds for center with zoom
96+
*/
97+
private static final long ANIMATION_DURATION_MS = 1000;
98+
8899
/**
89100
* Main OSM view
90101
*/
@@ -171,6 +182,7 @@ public void onCreate(Bundle savedInstanceState) {
171182
osmView = findViewById(R.id.displaytrackmap_osmView);
172183
// pinch to zoom
173184
osmView.setMultiTouchControls(true);
185+
osmView.getZoomController().setVisibility(CustomZoomButtonsController.Visibility.NEVER);
174186
// we'll use osmView to define if the screen is always on or not
175187
osmView.setKeepScreenOn(prefs.getBoolean(OSMTracker.Preferences.KEY_UI_DISPLAY_KEEP_ON, OSMTracker.Preferences.VAL_UI_DISPLAY_KEEP_ON));
176188
osmViewController = osmView.getController();
@@ -205,6 +217,12 @@ public void onChange(boolean selfChange) {
205217
// Register listeners for zoom buttons
206218
findViewById(R.id.displaytrackmap_imgZoomIn).setOnClickListener(v -> osmViewController.zoomIn());
207219
findViewById(R.id.displaytrackmap_imgZoomOut).setOnClickListener(v -> osmViewController.zoomOut());
220+
findViewById(R.id.displaytrackmap_imgZoomCenter).setOnClickListener(view -> {
221+
centerToGpsPos = true;
222+
if (currentPosition != null) {
223+
osmViewController.animateTo(currentPosition,CENTER_DEFAULT_ZOOM_LEVEL, ANIMATION_DURATION_MS);
224+
}
225+
});
208226
}
209227

210228
/**
970 Bytes
Loading
-1.34 KB
Loading
-1.13 KB
Loading
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:color="@color/map_onClickBackground"
4+
>
5+
<item>
6+
<shape android:shape="oval">
7+
<solid android:color="@color/map_btnBackground" />
8+
<stroke android:width="1dp" android:color="@color/btnBorder" />
9+
</shape>
10+
</item>
11+
</ripple>
Lines changed: 54 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,62 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
android:layout_width="wrap_content"
4-
android:layout_height="wrap_content" >
4+
android:layout_height="wrap_content"
5+
xmlns:app="http://schemas.android.com/apk/res-auto">
56

6-
<org.osmdroid.views.MapView
7-
android:id="@+id/displaytrackmap_osmView"
8-
android:layout_width="fill_parent"
9-
android:layout_height="fill_parent" />
7+
<androidx.constraintlayout.widget.ConstraintLayout
8+
android:layout_width="match_parent"
9+
android:layout_height="match_parent">
1010

11-
<ImageView
12-
android:id="@+id/displaytrackmap_imgZoomIn"
13-
android:layout_width="wrap_content"
14-
android:layout_height="wrap_content"
15-
android:layout_alignParentRight="true"
16-
android:contentDescription="@string/acc.zoom_in"
17-
android:src="@drawable/zoom_in" >
18-
</ImageView>
11+
<org.osmdroid.views.MapView
12+
android:id="@+id/displaytrackmap_osmView"
13+
android:layout_width="fill_parent"
14+
android:layout_height="fill_parent"
15+
app:layout_constraintBottom_toBottomOf="parent"
16+
app:layout_constraintEnd_toEndOf="parent"
17+
app:layout_constraintHorizontal_bias="1.0"
18+
app:layout_constraintStart_toStartOf="parent"
19+
app:layout_constraintTop_toTopOf="parent"
20+
app:layout_constraintVertical_bias="1.0"/>
1921

20-
<ImageView
21-
android:id="@+id/displaytrackmap_imgZoomOut"
22-
android:layout_width="wrap_content"
23-
android:layout_height="wrap_content"
24-
android:contentDescription="@string/acc.zoom_in"
25-
android:src="@drawable/zoom_out" >
26-
</ImageView>
22+
<ImageView
23+
android:id="@+id/displaytrackmap_imgZoomCenter"
24+
android:layout_width="50sp"
25+
android:layout_height="50sp"
26+
android:layout_marginEnd="20dp"
27+
android:padding="10dp"
28+
android:layout_marginBottom="200dp"
29+
android:contentDescription="@string/acc.zoom_center"
30+
android:background="@drawable/map_btn_style"
31+
android:src="@drawable/gps_center"
32+
app:layout_constraintBottom_toBottomOf="parent"
33+
app:layout_constraintEnd_toEndOf="parent" />
34+
35+
<ImageView
36+
android:id="@+id/displaytrackmap_imgZoomIn"
37+
android:layout_width="50sp"
38+
android:layout_height="50sp"
39+
android:layout_alignParentRight="true"
40+
android:layout_marginTop="10sp"
41+
android:padding="10dp"
42+
android:contentDescription="@string/acc.zoom_in"
43+
android:src="@drawable/zoom_in"
44+
android:background="@drawable/map_btn_style"
45+
app:layout_constraintEnd_toEndOf="@+id/displaytrackmap_imgZoomCenter"
46+
app:layout_constraintTop_toBottomOf="@+id/displaytrackmap_imgZoomCenter" />
47+
48+
<ImageView
49+
android:id="@+id/displaytrackmap_imgZoomOut"
50+
android:layout_width="50sp"
51+
android:layout_height="50sp"
52+
android:layout_marginTop="10sp"
53+
android:padding="10dp"
54+
android:contentDescription="@string/acc.zoom_out"
55+
android:src="@drawable/zoom_out"
56+
android:background="@drawable/map_btn_style"
57+
app:layout_constraintEnd_toEndOf="@+id/displaytrackmap_imgZoomIn"
58+
app:layout_constraintTop_toBottomOf="@+id/displaytrackmap_imgZoomIn" />
59+
60+
</androidx.constraintlayout.widget.ConstraintLayout>
2761

2862
</RelativeLayout>

app/src/main/res/values/accessibility.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<!-- Zoom in/out in map view -->
88
<string name="acc.zoom_in">Zoom in</string>
99
<string name="acc.zoom_out">Zoom out</string>
10+
<string name="acc.zoom_center">Zoom center</string>
1011

1112
<!-- GPS status bar -->
1213
<string name="acc.sat_indicator">Satellite signal strength indicator</string>

app/src/main/res/values/colors.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
<color name="colorAccent">#39796b</color>
99
<color name="colorPrimaryText">#ffffff</color>
1010

11+
<!-- Map buttons -->
12+
<color name="btnBorder">#000000</color>
13+
<color name="map_btnBackground">#19303234</color>
14+
<color name="map_onClickBackground">#303234</color>
15+
1116

1217
<!-- Light Base application colors -->
1318
<!-- https://material.io/resources/color/#!/?view.left=0&view.right=0&primary.color=80CBC4 -->

0 commit comments

Comments
 (0)