diff --git a/README.md b/README.md index 02077b8..0cc598c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +This is a copy of darryncampbell's repo, updated to work with flutter 3.13.8 and recent AndroidStudio. Tested on TC26 + *Please be aware that this application / sample is provided as-is for demonstration purposes without any guarantee of support* ========================================================= @@ -71,7 +73,7 @@ EventChannel(flutterEngine.dartExecutor, SCAN_CHANNEL).setStreamHandler( val intentFilter = IntentFilter() intentFilter.addAction(PROFILE_INTENT_ACTION) registerReceiver( - dataWedgeBroadcastReceiver, intentFilter) + dataWedgeBroadcastReceiver, intentFilter, RECEIVER_EXPORTED) } override fun onCancel(arguments: Any?) { diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..ea5e85e --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,46 @@ +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") +} + +android { + namespace = "com.darryncampbell.datawedgeflutter" + compileSdk = flutter.compileSdkVersion + ndkVersion = flutter.ndkVersion + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_11.toString() + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId = "com.darryncampbell.datawedgeflutter" + // You can update the following values to match your application needs. + // For more information, see: https://flutter.dev/to/review-gradle-config. + // registerReceiver() needs minSdk of 26 + minSdk = 26 // flutter.minSdkVersion + // RECEIVER_EXPORTED (required in Android 14) needs targetSdk of 33 + targetSdk = 33 // flutter.targetSdkVersion + versionCode = flutter.versionCode + versionName = flutter.versionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig = signingConfigs.getByName("debug") + } + } +} + +flutter { + source = "../.." +} diff --git a/datawedge_flutter/.fvmrc b/datawedge_flutter/.fvmrc new file mode 100644 index 0000000..a4d5f6d --- /dev/null +++ b/datawedge_flutter/.fvmrc @@ -0,0 +1,3 @@ +{ + "flutter": "3.35.4" +} \ No newline at end of file diff --git a/datawedge_flutter/.gitignore b/datawedge_flutter/.gitignore index 1ba9c33..1b6a1cc 100644 --- a/datawedge_flutter/.gitignore +++ b/datawedge_flutter/.gitignore @@ -8,6 +8,7 @@ .buildlog/ .history .svn/ +migrate_working_dir/ # IntelliJ related *.iml @@ -22,6 +23,7 @@ # Flutter/Dart/Pub related **/doc/api/ +**/ios/Flutter/.last_build_id .dart_tool/ .flutter-plugins .flutter-plugins-dependencies @@ -30,14 +32,19 @@ .pub/ /build/ -# Web related -lib/generated_plugin_registrant.dart - # 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 + # Exceptions to above rules. !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages + +# FVM Version Cache +.fvm/ \ No newline at end of file diff --git a/datawedge_flutter/README.md b/datawedge_flutter/README.md index eb8a875..ed83040 100644 --- a/datawedge_flutter/README.md +++ b/datawedge_flutter/README.md @@ -8,9 +8,9 @@ This project is a starting point for a Flutter application. A few resources to get you started if this is your first Flutter project: -- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) -- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) +- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) -For help getting started with Flutter, view our -[online documentation](https://flutter.dev/docs), which offers tutorials, +For help getting started with Flutter development, view the +[online documentation](https://docs.flutter.dev/), which offers tutorials, samples, guidance on mobile development, and a full API reference. diff --git a/datawedge_flutter/android/.gitignore b/datawedge_flutter/android/.gitignore index bc2100d..6f56801 100644 --- a/datawedge_flutter/android/.gitignore +++ b/datawedge_flutter/android/.gitignore @@ -5,3 +5,9 @@ gradle-wrapper.jar /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/datawedge_flutter/android/app/build.gradle b/datawedge_flutter/android/app/build.gradle deleted file mode 100644 index f7c4535..0000000 --- a/datawedge_flutter/android/app/build.gradle +++ /dev/null @@ -1,63 +0,0 @@ -def localProperties = new Properties() -def localPropertiesFile = rootProject.file('local.properties') -if (localPropertiesFile.exists()) { - localPropertiesFile.withReader('UTF-8') { reader -> - localProperties.load(reader) - } -} - -def flutterRoot = localProperties.getProperty('flutter.sdk') -if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") -} - -def flutterVersionCode = localProperties.getProperty('flutter.versionCode') -if (flutterVersionCode == null) { - flutterVersionCode = '1' -} - -def flutterVersionName = localProperties.getProperty('flutter.versionName') -if (flutterVersionName == null) { - flutterVersionName = '1.0' -} - -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" - -android { - compileSdkVersion 28 - - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - } - - lintOptions { - disable 'InvalidPackage' - } - - defaultConfig { - applicationId "com.darryncampbell.datawedgeflutter" - minSdkVersion 16 - targetSdkVersion 28 - versionCode flutterVersionCode.toInteger() - versionName flutterVersionName - } - - buildTypes { - release { - // TODO: Add your own signing config for the release build. - // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig signingConfigs.debug - } - } -} - -flutter { - source '../..' -} - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' -} diff --git a/datawedge_flutter/android/app/build.gradle.kts b/datawedge_flutter/android/app/build.gradle.kts new file mode 100644 index 0000000..00c3ea5 --- /dev/null +++ b/datawedge_flutter/android/app/build.gradle.kts @@ -0,0 +1,45 @@ +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") +} + +android { + namespace = "com.darryncampbell.datawedgeflutter" + compileSdk = flutter.compileSdkVersion + ndkVersion = flutter.ndkVersion + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_11.toString() + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId = "com.darryncampbell.datawedgeflutter" + // You can update the following values to match your application needs. + // For more information, see: https://flutter.dev/to/review-gradle-config. + // @@ registerReceiver() needs minSdk of 26 + minSdk = 26 // flutter.minSdkVersion + targetSdk = flutter.targetSdkVersion + versionCode = flutter.versionCode + versionName = flutter.versionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig = signingConfigs.getByName("debug") + } + } +} + +flutter { + source = "../.." +} diff --git a/datawedge_flutter/android/app/src/debug/AndroidManifest.xml b/datawedge_flutter/android/app/src/debug/AndroidManifest.xml index 9b47a44..399f698 100644 --- a/datawedge_flutter/android/app/src/debug/AndroidManifest.xml +++ b/datawedge_flutter/android/app/src/debug/AndroidManifest.xml @@ -1,6 +1,6 @@ - - diff --git a/datawedge_flutter/android/app/src/main/AndroidManifest.xml b/datawedge_flutter/android/app/src/main/AndroidManifest.xml index b6f3e84..0309c43 100644 --- a/datawedge_flutter/android/app/src/main/AndroidManifest.xml +++ b/datawedge_flutter/android/app/src/main/AndroidManifest.xml @@ -1,17 +1,13 @@ - - + - - @@ -44,4 +31,15 @@ android:name="flutterEmbedding" android:value="2" /> + + + + + + + diff --git a/datawedge_flutter/android/app/src/main/kotlin/com/darryncampbell/datawedgeflutter/DWSetup.kt b/datawedge_flutter/android/app/src/main/kotlin/com/darryncampbell/datawedgeflutter/DWSetup.kt new file mode 100644 index 0000000..b84f2af --- /dev/null +++ b/datawedge_flutter/android/app/src/main/kotlin/com/darryncampbell/datawedgeflutter/DWSetup.kt @@ -0,0 +1,159 @@ +package com.darryncampbell.datawedgeflutter + +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Context.RECEIVER_EXPORTED +import android.content.Intent +import android.content.IntentFilter +import android.os.Bundle +import android.util.Log +import io.flutter.embedding.android.FlutterActivity +import io.flutter.embedding.engine.FlutterEngine +import io.flutter.plugin.common.EventChannel +import io.flutter.plugin.common.EventChannel.EventSink +import io.flutter.plugin.common.EventChannel.StreamHandler +import io.flutter.plugin.common.MethodChannel +import org.json.JSONObject +import java.text.SimpleDateFormat +import java.util.Calendar + +// This sample implementation is heavily based on the flutter demo at +// https://github.com/flutter/flutter/blob/master/examples/platform_channel/android/app/src/main/java/com/example/platformchannel/MainActivity.java + +class DWSetup(private val flutterActivity: FlutterActivity) { + private val COMMAND_CHANNEL = "com.darryncampbell.datawedgeflutter/command" + private val SCAN_CHANNEL = "com.darryncampbell.datawedgeflutter/scan" + private val PROFILE_INTENT_ACTION = "com.darryncampbell.datawedgeflutter.SCAN" + private val PROFILE_INTENT_BROADCAST = "2" + + private val dwInterface = DWInterface() + + private val LOGTAG = "DWSetup" + + fun setupHandlers(flutterEngine: FlutterEngine) { + Log.i(LOGTAG, "setupHandlers setStreamHandler") + EventChannel(flutterEngine.dartExecutor, SCAN_CHANNEL).setStreamHandler( + object : StreamHandler { + private var dataWedgeBroadcastReceiver: BroadcastReceiver? = null + override fun onListen(arguments: Any?, events: EventSink?) { + dataWedgeBroadcastReceiver = createDataWedgeBroadcastReceiver(events) + val intentFilter = IntentFilter() + intentFilter.addAction(PROFILE_INTENT_ACTION) + intentFilter.addAction(DWInterface.DATAWEDGE_RETURN_ACTION) + intentFilter.addCategory(DWInterface.DATAWEDGE_RETURN_CATEGORY) + try { + flutterActivity.registerReceiver( + dataWedgeBroadcastReceiver, intentFilter, RECEIVER_EXPORTED + ) + } catch (e: Exception) { + Log.i(LOGTAG, "Unable to register receiver $e") + } + } + + override fun onCancel(arguments: Any?) { + flutterActivity.unregisterReceiver(dataWedgeBroadcastReceiver) + dataWedgeBroadcastReceiver = null + } + } + ) + + Log.i(LOGTAG, "setupHandlers setMethodCallHandler") + MethodChannel( + flutterEngine.dartExecutor, + COMMAND_CHANNEL + ).setMethodCallHandler { call, result -> + Log.i(LOGTAG, "setMethodCallHandler " + call.method) + if (call.method == "sendDataWedgeCommandStringParameter") { + val arguments = JSONObject(call.arguments.toString()) + val command: String = arguments.get("command") as String + val parameter: String = arguments.get("parameter") as String + dwInterface.sendCommandString( + flutterActivity.applicationContext, + command, + parameter + ) + // result.success(0); // DataWedge does not return responses + } else if (call.method == "createDataWedgeProfile") { + createDataWedgeProfile(call.arguments.toString()) + } else { + result.notImplemented() + } + } + Log.i(LOGTAG, "setupHandlers completed") + } + + private fun createDataWedgeBroadcastReceiver(events: EventSink?): BroadcastReceiver { + Log.i(LOGTAG, "createDataWedgeBroadcastReceiver") + return object : BroadcastReceiver() { + override fun onReceive(context: Context, intent: Intent) { + if (intent.action.equals(PROFILE_INTENT_ACTION)) { + // A barcode has been scanned + val scanData = + intent.getStringExtra(DWInterface.DATAWEDGE_SCAN_EXTRA_DATA_STRING) + val symbology = + intent.getStringExtra(DWInterface.DATAWEDGE_SCAN_EXTRA_LABEL_TYPE) + val date = Calendar.getInstance().time + val df = SimpleDateFormat("yyyy-MM-dd HH:mm:ss") + val dateTimeString = df.format(date) + val currentScan = + Scan(scanData.toString(), symbology.toString(), dateTimeString) + events?.success(currentScan.toJson()) + } + // Could handle return values from DW here such as RETURN_GET_ACTIVE_PROFILE + // or RETURN_ENUMERATE_SCANNERS + } + } + } + + private fun createDataWedgeProfile(profileName: String) { + Log.i(LOGTAG, "createDataWedgeProfile " + profileName) + // Create and configure the DataWedge profile associated with this application + // For readability's sake, I have not defined each of the keys in the DWInterface file + dwInterface.sendCommandString( + flutterActivity, + DWInterface.DATAWEDGE_SEND_CREATE_PROFILE, + profileName + ) + val profileConfig = Bundle() + profileConfig.putString("PROFILE_NAME", profileName) + profileConfig.putString("PROFILE_ENABLED", "true") // These are all strings + profileConfig.putString("CONFIG_MODE", "UPDATE") + val barcodeConfig = Bundle() + barcodeConfig.putString("PLUGIN_NAME", "BARCODE") + barcodeConfig.putString( + "RESET_CONFIG", + "true" + ) // This is the default but never hurts to specify + val barcodeProps = Bundle() + barcodeConfig.putBundle("PARAM_LIST", barcodeProps) + profileConfig.putBundle("PLUGIN_CONFIG", barcodeConfig) + val appConfig = Bundle() + appConfig.putString( + "PACKAGE_NAME", + flutterActivity.packageName + ) // Associate the profile with this app + appConfig.putStringArray("ACTIVITY_LIST", arrayOf("*")) + profileConfig.putParcelableArray("APP_LIST", arrayOf(appConfig)) + dwInterface.sendCommandBundle( + flutterActivity, + DWInterface.DATAWEDGE_SEND_SET_CONFIG, + profileConfig + ) + // You can only configure one plugin at a time in some versions of DW, now do the intent output + profileConfig.remove("PLUGIN_CONFIG") + val intentConfig = Bundle() + intentConfig.putString("PLUGIN_NAME", "INTENT") + intentConfig.putString("RESET_CONFIG", "true") + val intentProps = Bundle() + intentProps.putString("intent_output_enabled", "true") + intentProps.putString("intent_action", PROFILE_INTENT_ACTION) + intentProps.putString("intent_delivery", PROFILE_INTENT_BROADCAST) // "2" + intentConfig.putBundle("PARAM_LIST", intentProps) + profileConfig.putBundle("PLUGIN_CONFIG", intentConfig) + dwInterface.sendCommandBundle( + flutterActivity, + DWInterface.DATAWEDGE_SEND_SET_CONFIG, + profileConfig + ) + } +} diff --git a/datawedge_flutter/android/app/src/main/kotlin/com/darryncampbell/datawedgeflutter/MainActivity.kt b/datawedge_flutter/android/app/src/main/kotlin/com/darryncampbell/datawedgeflutter/MainActivity.kt index 2fdbbb5..8212764 100644 --- a/datawedge_flutter/android/app/src/main/kotlin/com/darryncampbell/datawedgeflutter/MainActivity.kt +++ b/datawedge_flutter/android/app/src/main/kotlin/com/darryncampbell/datawedgeflutter/MainActivity.kt @@ -1,120 +1,17 @@ package com.darryncampbell.datawedgeflutter -import android.content.* -import android.os.Bundle import io.flutter.embedding.android.FlutterActivity import io.flutter.embedding.engine.FlutterEngine -import io.flutter.plugin.common.EventChannel -import io.flutter.plugin.common.EventChannel.EventSink -import io.flutter.plugin.common.EventChannel.StreamHandler -import io.flutter.plugin.common.MethodChannel -import org.json.JSONObject -import java.text.SimpleDateFormat -import java.util.* -import io.flutter.plugins.GeneratedPluginRegistrant; // This sample implementation is heavily based on the flutter demo at // https://github.com/flutter/flutter/blob/master/examples/platform_channel/android/app/src/main/java/com/example/platformchannel/MainActivity.java -class MainActivity: FlutterActivity() { - private val COMMAND_CHANNEL = "com.darryncampbell.datawedgeflutter/command" - private val SCAN_CHANNEL = "com.darryncampbell.datawedgeflutter/scan" - private val PROFILE_INTENT_ACTION = "com.darryncampbell.datawedgeflutter.SCAN" - private val PROFILE_INTENT_BROADCAST = "2" +class MainActivity : FlutterActivity() { - private val dwInterface = DWInterface() + private val dwSetup = DWSetup(this) override fun configureFlutterEngine(flutterEngine: FlutterEngine) { - GeneratedPluginRegistrant.registerWith(flutterEngine) - EventChannel(flutterEngine.dartExecutor, SCAN_CHANNEL).setStreamHandler( - object : StreamHandler { - private var dataWedgeBroadcastReceiver: BroadcastReceiver? = null - override fun onListen(arguments: Any?, events: EventSink?) { - dataWedgeBroadcastReceiver = createDataWedgeBroadcastReceiver(events) - val intentFilter = IntentFilter() - intentFilter.addAction(PROFILE_INTENT_ACTION) - intentFilter.addAction(DWInterface.DATAWEDGE_RETURN_ACTION) - intentFilter.addCategory(DWInterface.DATAWEDGE_RETURN_CATEGORY) - registerReceiver( - dataWedgeBroadcastReceiver, intentFilter) - } - - override fun onCancel(arguments: Any?) { - unregisterReceiver(dataWedgeBroadcastReceiver) - dataWedgeBroadcastReceiver = null - } - } - ) - - MethodChannel(flutterEngine.dartExecutor, COMMAND_CHANNEL).setMethodCallHandler { call, result -> - if (call.method == "sendDataWedgeCommandStringParameter") - { - val arguments = JSONObject(call.arguments.toString()) - val command: String = arguments.get("command") as String - val parameter: String = arguments.get("parameter") as String - dwInterface.sendCommandString(applicationContext, command, parameter) - // result.success(0); // DataWedge does not return responses - } - else if (call.method == "createDataWedgeProfile") - { - createDataWedgeProfile(call.arguments.toString()) - } - else { - result.notImplemented() - } - } - } - - private fun createDataWedgeBroadcastReceiver(events: EventSink?): BroadcastReceiver? { - return object : BroadcastReceiver() { - override fun onReceive(context: Context, intent: Intent) { - if (intent.action.equals(PROFILE_INTENT_ACTION)) - { - // A barcode has been scanned - var scanData = intent.getStringExtra(DWInterface.DATAWEDGE_SCAN_EXTRA_DATA_STRING) - var symbology = intent.getStringExtra(DWInterface.DATAWEDGE_SCAN_EXTRA_LABEL_TYPE) - var date = Calendar.getInstance().getTime() - var df = SimpleDateFormat("dd/MM/yyyy HH:mm:ss") - var dateTimeString = df.format(date) - var currentScan = Scan(scanData, symbology, dateTimeString); - events?.success(currentScan.toJson()) - } - // Could handle return values from DW here such as RETURN_GET_ACTIVE_PROFILE - // or RETURN_ENUMERATE_SCANNERS - } - } - } - - private fun createDataWedgeProfile(profileName: String) { - // Create and configure the DataWedge profile associated with this application - // For readability's sake, I have not defined each of the keys in the DWInterface file - dwInterface.sendCommandString(this, DWInterface.DATAWEDGE_SEND_CREATE_PROFILE, profileName) - val profileConfig = Bundle() - profileConfig.putString("PROFILE_NAME", profileName) - profileConfig.putString("PROFILE_ENABLED", "true") // These are all strings - profileConfig.putString("CONFIG_MODE", "UPDATE") - val barcodeConfig = Bundle() - barcodeConfig.putString("PLUGIN_NAME", "BARCODE") - barcodeConfig.putString("RESET_CONFIG", "true") // This is the default but never hurts to specify - val barcodeProps = Bundle() - barcodeConfig.putBundle("PARAM_LIST", barcodeProps) - profileConfig.putBundle("PLUGIN_CONFIG", barcodeConfig) - val appConfig = Bundle() - appConfig.putString("PACKAGE_NAME", packageName) // Associate the profile with this app - appConfig.putStringArray("ACTIVITY_LIST", arrayOf("*")) - profileConfig.putParcelableArray("APP_LIST", arrayOf(appConfig)) - dwInterface.sendCommandBundle(this, DWInterface.DATAWEDGE_SEND_SET_CONFIG, profileConfig) - // You can only configure one plugin at a time in some versions of DW, now do the intent output - profileConfig.remove("PLUGIN_CONFIG") - val intentConfig = Bundle() - intentConfig.putString("PLUGIN_NAME", "INTENT") - intentConfig.putString("RESET_CONFIG", "true") - val intentProps = Bundle() - intentProps.putString("intent_output_enabled", "true") - intentProps.putString("intent_action", PROFILE_INTENT_ACTION) - intentProps.putString("intent_delivery", PROFILE_INTENT_BROADCAST) // "2" - intentConfig.putBundle("PARAM_LIST", intentProps) - profileConfig.putBundle("PLUGIN_CONFIG", intentConfig) - dwInterface.sendCommandBundle(this, DWInterface.DATAWEDGE_SEND_SET_CONFIG, profileConfig) + dwSetup.setupHandlers(flutterEngine) + super.configureFlutterEngine(flutterEngine) } } diff --git a/datawedge_flutter/android/app/src/main/kotlin/com/darryncampbell/datawedgeflutter/Scan.kt b/datawedge_flutter/android/app/src/main/kotlin/com/darryncampbell/datawedgeflutter/Scan.kt index 781073e..68bf561 100644 --- a/datawedge_flutter/android/app/src/main/kotlin/com/darryncampbell/datawedgeflutter/Scan.kt +++ b/datawedge_flutter/android/app/src/main/kotlin/com/darryncampbell/datawedgeflutter/Scan.kt @@ -2,14 +2,15 @@ package com.darryncampbell.datawedgeflutter import org.json.JSONObject; -class Scan(val data: String, val symbology: String, val dateTime: String) -{ - fun toJson(): String{ - return JSONObject(mapOf( - "scanData" to this.data, - "symbology" to this.symbology, - "dateTime" to this.dateTime - )).toString(); +class Scan(val data: String, val symbology: String, val dateTime: String) { + fun toJson(): String { + return JSONObject( + mapOf( + "scanData" to this.data, + "symbology" to this.symbology, + "dateTime" to this.dateTime + ) + ).toString(); } } diff --git a/datawedge_flutter/android/app/src/main/res/values/styles.xml b/datawedge_flutter/android/app/src/main/res/values/styles.xml index 1f83a33..cb1ef88 100644 --- a/datawedge_flutter/android/app/src/main/res/values/styles.xml +++ b/datawedge_flutter/android/app/src/main/res/values/styles.xml @@ -1,18 +1,18 @@ - - - diff --git a/datawedge_flutter/android/app/src/profile/AndroidManifest.xml b/datawedge_flutter/android/app/src/profile/AndroidManifest.xml index 9b47a44..399f698 100644 --- a/datawedge_flutter/android/app/src/profile/AndroidManifest.xml +++ b/datawedge_flutter/android/app/src/profile/AndroidManifest.xml @@ -1,6 +1,6 @@ - - diff --git a/datawedge_flutter/android/build.gradle b/datawedge_flutter/android/build.gradle deleted file mode 100644 index 3100ad2..0000000 --- a/datawedge_flutter/android/build.gradle +++ /dev/null @@ -1,31 +0,0 @@ -buildscript { - ext.kotlin_version = '1.3.50' - repositories { - google() - jcenter() - } - - dependencies { - classpath 'com.android.tools.build:gradle:3.5.0' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - -allprojects { - repositories { - google() - jcenter() - } -} - -rootProject.buildDir = '../build' -subprojects { - project.buildDir = "${rootProject.buildDir}/${project.name}" -} -subprojects { - project.evaluationDependsOn(':app') -} - -task clean(type: Delete) { - delete rootProject.buildDir -} diff --git a/datawedge_flutter/android/build.gradle.kts b/datawedge_flutter/android/build.gradle.kts new file mode 100644 index 0000000..dbee657 --- /dev/null +++ b/datawedge_flutter/android/build.gradle.kts @@ -0,0 +1,24 @@ +allprojects { + repositories { + google() + mavenCentral() + } +} + +val newBuildDir: Directory = + rootProject.layout.buildDirectory + .dir("../../build") + .get() +rootProject.layout.buildDirectory.value(newBuildDir) + +subprojects { + val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name) + project.layout.buildDirectory.value(newSubprojectBuildDir) +} +subprojects { + project.evaluationDependsOn(":app") +} + +tasks.register("clean") { + delete(rootProject.layout.buildDirectory) +} diff --git a/datawedge_flutter/android/gradle.properties b/datawedge_flutter/android/gradle.properties index 38c8d45..f018a61 100644 --- a/datawedge_flutter/android/gradle.properties +++ b/datawedge_flutter/android/gradle.properties @@ -1,4 +1,3 @@ -org.gradle.jvmargs=-Xmx1536M -android.enableR8=true +org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError android.useAndroidX=true android.enableJetifier=true diff --git a/datawedge_flutter/android/gradle/wrapper/gradle-wrapper.properties b/datawedge_flutter/android/gradle/wrapper/gradle-wrapper.properties index 296b146..ac3b479 100644 --- a/datawedge_flutter/android/gradle/wrapper/gradle-wrapper.properties +++ b/datawedge_flutter/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Fri Jun 23 08:50:38 CEST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip diff --git a/datawedge_flutter/android/settings.gradle b/datawedge_flutter/android/settings.gradle deleted file mode 100644 index 5a2f14f..0000000 --- a/datawedge_flutter/android/settings.gradle +++ /dev/null @@ -1,15 +0,0 @@ -include ':app' - -def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() - -def plugins = new Properties() -def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') -if (pluginsFile.exists()) { - pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } -} - -plugins.each { name, path -> - def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() - include ":$name" - project(":$name").projectDir = pluginDirectory -} diff --git a/datawedge_flutter/android/settings.gradle.kts b/datawedge_flutter/android/settings.gradle.kts new file mode 100644 index 0000000..fb605bc --- /dev/null +++ b/datawedge_flutter/android/settings.gradle.kts @@ -0,0 +1,26 @@ +pluginManagement { + val flutterSdkPath = + run { + val properties = java.util.Properties() + file("local.properties").inputStream().use { properties.load(it) } + val flutterSdkPath = properties.getProperty("flutter.sdk") + require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" } + flutterSdkPath + } + + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") + + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +plugins { + id("dev.flutter.flutter-plugin-loader") version "1.0.0" + id("com.android.application") version "8.9.1" apply false + id("org.jetbrains.kotlin.android") version "2.1.0" apply false +} + +include(":app") diff --git a/datawedge_flutter/lib/main.dart b/datawedge_flutter/lib/main.dart index 5f17419..e21fbc5 100644 --- a/datawedge_flutter/lib/main.dart +++ b/datawedge_flutter/lib/main.dart @@ -4,30 +4,56 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; void main() { - runApp(MyApp()); + runApp(const MyApp()); } class MyApp extends StatelessWidget { + const MyApp({super.key}); + // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'DataWedge Flutter', theme: ThemeData( - primarySwatch: Colors.orange, + // This is the theme of your application. + // + // TRY THIS: Try running your application with "flutter run". You'll see + // the application has a purple toolbar. Then, without quitting the app, + // try changing the seedColor in the colorScheme below to Colors.green + // and then invoke "hot reload" (save your changes or press the "hot + // reload" button in a Flutter-supported IDE, or press "r" if you used + // the command line to start the app). + // + // Notice that the counter didn't reset back to zero; the application + // state is not lost during the reload. To reset the state, use hot + // restart instead. + // + // This works for code too, not just values: Most code changes can be + // tested with just a hot reload. + colorScheme: ColorScheme.fromSeed(seedColor: Colors.orange), ), - home: MyHomePage(title: 'DataWedge Flutter'), + home: const MyHomePage(title: 'DataWedge Flutter'), ); } } class MyHomePage extends StatefulWidget { - MyHomePage({Key? key, required this.title}) : super(key: key); + const MyHomePage({super.key, required this.title}); + + // This widget is the home page of your application. It is stateful, meaning + // that it has a State object (defined below) that contains fields that affect + // how it looks. + + // This class is the configuration for the state. It holds the values (in this + // case the title) provided by the parent (in this case the App widget) and + // used by the build method of the State. Fields in a Widget subclass are + // always marked "final". final String title; @override - _MyHomePageState createState() => _MyHomePageState(); + State createState() => _MyHomePageState(); } class _MyHomePageState extends State { diff --git a/datawedge_flutter/pubspec.lock b/datawedge_flutter/pubspec.lock index 7ffced4..164b3dc 100644 --- a/datawedge_flutter/pubspec.lock +++ b/datawedge_flutter/pubspec.lock @@ -5,149 +5,209 @@ packages: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.6.1" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 + url: "https://pub.dev" source: hosted - version: "1.1.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" + version: "1.4.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.2" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" + url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.19.1" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.dartlang.org" + sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 + url: "https://pub.dev" source: hosted - version: "1.0.3" + version: "1.0.8" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.3" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: "5398f14efa795ffb7a33e9b6a08798b26a180edac4ad7db3f231e40f82ce11e1" + url: "https://pub.dev" + source: hosted + version: "5.0.0" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de" + url: "https://pub.dev" + source: hosted + version: "11.0.2" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" + url: "https://pub.dev" + source: hosted + version: "3.0.10" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + lints: + dependency: transitive + description: + name: lints + sha256: c35bb79562d980e9a453fc715854e1ed39e24e7d0297a880ef54e17f9874a9d7 + url: "https://pub.dev" + source: hosted + version: "5.1.1" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 + url: "https://pub.dev" source: hosted - version: "0.12.10" + version: "0.12.17" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + url: "https://pub.dev" + source: hosted + version: "0.11.1" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c + url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.16.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.1" sky_engine: dependency: transitive description: flutter source: sdk - version: "0.0.99" + version: "0.0.0" source_span: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" source: hosted - version: "1.8.1" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.12.1" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.4" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00" + url: "https://pub.dev" source: hosted - version: "0.3.0" - typed_data: + version: "0.7.6" + vector_math: dependency: transitive description: - name: typed_data - url: "https://pub.dartlang.org" + name: vector_math + sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b + url: "https://pub.dev" source: hosted - version: "1.3.0" - vector_math: + version: "2.2.0" + vm_service: dependency: transitive description: - name: vector_math - url: "https://pub.dartlang.org" + name: vm_service + sha256: "45caa6c5917fa127b5dbcfbd1fa60b14e583afdc08bfc96dda38886ca252eb60" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "15.0.2" sdks: - dart: ">=2.12.0 <3.0.0" + dart: ">=3.9.2 <4.0.0" + flutter: ">=3.18.0-18.0.pre.54" diff --git a/datawedge_flutter/pubspec.yaml b/datawedge_flutter/pubspec.yaml index 11fc3ac..0f319d7 100644 --- a/datawedge_flutter/pubspec.yaml +++ b/datawedge_flutter/pubspec.yaml @@ -1,5 +1,8 @@ name: datawedgeflutter description: Accessing DataWedge from a Flutter app +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev # The following defines the version and build number for your application. # A version number is three numbers separated by dots, like 1.2.43 @@ -8,31 +11,45 @@ description: Accessing DataWedge from a Flutter app # build by specifying --build-name and --build-number, respectively. # In Android, build-name is used as versionName while build-number used as versionCode. # Read more about Android versioning at https://developer.android.com/studio/publish/versioning -# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. +# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.0.0+1 +# In Windows, build-name is used as the major, minor, and patch parts +# of the product and file versions while build-number is used as the build suffix. +version: 1.0.1+2 environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ^3.9.2 +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. dependencies: flutter: sdk: flutter - # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^1.0.3 + cupertino_icons: ^1.0.8 dev_dependencies: flutter_test: sdk: flutter + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + flutter_lints: ^5.0.0 + # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec -# The following section is specific to Flutter. +# The following section is specific to Flutter packages. flutter: # The following line ensures that the Material Icons font is @@ -46,10 +63,10 @@ flutter: # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware. + # https://flutter.dev/to/resolution-aware-images # For details regarding adding assets from package dependencies, see - # https://flutter.dev/assets-and-images/#from-packages + # https://flutter.dev/to/asset-from-package # To add custom fonts to your application, add a fonts section here, # in this "flutter" section. Each entry in this list should have a @@ -69,4 +86,4 @@ flutter: # weight: 700 # # For details regarding fonts from package dependencies, - # see https://flutter.dev/custom-fonts/#from-packages + # see https://flutter.dev/to/font-from-package diff --git a/datawedge_flutter/test/widget_test.dart b/datawedge_flutter/test/widget_test.dart index c380d39..454c1c4 100644 --- a/datawedge_flutter/test/widget_test.dart +++ b/datawedge_flutter/test/widget_test.dart @@ -1,7 +1,7 @@ // This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester -// utility that Flutter provides. For example, you can send tap and scroll +// utility in the flutter_test package. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. @@ -13,7 +13,7 @@ import 'package:datawedgeflutter/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. - await tester.pumpWidget(MyApp()); + await tester.pumpWidget(const MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget);