Compare commits

..

No commits in common. 'main' and 'aamir_dev' have entirely different histories.

@ -57,12 +57,12 @@ android {
signingConfigs { signingConfigs {
// release { release {
// storeFile file("key.jks") storeFile file("key.jks")
// storePassword "123456" storePassword "123456"
// keyAlias "key0" keyAlias "key0"
// keyPassword "123456" keyPassword "123456"
// } }
} }
@ -71,15 +71,15 @@ android {
release { release {
minifyEnabled true minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
// signingConfig signingConfigs.release signingConfig signingConfigs.release
} }
debug { debug {
debuggable true debuggable true
minifyEnabled false minifyEnabled true
// signingConfig signingConfigs.release signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
} }
} }

@ -46,8 +46,6 @@
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter> </intent-filter>
</activity> </activity>
<!-- Don't delete the meta-data below. <!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java --> This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data <meta-data

@ -2,16 +2,12 @@ package com.eventtan.test.penguin_flutter_sample
import android.content.Intent import android.content.Intent
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.os.Build
import android.util.Log import android.util.Log
import androidx.annotation.RequiresApi
import com.eventtan.app.penguin_flutter_sample.penguin.PenguinView
import com.eventtan.app.penguin_flutter_sample.penguin.PenguinViewFactory import com.eventtan.app.penguin_flutter_sample.penguin.PenguinViewFactory
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
import io.flutter.embedding.android.FlutterActivity import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
/** /**
@ -24,33 +20,23 @@ class MainActivity : FlutterActivity() {
private lateinit var flutterEngine: FlutterEngine private lateinit var flutterEngine: FlutterEngine
private val CHANNEL = "com.aamir/launch_penguin_ui"
/** /**
* Configures the Flutter engine by registering platform view factories. * Configures the Flutter engine by registering platform view factories.
* *
* @param flutterEngine The [FlutterEngine] instance associated with this activity. * @param flutterEngine The [FlutterEngine] instance associated with this activity.
*/ */
@RequiresApi(Build.VERSION_CODES.O)
override fun configureFlutterEngine(flutterEngine: FlutterEngine) { override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine) super.configureFlutterEngine(flutterEngine)
flutterEngine.platformViewsController.registry.registerViewFactory(
"penguin_lib", // Unique identifier for the view factory
PenguinViewFactory(
flutterEngine.dartExecutor.binaryMessenger, // Used for communication with Dart
this // Reference to the current MainActivity
)
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler { )
call, result ->
when (call.method) {
"launchPenguin" -> {
print("the platform channel is being called" )
val args = call.arguments as Map<String, Any>?
Log.d("TAG", "configureFlutterEngine: $args")
println("args")
args?.let {
PenguinView(activity,100,args,flutterEngine.dartExecutor.binaryMessenger , activity = this,)
}
}
}
}
} }

