MainActivity: config via launch-intent extras (url/user/pass) voor installatie zonder UI-interactie
This commit is contained in:
parent
c21d3dc837
commit
2f8b9bfe43
1 changed files with 29 additions and 0 deletions
|
|
@ -57,6 +57,32 @@ class MainActivity : AppCompatActivity() {
|
|||
|
||||
// Staat altijd zichtbaar in de status-edit: pionnen van de volgende controle alvast zetten.
|
||||
AlarmScheduler.scheduleNoonCheck(this)
|
||||
|
||||
// Config via launch-intent (installatie/hulp): adb shell am start ... --es url "..." --es user "..." --es pass "..."
|
||||
handleSetupIntent(intent)
|
||||
}
|
||||
|
||||
override fun onNewIntent(intent: Intent) {
|
||||
super.onNewIntent(intent)
|
||||
setIntent(intent)
|
||||
handleSetupIntent(intent)
|
||||
}
|
||||
|
||||
/** Slaat CalDAV-config van intent-extra's op en draait direct een controle. */
|
||||
private fun handleSetupIntent(intent: Intent?) {
|
||||
val url = intent?.getStringExtra(EXTRA_SETUP_URL)
|
||||
val user = intent?.getStringExtra(EXTRA_SETUP_USER)
|
||||
val pass = intent?.getStringExtra(EXTRA_SETUP_PASS)
|
||||
if (url == null && user == null && pass == null) return
|
||||
if (!url.isNullOrBlank()) prefs.calendarUrl = url.trim()
|
||||
if (!user.isNullOrBlank()) prefs.username = user.trim()
|
||||
if (pass != null) prefs.password = pass
|
||||
renderSettings()
|
||||
lifecycleScope.launch {
|
||||
val r = ShiftCheck.run(this@MainActivity)
|
||||
renderStatus()
|
||||
toast(r.message)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
|
@ -167,5 +193,8 @@ class MainActivity : AppCompatActivity() {
|
|||
|
||||
private companion object {
|
||||
const val REQ_NOTIFICATIONS = 42
|
||||
const val EXTRA_SETUP_URL = "url"
|
||||
const val EXTRA_SETUP_USER = "user"
|
||||
const val EXTRA_SETUP_PASS = "pass"
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue