diff --git a/app/src/main/java/org/schabi/newpipe/settings/ComposeUpdateActions.kt b/app/src/main/java/org/schabi/newpipe/settings/ComposeUpdateActions.kt new file mode 100644 index 000000000..e724e894a --- /dev/null +++ b/app/src/main/java/org/schabi/newpipe/settings/ComposeUpdateActions.kt @@ -0,0 +1,15 @@ +/* + * SPDX-FileCopyrightText: 2026 NewPipe e.V. + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package org.schabi.newpipe.settings + +import android.content.Context +import net.newpipe.app.platform.UpdateActions +import org.schabi.newpipe.NewVersionWorker + +class ComposeUpdateActions(private val context: Context) : UpdateActions { + + override fun checkForUpdates() = NewVersionWorker.enqueueNewVersionCheckingWork(context, isManual = true) +} diff --git a/shared/src/androidMain/kotlin/net/newpipe/app/platform/AndroidUpdateActions.kt b/shared/src/androidMain/kotlin/net/newpipe/app/platform/AndroidUpdateActions.kt new file mode 100644 index 000000000..8dbdef131 --- /dev/null +++ b/shared/src/androidMain/kotlin/net/newpipe/app/platform/AndroidUpdateActions.kt @@ -0,0 +1,31 @@ +/* + * SPDX-FileCopyrightText: 2026 NewPipe e.V. + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package net.newpipe.app.platform + +import android.content.Context +import co.touchlab.kermit.Logger +import org.koin.core.annotation.Singleton + +@Singleton(binds = [UpdateActions::class]) +class AndroidUpdateActions(context: Context) : UpdateActions { + + private val host: UpdateActions = loadHost(context) + + override fun checkForUpdates() = host.checkForUpdates() + + private fun loadHost(context: Context): UpdateActions = runCatching { + Class.forName(HOST_CLASS) + .getDeclaredConstructor(Context::class.java) + .newInstance(context) as UpdateActions + }.getOrElse { error -> + Logger.w(messageString = "No host update actions found, falling back to no-op", throwable = error) + NoOpUpdateActions + } + + private companion object { + const val HOST_CLASS = "org.schabi.newpipe.settings.ComposeUpdateActions" + } +} diff --git a/shared/src/commonMain/kotlin/net/newpipe/app/platform/UpdateActions.kt b/shared/src/commonMain/kotlin/net/newpipe/app/platform/UpdateActions.kt new file mode 100644 index 000000000..63f388145 --- /dev/null +++ b/shared/src/commonMain/kotlin/net/newpipe/app/platform/UpdateActions.kt @@ -0,0 +1,21 @@ +/* + * SPDX-FileCopyrightText: 2026 NewPipe e.V. + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package net.newpipe.app.platform + +import co.touchlab.kermit.Logger + +/** + * Platform-specific actions triggered from the Updates settings screen + */ +interface UpdateActions { + + fun checkForUpdates() +} + +internal object NoOpUpdateActions : UpdateActions { + + override fun checkForUpdates() = Logger.w(messageString = "Update action 'checkForUpdates' is unsupported on this platform") +} diff --git a/shared/src/iosMain/kotlin/net/newpipe/app/platform/IOSUpdateActions.kt b/shared/src/iosMain/kotlin/net/newpipe/app/platform/IOSUpdateActions.kt new file mode 100644 index 000000000..02ee1c14d --- /dev/null +++ b/shared/src/iosMain/kotlin/net/newpipe/app/platform/IOSUpdateActions.kt @@ -0,0 +1,11 @@ +/* + * SPDX-FileCopyrightText: 2026 NewPipe e.V. + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package net.newpipe.app.platform + +import org.koin.core.annotation.Singleton + +@Singleton(binds = [UpdateActions::class]) +class IOSUpdateActions : UpdateActions by NoOpUpdateActions diff --git a/shared/src/jvmMain/kotlin/net/newpipe/app/platform/JVMUpdateActions.kt b/shared/src/jvmMain/kotlin/net/newpipe/app/platform/JVMUpdateActions.kt new file mode 100644 index 000000000..312745fc0 --- /dev/null +++ b/shared/src/jvmMain/kotlin/net/newpipe/app/platform/JVMUpdateActions.kt @@ -0,0 +1,11 @@ +/* + * SPDX-FileCopyrightText: 2026 NewPipe e.V. + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package net.newpipe.app.platform + +import org.koin.core.annotation.Singleton + +@Singleton(binds = [UpdateActions::class]) +class JVMUpdateActions : UpdateActions by NoOpUpdateActions