Plugins: bringup

This commit is contained in:
MM20
2023-11-05 19:02:59 +01:00
parent 7da84a747f
commit 801caf9dd6
54 changed files with 1335 additions and 88 deletions
+1
View File
@@ -51,5 +51,6 @@ dependencies {
implementation(project(":core:ktx"))
implementation(project(":core:i18n"))
implementation(project(":libs:material-color-utilities"))
api(project(":core:shared"))
}
@@ -0,0 +1,12 @@
package de.mm20.launcher2.plugin
data class Plugin(
val enabled: Boolean,
val label: String,
val description: String? = null,
val settingsActivity: String? = null,
val packageName: String,
val className: String,
val type: PluginType,
val authority: String,
)
@@ -0,0 +1,17 @@
package de.mm20.launcher2.plugin
import kotlinx.coroutines.flow.Flow
interface PluginRepository {
fun findMany(
type: PluginType? = null,
enabled: Boolean? = null,
packageName: String? = null,
): Flow<List<Plugin>>
fun get(authority: String): Flow<Plugin?>
fun insertMany(plugins: List<Plugin>)
fun insert(plugin: Plugin)
fun update(plugin: Plugin)
fun deleteMany()
}
@@ -16,8 +16,6 @@ interface File : SavableSearchable {
val isDirectory: Boolean
val metaData: ImmutableMap<FileMetaType, String>
val isStoredInCloud: Boolean
override val preferDetailsOverLaunch: Boolean
get() = false
@@ -5,7 +5,7 @@ interface SearchableSerializer {
val typePrefix: String
}
class NullSerializer : SearchableSerializer {
class NullSerializer : SearchableSerializer{
override fun serialize(searchable: SavableSearchable): String? {
return null
}
+48
View File
@@ -1,6 +1,7 @@
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
`maven-publish`
}
android {
@@ -35,4 +36,51 @@ android {
jvmTarget = "1.8"
}
namespace = "de.mm20.launcher2.shared"
publishing {
singleVariant("release") {
withSourcesJar()
}
}
}
publishing {
publications {
register<MavenPublication>("release") {
groupId = "de.mm20.launcher2"
artifactId = "shared"
version = "1.0.0-SNAPSHOT"
pom {
name = "Kvaesitso SDK"
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
id = "MM2-0"
name = "U.N.Owen"
}
}
}
afterEvaluate {
from(components["release"])
}
}
}
repositories {
mavenLocal()
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/MM2-0/Kvaesitso")
credentials {
username = project.findProperty("gpr.user") as String? ?: System.getenv("USERNAME")
password = project.findProperty("gpr.key") as String? ?: System.getenv("TOKEN")
}
}
}
}
@@ -0,0 +1,10 @@
package de.mm20.launcher2.plugin
sealed class PluginState {
data object Ready : PluginState()
data class SetupRequired(
val setupActivity: String,
val message: String? = null,
) : PluginState()
}
@@ -0,0 +1,5 @@
package de.mm20.launcher2.plugin
enum class PluginType {
FileSearch,
}
@@ -0,0 +1,25 @@
package de.mm20.launcher2.plugin.config
/**
* Defines how the launcher should store search results from a plugin (i.e. when the search result is
* added to favorites).
*/
enum class StorageStrategy {
/**
* The launcher only stores the ID and the plugin provider for the search result. To restore the
* search result, the launcher will query the plugin provider again. This strategy allows the
* plugin provider to update a search result at a later point in time. However, plugins that use
* this strategy must guarantee that a search result can be restored in a timely manner. In
* particular, the plugin provider must be able to restore a search result without any network
* requests.
*/
StoreReference,
/**
* The launcher stores all relevant information in its own internal database. This strategy
* is easier to implement, but search results cannot be updated at a later point in time.
* Use this strategy if your plugin needs to perform network requests to retrieve search
* results and if you don't want to implement a cache for search results.
*/
StoreCopy,
}
@@ -1,28 +1,8 @@
package de.mm20.launcher2.provider.files
package de.mm20.launcher2.plugin.contracts
import android.content.ContentUris
import android.net.Uri
abstract class FilePluginContract {
object FilePluginContract {
object Roots {
const val Id = "id"
const val DisplayName = "display_name"
const val Description = "description"
const val Status = "status"
const val AccountAuthority = "account_authority"
const val PathSegment = "roots"
fun getContentUri(authority: String): Uri {
return Uri.Builder()
.scheme("content")
.authority(authority)
.path(PathSegment)
.build()
}
}
object Files {
object FileColumns {
/**
* The unique ID of the file.
* Type: String
@@ -36,7 +16,8 @@ object FilePluginContract {
const val DisplayName = "display_name"
/**
* The MIME type of the file.
* The MIME type of the file. This is used to determine how to open the file. Make sure that
* this is either a common MIME type or that your app can handle this MIME type.
* Type: String?
*/
const val MimeType = "mime_type"
@@ -53,6 +34,22 @@ object FilePluginContract {
*/
const val Path = "path"
/**
* The URI to view the file.
* Type: String?
*/
const val ContentUri = "uri"
const val ThumbnailUri = "thumbnail_uri"
const val StorageStrategy = "storage_strategy"
/**
* Whether the file is a directory.
* Type: Int
*/
const val IsDirectory = "is_directory"
const val MetaTitle = "meta_title"
const val MetaArtist = "meta_artist"
const val MetaAlbum = "meta_album"
@@ -0,0 +1,10 @@
package de.mm20.launcher2.plugin.contracts
object PluginContract {
const val Permission = "de.mm20.launcher2.permission.USE_PLUGINS"
object Methods {
const val GetType = "getType"
const val GetState = "getState"
}
}
@@ -0,0 +1,9 @@
package de.mm20.launcher2.plugin.contracts
abstract class SearchPluginContract {
object Paths {
const val Search = "search"
const val Root = "root"
const val QueryParam = "query"
}
}
@@ -1,14 +0,0 @@
package de.mm20.launcher2.provider.accounts
object AccountPluginContract {
object Accounts {
const val Id = "id"
const val DisplayName = "display_name"
const val Type = "type"
}
object AccountTypes {
const val Id = "id"
const val DisplayName = "display_name"
const val SupportsMultipleAccounts = "supports_multiple_accounts"
}
}