mirror of
https://github.com/ev-map/EVMap.git
synced 2026-06-12 00:08:34 -04:00
Preserve selected map type across app restarts
This commit is contained in:
@@ -729,6 +729,7 @@ class MapFragment : Fragment(), OnMapReadyCallback, MapsActivity.FragmentCallbac
|
|||||||
backPressedCallback.handleOnBackPressed()
|
backPressedCallback.handleOnBackPressed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
map.setMapType(vm.mapType.value)
|
||||||
|
|
||||||
// set padding so that compass is not obstructed by toolbar
|
// set padding so that compass is not obstructed by toolbar
|
||||||
map.setPadding(0, binding.toolbarContainer.height, 0, 0)
|
map.setPadding(0, binding.toolbarContainer.height, 0, 0)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package net.vonforst.evmap.storage
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
|
import com.car2go.maps.AnyMap
|
||||||
import net.vonforst.evmap.R
|
import net.vonforst.evmap.R
|
||||||
import net.vonforst.evmap.viewmodel.FILTERS_CUSTOM
|
import net.vonforst.evmap.viewmodel.FILTERS_CUSTOM
|
||||||
import net.vonforst.evmap.viewmodel.FILTERS_DISABLED
|
import net.vonforst.evmap.viewmodel.FILTERS_DISABLED
|
||||||
@@ -73,6 +74,12 @@ class PreferenceDataSource(val context: Context) {
|
|||||||
context.getString(R.string.pref_map_provider_default)
|
context.getString(R.string.pref_map_provider_default)
|
||||||
)!!
|
)!!
|
||||||
|
|
||||||
|
var mapType: AnyMap.Type
|
||||||
|
get() = AnyMap.Type.valueOf(sp.getString("map_type", null) ?: AnyMap.Type.NORMAL.toString())
|
||||||
|
set(type) {
|
||||||
|
sp.edit().putString("map_type", type.toString()).apply()
|
||||||
|
}
|
||||||
|
|
||||||
var welcomeDialogShown: Boolean
|
var welcomeDialogShown: Boolean
|
||||||
get() = sp.getBoolean("welcome_dialog_shown", false)
|
get() = sp.getBoolean("welcome_dialog_shown", false)
|
||||||
set(value) {
|
set(value) {
|
||||||
|
|||||||
@@ -210,7 +210,10 @@ class MapViewModel(application: Application, geApiKey: String) : AndroidViewMode
|
|||||||
|
|
||||||
val mapType: MutableLiveData<AnyMap.Type> by lazy {
|
val mapType: MutableLiveData<AnyMap.Type> by lazy {
|
||||||
MutableLiveData<AnyMap.Type>().apply {
|
MutableLiveData<AnyMap.Type>().apply {
|
||||||
value = AnyMap.Type.NORMAL
|
value = prefs.mapType
|
||||||
|
observeForever {
|
||||||
|
prefs.mapType = it
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user