Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #351 display map design #491

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions app/src/main/java/net/osmtracker/activity/DisplayTrackMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.osmdroid.config.Configuration;
import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.CustomZoomButtonsController;
import org.osmdroid.views.MapView;
import org.osmdroid.views.overlay.Polyline;
import org.osmdroid.views.overlay.ScaleBarOverlay;
Expand Down Expand Up @@ -85,6 +86,16 @@ public class DisplayTrackMap extends Activity {
*/
private static final int DEFAULT_ZOOM = 16;

/**
* Default zoom level for center with zoom
*/
private static final double CENTER_DEFAULT_ZOOM_LEVEL = 18;

/**
* Animation duration in milliseconds for center with zoom
*/
private static final long ANIMATION_DURATION_MS = 1000;

/**
* Main OSM view
*/
Expand Down Expand Up @@ -171,6 +182,7 @@ public void onCreate(Bundle savedInstanceState) {
osmView = findViewById(R.id.displaytrackmap_osmView);
// pinch to zoom
osmView.setMultiTouchControls(true);
osmView.getZoomController().setVisibility(CustomZoomButtonsController.Visibility.NEVER);
// we'll use osmView to define if the screen is always on or not
osmView.setKeepScreenOn(prefs.getBoolean(OSMTracker.Preferences.KEY_UI_DISPLAY_KEEP_ON, OSMTracker.Preferences.VAL_UI_DISPLAY_KEEP_ON));
osmViewController = osmView.getController();
Expand Down Expand Up @@ -205,6 +217,12 @@ public void onChange(boolean selfChange) {
// Register listeners for zoom buttons
findViewById(R.id.displaytrackmap_imgZoomIn).setOnClickListener(v -> osmViewController.zoomIn());
findViewById(R.id.displaytrackmap_imgZoomOut).setOnClickListener(v -> osmViewController.zoomOut());
findViewById(R.id.displaytrackmap_imgZoomCenter).setOnClickListener(view -> {
centerToGpsPos = true;
if (currentPosition != null) {
osmViewController.animateTo(currentPosition,CENTER_DEFAULT_ZOOM_LEVEL, ANIMATION_DURATION_MS);
}
});
}

/**
Expand Down
Binary file added app/src/main/res/drawable-mdpi/gps_center.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 modified app/src/main/res/drawable-mdpi/zoom_in.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 modified app/src/main/res/drawable-mdpi/zoom_out.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions app/src/main/res/drawable/map_btn_style.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/map_onClickBackground"
>
<item>
<shape android:shape="oval">
<solid android:color="@color/map_btnBackground" />
<stroke android:width="1dp" android:color="@color/btnBorder" />
</shape>
</item>
</ripple>
74 changes: 54 additions & 20 deletions app/src/main/res/layout/displaytrackmap.xml
Original file line number Diff line number Diff line change
@@ -1,28 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">

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

<ImageView
android:id="@+id/displaytrackmap_imgZoomIn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:contentDescription="@string/acc.zoom_in"
android:src="@drawable/zoom_in" >
</ImageView>
<org.osmdroid.views.MapView
android:id="@+id/displaytrackmap_osmView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0"/>

<ImageView
android:id="@+id/displaytrackmap_imgZoomOut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/acc.zoom_in"
android:src="@drawable/zoom_out" >
</ImageView>
<ImageView
android:id="@+id/displaytrackmap_imgZoomCenter"
android:layout_width="50sp"
android:layout_height="50sp"
android:layout_marginEnd="20dp"
android:padding="10dp"
android:layout_marginBottom="200dp"
android:contentDescription="@string/acc.zoom_center"
android:background="@drawable/map_btn_style"
android:src="@drawable/gps_center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

<ImageView
android:id="@+id/displaytrackmap_imgZoomIn"
android:layout_width="50sp"
android:layout_height="50sp"
android:layout_alignParentRight="true"
android:layout_marginTop="10sp"
android:padding="10dp"
android:contentDescription="@string/acc.zoom_in"
android:src="@drawable/zoom_in"
android:background="@drawable/map_btn_style"
app:layout_constraintEnd_toEndOf="@+id/displaytrackmap_imgZoomCenter"
app:layout_constraintTop_toBottomOf="@+id/displaytrackmap_imgZoomCenter" />

<ImageView
android:id="@+id/displaytrackmap_imgZoomOut"
android:layout_width="50sp"
android:layout_height="50sp"
android:layout_marginTop="10sp"
android:padding="10dp"
android:contentDescription="@string/acc.zoom_out"
android:src="@drawable/zoom_out"
android:background="@drawable/map_btn_style"
app:layout_constraintEnd_toEndOf="@+id/displaytrackmap_imgZoomIn"
app:layout_constraintTop_toBottomOf="@+id/displaytrackmap_imgZoomIn" />

</androidx.constraintlayout.widget.ConstraintLayout>

</RelativeLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values/accessibility.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<!-- Zoom in/out in map view -->
<string name="acc.zoom_in">Zoom in</string>
<string name="acc.zoom_out">Zoom out</string>
<string name="acc.zoom_center">Zoom center</string>

<!-- GPS status bar -->
<string name="acc.sat_indicator">Satellite signal strength indicator</string>
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
<color name="colorAccent">#39796b</color>
<color name="colorPrimaryText">#ffffff</color>

<!-- Map buttons -->
<color name="btnBorder">#000000</color>
<color name="map_btnBackground">#19303234</color>
<color name="map_onClickBackground">#303234</color>


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