Plugin stuff, idk, i wrote that shit yesterday
This commit is contained in:
@@ -34,6 +34,9 @@ abstract class BasePluginProvider : ContentProvider() {
|
||||
}
|
||||
}
|
||||
}
|
||||
PluginContract.Methods.GetConfig -> {
|
||||
getPluginConfig()
|
||||
}
|
||||
|
||||
else -> super.call(method, arg, extras)
|
||||
}
|
||||
@@ -41,6 +44,10 @@ abstract class BasePluginProvider : ContentProvider() {
|
||||
|
||||
internal abstract fun getPluginType(): PluginType
|
||||
|
||||
internal open fun getPluginConfig(): Bundle {
|
||||
return Bundle.EMPTY
|
||||
}
|
||||
|
||||
open suspend fun getPluginState(): PluginState {
|
||||
return PluginState.Ready
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
package de.mm20.launcher2.sdk.base
|
||||
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import android.database.Cursor
|
||||
import android.database.MatrixCursor
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.os.CancellationSignal
|
||||
import de.mm20.launcher2.plugin.contracts.PluginContract
|
||||
import de.mm20.launcher2.plugin.config.SearchPluginConfig
|
||||
import de.mm20.launcher2.plugin.contracts.SearchPluginContract
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.runBlocking
|
||||
|
||||
abstract class SearchPluginProvider<T> : BasePluginProvider() {
|
||||
abstract class SearchPluginProvider<T>(
|
||||
private val config: SearchPluginConfig,
|
||||
) : BasePluginProvider() {
|
||||
|
||||
/**
|
||||
* Search for items matching the given query
|
||||
@@ -108,6 +108,10 @@ abstract class SearchPluginProvider<T> : BasePluginProvider() {
|
||||
}
|
||||
}
|
||||
|
||||
final override fun getPluginConfig(): Bundle {
|
||||
return config.toBundle()
|
||||
}
|
||||
|
||||
internal abstract fun createCursor(capacity: Int): MatrixCursor
|
||||
internal abstract fun writeToCursor(cursor: MatrixCursor, item: T)
|
||||
}
|
||||
@@ -50,9 +50,4 @@ data class File(
|
||||
* If null, a default icon will be shown, depending on the file type.
|
||||
*/
|
||||
val thumbnailUri: Uri? = null,
|
||||
|
||||
/**
|
||||
* How the launcher should store this file in its database (i.e. when the user adds it to favorites).
|
||||
*/
|
||||
val storageStrategy: StorageStrategy = StorageStrategy.StoreCopy,
|
||||
)
|
||||
@@ -2,10 +2,13 @@ package de.mm20.launcher2.sdk.files
|
||||
|
||||
import android.database.MatrixCursor
|
||||
import de.mm20.launcher2.plugin.PluginType
|
||||
import de.mm20.launcher2.plugin.config.SearchPluginConfig
|
||||
import de.mm20.launcher2.plugin.contracts.FilePluginContract
|
||||
import de.mm20.launcher2.sdk.base.SearchPluginProvider
|
||||
|
||||
abstract class FileProvider : SearchPluginProvider<File>() {
|
||||
abstract class FileProvider(
|
||||
config: SearchPluginConfig = SearchPluginConfig(),
|
||||
) : SearchPluginProvider<File>(config) {
|
||||
abstract override suspend fun search(query: String): List<File>
|
||||
|
||||
final override fun getPluginType(): PluginType {
|
||||
@@ -23,7 +26,6 @@ abstract class FileProvider : SearchPluginProvider<File>() {
|
||||
FilePluginContract.FileColumns.ContentUri,
|
||||
FilePluginContract.FileColumns.ThumbnailUri,
|
||||
FilePluginContract.FileColumns.IsDirectory,
|
||||
FilePluginContract.FileColumns.StorageStrategy
|
||||
),
|
||||
capacity,
|
||||
)
|
||||
@@ -40,7 +42,6 @@ abstract class FileProvider : SearchPluginProvider<File>() {
|
||||
item.uri.toString(),
|
||||
item.thumbnailUri?.toString(),
|
||||
if (item.isDirectory) 1 else 0,
|
||||
item.storageStrategy.name,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user