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:
2026-08-21 20:29:26 +02:00
parent 6e43d52680
commit 8e5a53ade8
33 changed files with 1508 additions and 29 deletions
+68
View File
@@ -25,6 +25,32 @@ export type GalleryPage = {
items: GalleryImage[];
};
export type ImmichConnection = {
configured: boolean;
serverUrl: string;
userName: string;
};
export type ImmichAlbum = {
id: string;
name: string;
assetCount: number;
thumbnailUrl: string;
};
export type ImmichAsset = {
id: string;
fileName: string;
thumbnailUrl: string;
takenAt: string;
};
export type ImmichAssetsPage = {
items: ImmichAsset[];
page: number;
hasMore: boolean;
};
const demoState: WallpaperState = {
imageCount: 3,
enabled: true,
@@ -38,6 +64,7 @@ const demoState: WallpaperState = {
const inTauri = () => "__TAURI_INTERNALS__" in window;
const demoCrops = new Map<string, Pick<GalleryImage, "cropMode" | "cropZoom" | "cropPositionX" | "cropPositionY">>();
const defaultCrop = { cropMode: "cover" as const, cropZoom: 1, cropPositionX: 0.5, cropPositionY: 0.5 };
let demoImmichConnection: ImmichConnection = { configured: false, serverUrl: "", userName: "" };
export async function getState(): Promise<WallpaperState> {
return inTauri() ? invoke<WallpaperState>("plugin:wallpaper|get_state") : demoState;
@@ -123,3 +150,44 @@ export async function nextWallpaper(): Promise<WallpaperState> {
}
return invoke<WallpaperState>("plugin:wallpaper|next_wallpaper");
}
export async function getImmichConnection(): Promise<ImmichConnection> {
return inTauri() ? invoke<ImmichConnection>("plugin:wallpaper|get_immich_connection") : demoImmichConnection;
}
export async function connectImmich(serverUrl: string, apiKey: string): Promise<ImmichConnection> {
if (inTauri()) return invoke<ImmichConnection>("plugin:wallpaper|connect_immich", { serverUrl, apiKey });
if (!serverUrl.trim() || !apiKey.trim()) throw new Error("Missing Immich credentials");
demoImmichConnection = { configured: true, serverUrl: serverUrl.trim(), userName: "Demo User" };
return demoImmichConnection;
}
export async function disconnectImmich(): Promise<ImmichConnection> {
if (inTauri()) return invoke<ImmichConnection>("plugin:wallpaper|disconnect_immich");
demoImmichConnection = { configured: false, serverUrl: "", userName: "" };
return demoImmichConnection;
}
export async function getImmichAlbums(): Promise<ImmichAlbum[]> {
if (inTauri()) return (await invoke<{ albums: ImmichAlbum[] }>("plugin:wallpaper|get_immich_albums")).albums;
return [{ id: "demo-album", name: "Nature", assetCount: 3, thumbnailUrl: "/wallpapers/alpine.png" }];
}
export async function getImmichAssets(albumId: string | null, page = 1, size = 30): Promise<ImmichAssetsPage> {
if (inTauri()) return invoke<ImmichAssetsPage>("plugin:wallpaper|get_immich_assets", { albumId, page, size });
return {
items: demoState.imageUrls.map((thumbnailUrl, index) => ({
id: `00000000-0000-4000-8000-00000000000${index}`,
fileName: `wallpaper-${index + 1}.jpg`,
thumbnailUrl,
takenAt: "2026-08-21T12:00:00Z",
})),
page,
hasMore: false,
};
}
export async function importImmichAssets(ids: string[]): Promise<WallpaperState> {
if (inTauri()) return invoke<WallpaperState>("plugin:wallpaper|import_immich_assets", { ids });
return { ...demoState, imageUrls: [...demoState.imageUrls] };
}