commit d0709a4c5415ff1e43fa2509dd1d8b32518f92f4 Author: Aamir.Muhammad <> Date: Mon Aug 12 10:39:27 2024 +0300 Initial Commit diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..29a3a50 --- /dev/null +++ b/.gitignore @@ -0,0 +1,43 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.pub-cache/ +.pub/ +/build/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/.metadata b/.metadata new file mode 100644 index 0000000..65a4a37 --- /dev/null +++ b/.metadata @@ -0,0 +1,30 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "5dcb86f68f239346676ceb1ed1ea385bd215fba1" + channel: "stable" + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1 + base_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1 + - platform: android + create_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1 + base_revision: 5dcb86f68f239346676ceb1ed1ea385bd215fba1 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/README.md b/README.md new file mode 100644 index 0000000..59e38b0 --- /dev/null +++ b/README.md @@ -0,0 +1,53 @@ + +# PenNav (P&P) + +Experience top-tier, comprehensive campus-wide navigation with PenNav , featuring detailed 2D/3D maps and seamless home-to-office routing complete with step-by-step directions and tactile feedback. PenNav offers the flexibility to be seamlessly integrated into your current applications or used as a standalone app. PenNav ensures a smooth and effortless setup process, Enabling you to effortlessly customize your navigation solutions to suit your specific requirements. + +**Turn-by-turn guidance** +Turn-by-turn, indoor/outdoor real-time blue-dot experience with voice commands. PenNav offers outstanding accuracy and floor-level detection with several routing options. + +**Multi-floor routing** +Built from the ground up to support indoor navigation, floor-level detection and multi-floor navigation is at the core of what we do. Offering flexibility in connecting floors and buildings together offers navigation options which are unique and impressive. + +**Indoor/outdoor transition** +PenNav offers campus-wide and home-to-office options by leveraging GPS in outdoor navigation with seamless AI-driven indoor/outdoor transition detection. + +**Seamless Integration** +PenNav comes in a user-friendly package designed for effortless integration, featuring a vector-based map engine, comprehensive 2D/3D maps, and a full UI/UX experience that reduces integration time from weeks to hours. Its appearance is fully customizable, allowing it to mirror the client's brand through languages, colors, and typography options. + +--- + +## P&P Integration Guide for Flutter + + +## Overview +The Plug & Play module for Flutter is designed to offer a seamless integration with Penguin’s various SDKs, enabling quick incorporation into your Flutter applications for both iOS and Android platforms. This document serves as a demonstration of how to utilize the Plug & Play module within a Flutter app, showcasing a typical app structure and the integration process. + +**Key components of the demonstration include:** + + - **SDK Integration**: Examples of how to integrate PenNav SDKs into your Flutter project. + - **Flutter App Structure**: Guidance on organizing your Flutter app to efficiently use the Plug & Play module. + - **Cross-Platform Compatibility**: Instructions for ensuring the module works seamlessly on both iOS and Android. + +This guide will walk you through the steps to effectively implement and utilize the Plug & Play module within your Flutter applications. + +--- + + +#### Prerequisites + +- **Flutter SDK**: Ensure the Flutter SDK is installed. +- **Flutter Development Knowledge**: A foundational understanding of Flutter development for both iOS and Android platforms. +- **Penguin Native iOS Libraries**: Obtain the following libraries: `Penguin.xcframework`, `PenguinRenderer.xcframework`, and `PenNavUI.xcframework`. +- **PenNav Native Android Libraries**: Ensure the following libraries are available: `Penguin.aar`, `PenguinRenderer.aar`, and `PenNavUI.aar`. +- **Mapbox Account**: Register for a Mapbox account to acquire an access token required for Mapbox services. + +--- + +- ### [iOS Integration Guide for Flutter](doc/ios.md) + + This guide provides comprehensive instructions for integrating our native iOS libraries into a Flutter project. It details the steps required to set up and configure the libraries, ensuring they work seamlessly with your Flutter application on iOS. + +- ### [Android Integration Guide for Flutter](doc/android.md) + + This guide offers detailed instructions for incorporating our native Android libraries into a Flutter project. It covers the configuration and integration process, enabling smooth interaction between our libraries and your Flutter application on Android. \ No newline at end of file diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..0d29021 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,28 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at https://dart.dev/lints. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/android/.gitignore b/android/.gitignore new file mode 100644 index 0000000..6f56801 --- /dev/null +++ b/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/android/app/build.gradle b/android/app/build.gradle new file mode 100644 index 0000000..fd64e6c --- /dev/null +++ b/android/app/build.gradle @@ -0,0 +1,133 @@ +plugins { + id "com.android.application" + id "kotlin-android" + // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. + id "dev.flutter.flutter-gradle-plugin" +} + +def localProperties = new Properties() +def localPropertiesFile = rootProject.file("local.properties") +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader("UTF-8") { reader -> + localProperties.load(reader) + } +} + +def flutterVersionCode = localProperties.getProperty("flutter.versionCode") +if (flutterVersionCode == null) { + flutterVersionCode = "1" +} + +def flutterVersionName = localProperties.getProperty("flutter.versionName") +if (flutterVersionName == null) { + flutterVersionName = "1.0" +} + +android { + namespace = "com.eventtan.test.penguin_flutter_sample" + compileSdk = flutter.compileSdkVersion + ndkVersion = flutter.ndkVersion + + compileOptions { + coreLibraryDesugaringEnabled true + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + buildFeatures { + viewBinding true + dataBinding true + buildConfig true + } + + kotlinOptions { + jvmTarget = '17' + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId = "com.eventtan.test.penguin_flutter_sample" + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. + minSdk = 24 + targetSdk = flutter.targetSdkVersion + versionCode = flutterVersionCode.toInteger() + versionName = flutterVersionName + } + + + + signingConfigs { + release { + storeFile file("key.jks") + storePassword "123456" + keyAlias "key0" + keyPassword "123456" + } + + + } + + buildTypes { + release { + minifyEnabled true + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release + + + } + + debug { + debuggable true + minifyEnabled true + signingConfig signingConfigs.release + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + + + + + +} + +flutter { + source = "../.." +} + +dependencies { + coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4' + + + implementation 'androidx.appcompat:appcompat:1.4.0' + implementation 'com.google.android.material:material:1.9.0' + + implementation"androidx.multidex:multidex:2.0.1" + + + // Penguin Pre-libraries + implementation 'com.squareup.okhttp3:logging-interceptor:4.9.3' + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.retrofit2:converter-gson:2.9.0' + implementation 'com.squareup.retrofit2:adapter-java8:2.4.0' + implementation 'com.google.code.gson:gson:2.8.9' + implementation 'com.google.android.gms:play-services-location:21.0.1' + implementation 'com.squareup.okhttp3:okhttp:4.10.0' + implementation 'androidx.test.ext:junit:1.1.5' + implementation 'com.android.volley:volley:1.2.1' + def room_version = "2.4.0-alpha04" + implementation "androidx.room:room-runtime:$room_version" + annotationProcessor "androidx.room:room-compiler:$room_version" + implementation 'net.zetetic:android-database-sqlcipher:4.5.2' + implementation 'com.intuit.ssp:ssp-android:1.1.0' + implementation 'com.intuit.sdp:sdp-android:1.1.0' + implementation 'com.github.bumptech.glide:glide:4.12.0' + annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0' + implementation 'com.mapbox.maps:android:10.16.6' + + + implementation files('libs/PenNavUI.aar') + implementation files('libs/Penguin.aar') + implementation files('libs/PenguinRenderer.aar') + +} diff --git a/android/app/libs/PenNavUI.aar b/android/app/libs/PenNavUI.aar new file mode 100644 index 0000000..d1381b0 Binary files /dev/null and b/android/app/libs/PenNavUI.aar differ diff --git a/android/app/libs/Penguin.aar b/android/app/libs/Penguin.aar new file mode 100644 index 0000000..a531958 Binary files /dev/null and b/android/app/libs/Penguin.aar differ diff --git a/android/app/libs/PenguinRenderer.aar b/android/app/libs/PenguinRenderer.aar new file mode 100644 index 0000000..5e6da32 Binary files /dev/null and b/android/app/libs/PenguinRenderer.aar differ diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro new file mode 100644 index 0000000..b70298f --- /dev/null +++ b/android/app/proguard-rules.pro @@ -0,0 +1,49 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile + +-dontwarn org.bouncycastle.jsse.BCSSLParameters +-dontwarn org.bouncycastle.jsse.BCSSLSocket +-dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider +-dontwarn org.conscrypt.Conscrypt$Version +-dontwarn org.conscrypt.Conscrypt +-dontwarn org.conscrypt.ConscryptHostnameVerifier +-dontwarn org.openjsse.javax.net.ssl.SSLParameters +-dontwarn org.openjsse.javax.net.ssl.SSLSocket +-dontwarn org.openjsse.net.ssl.OpenJSSE + +-dontwarn penguin.com.pennav.Model.Navigation.NearLandmark + +-keep,includedescriptorclasses class net.sqlcipher.** { *; } +-keep,includedescriptorclasses interface net.sqlcipher.** { *; } + +-keep class retrofit2.** { *; } +-keep class okhttp3.** { *; } +-dontwarn retrofit2.** + +-keep class com.google.gson.** { *; } +-dontwarn com.google.gson.** + +# Penguin classes +-keep class com.peng.pennavmap.models.** { *; } +-keep class com.peng.pennavmap.db.** { *; } + + diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /dev/null +++ b/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..b47a018 --- /dev/null +++ b/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/kotlin/com/eventtan/test/penguin_flutter_sample/MainActivity.kt b/android/app/src/main/kotlin/com/eventtan/test/penguin_flutter_sample/MainActivity.kt new file mode 100644 index 0000000..a1f7f33 --- /dev/null +++ b/android/app/src/main/kotlin/com/eventtan/test/penguin_flutter_sample/MainActivity.kt @@ -0,0 +1,66 @@ +package com.eventtan.test.penguin_flutter_sample + +import android.content.Intent +import android.content.pm.PackageManager +import android.util.Log +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.PermissionManager +import io.flutter.embedding.android.FlutterActivity +import io.flutter.embedding.engine.FlutterEngine + + +/** + * The main activity for the Flutter application. + * This activity is responsible for configuring the Flutter engine and registering platform view factories. + */ +class MainActivity : FlutterActivity() { + + + + private lateinit var flutterEngine: FlutterEngine + + /** + * Configures the Flutter engine by registering platform view factories. + * + * @param flutterEngine The [FlutterEngine] instance associated with this activity. + */ + override fun configureFlutterEngine(flutterEngine: 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 + ) + + + ) + } + + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + + val granted = grantResults.all { it == PackageManager.PERMISSION_GRANTED } + + val intent = Intent("PERMISSION_RESULT_ACTION").apply { + putExtra("PERMISSION_GRANTED", granted) + } + sendBroadcast(intent) + + // Log the request code and permission results + Log.d("PermissionsResult", "Request Code: $requestCode") + Log.d("PermissionsResult", "Permissions: ${permissions.joinToString()}") + Log.d("PermissionsResult", "Grant Results: ${grantResults.joinToString()}") + + } + + +} + diff --git a/android/app/src/main/kotlin/com/eventtan/test/penguin_flutter_sample/PermissionManager/PermissionHelper.kt b/android/app/src/main/kotlin/com/eventtan/test/penguin_flutter_sample/PermissionManager/PermissionHelper.kt new file mode 100644 index 0000000..b57e257 --- /dev/null +++ b/android/app/src/main/kotlin/com/eventtan/test/penguin_flutter_sample/PermissionManager/PermissionHelper.kt @@ -0,0 +1,21 @@ +package com.eventtan.test.penguin_flutter_sample.PermissionManager + +import android.Manifest + +object PermissionHelper { + + fun getRequiredPermissions(): Array { + return arrayOf( + Manifest.permission.INTERNET, + Manifest.permission.ACCESS_FINE_LOCATION, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.ACCESS_NETWORK_STATE, + Manifest.permission.BLUETOOTH, + Manifest.permission.BLUETOOTH_ADMIN, + Manifest.permission.BLUETOOTH_SCAN, + Manifest.permission.BLUETOOTH_CONNECT, + Manifest.permission.HIGH_SAMPLING_RATE_SENSORS, + Manifest.permission.ACTIVITY_RECOGNITION + ) + } +} \ No newline at end of file diff --git a/android/app/src/main/kotlin/com/eventtan/test/penguin_flutter_sample/PermissionManager/PermissionManager.kt b/android/app/src/main/kotlin/com/eventtan/test/penguin_flutter_sample/PermissionManager/PermissionManager.kt new file mode 100644 index 0000000..6fd3ea5 --- /dev/null +++ b/android/app/src/main/kotlin/com/eventtan/test/penguin_flutter_sample/PermissionManager/PermissionManager.kt @@ -0,0 +1,50 @@ +package com.eventtan.test.penguin_flutter_sample.PermissionManager + +import android.app.Activity +import android.content.Context +import android.content.pm.PackageManager +import android.os.Build +import androidx.core.app.ActivityCompat +import androidx.core.content.ContextCompat + +class PermissionManager( + private val context: Context, + val listener: PermissionListener, + private val requestCode: Int, + vararg permissions: String +) { + + private val permissionsArray = permissions + + interface PermissionListener { + fun onPermissionGranted() + fun onPermissionDenied() + } + + fun arePermissionsGranted(): Boolean { + return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + permissionsArray.all { + ContextCompat.checkSelfPermission(context, it) == PackageManager.PERMISSION_GRANTED + } + } else { + true + } + } + + fun requestPermissions(activity: Activity) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + ActivityCompat.requestPermissions(activity, permissionsArray, requestCode) + } + } + + fun handlePermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) { + if (this.requestCode == requestCode) { + val allGranted = grantResults.all { it == PackageManager.PERMISSION_GRANTED } + if (allGranted) { + listener.onPermissionGranted() + } else { + listener.onPermissionDenied() + } + } + } +} \ No newline at end of file diff --git a/android/app/src/main/kotlin/com/eventtan/test/penguin_flutter_sample/PermissionManager/PermissionResultReceiver.kt b/android/app/src/main/kotlin/com/eventtan/test/penguin_flutter_sample/PermissionManager/PermissionResultReceiver.kt new file mode 100644 index 0000000..b28f8cc --- /dev/null +++ b/android/app/src/main/kotlin/com/eventtan/test/penguin_flutter_sample/PermissionManager/PermissionResultReceiver.kt @@ -0,0 +1,15 @@ +package com.eventtan.test.penguin_flutter_sample.PermissionManager + +// PermissionResultReceiver.kt +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Intent + +class PermissionResultReceiver( + private val callback: (Boolean) -> Unit +) : BroadcastReceiver() { + override fun onReceive(context: Context?, intent: Intent?) { + val granted = intent?.getBooleanExtra("PERMISSION_GRANTED", false) ?: false + callback(granted) + } +} \ No newline at end of file diff --git a/android/app/src/main/kotlin/com/eventtan/test/penguin_flutter_sample/penguin/PenguinView.kt b/android/app/src/main/kotlin/com/eventtan/test/penguin_flutter_sample/penguin/PenguinView.kt new file mode 100644 index 0000000..ebdb83c --- /dev/null +++ b/android/app/src/main/kotlin/com/eventtan/test/penguin_flutter_sample/penguin/PenguinView.kt @@ -0,0 +1,230 @@ +package com.eventtan.app.penguin_flutter_sample.penguin + +import android.app.Activity +import android.content.Context +import android.content.IntentFilter +import android.graphics.Color +import android.os.Handler +import android.os.Looper +import android.util.Log +import android.view.View +import android.view.ViewGroup +import android.widget.RelativeLayout +import android.widget.Toast +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 +import com.eventtan.test.penguin_flutter_sample.PermissionManager.PermissionResultReceiver +import com.peng.pennavmap.PlugAndPlayConfiguration +import com.peng.pennavmap.PlugAndPlaySDK +import com.peng.pennavmap.enums.InitializationErrorType +import com.peng.pennavmap.interfaces.PenNavUIDelegate +import com.peng.pennavmap.utils.Languages +import io.flutter.plugin.common.BinaryMessenger +import io.flutter.plugin.common.MethodCall +import io.flutter.plugin.common.MethodChannel +import io.flutter.plugin.platform.PlatformView + +/** + * Custom PlatformView for displaying Penguin UI components within a Flutter app. + * Implements `PlatformView` for rendering the view, `MethodChannel.MethodCallHandler` for handling method calls, + * and `PenNavUIDelegate` for handling SDK events. + */ +internal class PenguinView( + context: Context, + id: Int, + creationParams: Map?, + 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 permissionResultReceiver: PermissionResultReceiver + private val permissionIntentFilter = IntentFilter("PERMISSION_RESULT_ACTION") + + private companion object { + const val PERMISSIONS_REQUEST_CODE = 1 + } + + private lateinit var permissionManager: PermissionManager + + // Reference to the main activity + private var _activity: Activity = activity + + private lateinit var mContext: Context + + init { + // Set layout parameters for the mapLayout + mapLayout.layoutParams = ViewGroup.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT + ) + + mContext = (_activity as MainActivity).context + + + permissionResultReceiver = PermissionResultReceiver { granted -> + if (granted) { + onPermissionsGranted() + } else { + onPermissionsDenied() + } + } + + mContext.registerReceiver(permissionResultReceiver, permissionIntentFilter) + + // Set the background color of the layout + mapLayout.setBackgroundColor(Color.RED) + + permissionManager = PermissionManager( + context = mContext, + listener = object : PermissionManager.PermissionListener { + override fun onPermissionGranted() { + // Handle permissions granted + onPermissionsGranted() + } + + override fun onPermissionDenied() { + // Handle permissions denied + onPermissionsDenied() + } + }, + requestCode = PERMISSIONS_REQUEST_CODE, + *PermissionHelper.getRequiredPermissions() + ) + + if (!permissionManager.arePermissionsGranted()) { + permissionManager.requestPermissions(_activity) + } else { + // Permissions already granted + permissionManager.listener.onPermissionGranted() + } + + + + } + + private fun onPermissionsGranted() { + // Handle the actions when permissions are granted + Log.d("PermissionsResult", "onPermissionsGranted") + // Register the platform view factory for creating custom views + + // Initialize the Penguin SDK + initPenguin() + + + + } + + private fun onPermissionsDenied() { + // Handle the actions when permissions are denied + Log.d("PermissionsResult", "onPermissionsDenied") + + } + + /** + * Returns the view associated with this PlatformView. + * + * @return The main view for this PlatformView. + */ + override fun getView(): View { + return mapLayout + } + + /** + * Cleans up resources associated with this PlatformView. + */ + override fun dispose() { + // Cleanup code if needed + } + + /** + * Handles method calls from Dart code. + * + * @param call The method call from Dart. + * @param result The result callback to send responses back to Dart. + */ + override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) { + // Handle method calls from Dart code here + } + + /** + * Initializes the Penguin SDK with custom configuration and delegates. + */ + 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") + .setUserName("client") + .setLanguageID(Languages.en) + .setSimulationModeEnabled(true) + .setEnableBackButton(true) + .setDeepLinkData("deeplink") + .setCustomizeColor("#2CA0AF") + .setDeepLinkSchema("") + .setDeepLinkData(null) + .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 { } + + // Start the Penguin SDK + PlugAndPlaySDK.start(mContext, this) + } + + /** + * Called when Penguin UI setup is successful. + * + * @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() + } + } + } + + /** + * 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? + ) { + 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") + } + } +} + diff --git a/android/app/src/main/kotlin/com/eventtan/test/penguin_flutter_sample/penguin/PenguinViewFactory.kt b/android/app/src/main/kotlin/com/eventtan/test/penguin_flutter_sample/penguin/PenguinViewFactory.kt new file mode 100644 index 0000000..5ba640f --- /dev/null +++ b/android/app/src/main/kotlin/com/eventtan/test/penguin_flutter_sample/penguin/PenguinViewFactory.kt @@ -0,0 +1,38 @@ +package com.eventtan.app.penguin_flutter_sample.penguin + +import android.content.Context +import com.eventtan.test.penguin_flutter_sample.MainActivity +import io.flutter.plugin.common.BinaryMessenger +import io.flutter.plugin.common.StandardMessageCodec +import io.flutter.plugin.platform.PlatformView +import io.flutter.plugin.platform.PlatformViewFactory + +// PenguinViewFactory.kt + +/** + * A factory class for creating instances of [PenguinView]. + * + * @property messenger The [BinaryMessenger] used for communication. + * @property mainActivity The [MainActivity] instance associated with this view. + */ +class PenguinViewFactory( + private val messenger: BinaryMessenger, + private val mainActivity: MainActivity +) : PlatformViewFactory(StandardMessageCodec.INSTANCE) { + + /** + * Creates a new [PenguinView] instance. + * + * @param context The [Context] in which the view is running. + * @param viewId The unique ID of the view to be created. + * @param args Optional arguments passed for creating the view, expected to be a [Map]. + * @return A new instance of [PenguinView]. + */ + override fun create(context: Context, viewId: Int, args: Any?): PlatformView { + // Cast the arguments to a Map if they are provided + val creationParams = args as Map? + + // Instantiate and return the PenguinView with the provided parameters + return PenguinView(context, viewId, creationParams, messenger, mainActivity) + } +} \ No newline at end of file diff --git a/android/app/src/main/res/drawable-v21/launch_background.xml b/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..f74085f --- /dev/null +++ b/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/android/app/src/main/res/drawable/launch_background.xml b/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000..304732f --- /dev/null +++ b/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..db77bb4 Binary files /dev/null and b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..17987b7 Binary files /dev/null and b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..09d4391 Binary files /dev/null and b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..d5f1c8d Binary files /dev/null and b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..4d6372e Binary files /dev/null and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/values-night/styles.xml b/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..06952be --- /dev/null +++ b/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/android/app/src/main/res/values/colors.xml b/android/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..4e98d62 --- /dev/null +++ b/android/app/src/main/res/values/colors.xml @@ -0,0 +1,15 @@ + + + #FF018786 + #FF000000 + #FFFFFFFF + #EFEFEF + #2CA0AF + #d32f2f + #00000000 + #FFC107 + #3392E2 + #53973B + #DC0000 + #E5E4E4 + \ No newline at end of file diff --git a/android/app/src/main/res/values/dimens.xml b/android/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..1afc247 --- /dev/null +++ b/android/app/src/main/res/values/dimens.xml @@ -0,0 +1,9 @@ + + + 10.00dp + 15.00dp + 16.00dp + 25.00dp + 40.00dp + 60.00dp + \ No newline at end of file diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..4e0eefd --- /dev/null +++ b/android/app/src/main/res/values/strings.xml @@ -0,0 +1,17 @@ + + + Penguin_flutter_Sample + + ///////////////////////////////////////////////// + + https://temp.nav.penguinin.com + api + https://temp.nav.penguinin.com + pe + PIF + UGVuZ3VpbklOX1Blbk5hdl9QSUY= + + + mapbox_token + //////////////////////////////////////////// + \ No newline at end of file diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..8916c4c --- /dev/null +++ b/android/app/src/main/res/values/styles.xml @@ -0,0 +1,28 @@ + + + + + + + + + + +