Remove prefs load/save function comments.

master
voussoir 2022-04-02 21:47:18 -07:00
parent 3741d0baf5
commit ac5c3c2dd5
No known key found for this signature in database
GPG Key ID: 5F7554F8C26DACCB
1 changed files with 0 additions and 42 deletions

View File

@ -14,7 +14,6 @@
* https://github.com/osmdroid/osmdroid * https://github.com/osmdroid/osmdroid
*/ */
package org.y20k.trackbook.helpers package org.y20k.trackbook.helpers
import android.content.Context import android.content.Context
@ -27,7 +26,6 @@ import org.y20k.trackbook.Keys
import org.y20k.trackbook.extensions.getDouble import org.y20k.trackbook.extensions.getDouble
import org.y20k.trackbook.extensions.putDouble import org.y20k.trackbook.extensions.putDouble
/* /*
* PreferencesHelper object * PreferencesHelper object
*/ */
@ -45,62 +43,30 @@ object PreferencesHelper {
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this) sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
} }
/* Loads zoom level of map */
fun loadZoomLevel(): Double { fun loadZoomLevel(): Double {
// load zoom level
return sharedPreferences.getDouble(Keys.PREF_MAP_ZOOM_LEVEL, Keys.DEFAULT_ZOOM_LEVEL) return sharedPreferences.getDouble(Keys.PREF_MAP_ZOOM_LEVEL, Keys.DEFAULT_ZOOM_LEVEL)
} }
/* Saves zoom level of map */
fun saveZoomLevel(zoomLevel: Double) { fun saveZoomLevel(zoomLevel: Double) {
// save zoom level
sharedPreferences.edit { putDouble(Keys.PREF_MAP_ZOOM_LEVEL, zoomLevel) } sharedPreferences.edit { putDouble(Keys.PREF_MAP_ZOOM_LEVEL, zoomLevel) }
} }
/* Loads tracking state */
fun loadTrackingState(): Int { fun loadTrackingState(): Int {
// load tracking state
return sharedPreferences.getInt(Keys.PREF_TRACKING_STATE, Keys.STATE_TRACKING_NOT_STARTED) return sharedPreferences.getInt(Keys.PREF_TRACKING_STATE, Keys.STATE_TRACKING_NOT_STARTED)
} }
/* Saves tracking state */
fun saveTrackingState(trackingState: Int) { fun saveTrackingState(trackingState: Int) {
// save tracking state
sharedPreferences.edit { putInt(Keys.PREF_TRACKING_STATE, trackingState) } sharedPreferences.edit { putInt(Keys.PREF_TRACKING_STATE, trackingState) }
} }
/* Loads length unit system - metric or imperial */
fun loadUseImperialUnits(): Boolean { fun loadUseImperialUnits(): Boolean {
// load length unit system
return sharedPreferences.getBoolean(Keys.PREF_USE_IMPERIAL_UNITS, LengthUnitHelper.useImperialUnits()) return sharedPreferences.getBoolean(Keys.PREF_USE_IMPERIAL_UNITS, LengthUnitHelper.useImperialUnits())
} }
/* Loads length unit system - metric or imperial */
fun loadGpsOnly(): Boolean { fun loadGpsOnly(): Boolean {
// load length unit system
return sharedPreferences.getBoolean(Keys.PREF_GPS_ONLY, false) return sharedPreferences.getBoolean(Keys.PREF_GPS_ONLY, false)
} }
// /* Loads accuracy threshold used to determine if location is good enough */
// fun loadAccuracyThreshold(): Int {
// // load tracking state
// return sharedPreferences.getInt(Keys.PREF_LOCATION_ACCURACY_THRESHOLD, Keys.DEFAULT_THRESHOLD_LOCATION_ACCURACY)
// }
// /* Loads state of recording accuracy */
// fun loadRecordingAccuracyHigh(): Boolean {
// // load current setting
// return sharedPreferences.getBoolean(Keys.PREF_RECORDING_ACCURACY_HIGH, false)
// }
fun loadOmitRests(): Boolean { fun loadOmitRests(): Boolean {
return sharedPreferences.getBoolean(Keys.PREF_OMIT_RESTS, true) return sharedPreferences.getBoolean(Keys.PREF_OMIT_RESTS, true)
} }
@ -111,13 +77,11 @@ object PreferencesHelper {
// return sharedPreferences.getInt(Keys.PREF_ALTITUDE_SMOOTHING_VALUE, Keys.DEFAULT_ALTITUDE_SMOOTHING_VALUE) // return sharedPreferences.getInt(Keys.PREF_ALTITUDE_SMOOTHING_VALUE, Keys.DEFAULT_ALTITUDE_SMOOTHING_VALUE)
// } // }
/* Loads the state of a map */ /* Loads the state of a map */
fun loadCurrentBestLocation(): Location { fun loadCurrentBestLocation(): Location {
val provider: String = sharedPreferences.getString(Keys.PREF_CURRENT_BEST_LOCATION_PROVIDER, LocationManager.NETWORK_PROVIDER) ?: LocationManager.NETWORK_PROVIDER val provider: String = sharedPreferences.getString(Keys.PREF_CURRENT_BEST_LOCATION_PROVIDER, LocationManager.NETWORK_PROVIDER) ?: LocationManager.NETWORK_PROVIDER
// create location // create location
return Location(provider).apply { return Location(provider).apply {
// load location attributes
latitude = sharedPreferences.getDouble(Keys.PREF_CURRENT_BEST_LOCATION_LATITUDE, Keys.DEFAULT_LATITUDE) latitude = sharedPreferences.getDouble(Keys.PREF_CURRENT_BEST_LOCATION_LATITUDE, Keys.DEFAULT_LATITUDE)
longitude = sharedPreferences.getDouble(Keys.PREF_CURRENT_BEST_LOCATION_LONGITUDE, Keys.DEFAULT_LONGITUDE) longitude = sharedPreferences.getDouble(Keys.PREF_CURRENT_BEST_LOCATION_LONGITUDE, Keys.DEFAULT_LONGITUDE)
accuracy = sharedPreferences.getFloat(Keys.PREF_CURRENT_BEST_LOCATION_ACCURACY, Keys.DEFAULT_ACCURACY) accuracy = sharedPreferences.getFloat(Keys.PREF_CURRENT_BEST_LOCATION_ACCURACY, Keys.DEFAULT_ACCURACY)
@ -127,11 +91,9 @@ object PreferencesHelper {
} }
/* Saves the state of a map */ /* Saves the state of a map */
fun saveCurrentBestLocation(currentBestLocation: Location) { fun saveCurrentBestLocation(currentBestLocation: Location) {
sharedPreferences.edit { sharedPreferences.edit {
// save location
putDouble(Keys.PREF_CURRENT_BEST_LOCATION_LATITUDE, currentBestLocation.latitude) putDouble(Keys.PREF_CURRENT_BEST_LOCATION_LATITUDE, currentBestLocation.latitude)
putDouble(Keys.PREF_CURRENT_BEST_LOCATION_LONGITUDE, currentBestLocation.longitude) putDouble(Keys.PREF_CURRENT_BEST_LOCATION_LONGITUDE, currentBestLocation.longitude)
putFloat(Keys.PREF_CURRENT_BEST_LOCATION_ACCURACY, currentBestLocation.accuracy) putFloat(Keys.PREF_CURRENT_BEST_LOCATION_ACCURACY, currentBestLocation.accuracy)
@ -140,19 +102,15 @@ object PreferencesHelper {
} }
} }
/* Load currently selected app theme */
fun loadThemeSelection(): String { fun loadThemeSelection(): String {
return sharedPreferences.getString(Keys.PREF_THEME_SELECTION, Keys.STATE_THEME_FOLLOW_SYSTEM) ?: Keys.STATE_THEME_FOLLOW_SYSTEM return sharedPreferences.getString(Keys.PREF_THEME_SELECTION, Keys.STATE_THEME_FOLLOW_SYSTEM) ?: Keys.STATE_THEME_FOLLOW_SYSTEM
} }
/* Checks if housekeeping work needs to be done - used usually in DownloadWorker "REQUEST_UPDATE_COLLECTION" */ /* Checks if housekeeping work needs to be done - used usually in DownloadWorker "REQUEST_UPDATE_COLLECTION" */
fun isHouseKeepingNecessary(): Boolean { fun isHouseKeepingNecessary(): Boolean {
return sharedPreferences.getBoolean(Keys.PREF_ONE_TIME_HOUSEKEEPING_NECESSARY, true) return sharedPreferences.getBoolean(Keys.PREF_ONE_TIME_HOUSEKEEPING_NECESSARY, true)
} }
/* Saves state of housekeeping */ /* Saves state of housekeeping */
fun saveHouseKeepingNecessaryState(state: Boolean = false) { fun saveHouseKeepingNecessaryState(state: Boolean = false) {
sharedPreferences.edit { putBoolean(Keys.PREF_ONE_TIME_HOUSEKEEPING_NECESSARY, state) } sharedPreferences.edit { putBoolean(Keys.PREF_ONE_TIME_HOUSEKEEPING_NECESSARY, state) }