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
*/
package org.y20k.trackbook.helpers
import android.content.Context
@ -27,7 +26,6 @@ import org.y20k.trackbook.Keys
import org.y20k.trackbook.extensions.getDouble
import org.y20k.trackbook.extensions.putDouble
/*
* PreferencesHelper object
*/
@ -45,62 +43,30 @@ object PreferencesHelper {
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
}
/* Loads zoom level of map */
fun loadZoomLevel(): Double {
// load zoom level
return sharedPreferences.getDouble(Keys.PREF_MAP_ZOOM_LEVEL, Keys.DEFAULT_ZOOM_LEVEL)
}
/* Saves zoom level of map */
fun saveZoomLevel(zoomLevel: Double) {
// save zoom level
sharedPreferences.edit { putDouble(Keys.PREF_MAP_ZOOM_LEVEL, zoomLevel) }
}
/* Loads tracking state */
fun loadTrackingState(): Int {
// load tracking state
return sharedPreferences.getInt(Keys.PREF_TRACKING_STATE, Keys.STATE_TRACKING_NOT_STARTED)
}
/* Saves tracking state */
fun saveTrackingState(trackingState: Int) {
// save tracking state
sharedPreferences.edit { putInt(Keys.PREF_TRACKING_STATE, trackingState) }
}
/* Loads length unit system - metric or imperial */
fun loadUseImperialUnits(): Boolean {
// load length unit system
return sharedPreferences.getBoolean(Keys.PREF_USE_IMPERIAL_UNITS, LengthUnitHelper.useImperialUnits())
}
/* Loads length unit system - metric or imperial */
fun loadGpsOnly(): Boolean {
// load length unit system
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 {
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)
// }
/* Loads the state of a map */
fun loadCurrentBestLocation(): Location {
val provider: String = sharedPreferences.getString(Keys.PREF_CURRENT_BEST_LOCATION_PROVIDER, LocationManager.NETWORK_PROVIDER) ?: LocationManager.NETWORK_PROVIDER
// create location
return Location(provider).apply {
// load location attributes
latitude = sharedPreferences.getDouble(Keys.PREF_CURRENT_BEST_LOCATION_LATITUDE, Keys.DEFAULT_LATITUDE)
longitude = sharedPreferences.getDouble(Keys.PREF_CURRENT_BEST_LOCATION_LONGITUDE, Keys.DEFAULT_LONGITUDE)
accuracy = sharedPreferences.getFloat(Keys.PREF_CURRENT_BEST_LOCATION_ACCURACY, Keys.DEFAULT_ACCURACY)
@ -127,11 +91,9 @@ object PreferencesHelper {
}
/* Saves the state of a map */
fun saveCurrentBestLocation(currentBestLocation: Location) {
sharedPreferences.edit {
// save location
putDouble(Keys.PREF_CURRENT_BEST_LOCATION_LATITUDE, currentBestLocation.latitude)
putDouble(Keys.PREF_CURRENT_BEST_LOCATION_LONGITUDE, currentBestLocation.longitude)
putFloat(Keys.PREF_CURRENT_BEST_LOCATION_ACCURACY, currentBestLocation.accuracy)
@ -140,19 +102,15 @@ object PreferencesHelper {
}
}
/* Load currently selected app theme */
fun loadThemeSelection(): String {
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" */
fun isHouseKeepingNecessary(): Boolean {
return sharedPreferences.getBoolean(Keys.PREF_ONE_TIME_HOUSEKEEPING_NECESSARY, true)
}
/* Saves state of housekeeping */
fun saveHouseKeepingNecessaryState(state: Boolean = false) {
sharedPreferences.edit { putBoolean(Keys.PREF_ONE_TIME_HOUSEKEEPING_NECESSARY, state) }