WD: unresolved reference issue fixed
parent
2a37777b9a
commit
06192292d0
@ -1,52 +1,53 @@
|
|||||||
//package com.cloud.diplomaticquarterapp
|
package com.cloud.diplomaticquarterapp
|
||||||
//import com.ejada.hmg.MainActivity
|
|
||||||
//import android.os.Build
|
import com.ejada.hmg.MainActivity
|
||||||
//import android.util.Log
|
import android.os.Build
|
||||||
//import androidx.annotation.RequiresApi
|
import android.util.Log
|
||||||
//import com.cloud.diplomaticquarterapp.penguin.PenguinView
|
import androidx.annotation.RequiresApi
|
||||||
//import io.flutter.embedding.engine.FlutterEngine
|
import com.cloud.diplomaticquarterapp.penguin.PenguinView
|
||||||
//import io.flutter.plugin.common.MethodCall
|
import io.flutter.embedding.engine.FlutterEngine
|
||||||
//import io.flutter.plugin.common.MethodChannel
|
import io.flutter.plugin.common.MethodCall
|
||||||
//
|
import io.flutter.plugin.common.MethodChannel
|
||||||
//class PenguinInPlatformBridge(
|
|
||||||
// private var flutterEngine: FlutterEngine,
|
class PenguinInPlatformBridge(
|
||||||
// private var mainActivity: MainActivity
|
private var flutterEngine: FlutterEngine,
|
||||||
//) {
|
private var mainActivity: MainActivity
|
||||||
//
|
) {
|
||||||
// private lateinit var channel: MethodChannel
|
|
||||||
//
|
private lateinit var channel: MethodChannel
|
||||||
// companion object {
|
|
||||||
// private const val CHANNEL = "launch_penguin_ui"
|
companion object {
|
||||||
// }
|
private const val CHANNEL = "launch_penguin_ui"
|
||||||
//
|
}
|
||||||
// @RequiresApi(Build.VERSION_CODES.O)
|
|
||||||
// fun create() {
|
@RequiresApi(Build.VERSION_CODES.O)
|
||||||
//// openTok = OpenTok(mainActivity, flutterEngine)
|
fun create() {
|
||||||
// channel = MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL)
|
// openTok = OpenTok(mainActivity, flutterEngine)
|
||||||
// channel.setMethodCallHandler { call: MethodCall, result: MethodChannel.Result ->
|
channel = MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL)
|
||||||
// when (call.method) {
|
channel.setMethodCallHandler { call: MethodCall, result: MethodChannel.Result ->
|
||||||
// "launchPenguin" -> {
|
when (call.method) {
|
||||||
// print("the platform channel is being called")
|
"launchPenguin" -> {
|
||||||
// val args = call.arguments as Map<String, Any>?
|
print("the platform channel is being called")
|
||||||
// Log.d("TAG", "configureFlutterEngine: $args")
|
val args = call.arguments as Map<String, Any>?
|
||||||
// println("args")
|
Log.d("TAG", "configureFlutterEngine: $args")
|
||||||
// args?.let {
|
println("args")
|
||||||
// PenguinView(
|
args?.let {
|
||||||
// mainActivity,
|
PenguinView(
|
||||||
// 100,
|
mainActivity,
|
||||||
// args,
|
100,
|
||||||
// flutterEngine.dartExecutor.binaryMessenger,
|
args,
|
||||||
// activity = mainActivity,
|
flutterEngine.dartExecutor.binaryMessenger,
|
||||||
// channel
|
activity = mainActivity,
|
||||||
// )
|
channel
|
||||||
// }
|
)
|
||||||
// }
|
}
|
||||||
//
|
}
|
||||||
// else -> {
|
|
||||||
// result.notImplemented()
|
else -> {
|
||||||
// }
|
result.notImplemented()
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//
|
}
|
||||||
//}
|
|
||||||
|
}
|
||||||
|
|||||||
@ -1,97 +1,97 @@
|
|||||||
//package com.cloud.diplomaticquarterapp.penguin
|
package com.cloud.diplomaticquarterapp.penguin
|
||||||
//
|
|
||||||
//import android.content.Context
|
import android.content.Context
|
||||||
//import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
//import com.peng.pennavmap.PlugAndPlaySDK
|
import com.peng.pennavmap.PlugAndPlaySDK
|
||||||
//import com.peng.pennavmap.connections.ApiController
|
import com.peng.pennavmap.connections.ApiController
|
||||||
//import com.peng.pennavmap.interfaces.RefIdDelegate
|
import com.peng.pennavmap.interfaces.RefIdDelegate
|
||||||
//import com.peng.pennavmap.models.TokenModel
|
import com.peng.pennavmap.models.TokenModel
|
||||||
//import com.peng.pennavmap.models.postmodels.PostToken
|
import com.peng.pennavmap.models.postmodels.PostToken
|
||||||
//import com.peng.pennavmap.utils.AppSharedData
|
import com.peng.pennavmap.utils.AppSharedData
|
||||||
//import okhttp3.ResponseBody
|
import okhttp3.ResponseBody
|
||||||
//import retrofit2.Call
|
import retrofit2.Call
|
||||||
//import retrofit2.Callback
|
import retrofit2.Callback
|
||||||
//import retrofit2.Response
|
import retrofit2.Response
|
||||||
//import android.util.Log
|
import android.util.Log
|
||||||
//
|
|
||||||
//
|
|
||||||
//class PenguinNavigator() {
|
class PenguinNavigator() {
|
||||||
//
|
|
||||||
// fun navigateTo(mContext: Context, refID: String, delegate: RefIdDelegate,clientID : String,clientKey : String ) {
|
fun navigateTo(mContext: Context, refID: String, delegate: RefIdDelegate,clientID : String,clientKey : String ) {
|
||||||
// val postToken = PostToken(clientID, clientKey)
|
val postToken = PostToken(clientID, clientKey)
|
||||||
// getToken(mContext, postToken, object : RefIdDelegate {
|
getToken(mContext, postToken, object : RefIdDelegate {
|
||||||
// override fun onRefByIDSuccess(PoiId: String?) {
|
override fun onRefByIDSuccess(PoiId: String?) {
|
||||||
// Log.e("navigateTo", "PoiId is+++++++ $PoiId")
|
Log.e("navigateTo", "PoiId is+++++++ $PoiId")
|
||||||
//
|
|
||||||
// PlugAndPlaySDK.navigateTo(mContext, refID, object : RefIdDelegate {
|
PlugAndPlaySDK.navigateTo(mContext, refID, object : RefIdDelegate {
|
||||||
// override fun onRefByIDSuccess(PoiId: String?) {
|
override fun onRefByIDSuccess(PoiId: String?) {
|
||||||
// Log.e("navigateTo", "PoiId 2is+++++++ $PoiId")
|
Log.e("navigateTo", "PoiId 2is+++++++ $PoiId")
|
||||||
//
|
|
||||||
// delegate.onRefByIDSuccess(refID)
|
delegate.onRefByIDSuccess(refID)
|
||||||
//
|
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// override fun onGetByRefIDError(error: String?) {
|
override fun onGetByRefIDError(error: String?) {
|
||||||
// delegate.onRefByIDSuccess(error)
|
delegate.onRefByIDSuccess(error)
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// })
|
})
|
||||||
//
|
|
||||||
//
|
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// override fun onGetByRefIDError(error: String?) {
|
override fun onGetByRefIDError(error: String?) {
|
||||||
// delegate.onRefByIDSuccess(error)
|
delegate.onRefByIDSuccess(error)
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// })
|
})
|
||||||
//
|
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// fun getToken(mContext: Context, postToken: PostToken?, apiTokenCallBack: RefIdDelegate) {
|
fun getToken(mContext: Context, postToken: PostToken?, apiTokenCallBack: RefIdDelegate) {
|
||||||
// try {
|
try {
|
||||||
// // Create the API call
|
// Create the API call
|
||||||
// val purposesCall: Call<ResponseBody> = ApiController.getInstance(mContext)
|
val purposesCall: Call<ResponseBody> = ApiController.getInstance(mContext)
|
||||||
// .apiMethods
|
.apiMethods
|
||||||
// .getToken(postToken)
|
.getToken(postToken)
|
||||||
//
|
|
||||||
// // Enqueue the call for asynchronous execution
|
// Enqueue the call for asynchronous execution
|
||||||
// purposesCall.enqueue(object : Callback<ResponseBody?> {
|
purposesCall.enqueue(object : Callback<ResponseBody?> {
|
||||||
// override fun onResponse(
|
override fun onResponse(
|
||||||
// call: Call<ResponseBody?>,
|
call: Call<ResponseBody?>,
|
||||||
// response: Response<ResponseBody?>
|
response: Response<ResponseBody?>
|
||||||
// ) {
|
) {
|
||||||
// if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
// try {
|
try {
|
||||||
// response.body()?.use { responseBody ->
|
response.body()?.use { responseBody ->
|
||||||
// val responseBodyString: String = responseBody.string() // Use `string()` to get the actual response content
|
val responseBodyString: String = responseBody.string() // Use `string()` to get the actual response content
|
||||||
// if (responseBodyString.isNotEmpty()) {
|
if (responseBodyString.isNotEmpty()) {
|
||||||
// val tokenModel = Gson().fromJson(responseBodyString, TokenModel::class.java)
|
val tokenModel = Gson().fromJson(responseBodyString, TokenModel::class.java)
|
||||||
// if (tokenModel != null && tokenModel.token != null) {
|
if (tokenModel != null && tokenModel.token != null) {
|
||||||
// AppSharedData.apiToken = tokenModel.token
|
AppSharedData.apiToken = tokenModel.token
|
||||||
// apiTokenCallBack.onRefByIDSuccess(tokenModel.token)
|
apiTokenCallBack.onRefByIDSuccess(tokenModel.token)
|
||||||
// } else {
|
} else {
|
||||||
// apiTokenCallBack.onGetByRefIDError("Failed to parse token model")
|
apiTokenCallBack.onGetByRefIDError("Failed to parse token model")
|
||||||
// }
|
}
|
||||||
// } else {
|
} else {
|
||||||
// apiTokenCallBack.onGetByRefIDError("Response body is empty")
|
apiTokenCallBack.onGetByRefIDError("Response body is empty")
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// } catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
// apiTokenCallBack.onGetByRefIDError("An error occurred: ${e.message}")
|
apiTokenCallBack.onGetByRefIDError("An error occurred: ${e.message}")
|
||||||
// }
|
}
|
||||||
// } else {
|
} else {
|
||||||
// apiTokenCallBack.onGetByRefIDError("Unsuccessful response: " + response.code())
|
apiTokenCallBack.onGetByRefIDError("Unsuccessful response: " + response.code())
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// override fun onFailure(call: Call<ResponseBody?>, t: Throwable) {
|
override fun onFailure(call: Call<ResponseBody?>, t: Throwable) {
|
||||||
// apiTokenCallBack.onGetByRefIDError(t.message)
|
apiTokenCallBack.onGetByRefIDError(t.message)
|
||||||
// }
|
}
|
||||||
// })
|
})
|
||||||
// } catch (error: Exception) {
|
} catch (error: Exception) {
|
||||||
// apiTokenCallBack.onGetByRefIDError("Exception during API call: $error")
|
apiTokenCallBack.onGetByRefIDError("Exception during API call: $error")
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
//}
|
}
|
||||||
@ -1,321 +1,321 @@
|
|||||||
//package com.cloud.diplomaticquarterapp.penguin
|
package com.cloud.diplomaticquarterapp.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.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.Build
|
||||||
//import android.util.Log
|
import android.util.Log
|
||||||
//import android.view.View
|
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 androidx.annotation.RequiresApi
|
||||||
//import com.cloud.diplomaticquarterapp.PermissionManager.PermissionHelper
|
import com.cloud.diplomaticquarterapp.PermissionManager.PermissionHelper
|
||||||
//import com.cloud.diplomaticquarterapp.PermissionManager.PermissionManager
|
import com.cloud.diplomaticquarterapp.PermissionManager.PermissionManager
|
||||||
//import com.cloud.diplomaticquarterapp.PermissionManager.PermissionResultReceiver
|
import com.cloud.diplomaticquarterapp.PermissionManager.PermissionResultReceiver
|
||||||
//import com.ejada.hmg.MainActivity
|
import com.ejada.hmg.MainActivity
|
||||||
//import com.peng.pennavmap.PlugAndPlayConfiguration
|
import com.peng.pennavmap.PlugAndPlayConfiguration
|
||||||
//import com.peng.pennavmap.PlugAndPlaySDK
|
import com.peng.pennavmap.PlugAndPlaySDK
|
||||||
//import com.peng.pennavmap.enums.InitializationErrorType
|
import com.peng.pennavmap.enums.InitializationErrorType
|
||||||
//import com.peng.pennavmap.interfaces.PenNavUIDelegate
|
import com.peng.pennavmap.interfaces.PenNavUIDelegate
|
||||||
//import com.peng.pennavmap.utils.Languages
|
import com.peng.pennavmap.utils.Languages
|
||||||
//import io.flutter.plugin.common.BinaryMessenger
|
import io.flutter.plugin.common.BinaryMessenger
|
||||||
//import io.flutter.plugin.common.MethodCall
|
import io.flutter.plugin.common.MethodCall
|
||||||
//import io.flutter.plugin.common.MethodChannel
|
import io.flutter.plugin.common.MethodChannel
|
||||||
//import io.flutter.plugin.platform.PlatformView
|
import io.flutter.plugin.platform.PlatformView
|
||||||
//import com.cloud.diplomaticquarterapp.penguin.PenguinNavigator
|
import com.cloud.diplomaticquarterapp.penguin.PenguinNavigator
|
||||||
//import com.peng.pennavmap.interfaces.PIEventsDelegate
|
import com.peng.pennavmap.interfaces.PIEventsDelegate
|
||||||
//import com.peng.pennavmap.interfaces.PILocationDelegate
|
import com.peng.pennavmap.interfaces.PILocationDelegate
|
||||||
//import com.peng.pennavmap.interfaces.RefIdDelegate
|
import com.peng.pennavmap.interfaces.RefIdDelegate
|
||||||
//import com.peng.pennavmap.models.PIReportIssue
|
import com.peng.pennavmap.models.PIReportIssue
|
||||||
///**
|
/**
|
||||||
// * Custom PlatformView for displaying Penguin UI components within a Flutter app.
|
* Custom PlatformView for displaying Penguin UI components within a Flutter app.
|
||||||
// * 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)
|
@RequiresApi(Build.VERSION_CODES.O)
|
||||||
//internal class PenguinView(
|
internal class PenguinView(
|
||||||
// context: Context,
|
context: Context,
|
||||||
// id: Int,
|
id: Int,
|
||||||
// val creationParams: Map<String, Any>,
|
val creationParams: Map<String, Any>,
|
||||||
// messenger: BinaryMessenger,
|
messenger: BinaryMessenger,
|
||||||
// activity: MainActivity,
|
activity: MainActivity,
|
||||||
// val channel: MethodChannel
|
val channel: MethodChannel
|
||||||
//) : 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
|
||||||
//
|
|
||||||
// private val permissionResultReceiver: PermissionResultReceiver
|
private val permissionResultReceiver: PermissionResultReceiver
|
||||||
// private val permissionIntentFilter = IntentFilter("PERMISSION_RESULT_ACTION")
|
private val permissionIntentFilter = IntentFilter("PERMISSION_RESULT_ACTION")
|
||||||
//
|
|
||||||
// private companion object {
|
private companion object {
|
||||||
// const val PERMISSIONS_REQUEST_CODE = 1
|
const val PERMISSIONS_REQUEST_CODE = 1
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// private lateinit var permissionManager: PermissionManager
|
private lateinit var permissionManager: PermissionManager
|
||||||
//
|
|
||||||
// // Reference to the main activity
|
// Reference to the main activity
|
||||||
// private var _activity: Activity = activity
|
private var _activity: Activity = activity
|
||||||
//
|
|
||||||
// private lateinit var mContext: Context
|
private lateinit var mContext: Context
|
||||||
//
|
|
||||||
// lateinit var navigator: PenguinNavigator
|
lateinit var navigator: PenguinNavigator
|
||||||
//
|
|
||||||
// init {
|
init {
|
||||||
// // Set layout parameters for the mapLayout
|
// Set layout parameters for the mapLayout
|
||||||
// mapLayout.layoutParams = ViewGroup.LayoutParams(
|
mapLayout.layoutParams = ViewGroup.LayoutParams(
|
||||||
// ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT
|
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT
|
||||||
// )
|
)
|
||||||
//
|
|
||||||
// mContext = context
|
mContext = context
|
||||||
//
|
|
||||||
//
|
|
||||||
// permissionResultReceiver = PermissionResultReceiver { granted ->
|
permissionResultReceiver = PermissionResultReceiver { granted ->
|
||||||
// if (granted) {
|
if (granted) {
|
||||||
// onPermissionsGranted()
|
onPermissionsGranted()
|
||||||
// } else {
|
} else {
|
||||||
// onPermissionsDenied()
|
onPermissionsDenied()
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
// mContext.registerReceiver(
|
mContext.registerReceiver(
|
||||||
// permissionResultReceiver,
|
permissionResultReceiver,
|
||||||
// permissionIntentFilter,
|
permissionIntentFilter,
|
||||||
// RECEIVER_EXPORTED
|
RECEIVER_EXPORTED
|
||||||
// )
|
)
|
||||||
// } else {
|
} else {
|
||||||
// mContext.registerReceiver(
|
mContext.registerReceiver(
|
||||||
// permissionResultReceiver,
|
permissionResultReceiver,
|
||||||
// permissionIntentFilter,
|
permissionIntentFilter,
|
||||||
// )
|
)
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Set the background color of the layout
|
// Set the background color of the layout
|
||||||
// mapLayout.setBackgroundColor(Color.RED)
|
mapLayout.setBackgroundColor(Color.RED)
|
||||||
//
|
|
||||||
// permissionManager = PermissionManager(
|
permissionManager = PermissionManager(
|
||||||
// context = mContext,
|
context = mContext,
|
||||||
// listener = object : PermissionManager.PermissionListener {
|
listener = object : PermissionManager.PermissionListener {
|
||||||
// override fun onPermissionGranted() {
|
override fun onPermissionGranted() {
|
||||||
// // Handle permissions granted
|
// Handle permissions granted
|
||||||
// onPermissionsGranted()
|
onPermissionsGranted()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// override fun onPermissionDenied() {
|
override fun onPermissionDenied() {
|
||||||
// // Handle permissions denied
|
// Handle permissions denied
|
||||||
// onPermissionsDenied()
|
onPermissionsDenied()
|
||||||
// }
|
}
|
||||||
// },
|
},
|
||||||
// requestCode = PERMISSIONS_REQUEST_CODE,
|
requestCode = PERMISSIONS_REQUEST_CODE,
|
||||||
// *PermissionHelper.getRequiredPermissions()
|
*PermissionHelper.getRequiredPermissions()
|
||||||
// )
|
)
|
||||||
//
|
|
||||||
// if (!permissionManager.arePermissionsGranted()) {
|
if (!permissionManager.arePermissionsGranted()) {
|
||||||
// permissionManager.requestPermissions(_activity)
|
permissionManager.requestPermissions(_activity)
|
||||||
// } else {
|
} else {
|
||||||
// // Permissions already granted
|
// Permissions already granted
|
||||||
// permissionManager.listener.onPermissionGranted()
|
permissionManager.listener.onPermissionGranted()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
//
|
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// private fun onPermissionsGranted() {
|
private fun onPermissionsGranted() {
|
||||||
// // Handle the actions when permissions are granted
|
// Handle the actions when permissions are granted
|
||||||
// Log.d("PermissionsResult", "onPermissionsGranted")
|
Log.d("PermissionsResult", "onPermissionsGranted")
|
||||||
// // Register the platform view factory for creating custom views
|
// Register the platform view factory for creating custom views
|
||||||
//
|
|
||||||
// // Initialize the Penguin SDK
|
// Initialize the Penguin SDK
|
||||||
// initPenguin()
|
initPenguin()
|
||||||
//
|
|
||||||
//
|
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// private fun onPermissionsDenied() {
|
private fun onPermissionsDenied() {
|
||||||
// // Handle the actions when permissions are denied
|
// Handle the actions when permissions are denied
|
||||||
// Log.d("PermissionsResult", "onPermissionsDenied")
|
Log.d("PermissionsResult", "onPermissionsDenied")
|
||||||
//
|
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * Returns the view associated with this PlatformView.
|
* Returns the view associated with this PlatformView.
|
||||||
// *
|
*
|
||||||
// * @return The main view for this PlatformView.
|
* @return The main view for this PlatformView.
|
||||||
// */
|
*/
|
||||||
// override fun getView(): View {
|
override fun getView(): View {
|
||||||
// return mapLayout
|
return mapLayout
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * Cleans up resources associated with this PlatformView.
|
* Cleans up resources associated with this PlatformView.
|
||||||
// */
|
*/
|
||||||
// override fun dispose() {
|
override fun dispose() {
|
||||||
// // Cleanup code if needed
|
// Cleanup code if needed
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * Handles method calls from Dart code.
|
* Handles method calls from Dart code.
|
||||||
// *
|
*
|
||||||
// * @param call The method call from Dart.
|
* @param call The method call from Dart.
|
||||||
// * @param result The result callback to send responses back to Dart.
|
* @param result The result callback to send responses back to Dart.
|
||||||
// */
|
*/
|
||||||
// override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
|
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
|
||||||
// // Handle method calls from Dart code here
|
// Handle method calls from Dart code here
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * Initializes the Penguin SDK with custom configuration and delegates.
|
* Initializes the Penguin SDK with custom configuration and delegates.
|
||||||
// */
|
*/
|
||||||
// private fun initPenguin() {
|
private fun initPenguin() {
|
||||||
// navigator = PenguinNavigator()
|
navigator = PenguinNavigator()
|
||||||
// // Configure the PlugAndPlaySDK
|
// Configure the PlugAndPlaySDK
|
||||||
// val language = when (creationParams["languageCode"] as String) {
|
val language = when (creationParams["languageCode"] as String) {
|
||||||
// "ar" -> Languages.ar
|
"ar" -> Languages.ar
|
||||||
// "en" -> Languages.en
|
"en" -> Languages.en
|
||||||
// else -> {
|
else -> {
|
||||||
// Languages.en
|
Languages.en
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
|
Log.d(
|
||||||
|
"TAG",
|
||||||
|
"initPenguin: ${Languages.getLanguageEnum(creationParams["languageCode"] as String)}"
|
||||||
|
)
|
||||||
|
PlugAndPlaySDK.configuration = PlugAndPlayConfiguration.Builder()
|
||||||
|
.setBaseUrl(
|
||||||
|
creationParams["dataURL"] as String,
|
||||||
|
creationParams["positionURL"] as String
|
||||||
|
)
|
||||||
|
.setServiceName(
|
||||||
|
creationParams["dataServiceName"] as String,
|
||||||
|
creationParams["positionServiceName"] as String
|
||||||
|
)
|
||||||
|
.setClientData(
|
||||||
|
creationParams["clientID"] as String,
|
||||||
|
creationParams["clientKey"] as String
|
||||||
|
)
|
||||||
|
.setUserName(creationParams["username"] as String)
|
||||||
|
// .setLanguageID(Languages.en)
|
||||||
|
.setLanguageID(language)
|
||||||
|
.setSimulationModeEnabled(creationParams["isSimulationModeEnabled"] as Boolean)
|
||||||
|
.setEnableBackButton(true)
|
||||||
|
// .setDeepLinkData("deeplink")
|
||||||
|
.setCustomizeColor("#2CA0AF")
|
||||||
|
.setDeepLinkSchema("")
|
||||||
|
.setIsEnableReportIssue(true)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
// Set location delegate to handle location updates
|
||||||
|
// PlugAndPlaySDK.setPiLocationDelegate {
|
||||||
|
// Example code to handle location updates
|
||||||
|
// Uncomment and modify as needed
|
||||||
|
// if (location.size() > 0)
|
||||||
|
// Toast.makeText(_context, "Location Info Latitude: ${location[0]}, Longitude: ${location[1]}", Toast.LENGTH_SHORT).show()
|
||||||
// }
|
// }
|
||||||
// Log.d(
|
|
||||||
// "TAG",
|
// Set events delegate for reporting issues
|
||||||
// "initPenguin: ${Languages.getLanguageEnum(creationParams["languageCode"] as String)}"
|
// PlugAndPlaySDK.setPiEventsDelegate(new PIEventsDelegate() {
|
||||||
// )
|
// @Override
|
||||||
// PlugAndPlaySDK.configuration = PlugAndPlayConfiguration.Builder()
|
// public void onReportIssue(PIReportIssue issue) {
|
||||||
// .setBaseUrl(
|
// Log.e("Issue Reported: ", issue.getReportType());
|
||||||
// creationParams["dataURL"] as String,
|
|
||||||
// creationParams["positionURL"] as String
|
|
||||||
// )
|
|
||||||
// .setServiceName(
|
|
||||||
// creationParams["dataServiceName"] as String,
|
|
||||||
// creationParams["positionServiceName"] as String
|
|
||||||
// )
|
|
||||||
// .setClientData(
|
|
||||||
// creationParams["clientID"] as String,
|
|
||||||
// creationParams["clientKey"] as String
|
|
||||||
// )
|
|
||||||
// .setUserName(creationParams["username"] as String)
|
|
||||||
//// .setLanguageID(Languages.en)
|
|
||||||
// .setLanguageID(language)
|
|
||||||
// .setSimulationModeEnabled(creationParams["isSimulationModeEnabled"] as Boolean)
|
|
||||||
// .setEnableBackButton(true)
|
|
||||||
//// .setDeepLinkData("deeplink")
|
|
||||||
// .setCustomizeColor("#2CA0AF")
|
|
||||||
// .setDeepLinkSchema("")
|
|
||||||
// .setIsEnableReportIssue(true)
|
|
||||||
// .build()
|
|
||||||
//
|
|
||||||
// // Set location delegate to handle location updates
|
|
||||||
//// PlugAndPlaySDK.setPiLocationDelegate {
|
|
||||||
// // Example code to handle location updates
|
|
||||||
// // Uncomment and modify as needed
|
|
||||||
// // if (location.size() > 0)
|
|
||||||
// // Toast.makeText(_context, "Location Info Latitude: ${location[0]}, Longitude: ${location[1]}", Toast.LENGTH_SHORT).show()
|
|
||||||
//// }
|
|
||||||
//
|
|
||||||
// // Set events delegate for reporting issues
|
|
||||||
//// PlugAndPlaySDK.setPiEventsDelegate(new PIEventsDelegate() {
|
|
||||||
//// @Override
|
|
||||||
//// public void onReportIssue(PIReportIssue issue) {
|
|
||||||
//// Log.e("Issue Reported: ", issue.getReportType());
|
|
||||||
//// }
|
|
||||||
//// // Implement issue reporting logic here }
|
|
||||||
//// @Override
|
|
||||||
//// public void onSharedLocation(String link) {
|
|
||||||
//// // Implement Shared location logic here
|
|
||||||
//// }
|
|
||||||
//// })
|
|
||||||
//
|
|
||||||
// // Start the Penguin SDK
|
|
||||||
// PlugAndPlaySDK.start(mContext, this)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Navigates to the specified reference ID.
|
|
||||||
// *
|
|
||||||
// * @param refID The reference ID to navigate to.
|
|
||||||
// */
|
|
||||||
// fun navigateTo(refID: String) {
|
|
||||||
// try {
|
|
||||||
// if (refID.isBlank()) {
|
|
||||||
// Log.e("navigateTo", "Invalid refID: The reference ID is blank.")
|
|
||||||
// }
|
// }
|
||||||
//// referenceId = refID
|
// // Implement issue reporting logic here }
|
||||||
// navigator.navigateTo(mContext, refID,object : RefIdDelegate {
|
// @Override
|
||||||
// override fun onRefByIDSuccess(PoiId: String?) {
|
// public void onSharedLocation(String link) {
|
||||||
// Log.e("navigateTo", "PoiId is penguin view+++++++ $PoiId")
|
// // Implement Shared location logic here
|
||||||
//
|
|
||||||
//// channelFlutter.invokeMethod(
|
|
||||||
//// PenguinMethod.navigateToPOI.name,
|
|
||||||
//// "navigateTo Success"
|
|
||||||
//// )
|
|
||||||
// }
|
// }
|
||||||
//
|
// })
|
||||||
// override fun onGetByRefIDError(error: String?) {
|
|
||||||
// Log.e("navigateTo", "error is penguin view+++++++ $error")
|
// Start the Penguin SDK
|
||||||
//
|
PlugAndPlaySDK.start(mContext, this)
|
||||||
//// channelFlutter.invokeMethod(
|
}
|
||||||
//// PenguinMethod.navigateToPOI.name,
|
|
||||||
//// "navigateTo Failed: Invalid refID"
|
|
||||||
//// )
|
/**
|
||||||
// }
|
* Navigates to the specified reference ID.
|
||||||
// } , creationParams["clientID"] as String, creationParams["clientKey"] as String )
|
*
|
||||||
//
|
* @param refID The reference ID to navigate to.
|
||||||
// } catch (e: Exception) {
|
*/
|
||||||
// Log.e("navigateTo", "Exception occurred during navigation: ${e.message}", e)
|
fun navigateTo(refID: String) {
|
||||||
//// channelFlutter.invokeMethod(
|
try {
|
||||||
//// PenguinMethod.navigateToPOI.name,
|
if (refID.isBlank()) {
|
||||||
//// "Failed: Exception - ${e.message}"
|
Log.e("navigateTo", "Invalid refID: The reference ID is blank.")
|
||||||
//// )
|
}
|
||||||
// }
|
// referenceId = refID
|
||||||
// }
|
navigator.navigateTo(mContext, refID,object : RefIdDelegate {
|
||||||
//
|
override fun onRefByIDSuccess(PoiId: String?) {
|
||||||
// /**
|
Log.e("navigateTo", "PoiId is penguin view+++++++ $PoiId")
|
||||||
// * Called when Penguin UI setup is successful.
|
|
||||||
// *
|
// channelFlutter.invokeMethod(
|
||||||
// * @param warningCode Optional warning code received from the SDK.
|
// PenguinMethod.navigateToPOI.name,
|
||||||
// */
|
// "navigateTo Success"
|
||||||
// override fun onPenNavSuccess(warningCode: String?) {
|
// )
|
||||||
// val clinicId = creationParams["clinicID"] as String
|
}
|
||||||
//
|
|
||||||
// if(clinicId.isEmpty()) return
|
override fun onGetByRefIDError(error: String?) {
|
||||||
//
|
Log.e("navigateTo", "error is penguin view+++++++ $error")
|
||||||
// navigateTo(clinicId)
|
|
||||||
// }
|
// channelFlutter.invokeMethod(
|
||||||
//
|
// PenguinMethod.navigateToPOI.name,
|
||||||
// /**
|
// "navigateTo Failed: Invalid refID"
|
||||||
// * Called when there is an initialization error with Penguin UI.
|
// )
|
||||||
// *
|
}
|
||||||
// * @param description Description of the error.
|
} , creationParams["clientID"] as String, creationParams["clientKey"] as String )
|
||||||
// * @param errorType Type of initialization error.
|
|
||||||
// */
|
} catch (e: Exception) {
|
||||||
// override fun onPenNavInitializationError(
|
Log.e("navigateTo", "Exception occurred during navigation: ${e.message}", e)
|
||||||
// description: String?,
|
// channelFlutter.invokeMethod(
|
||||||
// errorType: InitializationErrorType?
|
// PenguinMethod.navigateToPOI.name,
|
||||||
// ) {
|
// "Failed: Exception - ${e.message}"
|
||||||
// val arguments: Map<String, Any?> = mapOf(
|
// )
|
||||||
// "description" to description,
|
}
|
||||||
// "type" to errorType?.name
|
}
|
||||||
// )
|
|
||||||
//
|
/**
|
||||||
// channel.invokeMethod(PenguinMethod.onPenNavInitializationError.name, arguments)
|
* Called when Penguin UI setup is successful.
|
||||||
// Toast.makeText(mContext, "Navigation Error: $description", Toast.LENGTH_SHORT).show()
|
*
|
||||||
// }
|
* @param warningCode Optional warning code received from the SDK.
|
||||||
//
|
*/
|
||||||
// /**
|
override fun onPenNavSuccess(warningCode: String?) {
|
||||||
// * Called when Penguin UI is dismissed.
|
val clinicId = creationParams["clinicID"] as String
|
||||||
// */
|
|
||||||
// override fun onPenNavUIDismiss() {
|
if(clinicId.isEmpty()) return
|
||||||
// // Handle UI dismissal if needed
|
|
||||||
// try {
|
navigateTo(clinicId)
|
||||||
// mContext.unregisterReceiver(permissionResultReceiver)
|
}
|
||||||
// dispose();
|
|
||||||
// } catch (e: IllegalArgumentException) {
|
/**
|
||||||
// Log.e("PenguinView", "Receiver not registered: $e")
|
* Called when there is an initialization error with Penguin UI.
|
||||||
// }
|
*
|
||||||
// }
|
* @param description Description of the error.
|
||||||
//}
|
* @param errorType Type of initialization error.
|
||||||
//
|
*/
|
||||||
|
override fun onPenNavInitializationError(
|
||||||
|
description: String?,
|
||||||
|
errorType: InitializationErrorType?
|
||||||
|
) {
|
||||||
|
val arguments: Map<String, Any?> = mapOf(
|
||||||
|
"description" to description,
|
||||||
|
"type" to errorType?.name
|
||||||
|
)
|
||||||
|
|
||||||
|
channel.invokeMethod(PenguinMethod.onPenNavInitializationError.name, arguments)
|
||||||
|
Toast.makeText(mContext, "Navigation Error: $description", Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when Penguin UI is dismissed.
|
||||||
|
*/
|
||||||
|
override fun onPenNavUIDismiss() {
|
||||||
|
// Handle UI dismissal if needed
|
||||||
|
try {
|
||||||
|
mContext.unregisterReceiver(permissionResultReceiver)
|
||||||
|
dispose();
|
||||||
|
} catch (e: IllegalArgumentException) {
|
||||||
|
Log.e("PenguinView", "Receiver not registered: $e")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue