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