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:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
#Mon May 25 16:29:05 CEST 2026
|
||||
gradle.version=8.9
|
||||
@@ -0,0 +1,21 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'expo-module-gradle-plugin'
|
||||
apply plugin: 'org.jetbrains.kotlin.android'
|
||||
|
||||
android {
|
||||
namespace "expo.modules.kioskmode"
|
||||
compileSdkVersion findProperty("expo.compileSdkVersion") ?: 34
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion findProperty("expo.minSdkVersion") ?: 23
|
||||
targetSdkVersion findProperty("expo.targetSdkVersion") ?: 34
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
buildConfig true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.facebook.react:react-android'
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package expo.modules.kioskmode
|
||||
|
||||
import android.app.admin.DeviceAdminReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.widget.Toast
|
||||
import android.content.ComponentName
|
||||
|
||||
class AdminReceiver : DeviceAdminReceiver() {
|
||||
override fun onEnabled(context: Context, intent: Intent) {
|
||||
super.onEnabled(context, intent)
|
||||
Toast.makeText(context, "Schnappix Admin Enabled", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
override fun onDisabled(context: Context, intent: Intent) {
|
||||
super.onDisabled(context, intent)
|
||||
Toast.makeText(context, "Schnappix Admin Disabled", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun getComponentName(context: Context): ComponentName {
|
||||
return ComponentName(context.applicationContext, AdminReceiver::class.java)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package expo.modules.kioskmode
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.ActivityManager
|
||||
import android.app.admin.DevicePolicyManager
|
||||
import android.content.Context
|
||||
import expo.modules.kotlin.modules.Module
|
||||
import expo.modules.kotlin.modules.ModuleDefinition
|
||||
|
||||
class KioskModeModule : Module() {
|
||||
override fun definition() = ModuleDefinition {
|
||||
Name("KioskMode")
|
||||
|
||||
Function("startKiosk") {
|
||||
val activity = appContext.currentActivity ?: return@Function false
|
||||
val dpm = activity.getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager
|
||||
val packageName = activity.packageName
|
||||
val adminComponent = AdminReceiver.getComponentName(activity)
|
||||
|
||||
activity.runOnUiThread {
|
||||
try {
|
||||
if (dpm.isDeviceOwnerApp(packageName)) {
|
||||
// Whitelist package to enable true Kiosk Mode
|
||||
dpm.setLockTaskPackages(adminComponent, arrayOf(packageName))
|
||||
}
|
||||
activity.startLockTask()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
return@Function true
|
||||
}
|
||||
|
||||
Function("stopKiosk") {
|
||||
val activity = appContext.currentActivity ?: return@Function false
|
||||
activity.runOnUiThread {
|
||||
try {
|
||||
activity.stopLockTask()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
return@Function true
|
||||
}
|
||||
|
||||
Function("isKioskActive") {
|
||||
val activity = appContext.currentActivity ?: return@Function false
|
||||
val am = activity.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
|
||||
return@Function if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
|
||||
am.lockTaskModeState != ActivityManager.LOCK_TASK_MODE_NONE
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
am.isInLockTaskMode
|
||||
}
|
||||
}
|
||||
|
||||
Function("isDeviceOwner") {
|
||||
val activity = appContext.currentActivity ?: return@Function false
|
||||
val dpm = activity.getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager
|
||||
return@Function dpm.isDeviceOwnerApp(activity.packageName)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user