Feat(Tis): DeviceInfo and Build applicationId
Send Device name and AndroidId in DeviceInfo, Handle multiple release version with different version number and application Id for each psp
This commit is contained in:
@@ -3,8 +3,6 @@ package com.example.design_system
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.view.ViewGroup
|
||||
import android.webkit.WebResourceError
|
||||
import android.webkit.WebResourceRequest
|
||||
import android.webkit.WebSettings
|
||||
import android.webkit.WebView
|
||||
import android.webkit.WebViewClient
|
||||
@@ -36,7 +34,7 @@ fun PspWebView(
|
||||
modifier: Modifier = Modifier,
|
||||
onWebView: (WebView) -> Unit,
|
||||
onPayClick: (amount: Long, id: String?) -> Unit,
|
||||
onUUID: () -> Unit,
|
||||
onDeviceInfo: () -> String,
|
||||
onPrintClick: (printEntities: List<PrintEntity>) -> Unit,
|
||||
) {
|
||||
|
||||
@@ -49,13 +47,13 @@ fun PspWebView(
|
||||
// Use rememberUpdatedState to ensure the bridge always calls the latest callbacks
|
||||
val currentOnPayClick by rememberUpdatedState(onPayClick)
|
||||
val currentOnPrintClick by rememberUpdatedState(onPrintClick)
|
||||
val currentOnUUID by rememberUpdatedState(onUUID)
|
||||
val currentOnDeviceInfo by rememberUpdatedState(onDeviceInfo)
|
||||
|
||||
val bridge = remember {
|
||||
PspJavaScriptInterface(
|
||||
onPayClick = { amount, id -> currentOnPayClick(amount, id) },
|
||||
onPrintClick = { entities -> currentOnPrintClick(entities) },
|
||||
onUUID = { currentOnUUID() }
|
||||
onDeviceInfo = { currentOnDeviceInfo() }
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+5
-4
@@ -11,7 +11,7 @@ import com.google.gson.reflect.TypeToken
|
||||
class PspJavaScriptInterface(
|
||||
private val onPayClick: (Long, String?) -> Unit,
|
||||
private val onPrintClick: (List<PrintEntity>) -> Unit,
|
||||
private val onUUID: () -> Unit,
|
||||
private val onDeviceInfo: () -> String,
|
||||
) {
|
||||
|
||||
@JavascriptInterface
|
||||
@@ -40,12 +40,13 @@ class PspJavaScriptInterface(
|
||||
|
||||
@JavascriptInterface
|
||||
@Keep
|
||||
fun uuid() {
|
||||
fun deviceInfo(): String {
|
||||
Log.d("PspBridge", "uuid called")
|
||||
try {
|
||||
onUUID()
|
||||
return try {
|
||||
onDeviceInfo()
|
||||
} catch (e: Exception) {
|
||||
Log.e("PspBridge", "Error in uuid callback", e)
|
||||
""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user