Skip to content

Commit

Permalink
Added map type toggle to current recording screen. Resolves #44
Browse files Browse the repository at this point in the history
  • Loading branch information
BradPatras committed Nov 25, 2023
1 parent 33a7a4f commit 2e79a12
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.widget.PopupMenu
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import com.iboism.gpxrecorder.Events
Expand Down Expand Up @@ -52,6 +54,20 @@ class RecorderFragment : Fragment(), RecorderServiceConnection.OnServiceConnecte
binding.playpauseBtn.setOnClickListener(this::playPauseButtonClicked)
binding.stopBtn.setOnClickListener(this::stopButtonClicked)

val moreMenu = PopupMenu(binding.root.context, binding.moreBtn)
val mapToggleMenuItem: MenuItem = moreMenu.menu.add("Toggle map type")

moreMenu.setOnMenuItemClickListener { menuItem ->
when (menuItem) {
mapToggleMenuItem -> mapController?.toggleMapType()
else -> return@setOnMenuItemClickListener false
}

return@setOnMenuItemClickListener true
}

binding.moreBtn.setOnClickListener { moreMenu.show() }

updateUI(gpxId)

binding.mapView.let {
Expand Down Expand Up @@ -141,13 +157,13 @@ class RecorderFragment : Fragment(), RecorderServiceConnection.OnServiceConnecte
}

val update = Single.just(Pair(gpxContent.title, isPaused))
.observeOn(AndroidSchedulers.mainThread())
.subscribe { pair ->
binding.routeTitleTv.text = pair.first
val pauseResumeString = if (pair.second) R.string.resume_recording else R.string.pause_recording
binding.playpauseBtn.setText(pauseResumeString)
mapController?.redraw()
}
.observeOn(AndroidSchedulers.mainThread())
.subscribe { pair ->
binding.routeTitleTv.text = pair.first
val pauseResumeString = if (pair.second) R.string.resume_recording else R.string.pause_recording
binding.playpauseBtn.setText(pauseResumeString)
mapController?.redraw()
}
realm.close()
}

Expand Down
15 changes: 15 additions & 0 deletions app/src/main/res/layout/fragment_active_route_details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@
app:layout_constraintStart_toStartOf="@id/current_rec_header"
app:layout_constraintTop_toBottomOf="@id/current_rec_header" />

<ImageButton android:id="@+id/more_btn"
android:alpha=".9"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:padding="4dp"
android:src="@drawable/ic_more"
android:elevation="5dp"
android:background="@android:color/transparent"
android:layout_marginEnd="12dp"
app:layout_constraintBottom_toTopOf="@+id/map_view"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tint="@color/on_nav_bar_surface"
android:contentDescription="More menu button" />

<Button
android:id="@+id/add_wpt_btn"
style="@style/Widget.Material3.Button.TextButton"
Expand Down

0 comments on commit 2e79a12

Please sign in to comment.