Skip to content

Commit

Permalink
NFix labexp#351: new map button layout
Browse files Browse the repository at this point in the history
  • Loading branch information
miltonials committed Dec 17, 2024
1 parent 3520b6c commit 52435c8
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 20 deletions.
16 changes: 16 additions & 0 deletions app/src/main/java/net/osmtracker/activity/DisplayTrackMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,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 @@ -207,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.
File renamed without changes.
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

0 comments on commit 52435c8

Please sign in to comment.