Add plugin settings screen
This commit is contained in:
@@ -2,9 +2,16 @@ package de.mm20.launcher2.files.providers
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import coil.imageLoader
|
||||
import coil.request.ImageRequest
|
||||
import de.mm20.launcher2.files.PluginFileSerializer
|
||||
import de.mm20.launcher2.icons.ColorLayer
|
||||
import de.mm20.launcher2.icons.LauncherIcon
|
||||
import de.mm20.launcher2.icons.StaticIconLayer
|
||||
import de.mm20.launcher2.icons.StaticLauncherIcon
|
||||
import de.mm20.launcher2.ktx.tryStartActivity
|
||||
import de.mm20.launcher2.plugin.config.StorageStrategy
|
||||
import de.mm20.launcher2.search.File
|
||||
@@ -47,6 +54,21 @@ data class PluginFile(
|
||||
return PluginFileSerializer()
|
||||
}
|
||||
|
||||
override suspend fun loadIcon(context: Context, size: Int, themed: Boolean): LauncherIcon? {
|
||||
if (thumbnailUri != null) {
|
||||
val request = ImageRequest.Builder(context)
|
||||
.data(thumbnailUri)
|
||||
.build()
|
||||
val result = context.imageLoader.execute(request)
|
||||
val drawable = result.drawable ?: return null
|
||||
return StaticLauncherIcon(
|
||||
foregroundLayer = StaticIconLayer(icon = drawable, scale = 1.5f),
|
||||
backgroundLayer = ColorLayer(),
|
||||
)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val Domain = "plugin.file"
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.Context
|
||||
import android.database.Cursor
|
||||
import android.net.Uri
|
||||
import android.os.CancellationSignal
|
||||
import android.util.Log
|
||||
import androidx.core.database.getStringOrNull
|
||||
import de.mm20.launcher2.plugin.Plugin
|
||||
import de.mm20.launcher2.plugin.config.StorageStrategy
|
||||
@@ -36,7 +37,13 @@ class PluginFileProvider(
|
||||
null,
|
||||
null,
|
||||
cancellationSignal
|
||||
) ?: return@suspendCancellableCoroutine it.resume(emptyList<File>())
|
||||
)
|
||||
|
||||
if (cursor == null) {
|
||||
Log.e("MM20", "Plugin ${plugin.authority} returned null cursor")
|
||||
it.resume(emptyList())
|
||||
return@suspendCancellableCoroutine
|
||||
}
|
||||
|
||||
val results = fromCursor(cursor) ?: emptyList()
|
||||
it.resume(results)
|
||||
|
||||
Reference in New Issue
Block a user