feat(immich): add Immich self-hosted import support
Adds an ImmichClient for Android to connect to a self-hosted Immich server, fetch albums and assets, and import selected images locally. API keys are encrypted with Android Keystore and stored securely. The plugin now exposes connect, disconnect and import actions and is documented for Immich import usage. - Encrypted Immich API keys with Android Keystore - Exposed connect, disconnect and import actions in the plugin - Updated docs and metadata to reflect Immich import flow
This commit is contained in:
@@ -40,6 +40,15 @@ class ImageCropArgs {
|
||||
var positionY: Double = 0.5
|
||||
}
|
||||
|
||||
@InvokeArg
|
||||
class ImmichConnectArgs { lateinit var serverUrl: String; lateinit var apiKey: String }
|
||||
|
||||
@InvokeArg
|
||||
class ImmichAssetsArgs { var albumId: String? = null; var page: Int = 1; var size: Int = 30 }
|
||||
|
||||
@InvokeArg
|
||||
class ImmichImportArgs { var ids: Array<String> = emptyArray() }
|
||||
|
||||
@TauriPlugin
|
||||
class WallpaperPlugin(private val activity: Activity) : Plugin(activity) {
|
||||
private val io = Executors.newSingleThreadExecutor()
|
||||
@@ -136,4 +145,38 @@ class WallpaperPlugin(private val activity: Activity) : Plugin(activity) {
|
||||
@Command fun nextWallpaper(invoke: Invoke) = io.execute {
|
||||
if (WallpaperStore.applyNext(activity)) invoke.resolve(WallpaperStore.state(activity)) else invoke.reject("Bitte wähle zuerst Bilder aus")
|
||||
}
|
||||
|
||||
@Command fun getImmichConnection(invoke: Invoke) = io.execute {
|
||||
invoke.resolve(ImmichClient.connection(activity))
|
||||
}
|
||||
|
||||
@Command fun connectImmich(invoke: Invoke) = io.execute {
|
||||
try {
|
||||
val args = invoke.parseArgs(ImmichConnectArgs::class.java)
|
||||
invoke.resolve(ImmichClient.connect(activity, args.serverUrl, args.apiKey))
|
||||
} catch (error: Exception) { invoke.reject(error.message ?: "Immich-Verbindung fehlgeschlagen") }
|
||||
}
|
||||
|
||||
@Command fun disconnectImmich(invoke: Invoke) = io.execute {
|
||||
invoke.resolve(ImmichClient.disconnect(activity))
|
||||
}
|
||||
|
||||
@Command fun getImmichAlbums(invoke: Invoke) = io.execute {
|
||||
try { invoke.resolve(ImmichClient.albums(activity)) }
|
||||
catch (error: Exception) { invoke.reject(error.message ?: "Immich-Alben konnten nicht geladen werden") }
|
||||
}
|
||||
|
||||
@Command fun getImmichAssets(invoke: Invoke) = io.execute {
|
||||
try {
|
||||
val args = invoke.parseArgs(ImmichAssetsArgs::class.java)
|
||||
invoke.resolve(ImmichClient.assets(activity, args.albumId, args.page, args.size))
|
||||
} catch (error: Exception) { invoke.reject(error.message ?: "Immich-Bilder konnten nicht geladen werden") }
|
||||
}
|
||||
|
||||
@Command fun importImmichAssets(invoke: Invoke) = io.execute {
|
||||
try {
|
||||
val args = invoke.parseArgs(ImmichImportArgs::class.java)
|
||||
invoke.resolve(ImmichClient.importAssets(activity, args.ids.toList()))
|
||||
} catch (error: Exception) { invoke.reject(error.message ?: "Immich-Bilder konnten nicht importiert werden") }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user