diff --git a/pay/analysis_options.yaml b/pay/analysis_options.yaml index 0caccc81..46349228 100644 --- a/pay/analysis_options.yaml +++ b/pay/analysis_options.yaml @@ -1 +1,4 @@ +analyzer: + exclude: + - build/** include: ../analysis_options.yaml \ No newline at end of file diff --git a/pay/example/analysis_options.yaml b/pay/example/analysis_options.yaml index fac60e24..74e451a2 100644 --- a/pay/example/analysis_options.yaml +++ b/pay/example/analysis_options.yaml @@ -1 +1,6 @@ +analyzer: + exclude: + - build/** + - android/** + - ios/** include: ../../analysis_options.yaml \ No newline at end of file diff --git a/pay/example/android/app/build.gradle b/pay/example/android/app/build.gradle deleted file mode 100644 index 0e977659..00000000 --- a/pay/example/android/app/build.gradle +++ /dev/null @@ -1,58 +0,0 @@ -plugins { - id "com.android.application" - id "kotlin-android" - 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 'io.flutter.plugins.pay_example' - compileSdk flutter.compileSdkVersion - - defaultConfig { - applicationId 'io.flutter.plugins.pay_example' - minSdkVersion flutter.minSdkVersion - targetSdkVersion flutter.targetSdkVersion - versionCode flutterVersionCode.toInteger() - versionName flutterVersionName - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - kotlinOptions { - jvmTarget = '1.8' - } - - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - } - - lint { - disable 'InvalidPackage' - } -} - -flutter { - source '../..' -} diff --git a/pay/example/android/app/build.gradle.kts b/pay/example/android/app/build.gradle.kts new file mode 100644 index 00000000..5c466789 --- /dev/null +++ b/pay/example/android/app/build.gradle.kts @@ -0,0 +1,39 @@ +import com.android.build.api.dsl.ApplicationExtension +import org.gradle.kotlin.dsl.configure + +plugins { + id("com.android.application") + id("dev.flutter.flutter-gradle-plugin") +} + +extensions.configure { + namespace = "io.flutter.plugins.pay_example" + compileSdk = flutter.compileSdkVersion + + defaultConfig { + applicationId = "io.flutter.plugins.pay_example" + minSdk = flutter.minSdkVersion + targetSdk = flutter.targetSdkVersion + versionCode = flutter.flutterVersionCode?.toInt() + versionName = flutter.flutterVersionName + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + sourceSets.named("main") { + kotlin.directories += "src/main/kotlin" + } +} + +kotlin { + compilerOptions { + jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 + } +} + +flutter { + source = "../.." +} diff --git a/pay/example/android/app/src/main/AndroidManifest.xml b/pay/example/android/app/src/main/AndroidManifest.xml index 0086071f..ff05d506 100644 --- a/pay/example/android/app/src/main/AndroidManifest.xml +++ b/pay/example/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - + ("clean") { + delete(rootProject.layout.buildDirectory) +} diff --git a/pay/example/android/gradle.properties b/pay/example/android/gradle.properties index eac5ff93..ec57cac8 100644 --- a/pay/example/android/gradle.properties +++ b/pay/example/android/gradle.properties @@ -1,7 +1,3 @@ org.gradle.jvmargs=-Xmx1536M android.useAndroidX=true -android.enableJetifier=true -# This builtInKotlin flag was added automatically by Flutter migrator -android.builtInKotlin=false -# This newDsl flag was added automatically by Flutter migrator android.newDsl=false diff --git a/pay/example/android/gradle/wrapper/gradle-wrapper.properties b/pay/example/android/gradle/wrapper/gradle-wrapper.properties index a10c8212..070de9d0 100644 --- a/pay/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/pay/example/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip \ No newline at end of file +distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.1-bin.zip \ No newline at end of file diff --git a/pay/example/android/settings.gradle b/pay/example/android/settings.gradle deleted file mode 100644 index c403e19f..00000000 --- a/pay/example/android/settings.gradle +++ /dev/null @@ -1,26 +0,0 @@ -pluginManagement { - def flutterSdkPath = { - def properties = new Properties() - file("local.properties").withInputStream { properties.load(it) } - def flutterSdkPath = properties.getProperty("flutter.sdk") - assert flutterSdkPath != null, "flutter.sdk not set in local.properties" - return 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.6.0" apply false - id "org.jetbrains.kotlin.android" version "2.0.20" apply false -} - -rootProject.name = "Google Pay Flutter sample application" -include ":app" \ No newline at end of file diff --git a/pay/example/android/settings.gradle.kts b/pay/example/android/settings.gradle.kts new file mode 100644 index 00000000..497f768f --- /dev/null +++ b/pay/example/android/settings.gradle.kts @@ -0,0 +1,26 @@ +pluginManagement { + val flutterSdkPath = { + val properties = java.util.Properties() + file("local.properties").inputStream().use { properties.load(it) } + val sdkPath = properties.getProperty("flutter.sdk") + require(sdkPath != null) { "flutter.sdk not set in local.properties" } + sdkPath + }() + + 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 "9.3.2" apply false + id("org.jetbrains.kotlin.android") version "2.4.20" apply false +} + +rootProject.name = "Google Pay Flutter sample application" +include(":app") diff --git a/pay/example/ios/Podfile b/pay/example/ios/Podfile index e72e0b48..17ed9861 100644 --- a/pay/example/ios/Podfile +++ b/pay/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '13.0' +# platform :ios, '15.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/pay/example/ios/Podfile.lock b/pay/example/ios/Podfile.lock index be9d1fbd..d62e9312 100644 --- a/pay/example/ios/Podfile.lock +++ b/pay/example/ios/Podfile.lock @@ -1,28 +1,16 @@ PODS: - Flutter (1.0.0) - - integration_test (0.0.1): - - Flutter - - pay_ios (0.0.1): - - Flutter DEPENDENCIES: - Flutter (from `Flutter`) - - integration_test (from `.symlinks/plugins/integration_test/ios`) - - pay_ios (from `.symlinks/plugins/pay_ios/ios`) EXTERNAL SOURCES: Flutter: :path: Flutter - integration_test: - :path: ".symlinks/plugins/integration_test/ios" - pay_ios: - :path: ".symlinks/plugins/pay_ios/ios" SPEC CHECKSUMS: - Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467 - integration_test: 4a889634ef21a45d28d50d622cf412dc6d9f586e - pay_ios: 616e4e1ef4b51b69e11042ff18ba6bbe7408e13b + Flutter: 71a624a5bc0c04062bf19101d501e466baf2fb47 -PODFILE CHECKSUM: 0dbd5a87e0ace00c9610d2037ac22083a01f861d +PODFILE CHECKSUM: a938cb79d452854fa9f13c14ded5e356e38f0fc7 COCOAPODS: 1.16.2 diff --git a/pay/example/ios/Runner.xcodeproj/project.pbxproj b/pay/example/ios/Runner.xcodeproj/project.pbxproj index 2385df18..72dd038c 100644 --- a/pay/example/ios/Runner.xcodeproj/project.pbxproj +++ b/pay/example/ios/Runner.xcodeproj/project.pbxproj @@ -9,6 +9,7 @@ /* Begin PBXBuildFile section */ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; }; 7D20093E3DFDE65B80AFACA4 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 47808D748B4BB44556154622 /* Pods_Runner.framework */; }; 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; @@ -36,6 +37,7 @@ 38B04ABE423E7035C8378B6A /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 47808D748B4BB44556154622 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FlutterGeneratedPluginSwiftPackage; path = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; @@ -60,6 +62,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */, 7D20093E3DFDE65B80AFACA4 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -70,6 +73,7 @@ 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( + 78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */, 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 9740EEB21CF90195004384FC /* Debug.xcconfig */, 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, @@ -153,13 +157,15 @@ 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - 6C52222BA1A347FA009E0125 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); dependencies = ( ); name = Runner; + packageProductDependencies = ( + 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */, + ); productName = Runner; productReference = 97C146EE1CF9000F007C117D /* Runner.app */; productType = "com.apple.product-type.application"; @@ -189,6 +195,9 @@ es, ); mainGroup = 97C146E51CF9000F007C117D; + packageReferences = ( + 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */, + ); productRefGroup = 97C146EF1CF9000F007C117D /* Products */; projectDirPath = ""; projectRoot = ""; @@ -251,23 +260,6 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; - 6C52222BA1A347FA009E0125 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; alwaysOutOfDate = 1; @@ -365,7 +357,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -450,7 +442,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -501,7 +493,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -588,6 +580,20 @@ defaultConfigurationName = Debug; }; /* End XCConfigurationList section */ + +/* Begin XCLocalSwiftPackageReference section */ + 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */ = { + isa = XCLocalSwiftPackageReference; + relativePath = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; + }; +/* End XCLocalSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */ = { + isa = XCSwiftPackageProductDependency; + productName = FlutterGeneratedPluginSwiftPackage; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = 97C146E61CF9000F007C117D /* Project object */; } diff --git a/pay/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/pay/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 9c12df59..5db441f5 100644 --- a/pay/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/pay/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -5,6 +5,24 @@ + + + + + + + + + + =3.0.0 <4.0.0" - flutter: ">=3.10.0" + sdk: ^3.12.0 + flutter: ">=3.44.0" flutter: uses-material-design: true diff --git a/pay/pubspec.yaml b/pay/pubspec.yaml index bf7f7d70..b52ca406 100644 --- a/pay/pubspec.yaml +++ b/pay/pubspec.yaml @@ -18,8 +18,8 @@ version: 3.3.0 repository: https://github.com/google-pay/flutter-plugin/tree/main/pay environment: - sdk: ">=3.0.0 <4.0.0" - flutter: ">=3.10.0" + sdk: ^3.12.0 + flutter: ">=3.44.0" flutter: plugin: diff --git a/pay_android/analysis_options.yaml b/pay_android/analysis_options.yaml index 0caccc81..e02b68f9 100644 --- a/pay_android/analysis_options.yaml +++ b/pay_android/analysis_options.yaml @@ -1 +1,5 @@ +analyzer: + exclude: + - build/** + - android/** include: ../analysis_options.yaml \ No newline at end of file diff --git a/pay_android/android/build.gradle b/pay_android/android/build.gradle deleted file mode 100644 index 45ba8190..00000000 --- a/pay_android/android/build.gradle +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Copyright 2024 Google LLC. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget - -group 'io.flutter.plugins.pay_android' -version '1.0-SNAPSHOT' - -buildscript { - ext.kotlin_version = '2.2.10' - repositories { - google() - mavenCentral() - } - - dependencies { - classpath 'com.android.tools.build:gradle:8.13.1' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - -rootProject.allprojects { - repositories { - google() - mavenCentral() - } -} - -apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' - -kotlin { - compilerOptions { - jvmTarget = JvmTarget.fromTarget("17") - } -} - -android { - namespace = 'io.flutter.plugins.pay_android' - compileSdk = flutter.compileSdkVersion - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - test.java.srcDirs += 'src/test/kotlin' - androidTest.java.srcDirs += 'src/androidTest/kotlin' - } - - defaultConfig { - minSdkVersion 23 - } - - lintOptions { - disable 'InvalidPackage' - } -} - -dependencies { - implementation 'com.google.android.gms:play-services-wallet:19.5.0' - - testImplementation 'androidx.test.ext:truth:1.7.0' - testImplementation 'androidx.test.ext:junit:1.3.0' - testImplementation 'junit:junit:4.13.2' - testImplementation 'org.mockito:mockito-inline:5.2.0' - testImplementation 'org.robolectric:robolectric:4.16' - - androidTestImplementation 'androidx.test:core:1.7.0' - androidTestImplementation 'androidx.test:runner:1.7.0' - androidTestImplementation 'androidx.test:rules:1.7.0' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.7.0' -} diff --git a/pay_android/android/build.gradle.kts b/pay_android/android/build.gradle.kts new file mode 100644 index 00000000..7307b5dd --- /dev/null +++ b/pay_android/android/build.gradle.kts @@ -0,0 +1,82 @@ +/** + * Copyright 2024 Google LLC. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import com.android.build.api.dsl.LibraryExtension + +group = "io.flutter.plugins.pay_android" +version = "1.0-SNAPSHOT" + +buildscript { + repositories { + google() + mavenCentral() + } + + dependencies { + classpath("com.android.tools.build:gradle:9.3.2") + } +} + +plugins { + id("com.android.library") +} + +extensions.configure { + namespace = "io.flutter.plugins.pay_android" + compileSdk = flutter.compileSdkVersion + + defaultConfig { + minSdk = 23 + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + sourceSets { + named("main") { + kotlin.directories += "src/main/kotlin" + } + named("test") { + kotlin.directories += "src/test/kotlin" + } + } + + lint { + disable += "InvalidPackage" + } +} + +kotlin { + compilerOptions { + jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 + } +} + +dependencies { + implementation("com.google.android.gms:play-services-wallet:19.5.0") + + testImplementation("androidx.test.ext:truth:1.7.0") + testImplementation("androidx.test.ext:junit:1.3.0") + testImplementation("junit:junit:4.13.2") + testImplementation("org.mockito:mockito-inline:5.2.0") + testImplementation("org.robolectric:robolectric:4.16") + + androidTestImplementation("androidx.test:core:1.7.0") + androidTestImplementation("androidx.test:runner:1.7.0") + androidTestImplementation("androidx.test:rules:1.7.0") + androidTestImplementation("androidx.test.espresso:espresso-core:3.7.0") +} diff --git a/pay_android/android/gradle.properties b/pay_android/android/gradle.properties index 94adc3a3..ad8917e9 100644 --- a/pay_android/android/gradle.properties +++ b/pay_android/android/gradle.properties @@ -1,3 +1,2 @@ org.gradle.jvmargs=-Xmx1536M -android.useAndroidX=true -android.enableJetifier=true +android.useAndroidX=true \ No newline at end of file diff --git a/pay_android/android/settings.gradle b/pay_android/android/settings.gradle deleted file mode 100644 index a423df9f..00000000 --- a/pay_android/android/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'Google Pay Flutter plug-in' diff --git a/pay_android/android/settings.gradle.kts b/pay_android/android/settings.gradle.kts new file mode 100644 index 00000000..f4cd2974 --- /dev/null +++ b/pay_android/android/settings.gradle.kts @@ -0,0 +1 @@ +rootProject.name = "Google Pay Flutter plug-in" diff --git a/pay_android/android/src/main/AndroidManifest.xml b/pay_android/android/src/main/AndroidManifest.xml index 41e36c3e..7b322727 100644 --- a/pay_android/android/src/main/AndroidManifest.xml +++ b/pay_android/android/src/main/AndroidManifest.xml @@ -14,8 +14,7 @@ limitations under the License. --> - + ) : PlatformView { +internal class PayButtonView(private val context: Context, binaryMessenger: BinaryMessenger, viewId: Int, creationParams: Map) : PlatformView { - private val payButton: PayButton - private val methodChannel: MethodChannel + private val payButton: PayButton = PayButton(context) - init { - // Instantiate method channel - methodChannel = MethodChannel(binaryMessenger, "$VIEW_TYPE/$viewId"); + private val methodChannel: MethodChannel = MethodChannel(binaryMessenger, "$VIEW_TYPE/$viewId") - // Build pay button - payButton = PayButton(context) + init { buildPayButton(creationParams) } - private fun buildPayButton(buttonParams: Map) { - val buttonTheme = ButtonThemeFactory.fromString(buttonParams["theme"] as String) - val buttonType = ButtonTypeFactory.fromString(buttonParams["type"] as String) - val cornerRadiusDp = buttonParams["cornerRadius"] as Int + private fun buildPayButton(buttonParams: Map) { + val buttonTheme = (buttonParams["theme"] as? String)?.let(ButtonThemeFactory::fromString) ?: ButtonTheme.DARK + val buttonType = (buttonParams["type"] as? String)?.let(ButtonTypeFactory::fromString) ?: ButtonType.BUY + val cornerRadiusDp = (buttonParams["cornerRadius"] as? Number)?.toInt() ?: 0 val cornerRadius = (cornerRadiusDp * context.resources.displayMetrics.density).toInt() // Parse payment configuration diff --git a/pay_android/android/src/main/kotlin/io/flutter/plugins/pay_android/view/PayButtonViewFactory.kt b/pay_android/android/src/main/kotlin/io/flutter/plugins/pay_android/view/PayButtonViewFactory.kt index ac720b3f..19316c86 100644 --- a/pay_android/android/src/main/kotlin/io/flutter/plugins/pay_android/view/PayButtonViewFactory.kt +++ b/pay_android/android/src/main/kotlin/io/flutter/plugins/pay_android/view/PayButtonViewFactory.kt @@ -24,6 +24,10 @@ import io.flutter.plugin.platform.PlatformViewFactory class PayButtonViewFactory(private val binaryMessenger: BinaryMessenger) : PlatformViewFactory(StandardMessageCodec.INSTANCE) { override fun create(context: Context, viewId: Int, args: Any?): PlatformView { - return PayButtonView(context, binaryMessenger, viewId, args as Map) + @Suppress("UNCHECKED_CAST") + val creationParams = args as? Map + ?: throw IllegalArgumentException("PayButtonView requires populated creation parameters. Confirm that you are populating a valid creationParams object from the Flutter end.") + + return PayButtonView(context, binaryMessenger, viewId, creationParams) } } \ No newline at end of file diff --git a/pay_android/lib/src/widgets/google_pay_button.dart b/pay_android/lib/src/widgets/google_pay_button.dart index 7dedd315..4a550342 100644 --- a/pay_android/lib/src/widgets/google_pay_button.dart +++ b/pay_android/lib/src/widgets/google_pay_button.dart @@ -24,14 +24,11 @@ enum GooglePayButtonType { pay, plain, subscribe, - pix + pix, } /// The button themes supported on Google Pay. -enum GooglePayButtonTheme { - dark, - light, -} +enum GooglePayButtonTheme { dark, light } /// A button widget that follows the Google Pay button themes and design /// guidelines. @@ -50,7 +47,7 @@ enum GooglePayButtonTheme { class RawGooglePayButton extends StatelessWidget { /// The payment configuration for the button to show the last 4 digits of a /// pre-selected card - final PaymentConfiguration _paymentConfiguration; + final PaymentConfiguration paymentConfiguration; /// The default width for the Google Pay Button. static const double minimumButtonWidth = 168; @@ -83,26 +80,22 @@ class RawGooglePayButton extends StatelessWidget { /// Creates a Google Pay button widget with the parameters specified. RawGooglePayButton({ super.key, - required final PaymentConfiguration paymentConfiguration, + required this.paymentConfiguration, this.onPressed, this.cornerRadius = defaultButtonHeight ~/ 2, this.theme = GooglePayButtonTheme.dark, this.type = GooglePayButtonType.buy, this.gestureRecognizers = const >{}, - }) : _paymentConfiguration = paymentConfiguration, - constraints = const BoxConstraints.tightFor( - width: minimumButtonWidth, - height: defaultButtonHeight, - ) { + }) : constraints = const BoxConstraints.tightFor( + width: minimumButtonWidth, + height: defaultButtonHeight, + ) { assert(constraints.debugAssertIsValid()); } @override Widget build(BuildContext context) { - return ConstrainedBox( - constraints: constraints, - child: _platformButton, - ); + return ConstrainedBox(constraints: constraints, child: _platformButton); } /// Wrapper method to deliver the button @@ -110,16 +103,16 @@ class RawGooglePayButton extends StatelessWidget { switch (defaultTargetPlatform) { case TargetPlatform.android: return PlatformViewLink( - viewType: viewType, - surfaceFactory: (context, controller) { - return AndroidViewSurface( - controller: controller as AndroidViewController, - gestureRecognizers: gestureRecognizers, - hitTestBehavior: PlatformViewHitTestBehavior.opaque, - ); - }, - onCreatePlatformView: (params) => - PlatformViewsService.initAndroidView( + viewType: viewType, + surfaceFactory: (context, controller) { + return AndroidViewSurface( + controller: controller as AndroidViewController, + gestureRecognizers: gestureRecognizers, + hitTestBehavior: PlatformViewHitTestBehavior.opaque, + ); + }, + onCreatePlatformView: (params) => + PlatformViewsService.initAndroidView( id: params.id, viewType: viewType, layoutDirection: TextDirection.ltr, @@ -127,21 +120,22 @@ class RawGooglePayButton extends StatelessWidget { 'theme': theme.enumString, 'type': type.enumString, 'cornerRadius': cornerRadius, - 'paymentConfiguration': - _paymentConfiguration.rawConfigurationData(), + 'paymentConfiguration': paymentConfiguration + .rawConfigurationData(), }, creationParamsCodec: const StandardMessageCodec(), onFocus: () { params.onFocusChanged(true); }, ) - ..addOnPlatformViewCreatedListener(_onPlatformViewCreated) - ..addOnPlatformViewCreatedListener( - params.onPlatformViewCreated) - ..create()); + ..addOnPlatformViewCreatedListener(_onPlatformViewCreated) + ..addOnPlatformViewCreatedListener(params.onPlatformViewCreated) + ..create(), + ); default: throw UnsupportedError( - 'This platform $defaultTargetPlatform does not support Google Pay'); + 'This platform $defaultTargetPlatform does not support Google Pay', + ); } } @@ -159,23 +153,23 @@ class RawGooglePayButton extends StatelessWidget { extension on GooglePayButtonType { /// Creates a string representation of the [GooglePayButtonType] enumeration. String get enumString => { - GooglePayButtonType.plain: 'plain', - GooglePayButtonType.buy: 'buy', - GooglePayButtonType.donate: 'donate', - GooglePayButtonType.checkout: 'checkout', - GooglePayButtonType.book: 'book', - GooglePayButtonType.subscribe: 'subscribe', - GooglePayButtonType.pay: 'pay', - GooglePayButtonType.order: 'order', - GooglePayButtonType.pix: 'pix', - }[this]!; + GooglePayButtonType.plain: 'plain', + GooglePayButtonType.buy: 'buy', + GooglePayButtonType.donate: 'donate', + GooglePayButtonType.checkout: 'checkout', + GooglePayButtonType.book: 'book', + GooglePayButtonType.subscribe: 'subscribe', + GooglePayButtonType.pay: 'pay', + GooglePayButtonType.order: 'order', + GooglePayButtonType.pix: 'pix', + }[this]!; } /// A set of utility methods associated to the [GooglePayButtonTheme] enumeration. extension on GooglePayButtonTheme { /// Creates a string representation of the [GooglePayButtonTheme] enumeration. String get enumString => { - GooglePayButtonTheme.dark: 'dark', - GooglePayButtonTheme.light: 'light', - }[this]!; + GooglePayButtonTheme.dark: 'dark', + GooglePayButtonTheme.light: 'light', + }[this]!; } diff --git a/pay_android/pubspec.yaml b/pay_android/pubspec.yaml index 5941a697..3c4482d7 100644 --- a/pay_android/pubspec.yaml +++ b/pay_android/pubspec.yaml @@ -18,8 +18,8 @@ version: 3.2.0 homepage: https://github.com/google-pay/flutter-plugin environment: - sdk: ">=3.0.0 <4.0.0" - flutter: ">=3.10.0" + sdk: ^3.12.0 + flutter: ">=3.44.0" flutter: plugin: