Initialize Schnappix Photo Booth application with custom UVC camera, silent Wi-Fi IPP printing, local gallery storage, and kiosk screen pinning support

This commit is contained in:
2026-05-25 16:44:15 +02:00
parent 5958319772
commit 872e1ffc86
51 changed files with 8931 additions and 1 deletions
+58
View File
@@ -0,0 +1,58 @@
import * as MediaLibrary from 'expo-media-library';
import { Platform } from 'react-native';
const ALBUM_NAME = 'Schnappix';
/**
* Request necessary media library permissions.
* @returns Promise<boolean> True if permissions are granted.
*/
export async function requestStoragePermission(): Promise<boolean> {
const { status, canAskAgain } = await MediaLibrary.getPermissionsAsync();
if (status === 'granted') {
return true;
}
if (canAskAgain) {
const { status: newStatus } = await MediaLibrary.requestPermissionsAsync();
return newStatus === 'granted';
}
return false;
}
/**
* Saves a local image file directly to the public DCIM gallery inside the "Schnappix" album.
*
* @param localUri The local file URI of the image (temp cached file).
* @returns Promise<string> The permanent URI of the saved asset in the gallery.
*/
export async function saveToGallery(localUri: string): Promise<string> {
const hasPermission = await requestStoragePermission();
if (!hasPermission) {
throw new Error('Storage permission not granted. Cannot save photo to gallery.');
}
// 1. Create a media asset from the local file
const asset = await MediaLibrary.createAssetAsync(localUri);
try {
// 2. Check if the "Schnappix" album already exists
let album = await MediaLibrary.getAlbumAsync(ALBUM_NAME);
if (!album) {
// 3. If it doesn't exist, create it with our asset
await MediaLibrary.createAlbumAsync(ALBUM_NAME, asset, false);
console.log(`Created new album "${ALBUM_NAME}" and saved photo.`);
} else {
// 4. If it exists, add our asset to it
await MediaLibrary.addAssetsToAlbumAsync([asset], album, false);
console.log(`Saved photo to existing album "${ALBUM_NAME}".`);
}
return asset.uri;
} catch (e: any) {
console.error('Error saving asset to album, returning fallback asset URI:', e);
return asset.uri;
}
}