parent
2944273a01
commit
c4d6a0479b
12 changed files with 88 additions and 164 deletions
|
@ -3,9 +3,7 @@
|
||||||
package="org.y20k.trackbook">
|
package="org.y20k.trackbook">
|
||||||
|
|
||||||
<!-- USE GPS AND NETWORK - EXCLUDE NON-GPS DEVICES -->
|
<!-- USE GPS AND NETWORK - EXCLUDE NON-GPS DEVICES -->
|
||||||
<uses-feature
|
<uses-feature android:name="android.hardware.location.gps" android:required="true" />
|
||||||
android:name="android.hardware.location.gps"
|
|
||||||
android:required="true" />
|
|
||||||
<uses-feature android:name="android.hardware.location.network" />
|
<uses-feature android:name="android.hardware.location.network" />
|
||||||
|
|
||||||
<!-- NORMAL PERMISSIONS, automatically granted -->
|
<!-- NORMAL PERMISSIONS, automatically granted -->
|
||||||
|
@ -38,8 +36,8 @@
|
||||||
<!-- TRACKER SERVICE -->
|
<!-- TRACKER SERVICE -->
|
||||||
<service
|
<service
|
||||||
android:name=".TrackerService"
|
android:name=".TrackerService"
|
||||||
android:exported="false"
|
android:foregroundServiceType="location"
|
||||||
android:foregroundServiceType="location">
|
android:exported="false">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="org.y20k.trackbook.action.START" />
|
<action android:name="org.y20k.trackbook.action.START" />
|
||||||
<action android:name="org.y20k.trackbook.action.STOP" />
|
<action android:name="org.y20k.trackbook.action.STOP" />
|
||||||
|
@ -50,8 +48,8 @@
|
||||||
<!-- TRACKING TOGGLE SERVICE SYSTEM QUICK SETTINGS -->
|
<!-- TRACKING TOGGLE SERVICE SYSTEM QUICK SETTINGS -->
|
||||||
<service
|
<service
|
||||||
android:name=".TrackingToggleTileService"
|
android:name=".TrackingToggleTileService"
|
||||||
android:icon="@drawable/ic_notification_icon_small_24dp"
|
|
||||||
android:label="@string/quick_settings_tile_title_default"
|
android:label="@string/quick_settings_tile_title_default"
|
||||||
|
android:icon="@drawable/ic_notification_icon_small_24dp"
|
||||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
|
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.service.quicksettings.action.QS_TILE" />
|
<action android:name="android.service.quicksettings.action.QS_TILE" />
|
||||||
|
|
|
@ -41,17 +41,11 @@ class NotificationHelper(private val trackerService: TrackerService) {
|
||||||
|
|
||||||
|
|
||||||
/* Main class variables */
|
/* Main class variables */
|
||||||
private val notificationManager: NotificationManager =
|
private val notificationManager: NotificationManager = trackerService.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||||
trackerService.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
|
||||||
|
|
||||||
|
|
||||||
/* Creates notification */
|
/* Creates notification */
|
||||||
fun createNotification(
|
fun createNotification(trackingState: Int, trackLength: Float, duration: Long, useImperial: Boolean): Notification {
|
||||||
trackingState: Int,
|
|
||||||
trackLength: Float,
|
|
||||||
duration: Long,
|
|
||||||
useImperial: Boolean
|
|
||||||
): Notification {
|
|
||||||
|
|
||||||
// create notification channel if necessary
|
// create notification channel if necessary
|
||||||
if (shouldCreateNotificationChannel()) {
|
if (shouldCreateNotificationChannel()) {
|
||||||
|
@ -59,8 +53,7 @@ class NotificationHelper(private val trackerService: TrackerService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build notification
|
// Build notification
|
||||||
val builder =
|
val builder = NotificationCompat.Builder(trackerService, Keys.NOTIFICATION_CHANNEL_RECORDING)
|
||||||
NotificationCompat.Builder(trackerService, Keys.NOTIFICATION_CHANNEL_RECORDING)
|
|
||||||
builder.setContentIntent(showActionPendingIntent)
|
builder.setContentIntent(showActionPendingIntent)
|
||||||
builder.setSmallIcon(R.drawable.ic_notification_icon_small_24dp)
|
builder.setSmallIcon(R.drawable.ic_notification_icon_small_24dp)
|
||||||
builder.setContentText(getContentString(trackerService, duration, trackLength, useImperial))
|
builder.setContentText(getContentString(trackerService, duration, trackLength, useImperial))
|
||||||
|
@ -70,23 +63,13 @@ class NotificationHelper(private val trackerService: TrackerService) {
|
||||||
Keys.STATE_TRACKING_ACTIVE -> {
|
Keys.STATE_TRACKING_ACTIVE -> {
|
||||||
builder.setContentTitle(trackerService.getString(R.string.notification_title_trackbook_running))
|
builder.setContentTitle(trackerService.getString(R.string.notification_title_trackbook_running))
|
||||||
builder.addAction(stopAction)
|
builder.addAction(stopAction)
|
||||||
builder.setLargeIcon(
|
builder.setLargeIcon(AppCompatResources.getDrawable(trackerService, R.drawable.ic_notification_icon_large_tracking_active_48dp)!!.toBitmap())
|
||||||
AppCompatResources.getDrawable(
|
|
||||||
trackerService,
|
|
||||||
R.drawable.ic_notification_icon_large_tracking_active_48dp
|
|
||||||
)!!.toBitmap()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
builder.setContentTitle(trackerService.getString(R.string.notification_title_trackbook_not_running))
|
builder.setContentTitle(trackerService.getString(R.string.notification_title_trackbook_not_running))
|
||||||
builder.addAction(resumeAction)
|
builder.addAction(resumeAction)
|
||||||
builder.addAction(showAction)
|
builder.addAction(showAction)
|
||||||
builder.setLargeIcon(
|
builder.setLargeIcon(AppCompatResources.getDrawable(trackerService, R.drawable.ic_notification_icon_large_tracking_stopped_48dp)!!.toBitmap())
|
||||||
AppCompatResources.getDrawable(
|
|
||||||
trackerService,
|
|
||||||
R.drawable.ic_notification_icon_large_tracking_stopped_48dp
|
|
||||||
)!!.toBitmap()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,42 +79,27 @@ class NotificationHelper(private val trackerService: TrackerService) {
|
||||||
|
|
||||||
|
|
||||||
/* Build context text for notification builder */
|
/* Build context text for notification builder */
|
||||||
private fun getContentString(
|
private fun getContentString(context: Context, duration: Long, trackLength: Float, useImperial: Boolean): String {
|
||||||
context: Context,
|
return "${LengthUnitHelper.convertDistanceToString(trackLength, useImperial)} • ${DateTimeHelper.convertToReadableTime(context, duration)}"
|
||||||
duration: Long,
|
|
||||||
trackLength: Float,
|
|
||||||
useImperial: Boolean
|
|
||||||
): String {
|
|
||||||
return "${LengthUnitHelper.convertDistanceToString(
|
|
||||||
trackLength,
|
|
||||||
useImperial
|
|
||||||
)} • ${DateTimeHelper.convertToReadableTime(context, duration)}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Checks if notification channel should be created */
|
/* Checks if notification channel should be created */
|
||||||
private fun shouldCreateNotificationChannel() =
|
private fun shouldCreateNotificationChannel() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !nowPlayingChannelExists()
|
||||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !nowPlayingChannelExists()
|
|
||||||
|
|
||||||
|
|
||||||
/* Checks if notification channel exists */
|
/* Checks if notification channel exists */
|
||||||
@RequiresApi(Build.VERSION_CODES.O)
|
@RequiresApi(Build.VERSION_CODES.O)
|
||||||
private fun nowPlayingChannelExists() =
|
private fun nowPlayingChannelExists() = notificationManager.getNotificationChannel(Keys.NOTIFICATION_CHANNEL_RECORDING) != null
|
||||||
notificationManager.getNotificationChannel(Keys.NOTIFICATION_CHANNEL_RECORDING) != null
|
|
||||||
|
|
||||||
|
|
||||||
/* Create a notification channel */
|
/* Create a notification channel */
|
||||||
@RequiresApi(Build.VERSION_CODES.O)
|
@RequiresApi(Build.VERSION_CODES.O)
|
||||||
private fun createNotificationChannel() {
|
private fun createNotificationChannel() {
|
||||||
val notificationChannel = NotificationChannel(
|
val notificationChannel = NotificationChannel(Keys.NOTIFICATION_CHANNEL_RECORDING,
|
||||||
Keys.NOTIFICATION_CHANNEL_RECORDING,
|
|
||||||
trackerService.getString(R.string.notification_channel_recording_name),
|
trackerService.getString(R.string.notification_channel_recording_name),
|
||||||
NotificationManager.IMPORTANCE_LOW
|
NotificationManager.IMPORTANCE_LOW)
|
||||||
)
|
.apply { description = trackerService.getString(R.string.notification_channel_recording_description) }
|
||||||
.apply {
|
|
||||||
description =
|
|
||||||
trackerService.getString(R.string.notification_channel_recording_description)
|
|
||||||
}
|
|
||||||
notificationManager.createNotificationChannel(notificationChannel)
|
notificationManager.createNotificationChannel(notificationChannel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,14 +107,11 @@ class NotificationHelper(private val trackerService: TrackerService) {
|
||||||
/* Notification pending intents */
|
/* Notification pending intents */
|
||||||
private val stopActionPendingIntent = PendingIntent.getService(
|
private val stopActionPendingIntent = PendingIntent.getService(
|
||||||
trackerService,14,
|
trackerService,14,
|
||||||
Intent(trackerService, TrackerService::class.java).setAction(Keys.ACTION_STOP), 0
|
Intent(trackerService, TrackerService::class.java).setAction(Keys.ACTION_STOP),0)
|
||||||
)
|
|
||||||
private val resumeActionPendingIntent = PendingIntent.getService(
|
private val resumeActionPendingIntent = PendingIntent.getService(
|
||||||
trackerService, 16,
|
trackerService, 16,
|
||||||
Intent(trackerService, TrackerService::class.java).setAction(Keys.ACTION_RESUME), 0
|
Intent(trackerService, TrackerService::class.java).setAction(Keys.ACTION_RESUME),0)
|
||||||
)
|
private val showActionPendingIntent: PendingIntent? = TaskStackBuilder.create(trackerService).run {
|
||||||
private val showActionPendingIntent: PendingIntent? =
|
|
||||||
TaskStackBuilder.create(trackerService).run {
|
|
||||||
addNextIntentWithParentStack(Intent(trackerService, MainActivity::class.java))
|
addNextIntentWithParentStack(Intent(trackerService, MainActivity::class.java))
|
||||||
getPendingIntent(10, PendingIntent.FLAG_UPDATE_CURRENT)
|
getPendingIntent(10, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||||
}
|
}
|
||||||
|
@ -156,17 +121,14 @@ class NotificationHelper(private val trackerService: TrackerService) {
|
||||||
private val stopAction = NotificationCompat.Action(
|
private val stopAction = NotificationCompat.Action(
|
||||||
R.drawable.ic_notification_action_stop_24dp,
|
R.drawable.ic_notification_action_stop_24dp,
|
||||||
trackerService.getString(R.string.notification_stop),
|
trackerService.getString(R.string.notification_stop),
|
||||||
stopActionPendingIntent
|
stopActionPendingIntent)
|
||||||
)
|
|
||||||
private val resumeAction = NotificationCompat.Action(
|
private val resumeAction = NotificationCompat.Action(
|
||||||
R.drawable.ic_notification_action_resume_36dp,
|
R.drawable.ic_notification_action_resume_36dp,
|
||||||
trackerService.getString(R.string.notification_resume),
|
trackerService.getString(R.string.notification_resume),
|
||||||
resumeActionPendingIntent
|
resumeActionPendingIntent)
|
||||||
)
|
|
||||||
private val showAction = NotificationCompat.Action(
|
private val showAction = NotificationCompat.Action(
|
||||||
R.drawable.ic_notification_action_show_36dp,
|
R.drawable.ic_notification_action_show_36dp,
|
||||||
trackerService.getString(R.string.notification_show),
|
trackerService.getString(R.string.notification_show),
|
||||||
showActionPendingIntent
|
showActionPendingIntent)
|
||||||
)
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -80,10 +80,7 @@ object PreferencesHelper {
|
||||||
// get preferences
|
// get preferences
|
||||||
val settings = PreferenceManager.getDefaultSharedPreferences(context)
|
val settings = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
// load length unit system
|
// load length unit system
|
||||||
return settings.getBoolean(
|
return settings.getBoolean(Keys.PREF_USE_IMPERIAL_UNITS, LengthUnitHelper.useImperialUnits())
|
||||||
Keys.PREF_USE_IMPERIAL_UNITS,
|
|
||||||
LengthUnitHelper.useImperialUnits()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -100,10 +97,7 @@ object PreferencesHelper {
|
||||||
// get preferences
|
// get preferences
|
||||||
val settings = PreferenceManager.getDefaultSharedPreferences(context)
|
val settings = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
// load tracking state
|
// load tracking state
|
||||||
return settings.getInt(
|
return settings.getInt(Keys.PREF_LOCATION_ACCURACY_THRESHOLD, Keys.DEFAULT_THRESHOLD_LOCATION_ACCURACY)
|
||||||
Keys.PREF_LOCATION_ACCURACY_THRESHOLD,
|
|
||||||
Keys.DEFAULT_THRESHOLD_LOCATION_ACCURACY
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,23 +105,15 @@ object PreferencesHelper {
|
||||||
fun loadCurrentBestLocation(context: Context): Location {
|
fun loadCurrentBestLocation(context: Context): Location {
|
||||||
// get preferences
|
// get preferences
|
||||||
val settings = PreferenceManager.getDefaultSharedPreferences(context)
|
val settings = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
val provider: String = settings.getString(
|
val provider: String = settings.getString(Keys.PREF_CURRENT_BEST_LOCATION_PROVIDER, LocationManager.NETWORK_PROVIDER) ?: LocationManager.NETWORK_PROVIDER
|
||||||
Keys.PREF_CURRENT_BEST_LOCATION_PROVIDER,
|
|
||||||
LocationManager.NETWORK_PROVIDER
|
|
||||||
) ?: LocationManager.NETWORK_PROVIDER
|
|
||||||
// create location
|
// create location
|
||||||
val currentBestLocation = Location(provider)
|
val currentBestLocation = Location(provider)
|
||||||
// load location attributes
|
// load location attributes
|
||||||
currentBestLocation.latitude =
|
currentBestLocation.latitude = settings.getDouble(Keys.PREF_CURRENT_BEST_LOCATION_LATITUDE, Keys.DEFAULT_LATITUDE)
|
||||||
settings.getDouble(Keys.PREF_CURRENT_BEST_LOCATION_LATITUDE, Keys.DEFAULT_LATITUDE)
|
currentBestLocation.longitude = settings.getDouble(Keys.PREF_CURRENT_BEST_LOCATION_LONGITUDE, Keys.DEFAULT_LONGITUDE)
|
||||||
currentBestLocation.longitude =
|
currentBestLocation.accuracy = settings.getFloat(Keys.PREF_CURRENT_BEST_LOCATION_ACCURACY, Keys.DEFAULT_ACCURACY)
|
||||||
settings.getDouble(Keys.PREF_CURRENT_BEST_LOCATION_LONGITUDE, Keys.DEFAULT_LONGITUDE)
|
currentBestLocation.altitude = settings.getDouble(Keys.PREF_CURRENT_BEST_LOCATION_ALTITUDE, Keys.DEFAULT_ALTITUDE)
|
||||||
currentBestLocation.accuracy =
|
currentBestLocation.time = settings.getLong(Keys.PREF_CURRENT_BEST_LOCATION_TIME, Keys.DEFAULT_TIME)
|
||||||
settings.getFloat(Keys.PREF_CURRENT_BEST_LOCATION_ACCURACY, Keys.DEFAULT_ACCURACY)
|
|
||||||
currentBestLocation.altitude =
|
|
||||||
settings.getDouble(Keys.PREF_CURRENT_BEST_LOCATION_ALTITUDE, Keys.DEFAULT_ALTITUDE)
|
|
||||||
currentBestLocation.time =
|
|
||||||
settings.getLong(Keys.PREF_CURRENT_BEST_LOCATION_TIME, Keys.DEFAULT_TIME)
|
|
||||||
return currentBestLocation
|
return currentBestLocation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,9 +135,7 @@ object PreferencesHelper {
|
||||||
|
|
||||||
/* Load currently selected app theme */
|
/* Load currently selected app theme */
|
||||||
fun loadThemeSelection(context: Context): String {
|
fun loadThemeSelection(context: Context): String {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context)
|
return PreferenceManager.getDefaultSharedPreferences(context).getString(Keys.PREF_THEME_SELECTION, Keys.STATE_THEME_FOLLOW_SYSTEM) ?: Keys.STATE_THEME_FOLLOW_SYSTEM
|
||||||
.getString(Keys.PREF_THEME_SELECTION, Keys.STATE_THEME_FOLLOW_SYSTEM)
|
|
||||||
?: Keys.STATE_THEME_FOLLOW_SYSTEM
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -51,25 +51,18 @@ import org.y20k.trackbook.helpers.PreferencesHelper
|
||||||
/*
|
/*
|
||||||
* MapFragmentLayoutHolder class
|
* MapFragmentLayoutHolder class
|
||||||
*/
|
*/
|
||||||
data class MapFragmentLayoutHolder(
|
data class MapFragmentLayoutHolder(private var context: Context, private var markerListener: MapOverlay.MarkerListener, private var inflater: LayoutInflater, private var container: ViewGroup?, private val startLocation: Location, private val trackingState: Int) {
|
||||||
private var context: Context,
|
|
||||||
private var markerListener: MapOverlay.MarkerListener,
|
|
||||||
private var inflater: LayoutInflater,
|
|
||||||
private var container: ViewGroup?,
|
|
||||||
private val startLocation: Location,
|
|
||||||
private val trackingState: Int
|
|
||||||
) {
|
|
||||||
|
|
||||||
/* Define log tag */
|
/* Define log tag */
|
||||||
private val TAG: String = LogHelper.makeLogTag(MapFragmentLayoutHolder::class.java)
|
private val TAG: String = LogHelper.makeLogTag(MapFragmentLayoutHolder::class.java)
|
||||||
|
|
||||||
|
|
||||||
/* Main class variables */
|
/* Main class variables */
|
||||||
val rootView: View = inflater.inflate(R.layout.fragment_map, container, false)
|
val rootView: View
|
||||||
private val mapView: MapView
|
val mapView: MapView
|
||||||
val currentLocationButton: FloatingActionButton
|
val currentLocationButton: FloatingActionButton
|
||||||
val recordingButton: FloatingActionButton
|
val recordingButton: FloatingActionButton
|
||||||
private val recordingButtonSubMenu: Group
|
val recordingButtonSubMenu: Group
|
||||||
val saveButton: FloatingActionButton
|
val saveButton: FloatingActionButton
|
||||||
val clearButton: FloatingActionButton
|
val clearButton: FloatingActionButton
|
||||||
val resumeButton: FloatingActionButton
|
val resumeButton: FloatingActionButton
|
||||||
|
@ -84,6 +77,7 @@ data class MapFragmentLayoutHolder(
|
||||||
/* Init block */
|
/* Init block */
|
||||||
init {
|
init {
|
||||||
// find views
|
// find views
|
||||||
|
rootView = inflater.inflate(R.layout.fragment_map, container, false)
|
||||||
mapView = rootView.findViewById(R.id.map)
|
mapView = rootView.findViewById(R.id.map)
|
||||||
currentLocationButton = rootView.findViewById(R.id.fab_location_button)
|
currentLocationButton = rootView.findViewById(R.id.fab_location_button)
|
||||||
recordingButton = rootView.findViewById(R.id.fab_main_button)
|
recordingButton = rootView.findViewById(R.id.fab_main_button)
|
||||||
|
@ -108,19 +102,14 @@ data class MapFragmentLayoutHolder(
|
||||||
}
|
}
|
||||||
|
|
||||||
// add compass to map
|
// add compass to map
|
||||||
val compassOverlay =
|
val compassOverlay = CompassOverlay(context, InternalCompassOrientationProvider(context), mapView)
|
||||||
CompassOverlay(context, InternalCompassOrientationProvider(context), mapView)
|
|
||||||
compassOverlay.enableCompass()
|
compassOverlay.enableCompass()
|
||||||
compassOverlay.setCompassCenter(36f, 60f)
|
compassOverlay.setCompassCenter(36f, 60f)
|
||||||
|
|
||||||
mapView.overlays.add(compassOverlay)
|
mapView.overlays.add(compassOverlay)
|
||||||
|
|
||||||
// add my location overlay
|
// add my location overlay
|
||||||
currentPositionOverlay = MapOverlay(markerListener).createMyLocationOverlay(
|
currentPositionOverlay = MapOverlay(markerListener).createMyLocationOverlay(context, startLocation, trackingState)
|
||||||
context,
|
|
||||||
startLocation,
|
|
||||||
trackingState
|
|
||||||
)
|
|
||||||
mapView.overlays.add(currentPositionOverlay)
|
mapView.overlays.add(currentPositionOverlay)
|
||||||
centerMap(startLocation)
|
centerMap(startLocation)
|
||||||
|
|
||||||
|
@ -138,7 +127,7 @@ data class MapFragmentLayoutHolder(
|
||||||
/* Listen for user interaction */
|
/* Listen for user interaction */
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
private fun addInteractionListener() {
|
private fun addInteractionListener() {
|
||||||
mapView.setOnTouchListener { _, _ ->
|
mapView.setOnTouchListener { v, event ->
|
||||||
userInteraction = true
|
userInteraction = true
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
@ -159,7 +148,7 @@ data class MapFragmentLayoutHolder(
|
||||||
/* 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.zoomLevelDouble)
|
PreferencesHelper.saveZoomLevel(context, mapView.getZoomLevelDouble())
|
||||||
// reset user interaction state
|
// reset user interaction state
|
||||||
userInteraction = false
|
userInteraction = false
|
||||||
}
|
}
|
||||||
|
@ -168,8 +157,7 @@ data class MapFragmentLayoutHolder(
|
||||||
/* Mark current position on map */
|
/* Mark current position on map */
|
||||||
fun markCurrentPosition(location: Location, trackingState: Int = Keys.STATE_TRACKING_NOT) {
|
fun markCurrentPosition(location: Location, trackingState: Int = Keys.STATE_TRACKING_NOT) {
|
||||||
mapView.overlays.remove(currentPositionOverlay)
|
mapView.overlays.remove(currentPositionOverlay)
|
||||||
currentPositionOverlay =
|
currentPositionOverlay = MapOverlay(markerListener).createMyLocationOverlay(context, location, trackingState)
|
||||||
MapOverlay(markerListener).createMyLocationOverlay(context, location, trackingState)
|
|
||||||
mapView.overlays.add(currentPositionOverlay)
|
mapView.overlays.add(currentPositionOverlay)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,8 +168,7 @@ data class MapFragmentLayoutHolder(
|
||||||
mapView.overlays.remove(currentTrackOverlay)
|
mapView.overlays.remove(currentTrackOverlay)
|
||||||
}
|
}
|
||||||
if (track.wayPoints.isNotEmpty()) {
|
if (track.wayPoints.isNotEmpty()) {
|
||||||
currentTrackOverlay =
|
currentTrackOverlay = MapOverlay(markerListener).createTrackOverlay(context, track, trackingState)
|
||||||
MapOverlay(markerListener).createTrackOverlay(context, track, trackingState)
|
|
||||||
mapView.overlays.add(currentTrackOverlay)
|
mapView.overlays.add(currentTrackOverlay)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,13 +201,10 @@ data class MapFragmentLayoutHolder(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Toggles content and visibility of the location error snackbar */
|
/* Toggles content and visibility of the location error snackbar */
|
||||||
fun toggleLocationErrorBar(gpsProviderActive: Boolean, networkProviderActive: Boolean) {
|
fun toggleLocationErrorBar(gpsProviderActive: Boolean, networkProviderActive: Boolean) {
|
||||||
if (ContextCompat.checkSelfPermission(
|
if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_DENIED) {
|
||||||
context,
|
|
||||||
Manifest.permission.ACCESS_FINE_LOCATION
|
|
||||||
) == PackageManager.PERMISSION_DENIED
|
|
||||||
) {
|
|
||||||
// CASE: Location permission not granted
|
// CASE: Location permission not granted
|
||||||
locationErrorBar.setText(R.string.snackbar_message_location_permission_denied)
|
locationErrorBar.setText(R.string.snackbar_message_location_permission_denied)
|
||||||
locationErrorBar.show()
|
locationErrorBar.show()
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
android:height="24dp"
|
||||||
|
android:viewportHeight="96.0"
|
||||||
android:viewportWidth="96.0"
|
android:viewportWidth="96.0"
|
||||||
android:viewportHeight="96.0">
|
android:width="24dp">
|
||||||
<path
|
<path
|
||||||
android:fillAlpha="0.33"
|
android:fillAlpha="0.33"
|
||||||
android:fillColor="@color/trackbook_blue"
|
android:fillColor="@color/trackbook_blue"
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
android:height="24dp"
|
||||||
|
android:viewportHeight="96.0"
|
||||||
android:viewportWidth="96.0"
|
android:viewportWidth="96.0"
|
||||||
android:viewportHeight="96.0">
|
android:width="24dp">
|
||||||
|
|
||||||
<path
|
<path
|
||||||
android:fillColor="@color/trackbook_red"
|
android:fillColor="@color/trackbook_red"
|
||||||
|
|
|
@ -31,21 +31,17 @@
|
||||||
|
|
||||||
|
|
||||||
<!-- COLOR NAMES -->
|
<!-- COLOR NAMES -->
|
||||||
|
<color name="trackbook_grey">#FF595959</color> <!-- derived from recommended dark theme surface color -->
|
||||||
<!-- derived from recommended dark theme surface color -->
|
|
||||||
<color name="trackbook_grey">#FF595959</color>
|
|
||||||
<color name="trackbook_grey_light">#FF7D7D7D</color>
|
<color name="trackbook_grey_light">#FF7D7D7D</color>
|
||||||
<color name="trackbook_grey_lighter">#FFDADADA</color>
|
<color name="trackbook_grey_lighter">#FFDADADA</color>
|
||||||
<color name="trackbook_grey_very_light">#FFF2F2F2</color>
|
<color name="trackbook_grey_very_light">#FFF2F2F2</color>
|
||||||
<color name="trackbook_grey_dark">#FF414141</color>
|
<color name="trackbook_grey_dark">#FF414141</color>
|
||||||
<color name="trackbook_grey_darker">#FF2D2D2D</color>
|
<color name="trackbook_grey_darker">#FF2D2D2D</color>
|
||||||
|
|
||||||
<!-- Slightly muted variant of -> Material Design 2: Red 600 -->
|
<color name="trackbook_red">#DC3D33</color> <!-- Slightly muted variant of -> Material Design 2: Red 600 -->
|
||||||
<color name="trackbook_red">#DC3D33</color>
|
|
||||||
<color name="trackbook_red_dark">#FFCA2D23</color>
|
<color name="trackbook_red_dark">#FFCA2D23</color>
|
||||||
|
|
||||||
<!-- Material Design recommended dark theme surface color -->
|
<color name="trackbook_black">#FF121212</color> <!-- Material Design recommended dark theme surface color -->
|
||||||
<color name="trackbook_black">#FF121212</color>
|
|
||||||
<color name="trackbook_white">#FFFFFFFF</color>
|
<color name="trackbook_white">#FFFFFFFF</color>
|
||||||
<color name="trackbook_transparent">#00ffffff</color>
|
<color name="trackbook_transparent">#00ffffff</color>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue