Implements most of of the changes proposed by @TacoTheDank (thank you!) in this pull request (see https://github.com/y20k/trackbook/pull/91)
This commit is contained in:
parent
1b69980491
commit
eb296188d8
16 changed files with 79 additions and 76 deletions
|
@ -10,8 +10,8 @@ android {
|
||||||
applicationId 'org.y20k.trackbook'
|
applicationId 'org.y20k.trackbook'
|
||||||
minSdkVersion 25
|
minSdkVersion 25
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
versionCode 46
|
versionCode 47
|
||||||
versionName '2.0.9'
|
versionName '2.0.10'
|
||||||
resConfigs "en", "da", "de", "fr", "hr", "id", "it", "ja", "nb-rNO", "nl", "pt-rBR", "sv", "tr", "zh-rCN"
|
resConfigs "en", "da", "de", "fr", "hr", "id", "it", "ja", "nb-rNO", "nl", "pt-rBR", "sv", "tr", "zh-rCN"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,17 +52,17 @@ android {
|
||||||
dependencies {
|
dependencies {
|
||||||
// Kotlin
|
// Kotlin
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.8'
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'
|
||||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.8'
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9'
|
||||||
|
|
||||||
// AndroidX
|
// AndroidX
|
||||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
|
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||||
implementation 'androidx.core:core-ktx:1.3.2'
|
implementation 'androidx.core:core-ktx:1.3.2'
|
||||||
implementation "androidx.navigation:navigation-fragment-ktx:$navigation_version"
|
implementation "androidx.navigation:navigation-fragment-ktx:$navigation_version"
|
||||||
implementation "androidx.navigation:navigation-ui-ktx:$navigation_version"
|
implementation "androidx.navigation:navigation-ui-ktx:$navigation_version"
|
||||||
implementation 'androidx.preference:preference-ktx:1.1.1'
|
implementation 'androidx.preference:preference-ktx:1.1.1'
|
||||||
implementation 'com.google.android.material:material:1.2.0-rc01'
|
implementation 'com.google.android.material:material:1.2.1'
|
||||||
|
|
||||||
// Gson
|
// Gson
|
||||||
implementation 'com.google.code.gson:gson:2.8.6'
|
implementation 'com.google.code.gson:gson:2.8.6'
|
||||||
|
|
|
@ -77,12 +77,12 @@ class MainActivity : AppCompatActivity() {
|
||||||
navHostFragment.navController.addOnDestinationChangedListener { _, destination, _ ->
|
navHostFragment.navController.addOnDestinationChangedListener { _, destination, _ ->
|
||||||
when (destination.id) {
|
when (destination.id) {
|
||||||
R.id.fragment_track -> {
|
R.id.fragment_track -> {
|
||||||
runOnUiThread( Runnable() {
|
runOnUiThread {
|
||||||
run(){
|
run {
|
||||||
// mark menu item "Tracks" as checked
|
// mark menu item "Tracks" as checked
|
||||||
bottomNavigationView.menu.findItem(R.id.tracklist_fragment).setChecked(true)
|
bottomNavigationView.menu.findItem(R.id.tracklist_fragment).isChecked = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
// do nothing
|
// do nothing
|
||||||
|
|
|
@ -48,8 +48,8 @@ class SettingsFragment : PreferenceFragmentCompat(), YesNoDialog.YesNoDialogList
|
||||||
// set the background color
|
// set the background color
|
||||||
view.setBackgroundColor(resources.getColor(R.color.app_window_background, null))
|
view.setBackgroundColor(resources.getColor(R.color.app_window_background, null))
|
||||||
// add padding - necessary because translucent status bar is used
|
// add padding - necessary because translucent status bar is used
|
||||||
val topPadding = UiHelper.getStatusBarHeight(activity as Context)
|
val topPadding: Int = UiHelper.getStatusBarHeight(activity as Context)
|
||||||
view.setPadding(0, topPadding.toInt(), 0, 0)
|
view.setPadding(0, topPadding, 0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ class SettingsFragment : PreferenceFragmentCompat(), YesNoDialog.YesNoDialogList
|
||||||
preferenceThemeSelection.setOnPreferenceChangeListener { preference, newValue ->
|
preferenceThemeSelection.setOnPreferenceChangeListener { preference, newValue ->
|
||||||
if (preference is ListPreference) {
|
if (preference is ListPreference) {
|
||||||
val index: Int = preference.entryValues.indexOf(newValue)
|
val index: Int = preference.entryValues.indexOf(newValue)
|
||||||
preferenceThemeSelection.summary = "${getString(R.string.pref_theme_selection_summary)} ${preference.entries.get(index)}"
|
preferenceThemeSelection.summary = "${getString(R.string.pref_theme_selection_summary)} ${preference.entries[index]}"
|
||||||
return@setOnPreferenceChangeListener true
|
return@setOnPreferenceChangeListener true
|
||||||
} else {
|
} else {
|
||||||
return@setOnPreferenceChangeListener false
|
return@setOnPreferenceChangeListener false
|
||||||
|
|
|
@ -185,7 +185,7 @@ class TrackFragment : Fragment(), RenameTrackDialog.RenameTrackListener, YesNoDi
|
||||||
try {
|
try {
|
||||||
startActivityForResult(intent, Keys.REQUEST_SAVE_GPX)
|
startActivityForResult(intent, Keys.REQUEST_SAVE_GPX)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
LogHelper.e(TAG, "Unable to save GPX. ")
|
LogHelper.e(TAG, "Unable to save GPX.")
|
||||||
Toast.makeText(activity as Context, R.string.toast_message_install_file_helper, Toast.LENGTH_LONG).show()
|
Toast.makeText(activity as Context, R.string.toast_message_install_file_helper, Toast.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ import kotlin.coroutines.CoroutineContext
|
||||||
/*
|
/*
|
||||||
* TrackerService class
|
* TrackerService class
|
||||||
*/
|
*/
|
||||||
class TrackerService(): Service(), CoroutineScope, SensorEventListener {
|
class TrackerService: Service(), CoroutineScope, SensorEventListener {
|
||||||
|
|
||||||
/* Define log tag */
|
/* Define log tag */
|
||||||
private val TAG: String = LogHelper.makeLogTag(TrackerService::class.java)
|
private val TAG: String = LogHelper.makeLogTag(TrackerService::class.java)
|
||||||
|
@ -210,7 +210,7 @@ class TrackerService(): Service(), CoroutineScope, SensorEventListener {
|
||||||
// try to mark last waypoint as stopover
|
// try to mark last waypoint as stopover
|
||||||
if (track.wayPoints.size > 0) {
|
if (track.wayPoints.size > 0) {
|
||||||
val lastWayPointIndex = track.wayPoints.size - 1
|
val lastWayPointIndex = track.wayPoints.size - 1
|
||||||
track.wayPoints.get(lastWayPointIndex).isStopOver = true
|
track.wayPoints[lastWayPointIndex].isStopOver = true
|
||||||
}
|
}
|
||||||
// set resumed flag
|
// set resumed flag
|
||||||
resumed = true
|
resumed = true
|
||||||
|
|
|
@ -31,7 +31,7 @@ import org.y20k.trackbook.helpers.PreferencesHelper
|
||||||
/*
|
/*
|
||||||
* TrackingToggleTileService class
|
* TrackingToggleTileService class
|
||||||
*/
|
*/
|
||||||
class TrackingToggleTileService(): TileService() {
|
class TrackingToggleTileService: TileService() {
|
||||||
|
|
||||||
/* Define log tag */
|
/* Define log tag */
|
||||||
private val TAG: String = LogHelper.makeLogTag(TrackingToggleTileService::class.java)
|
private val TAG: String = LogHelper.makeLogTag(TrackingToggleTileService::class.java)
|
||||||
|
|
|
@ -24,6 +24,7 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import androidx.recyclerview.widget.DefaultItemAnimator
|
import androidx.recyclerview.widget.DefaultItemAnimator
|
||||||
|
@ -68,8 +69,8 @@ class TracklistFragment : Fragment(), TracklistAdapter.TracklistAdapterListener,
|
||||||
tracklistOnboarding = rootView.findViewById(R.id.track_list_onboarding)
|
tracklistOnboarding = rootView.findViewById(R.id.track_list_onboarding)
|
||||||
|
|
||||||
// add padding - necessary because translucent status bar is used
|
// add padding - necessary because translucent status bar is used
|
||||||
val topPadding = UiHelper.getStatusBarHeight(activity as Context)
|
val topPadding: Int = UiHelper.getStatusBarHeight(activity as Context)
|
||||||
trackElementList.setPadding(0, topPadding.toInt(), 0, 0)
|
trackElementList.setPadding(0, topPadding, 0, 0)
|
||||||
|
|
||||||
// set up recycler view
|
// set up recycler view
|
||||||
trackElementList.layoutManager = CustomLinearLayoutManager(activity as Context)
|
trackElementList.layoutManager = CustomLinearLayoutManager(activity as Context)
|
||||||
|
@ -97,11 +98,12 @@ class TracklistFragment : Fragment(), TracklistAdapter.TracklistAdapterListener,
|
||||||
|
|
||||||
/* Overrides onTrackElementTapped from TracklistElementAdapterListener */
|
/* Overrides onTrackElementTapped from TracklistElementAdapterListener */
|
||||||
override fun onTrackElementTapped(tracklistElement: TracklistElement) {
|
override fun onTrackElementTapped(tracklistElement: TracklistElement) {
|
||||||
val bundle: Bundle = Bundle()
|
val bundle: Bundle = bundleOf(
|
||||||
bundle.putString(Keys.ARG_TRACK_TITLE, tracklistElement.name)
|
Keys.ARG_TRACK_TITLE to tracklistElement.name,
|
||||||
bundle.putString(Keys.ARG_TRACK_FILE_URI, tracklistElement.trackUriString)
|
Keys.ARG_TRACK_FILE_URI to tracklistElement.trackUriString,
|
||||||
bundle.putString(Keys.ARG_GPX_FILE_URI, tracklistElement.gpxUriString)
|
Keys.ARG_GPX_FILE_URI to tracklistElement.gpxUriString,
|
||||||
bundle.putLong(Keys.ARG_TRACK_ID, TrackHelper.getTrackId(tracklistElement))
|
Keys.ARG_TRACK_ID to TrackHelper.getTrackId(tracklistElement)
|
||||||
|
)
|
||||||
findNavController().navigate(R.id.fragment_track, bundle)
|
findNavController().navigate(R.id.fragment_track, bundle)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,8 @@ import android.text.method.ScrollingMovementMethod
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.core.view.isGone
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import org.y20k.trackbook.R
|
import org.y20k.trackbook.R
|
||||||
import org.y20k.trackbook.helpers.LogHelper
|
import org.y20k.trackbook.helpers.LogHelper
|
||||||
|
@ -56,25 +58,23 @@ object ErrorDialog {
|
||||||
builder.setView(view)
|
builder.setView(view)
|
||||||
|
|
||||||
// set detail view
|
// set detail view
|
||||||
if (errorDetails.isNotEmpty()) {
|
val detailsNotEmpty = errorDetails.isNotEmpty()
|
||||||
// show details link
|
// show/hide details link depending on whether details are empty or not
|
||||||
errorDetailsLinkView.visibility = View.VISIBLE
|
errorDetailsLinkView.isVisible = detailsNotEmpty
|
||||||
|
|
||||||
|
if (detailsNotEmpty) {
|
||||||
// allow scrolling on details view
|
// allow scrolling on details view
|
||||||
errorDetailsView.movementMethod = ScrollingMovementMethod()
|
errorDetailsView.movementMethod = ScrollingMovementMethod()
|
||||||
|
|
||||||
// show and hide details on click
|
// show and hide details on click
|
||||||
errorDetailsLinkView.setOnClickListener {
|
errorDetailsLinkView.setOnClickListener {
|
||||||
when (errorDetailsView.visibility) {
|
when (errorDetailsView.visibility) {
|
||||||
View.GONE -> errorDetailsView.visibility = View.VISIBLE
|
View.GONE -> errorDetailsView.isVisible = true
|
||||||
View.VISIBLE -> errorDetailsView.visibility = View.GONE
|
View.VISIBLE -> errorDetailsView.isGone = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// set details text view
|
// set details text view
|
||||||
errorDetailsView.text = errorDetails
|
errorDetailsView.text = errorDetails
|
||||||
} else {
|
|
||||||
// hide details link
|
|
||||||
errorDetailsLinkView.visibility = View.GONE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set text views
|
// set text views
|
||||||
|
|
|
@ -84,7 +84,7 @@ class YesNoDialog (private var yesNoDialogListener: YesNoDialogListener) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle outside-click as "no"
|
// handle outside-click as "no"
|
||||||
builder.setOnCancelListener(){
|
builder.setOnCancelListener{
|
||||||
yesNoDialogListener.onYesNoDialog(type, false, payload, payloadString)
|
yesNoDialogListener.onYesNoDialog(type, false, payload, payloadString)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ object DateTimeHelper {
|
||||||
|
|
||||||
/* Converts milliseconds to mm:ss or hh:mm:ss */
|
/* Converts milliseconds to mm:ss or hh:mm:ss */
|
||||||
fun convertToReadableTime(context: Context, milliseconds: Long): String {
|
fun convertToReadableTime(context: Context, milliseconds: Long): String {
|
||||||
var timeString: String = String()
|
val timeString: String
|
||||||
val hours: Long = TimeUnit.MILLISECONDS.toHours(milliseconds)
|
val hours: Long = TimeUnit.MILLISECONDS.toHours(milliseconds)
|
||||||
val minutes: Long = TimeUnit.MILLISECONDS.toMinutes(milliseconds) % TimeUnit.HOURS.toMinutes(1)
|
val minutes: Long = TimeUnit.MILLISECONDS.toMinutes(milliseconds) % TimeUnit.HOURS.toMinutes(1)
|
||||||
val seconds: Long = TimeUnit.MILLISECONDS.toSeconds(milliseconds) % TimeUnit.MINUTES.toSeconds(1)
|
val seconds: Long = TimeUnit.MILLISECONDS.toSeconds(milliseconds) % TimeUnit.MINUTES.toSeconds(1)
|
||||||
|
|
|
@ -35,6 +35,8 @@ import java.text.NumberFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.coroutines.resume
|
import kotlin.coroutines.resume
|
||||||
import kotlin.coroutines.suspendCoroutine
|
import kotlin.coroutines.suspendCoroutine
|
||||||
|
import kotlin.math.ln
|
||||||
|
import kotlin.math.pow
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -259,13 +261,13 @@ object FileHelper {
|
||||||
val jsonString: String = getTrackJsonString(track)
|
val jsonString: String = getTrackJsonString(track)
|
||||||
if (jsonString.isNotBlank()) {
|
if (jsonString.isNotBlank()) {
|
||||||
// write track file
|
// write track file
|
||||||
writeTextFile(jsonString, Uri.parse(track.trackUriString))
|
writeTextFile(jsonString, track.trackUriString.toUri())
|
||||||
}
|
}
|
||||||
if (saveGpxToo) {
|
if (saveGpxToo) {
|
||||||
val gpxString: String = TrackHelper.createGpxString(track)
|
val gpxString: String = TrackHelper.createGpxString(track)
|
||||||
if (gpxString.isNotBlank()) {
|
if (gpxString.isNotBlank()) {
|
||||||
// write GPX file
|
// write GPX file
|
||||||
writeTextFile(gpxString, Uri.parse(track.gpxUriString))
|
writeTextFile(gpxString, track.gpxUriString.toUri())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -401,13 +403,13 @@ object FileHelper {
|
||||||
if (bytes < unit) return "$bytes B"
|
if (bytes < unit) return "$bytes B"
|
||||||
|
|
||||||
// calculate exp
|
// calculate exp
|
||||||
val exp: Int = (Math.log(bytes.toDouble()) / Math.log(unit.toDouble())).toInt()
|
val exp: Int = (ln(bytes.toDouble()) / ln(unit.toDouble())).toInt()
|
||||||
|
|
||||||
// determine prefix symbol
|
// determine prefix symbol
|
||||||
val prefix: String = ((if (si) "kMGTPE" else "KMGTPE")[exp - 1] + if (si) "" else "i")
|
val prefix: String = ((if (si) "kMGTPE" else "KMGTPE")[exp - 1] + if (si) "" else "i")
|
||||||
|
|
||||||
// calculate result and set number format
|
// calculate result and set number format
|
||||||
val result: Double = bytes / Math.pow(unit.toDouble(), exp.toDouble())
|
val result: Double = bytes / unit.toDouble().pow(exp.toDouble())
|
||||||
val numberFormat = NumberFormat.getNumberInstance()
|
val numberFormat = NumberFormat.getNumberInstance()
|
||||||
numberFormat.maximumFractionDigits = 1
|
numberFormat.maximumFractionDigits = 1
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.y20k.trackbook.helpers
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.location.Location
|
import android.location.Location
|
||||||
import android.location.LocationManager
|
import android.location.LocationManager
|
||||||
|
import androidx.core.content.edit
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import org.y20k.trackbook.Keys
|
import org.y20k.trackbook.Keys
|
||||||
import org.y20k.trackbook.extensions.getDouble
|
import org.y20k.trackbook.extensions.getDouble
|
||||||
|
@ -48,10 +49,8 @@ object PreferencesHelper {
|
||||||
fun saveZoomLevel(context: Context, zoomLevel: Double) {
|
fun saveZoomLevel(context: Context, zoomLevel: Double) {
|
||||||
// get preferences
|
// get preferences
|
||||||
val settings = PreferenceManager.getDefaultSharedPreferences(context)
|
val settings = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
val editor = settings.edit()
|
|
||||||
// save zoom level
|
// save zoom level
|
||||||
editor.putDouble(Keys.PREF_MAP_ZOOM_LEVEL, zoomLevel)
|
settings.edit { putDouble(Keys.PREF_MAP_ZOOM_LEVEL, zoomLevel) }
|
||||||
editor.apply()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,10 +67,8 @@ object PreferencesHelper {
|
||||||
fun saveTrackingState(context: Context, trackingState: Int) {
|
fun saveTrackingState(context: Context, trackingState: Int) {
|
||||||
// get preferences
|
// get preferences
|
||||||
val settings = PreferenceManager.getDefaultSharedPreferences(context)
|
val settings = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
val editor = settings.edit()
|
|
||||||
// save tracking state
|
// save tracking state
|
||||||
editor.putInt(Keys.PREF_TRACKING_STATE, trackingState)
|
settings.edit { putInt(Keys.PREF_TRACKING_STATE, trackingState) }
|
||||||
editor.apply()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,14 +119,14 @@ object PreferencesHelper {
|
||||||
fun saveCurrentBestLocation(context: Context, currentBestLocation: Location) {
|
fun saveCurrentBestLocation(context: Context, currentBestLocation: Location) {
|
||||||
// get preferences
|
// get preferences
|
||||||
val settings = PreferenceManager.getDefaultSharedPreferences(context)
|
val settings = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
val editor = settings.edit()
|
settings.edit {
|
||||||
// save location
|
// save location
|
||||||
editor.putDouble(Keys.PREF_CURRENT_BEST_LOCATION_LATITUDE, currentBestLocation.latitude)
|
putDouble(Keys.PREF_CURRENT_BEST_LOCATION_LATITUDE, currentBestLocation.latitude)
|
||||||
editor.putDouble(Keys.PREF_CURRENT_BEST_LOCATION_LONGITUDE, currentBestLocation.longitude)
|
putDouble(Keys.PREF_CURRENT_BEST_LOCATION_LONGITUDE, currentBestLocation.longitude)
|
||||||
editor.putFloat(Keys.PREF_CURRENT_BEST_LOCATION_ACCURACY, currentBestLocation.accuracy)
|
putFloat(Keys.PREF_CURRENT_BEST_LOCATION_ACCURACY, currentBestLocation.accuracy)
|
||||||
editor.putDouble(Keys.PREF_CURRENT_BEST_LOCATION_ALTITUDE, currentBestLocation.altitude)
|
putDouble(Keys.PREF_CURRENT_BEST_LOCATION_ALTITUDE, currentBestLocation.altitude)
|
||||||
editor.putLong(Keys.PREF_CURRENT_BEST_LOCATION_TIME, currentBestLocation.time)
|
putLong(Keys.PREF_CURRENT_BEST_LOCATION_TIME, currentBestLocation.time)
|
||||||
editor.apply()
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -149,9 +146,7 @@ object PreferencesHelper {
|
||||||
/* Saves state of housekeeping */
|
/* Saves state of housekeeping */
|
||||||
fun saveHouseKeepingNecessaryState(context: Context, state: Boolean = false) {
|
fun saveHouseKeepingNecessaryState(context: Context, state: Boolean = false) {
|
||||||
val settings = PreferenceManager.getDefaultSharedPreferences(context)
|
val settings = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
val editor = settings.edit()
|
settings.edit { putBoolean(Keys.PREF_ONE_TIME_HOUSEKEEPING_NECESSARY, state) }
|
||||||
editor.putBoolean(Keys.PREF_ONE_TIME_HOUSEKEEPING_NECESSARY, state)
|
|
||||||
editor.apply()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -181,11 +181,11 @@ object TrackHelper {
|
||||||
/* Creates name for GPX file */
|
/* Creates name for GPX file */
|
||||||
private fun createGpxName(track: Track): String {
|
private fun createGpxName(track: Track): String {
|
||||||
val gpxName = StringBuilder("")
|
val gpxName = StringBuilder("")
|
||||||
gpxName.append("\t<metadata>\n");
|
gpxName.append("\t<metadata>\n")
|
||||||
gpxName.append("\t\t<name>")
|
gpxName.append("\t\t<name>")
|
||||||
gpxName.append("Trackbook Recording: ${track.name}")
|
gpxName.append("Trackbook Recording: ${track.name}")
|
||||||
gpxName.append("</name>\n")
|
gpxName.append("</name>\n")
|
||||||
gpxName.append("\t</metadata>\n");
|
gpxName.append("\t</metadata>\n")
|
||||||
return gpxName.toString()
|
return gpxName.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.constraintlayout.widget.Group
|
import androidx.constraintlayout.widget.Group
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.core.view.isGone
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import org.osmdroid.api.IMapController
|
import org.osmdroid.api.IMapController
|
||||||
|
@ -145,7 +147,7 @@ data class MapFragmentLayoutHolder(private var context: Context, private var mar
|
||||||
/* Save current best location and state of map to shared preferences */
|
/* Save current best location and state of map to shared preferences */
|
||||||
fun saveState(currentBestLocation: Location) {
|
fun saveState(currentBestLocation: Location) {
|
||||||
PreferencesHelper.saveCurrentBestLocation(context, currentBestLocation)
|
PreferencesHelper.saveCurrentBestLocation(context, currentBestLocation)
|
||||||
PreferencesHelper.saveZoomLevel(context, mapView.getZoomLevelDouble())
|
PreferencesHelper.saveZoomLevel(context, mapView.zoomLevelDouble)
|
||||||
// reset user interaction state
|
// reset user interaction state
|
||||||
userInteraction = false
|
userInteraction = false
|
||||||
}
|
}
|
||||||
|
@ -176,11 +178,11 @@ data class MapFragmentLayoutHolder(private var context: Context, private var mar
|
||||||
when (trackingState) {
|
when (trackingState) {
|
||||||
Keys.STATE_TRACKING_NOT -> {
|
Keys.STATE_TRACKING_NOT -> {
|
||||||
recordingButton.setImageResource(R.drawable.ic_fiber_manual_record_white_24dp)
|
recordingButton.setImageResource(R.drawable.ic_fiber_manual_record_white_24dp)
|
||||||
recordingButtonSubMenu.visibility = View.GONE
|
recordingButtonSubMenu.isGone = true
|
||||||
}
|
}
|
||||||
Keys.STATE_TRACKING_ACTIVE -> {
|
Keys.STATE_TRACKING_ACTIVE -> {
|
||||||
recordingButton.setImageResource(R.drawable.ic_fiber_manual_record_red_24dp)
|
recordingButton.setImageResource(R.drawable.ic_fiber_manual_record_red_24dp)
|
||||||
recordingButtonSubMenu.visibility = View.GONE
|
recordingButtonSubMenu.isGone = true
|
||||||
}
|
}
|
||||||
Keys.STATE_TRACKING_STOPPED -> {
|
Keys.STATE_TRACKING_STOPPED -> {
|
||||||
recordingButton.setImageResource(R.drawable.ic_save_white_24dp)
|
recordingButton.setImageResource(R.drawable.ic_save_white_24dp)
|
||||||
|
@ -192,8 +194,8 @@ data class MapFragmentLayoutHolder(private var context: Context, private var mar
|
||||||
/* Toggles visibility of recording button sub menu_bottom_navigation */
|
/* Toggles visibility of recording button sub menu_bottom_navigation */
|
||||||
fun toggleRecordingButtonSubMenu() {
|
fun toggleRecordingButtonSubMenu() {
|
||||||
when (recordingButtonSubMenu.visibility) {
|
when (recordingButtonSubMenu.visibility) {
|
||||||
View.VISIBLE -> recordingButtonSubMenu.visibility = View.GONE
|
View.VISIBLE -> recordingButtonSubMenu.isGone = true
|
||||||
else -> recordingButtonSubMenu.visibility = View.VISIBLE
|
else -> recordingButtonSubMenu.isVisible = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,8 @@ import android.view.ViewGroup
|
||||||
import android.widget.ImageButton
|
import android.widget.ImageButton
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.constraintlayout.widget.Group
|
import androidx.constraintlayout.widget.Group
|
||||||
|
import androidx.core.view.isGone
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.widget.NestedScrollView
|
import androidx.core.widget.NestedScrollView
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import com.google.android.material.textview.MaterialTextView
|
import com.google.android.material.textview.MaterialTextView
|
||||||
|
@ -210,12 +212,12 @@ data class TrackFragmentLayoutHolder(private var context: Context, private var m
|
||||||
|
|
||||||
// show / hide recording pause
|
// show / hide recording pause
|
||||||
if (track.recordingPaused != 0L) {
|
if (track.recordingPaused != 0L) {
|
||||||
recordingPausedLabelView.visibility = View.VISIBLE
|
recordingPausedLabelView.isVisible = true
|
||||||
recordingPausedView.visibility = View.VISIBLE
|
recordingPausedView.isVisible = true
|
||||||
recordingPausedView.text = DateTimeHelper.convertToReadableTime(context, track.recordingPaused)
|
recordingPausedView.text = DateTimeHelper.convertToReadableTime(context, track.recordingPaused)
|
||||||
} else {
|
} else {
|
||||||
recordingPausedLabelView.visibility = View.GONE
|
recordingPausedLabelView.isGone = true
|
||||||
recordingPausedView.visibility = View.GONE
|
recordingPausedView.isGone = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// inform user about possible accuracy issues with altitude measurements
|
// inform user about possible accuracy issues with altitude measurements
|
||||||
|
@ -247,14 +249,14 @@ data class TrackFragmentLayoutHolder(private var context: Context, private var m
|
||||||
when (newState) {
|
when (newState) {
|
||||||
BottomSheetBehavior.STATE_EXPANDED -> {
|
BottomSheetBehavior.STATE_EXPANDED -> {
|
||||||
statisticsSheet.background = context.getDrawable(R.drawable.shape_statistics_background_expanded)
|
statisticsSheet.background = context.getDrawable(R.drawable.shape_statistics_background_expanded)
|
||||||
trackManagementViews.visibility = View.VISIBLE
|
trackManagementViews.isVisible = true
|
||||||
shareButton.visibility = View.GONE
|
shareButton.isGone = true
|
||||||
// bottomSheet.setPadding(0,24,0,0)
|
// bottomSheet.setPadding(0,24,0,0)
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
statisticsSheet.background = context.getDrawable(R.drawable.shape_statistics_background_collapsed)
|
statisticsSheet.background = context.getDrawable(R.drawable.shape_statistics_background_collapsed)
|
||||||
trackManagementViews.visibility = View.GONE
|
trackManagementViews.isGone = true
|
||||||
shareButton.visibility = View.VISIBLE
|
shareButton.isVisible = true
|
||||||
// bottomSheet.setPadding(0,0,0,0)
|
// bottomSheet.setPadding(0,0,0,0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -262,12 +264,12 @@ data class TrackFragmentLayoutHolder(private var context: Context, private var m
|
||||||
override fun onSlide(bottomSheet: View, slideOffset: Float) {
|
override fun onSlide(bottomSheet: View, slideOffset: Float) {
|
||||||
if (slideOffset < 0.125f) {
|
if (slideOffset < 0.125f) {
|
||||||
statisticsSheet.background = context.getDrawable(R.drawable.shape_statistics_background_collapsed)
|
statisticsSheet.background = context.getDrawable(R.drawable.shape_statistics_background_collapsed)
|
||||||
trackManagementViews.visibility = View.GONE
|
trackManagementViews.isGone = true
|
||||||
shareButton.visibility = View.VISIBLE
|
shareButton.isVisible = true
|
||||||
} else {
|
} else {
|
||||||
statisticsSheet.background = context.getDrawable(R.drawable.shape_statistics_background_expanded)
|
statisticsSheet.background = context.getDrawable(R.drawable.shape_statistics_background_expanded)
|
||||||
trackManagementViews.visibility = View.VISIBLE
|
trackManagementViews.isVisible = true
|
||||||
shareButton.visibility = View.GONE
|
shareButton.isGone = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,14 +3,14 @@
|
||||||
buildscript {
|
buildscript {
|
||||||
ext {
|
ext {
|
||||||
kotlin_version = '1.4.10'
|
kotlin_version = '1.4.10'
|
||||||
navigation_version = '2.3.0'
|
navigation_version = '2.3.1'
|
||||||
}
|
}
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.1.0'
|
classpath 'com.android.tools.build:gradle:4.1.1'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navigation_version"
|
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navigation_version"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue