Add plugin settings screen

This commit is contained in:
MM20
2023-11-06 19:30:41 +01:00
parent 7c20d541cd
commit e7ae751340
20 changed files with 398 additions and 85 deletions
@@ -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)