@ -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() }
//// } }
// }
} }
/** /**

@ -1,8 +1,6 @@
package com.eventtan.app.penguin_flutter_sample.penguin package com.eventtan.app.penguin_flutter_sample.penguin
import android.content.Context import android.content.Context
import android.os.Build
import androidx.annotation.RequiresApi
import com.eventtan.test.penguin_flutter_sample.MainActivity import com.eventtan.test.penguin_flutter_sample.MainActivity
import io.flutter.plugin.common.BinaryMessenger import io.flutter.plugin.common.BinaryMessenger
import io.flutter.plugin.common.StandardMessageCodec import io.flutter.plugin.common.StandardMessageCodec
@ -30,10 +28,9 @@ class PenguinViewFactory(
* @param args Optional arguments passed for creating the view, expected to be a [Map]. * @param args Optional arguments passed for creating the view, expected to be a [Map].
* @return A new instance of [PenguinView]. * @return A new instance of [PenguinView].
*/ */
@RequiresApi(Build.VERSION_CODES.O)
override fun create(context: Context, viewId: Int, args: Any?): PlatformView { override fun create(context: Context, viewId: Int, args: Any?): PlatformView {
// Cast the arguments to a Map if they are provided // Cast the arguments to a Map if they are provided
val creationParams = args as Map<String, String> val creationParams = args as Map<String?, Any?>?
// Instantiate and return the PenguinView with the provided parameters // Instantiate and return the PenguinView with the provided parameters
return PenguinView(context, viewId, creationParams, messenger, mainActivity) return PenguinView(context, viewId, creationParams, messenger, mainActivity)

@ -12,6 +12,6 @@
<string name="client_key" translatable="false">UGVuZ3VpbklOX1Blbk5hdl9QSUY=</string> <string name="client_key" translatable="false">UGVuZ3VpbklOX1Blbk5hdl9QSUY=</string>
<string name="deep_link_schema" translatable="false"></string> <string name="deep_link_schema" translatable="false"></string>
<string name="deep_link_domain" translatable="false"></string> <string name="deep_link_domain" translatable="false"></string>
<string name="mapbox_access_token" translatable="false">sk.eyJ1IjoicndhaWQiLCJhIjoiY2x6NWo0bTMzMWZodzJrcGZpemYzc3Z4dSJ9.uSSZuwNSGCcCdPAiORECmg</string> <string name="mapbox_access_token" translatable="false">mapbox_token</string>
//////////////////////////////////////////// ////////////////////////////////////////////
</resources> </resources>

@ -2,21 +2,20 @@ buildscript {
repositories { repositories {
google() google()
mavenCentral() mavenCentral()
// maven { url 'https://plugins.gradle.org/m2' } maven { url 'https://plugins.gradle.org/m2' }
// maven { url 'https://jitpack.io' } // maven { url 'https://jitpack.io' }
maven { maven {
url 'https://api.mapbox.com/downloads/v2/releases/maven' url 'https://api.mapbox.com/downloads/v2/releases/maven'
authentication {
basic(BasicAuthentication)
}
credentials { credentials {
username = 'mapbox' username = 'mapbox'
password = "sk.eyJ1IjoicndhaWQiLCJhIjoiY2x6NWo0bTMzMWZodzJrcGZpemYzc3Z4dSJ9.uSSZuwNSGCcCdPAiORECmg" password = "sk.eyJ1IjoidmlyYWwtbW9ibWF4aW1lIiwiYSI6ImNseWZ0MzByYTAzZ2MyeHMxMXp3NWRscWYifQ.Dq-SRE-hyED1ojrJcq3JKA"
if (password == null || password == "") { if (password == null || password == "") {
throw new GradleException("MAPBOX_DOWNLOADS_TOKEN isn't set. Set it to the project properties or to the enviroment variables.") throw new GradleException("MAPBOX_DOWNLOADS_TOKEN isn't set. Set it to the project properties or to the enviroment variables.")
} }
} }
authentication {
basic(BasicAuthentication)
}
} }
} }
dependencies { dependencies {
@ -36,7 +35,7 @@ allprojects {
} }
credentials { credentials {
username = 'mapbox' username = 'mapbox'
password = "sk.eyJ1IjoicndhaWQiLCJhIjoiY2x6NWo0bTMzMWZodzJrcGZpemYzc3Z4dSJ9.uSSZuwNSGCcCdPAiORECmg" password = "sk.eyJ1IjoidmlyYWwtbW9ibWF4aW1lIiwiYSI6ImNseWZ0MzByYTAzZ2MyeHMxMXp3NWRscWYifQ.Dq-SRE-hyED1ojrJcq3JKA"
if (password == null || password == "") { if (password == null || password == "") {
throw new GradleException("MAPBOX_DOWNLOADS_TOKEN isn't set. Set it to the project properties or to the enviroment variables.") throw new GradleException("MAPBOX_DOWNLOADS_TOKEN isn't set. Set it to the project properties or to the enviroment variables.")
} }

@ -4,5 +4,5 @@ android.enableJetifier=true
android.nonTransitiveRClass=false android.nonTransitiveRClass=false
android.nonFinalResIds=false android.nonFinalResIds=false
MAPBOX_USER_NAME = "mapbox" MAPBOX_USER_NAME = "mapbox"
MAPBOX_DOWNLOADS_TOKEN="sk.eyJ1IjoicndhaWQiLCJhIjoiY2x6NWo0bTMzMWZodzJrcGZpemYzc3Z4dSJ9.uSSZuwNSGCcCdPAiORECmg" MAPBOX_DOWNLOADS_TOKEN="sk.eyJ1IjoidmlyYWwtbW9ibWF4aW1lIiwiYSI6ImNseWZ0MzByYTAzZ2MyeHMxMXp3NWRscWYifQ.Dq-SRE-hyED1ojrJcq3JKA"

@ -13,12 +13,13 @@ pluginManagement {
google() google()
mavenCentral() mavenCentral()
gradlePluginPortal() gradlePluginPortal()
maven { url 'https://plugins.gradle.org/m2' }
maven { url 'https://jitpack.io' } maven { url 'https://jitpack.io' }
maven { maven {
url 'https://api.mapbox.com/downloads/v2/releases/maven' url 'https://api.mapbox.com/downloads/v2/releases/maven'
credentials { credentials {
username = 'mapbox' username = 'mapbox'
password = 'sk.eyJ1IjoicndhaWQiLCJhIjoiY2x6NWo0bTMzMWZodzJrcGZpemYzc3Z4dSJ9.uSSZuwNSGCcCdPAiORECmg' password = 'sk.eyJ1IjoidmlyYWwtbW9ibWF4aW1lIiwiYSI6ImNseWZ0MzByYTAzZ2MyeHMxMXp3NWRscWYifQ.Dq-SRE-hyED1ojrJcq3JKA'
if (password == null || password == "") { if (password == null || password == "") {
throw new GradleException("MAPBOX_DOWNLOADS_TOKEN isn't set. Set it to the project properties or to the enviroment variables.") throw new GradleException("MAPBOX_DOWNLOADS_TOKEN isn't set. Set it to the project properties or to the enviroment variables.")
} }

@ -24,19 +24,42 @@ import UIKit
@UIApplicationMain @UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate { @objc class AppDelegate: FlutterAppDelegate {
var flutterEngine: FlutterEngine? var flutterEngine: FlutterEngine?
override func application( override func application(
_ application: UIApplication, _ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool { ) -> Bool {
flutterEngine = FlutterEngine(name: "my flutter engine")
guard let flutterEngine = flutterEngine else {
fatalError("Flutter engine initialization failed")
}
flutterEngine.run()
GeneratedPluginRegistrant.register(with: flutterEngine)
GeneratedPluginRegistrant.register(with: self) GeneratedPluginRegistrant.register(with: self)
let controller: FlutterViewController = window?.rootViewController as! FlutterViewController let controller: FlutterViewController = window?.rootViewController as! FlutterViewController
let channel = FlutterMethodChannel(name: "com.aamir/launch_penguin_ui", let channel = FlutterMethodChannel(name: "com.aamir/launch_penguin_ui",
binaryMessenger: controller.binaryMessenger) binaryMessenger: controller.binaryMessenger)
channel.setMethodCallHandler { [weak self] (call: FlutterMethodCall, result: @escaping FlutterResult) in channel.setMethodCallHandler { [weak self] (call: FlutterMethodCall, result: @escaping FlutterResult) in
if let arguments = call.arguments as? [String: Any], if let arguments = call.arguments as? [String: Any],
let storyboardName = arguments["storyboardName"] as? String { let storyboardName = arguments["storyboardName"] as? String {
if call.method == "launchPenguin"{ if call.method == "launchPenguin"{
// if let penguinModel = PenguinModel(from: arguments) {
// self.model = penguinModel
// initPenguin(args: penguinModel)
// } else {
// print("Error: Failed to initialize PenguinModel from arguments")
// }
self?.launchPenguinView(arguments: arguments, result: result) self?.launchPenguinView(arguments: arguments, result: result)
//let penguinView =
// PenguinView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height), viewIdentifier: 0, arguments: arguments, binaryMessenger: controller.binaryMessenger)
// let penguinUIView = penguinView.initPenguin(args: penguinModel)
// penguinUIView.frame = self.view.bounds
// penguinUIView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
// self.view.addSubview(penguinUIView)
// self?.launchStoryboard(named: storyboardName, result: result, arguments: arguments )
} }
else { else {
result(FlutterMethodNotImplemented) result(FlutterMethodNotImplemented)
@ -50,6 +73,34 @@ import UIKit
return super.application(application, didFinishLaunchingWithOptions: launchOptions) return super.application(application, didFinishLaunchingWithOptions: launchOptions)
} }
private func launchStoryboard(named storyboardName: String, result: @escaping FlutterResult, arguments: [String: Any]) {
let storyboard = UIStoryboard(name: storyboardName, bundle: nil)
guard let flutterEngine = flutterEngine else {
result(FlutterError(code: "ENGINE_UNAVAILABLE", message: "Flutter engine is not available", details: nil))
return
}
guard let viewController = storyboard.instantiateViewController(withIdentifier: "PenguinViewController") as? PenguinViewController else {
result(FlutterError(code: "INVALID_VIEW_CONTROLLER", message: "Unable to instantiate view controller", details: nil))
return
}
// Use the custom initializer
viewController.setProperties(flutterEngine: flutterEngine, arguments: arguments)
// let penguinViewController = PenguinViewController(flutterEngine: flutterEngine, arguments: arguments)
if let rootViewController = window?.rootViewController {
rootViewController.present(viewController, animated: true, completion: nil)
result("Storyboard \(storyboardName) launched successfully")
} else {
result(FlutterError(code: "UNAVAILABLE", message: "Root view controller is not available", details: nil))
}
}
private func launchPenguinView(arguments: [String: Any], result: @escaping FlutterResult) { private func launchPenguinView(arguments: [String: Any], result: @escaping FlutterResult) {
guard let controller = window?.rootViewController as? FlutterViewController else { guard let controller = window?.rootViewController as? FlutterViewController else {
@ -73,5 +124,30 @@ import UIKit
result(nil) // Call result to indicate the method was successfully handled result(nil) // Call result to indicate the method was successfully handled
} }
} }
// private func launchStoryboard(named storyboardName: String, result: @escaping FlutterResult, arguments arguments: [String: Any]) {
// let storyboard = UIStoryboard(name: storyboardName, bundle: nil)
// guard let viewController = storyboard.instantiateViewController(withIdentifier: "PenguinViewController") as? PenguinViewController else {
// result(FlutterError(code: "INVALID_VIEW_CONTROLLER", message: "Unable to instantiate view controller", details: nil))
// return
// }
//
// // viewController.arguments = arguments
//
// guard let flutterEngine = flutterEngine else {
// result(FlutterError(code: "ENGINE_UNAVAILABLE", message: "Flutter engine is not available", details: nil))
// return
// }
//
// viewController.flutterEngine = flutterEngine
// viewController.arguments = arguments
//
// if let rootViewController = window?.rootViewController {
// rootViewController.present(viewController, animated: true, completion: nil)
// result("Storyboard \(storyboardName) launched successfully")
// } else {
// result(FlutterError(code: "UNAVAILABLE", message: "Root view controller is not available", details: nil))
// }
// }
//}

@ -15,13 +15,10 @@ class NativePluginLauncher {
"clientID": "HMG", "clientID": "HMG",
"username":"Aamir", "username":"Aamir",
"isSimulationModeEnabled":false, "isSimulationModeEnabled":false,
"isShowUserName":false, "isShowUserName":true,
"isUpdateUserLocationSmoothly":true, "isUpdateUserLocationSmoothly":true,
"isEnableReportIssue":true, "isEnableReportIssue":true,
"isShowBackButtonEnabled":false, "languageCode":"en",
"languageCode":"ar",
"deepLinkData":"deeplink",
"deepLinkSchema":"",
"clientKey": "UGVuZ3VpbklOX1Blbk5hdl9QSUY=", "clientKey": "UGVuZ3VpbklOX1Blbk5hdl9QSUY=",
"mapBoxKey": "sk.eyJ1IjoicndhaWQiLCJhIjoiY2x6NWo0bTMzMWZodzJrcGZpemYzc3Z4dSJ9.uSSZuwNSGCcCdPAiORECmg" "mapBoxKey": "sk.eyJ1IjoicndhaWQiLCJhIjoiY2x6NWo0bTMzMWZodzJrcGZpemYzc3Z4dSJ9.uSSZuwNSGCcCdPAiORECmg"
}); });

Loading…
Cancel
Save