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