|
|
|
|
@ -2,8 +2,10 @@ package com.eventtan.app.penguin_flutter_sample.penguin
|
|
|
|
|
|
|
|
|
|
import android.app.Activity
|
|
|
|
|
import android.content.Context
|
|
|
|
|
import android.content.Context.RECEIVER_EXPORTED
|
|
|
|
|
import android.content.IntentFilter
|
|
|
|
|
import android.graphics.Color
|
|
|
|
|
import android.os.Build
|
|
|
|
|
import android.os.Handler
|
|
|
|
|
import android.os.Looper
|
|
|
|
|
import android.util.Log
|
|
|
|
|
@ -11,6 +13,7 @@ import android.view.View
|
|
|
|
|
import android.view.ViewGroup
|
|
|
|
|
import android.widget.RelativeLayout
|
|
|
|
|
import android.widget.Toast
|
|
|
|
|
import androidx.annotation.RequiresApi
|
|
|
|
|
import com.eventtan.test.penguin_flutter_sample.MainActivity
|
|
|
|
|
import com.eventtan.test.penguin_flutter_sample.PermissionManager.PermissionHelper
|
|
|
|
|
import com.eventtan.test.penguin_flutter_sample.PermissionManager.PermissionManager
|
|
|
|
|
@ -30,16 +33,17 @@ import io.flutter.plugin.platform.PlatformView
|
|
|
|
|
* Implements `PlatformView` for rendering the view, `MethodChannel.MethodCallHandler` for handling method calls,
|
|
|
|
|
* and `PenNavUIDelegate` for handling SDK events.
|
|
|
|
|
*/
|
|
|
|
|
@RequiresApi(Build.VERSION_CODES.O)
|
|
|
|
|
internal class PenguinView(
|
|
|
|
|
context: Context,
|
|
|
|
|
id: Int,
|
|
|
|
|
creationParams: Map<String?, Any?>?,
|
|
|
|
|
val creationParams: Map<String, String>,
|
|
|
|
|
messenger: BinaryMessenger,
|
|
|
|
|
activity: MainActivity
|
|
|
|
|
) : PlatformView, MethodChannel.MethodCallHandler, PenNavUIDelegate {
|
|
|
|
|
// The layout for displaying the Penguin UI
|
|
|
|
|
private val mapLayout: RelativeLayout = RelativeLayout(context)
|
|
|
|
|
private val _context: Context = context.applicationContext
|
|
|
|
|
private val _context: Context = context
|
|
|
|
|
|
|
|
|
|
private val permissionResultReceiver: PermissionResultReceiver
|
|
|
|
|
private val permissionIntentFilter = IntentFilter("PERMISSION_RESULT_ACTION")
|
|
|
|
|
@ -71,8 +75,8 @@ internal class PenguinView(
|
|
|
|
|
onPermissionsDenied()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mContext.registerReceiver(permissionResultReceiver, permissionIntentFilter)
|
|
|
|
|
//todo handle properly the way it in the main app check the sdk version and cal it appropiately
|
|
|
|
|
mContext.registerReceiver(permissionResultReceiver, permissionIntentFilter,RECEIVER_EXPORTED)
|
|
|
|
|
|
|
|
|
|
// Set the background color of the layout
|
|
|
|
|
mapLayout.setBackgroundColor(Color.RED)
|
|
|
|
|
@ -155,12 +159,12 @@ internal class PenguinView(
|
|
|
|
|
private fun initPenguin() {
|
|
|
|
|
// Configure the PlugAndPlaySDK
|
|
|
|
|
PlugAndPlaySDK.configuration = PlugAndPlayConfiguration.Builder()
|
|
|
|
|
.setBaseUrl("https://temp.penguinin.com", "https://temp.penguinin.com")
|
|
|
|
|
.setServiceName("api", "pe")
|
|
|
|
|
.setClientData("Client", "clientkey")
|
|
|
|
|
.setBaseUrl(creationParams["baseURL"], creationParams["positionURL"])
|
|
|
|
|
.setServiceName(creationParams["dataServiceName"], creationParams["positionServiceName"])
|
|
|
|
|
.setClientData(creationParams["clientID"], creationParams["clientKey"])
|
|
|
|
|
.setUserName("client")
|
|
|
|
|
.setLanguageID(Languages.en)
|
|
|
|
|
.setSimulationModeEnabled(true)
|
|
|
|
|
.setSimulationModeEnabled(false)
|
|
|
|
|
.setEnableBackButton(true)
|
|
|
|
|
.setDeepLinkData("deeplink")
|
|
|
|
|
.setCustomizeColor("#2CA0AF")
|
|
|
|
|
@ -189,16 +193,17 @@ internal class PenguinView(
|
|
|
|
|
* @param warningCode Optional warning code received from the SDK.
|
|
|
|
|
*/
|
|
|
|
|
override fun onPenNavSuccess(warningCode: String?) {
|
|
|
|
|
if (_context is Activity) {
|
|
|
|
|
_context.runOnUiThread {
|
|
|
|
|
Toast.makeText(_context, "Success Info: $warningCode", Toast.LENGTH_SHORT).show()
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
val handler = Handler(Looper.getMainLooper())
|
|
|
|
|
handler.post {
|
|
|
|
|
Toast.makeText(_context, "Success Info: $warningCode", Toast.LENGTH_SHORT).show()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// if (_context is Activity) {
|
|
|
|
|
// _context.runOnUiThread {
|
|
|
|
|
// Toast.makeText(_context, "Success Info: $warningCode", Toast.LENGTH_SHORT).show()
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// println("the warming is presented $$warningCode")
|
|
|
|
|
//// val handler = Handler(Looper.getMainLooper())
|
|
|
|
|
//// handler.post {
|
|
|
|
|
//// Toast.makeText(_context, "Success Info: $warningCode", Toast.LENGTH_SHORT).show()
|
|
|
|
|
//// }
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|