Group plugins by package

This commit is contained in:
MM20
2023-11-25 16:29:20 +01:00
parent 6c311fc947
commit 25cd9b707e
17 changed files with 728 additions and 101 deletions
@@ -0,0 +1,16 @@
package de.mm20.launcher2.plugin
import android.content.Intent
data class PluginPackage(
val packageName: String,
val label: String,
val description: String? = null,
val author: String? = null,
val settings: Intent? = null,
val plugins: List<Plugin>,
val isOfficial: Boolean = false,
) {
val enabled: Boolean = plugins.all { it.enabled }
}
@@ -15,5 +15,6 @@ interface PluginRepository {
fun insertMany(plugins: List<Plugin>): Job
fun insert(plugin: Plugin): Job
fun update(plugin: Plugin): Job
fun updateMany(plugins: List<Plugin>): Job
fun deleteMany(): Job
}
@@ -0,0 +1,35 @@
package de.mm20.launcher2.plugin
import android.app.PendingIntent
import android.os.Bundle
sealed class PluginState {
data class Ready(
/**
* Status text, providing additional info what this plugin is currently configured to do.
* For example "Search %user's files on %service"
*/
val text: String? = null,
) : PluginState()
data class SetupRequired(
val setupActivity: PendingIntent,
val message: String? = null,
) : PluginState()
companion object {
fun fromBundle(bundle: Bundle): PluginState? {
val type = bundle.getString("type") ?: return null
return when(type) {
"Ready" -> Ready(
text = bundle.getString("text"),
)
"SetupRequired" -> SetupRequired(
setupActivity = bundle.getParcelable("setupActivity") ?: return null,
message = bundle.getString("message"),
)
else -> null
}
}
}
}
@@ -1,10 +0,0 @@
package de.mm20.launcher2.plugin
sealed class PluginState {
data object Ready : PluginState()
data class SetupRequired(
val setupActivity: String,
val message: String? = null,
) : PluginState()
}