add update actions

This commit is contained in:
Ida Delphine authored and Tobi committed 2026-11-10 21:28:09 +01:00
1 parent a57de6e4ca
commit c23e0febc4
5 files changed
+89

No files matched your search

@@ -0,0 +1,15 @@
/*
* SPDX-FileCopyrightText: 2026 NewPipe e.V. <https://newpipe-ev.de>
* 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)
}
@@ -0,0 +1,31 @@
/*
* SPDX-FileCopyrightText: 2026 NewPipe e.V. <https://newpipe-ev.de>
* 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"
}
}
@@ -0,0 +1,21 @@
/*
* SPDX-FileCopyrightText: 2026 NewPipe e.V. <https://newpipe-ev.de>
* 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")
}
@@ -0,0 +1,11 @@
/*
* SPDX-FileCopyrightText: 2026 NewPipe e.V. <https://newpipe-ev.de>
* 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
@@ -0,0 +1,11 @@
/*
* SPDX-FileCopyrightText: 2026 NewPipe e.V. <https://newpipe-ev.de>
* 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