mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-10-31 08:15:02 +00:00
Merge pull request #7585 from element-hq/rav/app_startup_hook
Implement a hook allowing enterprise modules to perform actions on startup
This commit is contained in:
@@ -61,6 +61,13 @@ class MainActivity : NodeActivity() {
|
||||
setContent {
|
||||
MainContent(appBindings)
|
||||
}
|
||||
|
||||
val activity = this
|
||||
appBindings.appStartupHooks().forEach {
|
||||
lifecycleScope.launch {
|
||||
it.onAppStartup(activity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
||||
@@ -10,7 +10,9 @@ package io.element.android.x.di
|
||||
|
||||
import dev.zacsweers.metro.AppScope
|
||||
import dev.zacsweers.metro.ContributesTo
|
||||
import dev.zacsweers.metro.Multibinds
|
||||
import io.element.android.features.api.MigrationEntryPoint
|
||||
import io.element.android.features.enterprise.api.AppStartupHook
|
||||
import io.element.android.features.enterprise.api.EnterpriseService
|
||||
import io.element.android.features.lockscreen.api.LockScreenEntryPoint
|
||||
import io.element.android.features.lockscreen.api.LockScreenService
|
||||
@@ -51,4 +53,7 @@ interface AppBindings {
|
||||
fun buildMeta(): BuildMeta
|
||||
|
||||
fun sentrySdkDsn(): SentrySdkDsn?
|
||||
|
||||
@Multibinds(allowEmpty = true)
|
||||
fun appStartupHooks(): Set<AppStartupHook>
|
||||
}
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) 2026 Element Creations Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.features.enterprise.api
|
||||
|
||||
import android.app.Activity
|
||||
|
||||
/**
|
||||
* A hook that is called during app startup, from the `MainActivity`.
|
||||
*
|
||||
* Note that the hook is run in the background: it will not block startup of the app.
|
||||
*/
|
||||
fun interface AppStartupHook {
|
||||
/** @param activity The activity which is active while the app starts (i.e. the `MainActivity`). */
|
||||
suspend fun onAppStartup(activity: Activity)
|
||||
}
|
||||
Reference in New Issue
Block a user