Auto-Commit: 2026-08-20 08:51:21

This commit is contained in:
Jannik committed 2026-08-20 08:51:21 +02:00
1 parent 6b2d38ffe5
commit c1bea7b0c6
15 files changed
+136 -114

No files matched your search

@@ -1,2 +1,2 @@
#Mon Aug 17 18:06:08 CEST 2026
gradle.version=9.2.0
#Thu Aug 20 07:04:03 CEST 2026
gradle.version=8.9
@@ -59,5 +59,56 @@ class KioskModeModule : Module() {
val dpm = activity.getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager
return@Function dpm.isDeviceOwnerApp(activity.packageName)
}
AsyncFunction("saveImageToAlbum") { localUri: String, albumName: String, fileName: String, promise: expo.modules.kotlin.Promise ->
val context = appContext.reactContext ?: run {
promise.reject("ERR_CONTEXT", "React Context is null", null)
return@AsyncFunction
}
try {
val resolver = context.contentResolver
val values = android.content.ContentValues().apply {
put(android.provider.MediaStore.Images.Media.DISPLAY_NAME, fileName)
put(android.provider.MediaStore.Images.Media.MIME_TYPE, "image/jpeg")
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
put(android.provider.MediaStore.Images.Media.RELATIVE_PATH, "Pictures/${albumName}")
put(android.provider.MediaStore.Images.Media.IS_PENDING, 1)
}
}
val collection = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
android.provider.MediaStore.Images.Media.getContentUri(android.provider.MediaStore.VOLUME_EXTERNAL_PRIMARY)
} else {
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI
}
val uri = resolver.insert(collection, values)
if (uri == null) {
promise.reject("ERR_INSERT", "Failed to create new MediaStore record", null)
return@AsyncFunction
}
// Remove file:// prefix if present
val cleanLocalUri = localUri.replace("file://", "")
val localFile = java.io.File(cleanLocalUri)
resolver.openOutputStream(uri)?.use { out ->
java.io.FileInputStream(localFile).use { input ->
input.copyTo(out)
}
}
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
values.clear()
values.put(android.provider.MediaStore.Images.Media.IS_PENDING, 0)
resolver.update(uri, values, null, null)
}
promise.resolve(uri.toString())
} catch (e: Exception) {
promise.reject("ERR_SAVE", e.message, e)
}
}
}
}
+4
View File
@@ -15,6 +15,7 @@ export interface KioskModeInterface {
stopKiosk(): boolean;
isKioskActive(): boolean;
isDeviceOwner(): boolean;
saveImageToAlbum(localUri: string, albumName: string, fileName: string): Promise<string>;
}
const KioskModeProxy: KioskModeInterface = {
@@ -29,6 +30,9 @@ const KioskModeProxy: KioskModeInterface = {
},
isDeviceOwner() {
return KioskMode ? KioskMode.isDeviceOwner() : false;
},
async saveImageToAlbum(localUri: string, albumName: string, fileName: string): Promise<string> {
return KioskMode ? await KioskMode.saveImageToAlbum(localUri, albumName, fileName) : localUri;
}
};