Compare commits
2
Commits
9ad9aa7754
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
744e4f2e99 | ||
|
|
ab0037df7a |
@@ -57,6 +57,7 @@ class MainActivity : AppCompatActivity() {
|
||||
var currentPopupItems = listOf<LunaEvent.Type>()
|
||||
}
|
||||
|
||||
lateinit var settingsRepository : LocalSettingsRepository
|
||||
var logbook: Logbook? = null
|
||||
var pauseLogbookUpdate = false
|
||||
lateinit var progressIndicator: LinearProgressIndicator
|
||||
@@ -77,6 +78,7 @@ class MainActivity : AppCompatActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
handler = Handler(mainLooper)
|
||||
settingsRepository = LocalSettingsRepository(this@MainActivity)
|
||||
|
||||
// Show view
|
||||
setContentView(R.layout.activity_main)
|
||||
@@ -139,7 +141,6 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun populateHeaderMenu() {
|
||||
val settingsRepository = LocalSettingsRepository(this)
|
||||
val dynamicMenu = settingsRepository.loadDynamicMenu()
|
||||
val eventTypeStats = mutableMapOf<LunaEvent.Type, Int>()
|
||||
|
||||
@@ -212,7 +213,6 @@ class MainActivity : AppCompatActivity() {
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
|
||||
val settingsRepository = LocalSettingsRepository(this)
|
||||
if (settingsRepository.loadDataRepository() == LocalSettingsRepository.DATA_REPO.WEBDAV) {
|
||||
val webDavCredentials = settingsRepository.loadWebdavCredentials()
|
||||
if (webDavCredentials == null) {
|
||||
@@ -764,7 +764,7 @@ class MainActivity : AppCompatActivity() {
|
||||
val d = AlertDialog.Builder(this)
|
||||
d.setTitle(R.string.trim_logbook_dialog_title)
|
||||
d.setMessage(
|
||||
when (LocalSettingsRepository(this).loadDataRepository()) {
|
||||
when (settingsRepository.loadDataRepository()) {
|
||||
LocalSettingsRepository.DATA_REPO.WEBDAV -> R.string.trim_logbook_dialog_message_dav
|
||||
else -> R.string.trim_logbook_dialog_message_local
|
||||
}
|
||||
@@ -1000,7 +1000,9 @@ class MainActivity : AppCompatActivity() {
|
||||
val spinner = findViewById<Spinner>(R.id.logbooks_spinner)
|
||||
val sAdapter = ArrayAdapter<String>(this@MainActivity, android.R.layout.simple_spinner_item)
|
||||
sAdapter.setDropDownViewResource(R.layout.row_logbook_spinner)
|
||||
for (ln in logbooksNames) {
|
||||
|
||||
val selectedLogbook = settingsRepository.loadSelectedLogbook()
|
||||
logbooksNames.forEach { ln ->
|
||||
sAdapter.add(
|
||||
ln.ifEmpty { getString(R.string.default_logbook_name) }
|
||||
)
|
||||
@@ -1013,14 +1015,20 @@ class MainActivity : AppCompatActivity() {
|
||||
position: Int,
|
||||
id: Long
|
||||
) {
|
||||
val logbookName = logbooksNames[position]
|
||||
// Changed logbook: empty list
|
||||
setListAdapter(arrayListOf())
|
||||
// Load logbook
|
||||
loadLogbook(logbooksNames.get(position))
|
||||
loadLogbook(logbookName)
|
||||
// Save logbook selection
|
||||
settingsRepository.saveSelectedLogbook(logbookName)
|
||||
}
|
||||
|
||||
override fun onNothingSelected(parent: AdapterView<*>?) {}
|
||||
}
|
||||
|
||||
val selected = logbooksNames.indexOf(selectedLogbook)
|
||||
if (selected > 0) spinner.setSelection(selected)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
+11
@@ -15,6 +15,7 @@ class LocalSettingsRepository(val context: Context) {
|
||||
const val SHARED_PREFS_DAV_PASS = "webdav_password"
|
||||
const val SHARED_PREFS_DYNAMIC_MENU = "dynamic_menu"
|
||||
const val SHARED_PREFS_SIGNATURE = "signature"
|
||||
const val SHARED_PREFS_SELECTED_LOGBOOK = "selected_logbook"
|
||||
}
|
||||
enum class DATA_REPO {LOCAL_FILE, WEBDAV}
|
||||
val sharedPreferences: SharedPreferences
|
||||
@@ -76,4 +77,14 @@ class LocalSettingsRepository(val context: Context) {
|
||||
return null
|
||||
return arrayOf(url, user, pass)
|
||||
}
|
||||
|
||||
fun saveSelectedLogbook(selectedLogbookName: String) {
|
||||
sharedPreferences.edit (commit = true) {
|
||||
putString(SHARED_PREFS_SELECTED_LOGBOOK, selectedLogbookName)
|
||||
}
|
||||
}
|
||||
|
||||
fun loadSelectedLogbook() : String? {
|
||||
return sharedPreferences.getString(SHARED_PREFS_SELECTED_LOGBOOK, null)
|
||||
}
|
||||
}
|
||||
@@ -21,3 +21,13 @@ kotlin.code.style=official
|
||||
# resources declared in the library itself and none from the library's dependencies,
|
||||
# thereby reducing the size of the R class for that library
|
||||
android.nonTransitiveRClass=true
|
||||
android.defaults.buildfeatures.resvalues=true
|
||||
android.sdk.defaultTargetSdkToCompileSdkIfUnset=false
|
||||
android.enableAppCompileTimeRClass=false
|
||||
android.usesSdkInManifest.disallowed=false
|
||||
android.uniquePackageNames=false
|
||||
android.dependency.useConstraints=true
|
||||
android.r8.strictFullModeForKeepRules=false
|
||||
android.r8.optimizedResourceShrinking=false
|
||||
android.builtInKotlin=false
|
||||
android.newDsl=false
|
||||
@@ -1,6 +1,6 @@
|
||||
[versions]
|
||||
agp = "8.13.0"
|
||||
kotlin = "2.0.0"
|
||||
agp = "9.4.1"
|
||||
kotlin = "2.2.10"
|
||||
coreKtx = "1.10.1"
|
||||
junit = "4.13.2"
|
||||
junitVersion = "1.1.5"
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#Sat Nov 02 10:58:51 CET 2024
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.0-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
Reference in New Issue
Block a user