Navigation Menu

Skip to content

Commit

Permalink
Migrate to AndroidX with couple updates (#25)
Browse files Browse the repository at this point in the history
* Android x migration & 1.2.1 support

* bump version and update docs.

* Fix travis job
  • Loading branch information
hukid committed Mar 31, 2019
1 parent 5a27b49 commit 96489ed
Show file tree
Hide file tree
Showing 22 changed files with 107 additions and 101 deletions.
41 changes: 20 additions & 21 deletions .travis.yml
Expand Up @@ -3,20 +3,11 @@ matrix:
- language: android
sudo: false
jdk: oraclejdk8
cache:
directories:
- $HOME/.pub-cache
os:
- linux
licenses:
- 'android-sdk-preview-license-.+'
- 'android-sdk-license-.+'
- 'google-gdk-license-.+'
android:
components:
- tools
- platform-tools
- tools
- build-tools-27.0.3
- android-27
- extra-google-google_play_services
addons:
apt:
# Flutter depends on /usr/lib/x86_64-linux-gnu/libstdc++.so.6 version GLIBCXX_3.4.18
Expand All @@ -27,10 +18,17 @@ matrix:
- fonts-droid
before_install:
- cd example
- yes | sdkmanager "platforms;android-28"
- echo yes | sdkmanager "tools" >/dev/null
- echo yes | sdkmanager "platform-tools" >/dev/null
- echo yes | sdkmanager "build-tools;28.0.3" >/dev/null
- echo yes | sdkmanager "platforms;android-26" >/dev/null
- echo yes | sdkmanager "platforms;android-28" >/dev/null
- echo y | sdkmanager "extras;android;m2repository" >/dev/null
- echo y | sdkmanager "extras;google;m2repository" >/dev/null
- sdkmanager --list
install:
- git clone https://github.com/flutter/flutter.git -b beta --depth 1
- ./flutter/bin/flutter doctor
- git clone https://github.com/flutter/flutter.git -b stable --depth 1
- ./flutter/bin/flutter doctor -v
before_script:
# the file is encrypted by following https://docs.travis-ci.com/user/encrypting-files/
- openssl aes-256-cbc -K $encrypted_cd445d9edb5b_key -iv $encrypted_cd445d9edb5b_iv -in android/gradle.properties.enc -out android/gradle.properties -d
Expand All @@ -40,15 +38,16 @@ matrix:
- language: objective-c
os: osx
osx_image: xcode10.1
cache:
directories:
- $HOME/.pub-cache
before_install:
- cd example
- git clone https://github.com/flutter/flutter.git -b beta --depth 1
- ./flutter/bin/flutter doctor
- git clone https://github.com/flutter/flutter.git -b stable --depth 1
- ./flutter/bin/flutter doctor -v
before_script:
- cd ios && ruby <(curl https://connect.squareup.com/readersdk-installer) install --app-id $SQUARE_READER_SDK_APPLICATION_ID --repo-password $SQUARE_READER_SDK_REPOSITORY_PASSWORD --version 1.1.1 > /dev/null
- ./flutter/bin/flutter packages pub cache repair
- ./flutter/bin/flutter packages get
- cd ios && ruby <(curl https://connect.squareup.com/readersdk-installer) install --app-id $SQUARE_READER_SDK_APPLICATION_ID --repo-password $SQUARE_READER_SDK_REPOSITORY_PASSWORD > /dev/null
- pod update MTBBarcodeScanner # a workaround for flutter issue
script:
- cd ..
- ls -la
- ./flutter/bin/flutter -v build ios --no-codesign
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,10 @@
## Changelog

### v2.0.0 Mar 29, 2019

* Support AnroidX.
* Upgrade to Square Reader SDK 1.2.1 (Android Only)

### v1.1.1 Mar 13, 2019

* add **store customer card** suport.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -13,8 +13,8 @@ solutions on Android and iOS.
The Flutter plugin for Reader SDK acts as a wrapper on the native SDKs and is
currently compatible with the following native Reader SDK versions:

* iOS: version 1.1.1
* Android: 1.1.3
* iOS: 1.1.1 and above
* Android: 1.2.1 and above

Try the [sample app] to see the plugin in action or follow the instructions in
the [getting started guide] to build a custom solution from scratch.
Expand Down
12 changes: 6 additions & 6 deletions android/build.gradle
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
group 'com.squareup.readersdkflutterplugin'
version '1.1-SNAPSHOT'
version '2.0-SNAPSHOT'

buildscript {
repositories {
Expand Down Expand Up @@ -44,15 +44,15 @@ rootProject.allprojects {
apply plugin: 'com.android.library'

def DEFAULT_PLAY_SERVICES_BASE_VERSION = '12.0.1'
def MIN_READER_SDK_VERSION = '1.1.3'
def READER_SDK_VERSION = '[1.2.1 2.0)'

android {
compileSdkVersion 27
compileSdkVersion 28

defaultConfig {
minSdkVersion 21
targetSdkVersion 27
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
targetSdkVersion 28
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
lintOptions {
Expand All @@ -66,7 +66,7 @@ android {
}

dependencies {
def readerSdkVersion = rootProject.hasProperty('readerSdkVersion') ? rootProject.readerSdkVersion : MIN_READER_SDK_VERSION
def readerSdkVersion = rootProject.hasProperty('readerSdkVersion') ? rootProject.readerSdkVersion : READER_SDK_VERSION
def playServicesBaseVersion = rootProject.hasProperty('googlePlayServiceVersion') ? rootProject.googlePlayServiceVersion : DEFAULT_PLAY_SERVICES_BASE_VERSION
implementation "com.google.android.gms:play-services-base:$playServicesBaseVersion"
api "com.squareup.sdk.reader:reader-sdk-$SQUARE_READER_SDK_APPLICATION_ID:$readerSdkVersion"
Expand Down
Expand Up @@ -15,7 +15,6 @@
*/
package com.squareup.sdk.reader.flutter.internal;

import android.support.annotation.NonNull;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
Expand All @@ -28,7 +27,7 @@ public class DateFormatUtils {
}
};

public static String formatISO8601UTC(@NonNull Date date) {
public static String formatISO8601UTC(Date date) {
return ISO_8601.get().format(date);
}
}
Expand Up @@ -59,8 +59,12 @@ public class CardConverter {
case EFTPOS:
brandStringMap.put(brand, "EFTPOS");
break;
case FELICA:
brandStringMap.put(brand, "FELICA");
default:
throw new RuntimeException("Unexpected brand value: " + brand.name());
// UNKNOWN should never happen if the right Reader SDK version is loaded with plugin
// But we choose not break plugin if the type isn't important
brandStringMap.put(brand, "UNKNOWN");
}
}
}
Expand Down
Expand Up @@ -39,7 +39,9 @@ class TenderCardDetailsConverter {
entryMethodStringMap.put(method, "CONTACTLESS");
break;
default:
throw new RuntimeException("Unexpected entry method: " + method.name());
// UNKNOWN should never happen if the right Reader SDK version is loaded with plugin
// But we choose not break plugin if the type isn't important
entryMethodStringMap.put(method, "UNKNOWN");
}
}

Expand Down
Expand Up @@ -37,7 +37,9 @@ class TenderConverter {
tenderTypeMap.put(type, "other");
break;
default:
throw new RuntimeException("Unexpected tender type: " + type.name());
// unknown should never happen if the right Reader SDK version is loaded with plugin
// But we choose not break plugin if the type isn't important
tenderTypeMap.put(type, "unknown");
}
}

Expand Down
10 changes: 3 additions & 7 deletions doc/get-started.md
Expand Up @@ -164,19 +164,15 @@ information on installing Reader SDK for iOS, see the
[root README] for this repo.

1. Change to the iOS folder (`ios`) at the root of your Flutter project.
1. Modify your `Podfile` and uncomment the platform configuration line (`platform :ios, '<version>'`) if it is commented out.
1. Modify your `Podfile` and uncomment the platform configuration line (`platform :ios, '<version>'`) if it is commented out.
**NOTE**: you must target iOS `11.1` or higher (i.e.: `platform :ios, '11.1'`).
1. Download and configure the latest version of `SquareReaderSDK.framework` in
your project root by replacing `YOUR_SQUARE_READER_APP_ID` and
`YOUR_SQUARE_READER_REPOSITORY_PASSWORD` with your Reader SDK credentials and
`READER_SDK_VERSION` with the Reader SDK version you are using in the code
below.
`YOUR_SQUARE_READER_REPOSITORY_PASSWORD` with your Reader SDK credentials.

The command below will download the framework into the current directory. **The framework must be in either the `iOS` directory or the `iOS/Frameworks` directory of your Flutter project.** (The
current `READER_SDK_VERSION` is `1.1.1`.)
The command below will download the framework into the current directory. **The framework must be in either the `ios` directory or the `ios/Frameworks` directory of your Flutter project.**
```bash
ruby <(curl https://connect.squareup.com/readersdk-installer) install \
--version READER_SDK_VERSION \
--app-id YOUR_SQUARE_READER_APP_ID \
--repo-password YOUR_SQUARE_READER_REPOSITORY_PASSWORD
```
Expand Down
1 change: 1 addition & 0 deletions example/.gitignore
Expand Up @@ -13,6 +13,7 @@ android/.settings/org.eclipse.buildship.core.prefs
android/app/.classpath
android/app/.project
android/app/.settings/org.eclipse.buildship.core.prefs
android/app/bin/
ios/SquareReaderSDK.framework
ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
.vscode
8 changes: 3 additions & 5 deletions example/README.md
Expand Up @@ -70,13 +70,11 @@ You can view the [transaction details in Square Dashboard].

1. Change to the `ios` folder under `example`.
2. Install ReaderSDK, replacing `YOUR_SQUARE_READER_APP_ID` and
`YOUR_SQUARE_READER_REPOSITORY_PASSWORD` with your Reader SDK credentials
and `READER_SDK_VERSION` with the Reader SDK version you are using. You can
find the minimum supported Reader SDK version for iOS in the [root README]
for this repo:
`YOUR_SQUARE_READER_REPOSITORY_PASSWORD` with your Reader SDK credentials.

The command below will download the framework into the current directory. **The framework must be in either the `ios` directory or the `ios/Frameworks` directory of your Flutter project.**
```bash
ruby <(curl https://connect.squareup.com/readersdk-installer) install \
--version READER_SDK_VERSION \
--app-id YOUR_SQUARE_READER_APP_ID \
--repo-password YOUR_SQUARE_READER_REPOSITORY_PASSWORD
```
Expand Down
12 changes: 6 additions & 6 deletions example/android/app/build.gradle
Expand Up @@ -25,7 +25,7 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 27
compileSdkVersion 28

lintOptions {
disable 'InvalidPackage'
Expand All @@ -34,11 +34,11 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.flutter.squareup.sdk.reader"
minSdkVersion 21
targetSdkVersion 27
minSdkVersion 26
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}

Expand All @@ -64,8 +64,8 @@ dependencies {
implementation 'com.google.android.gms:play-services-safetynet:15.0.1'
implementation 'com.google.android.gms:play-services-ads-identifier:15.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
}

configurations.all {
Expand Down
6 changes: 3 additions & 3 deletions example/android/build.gradle
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.android.tools.build:gradle:3.3.1'
}
}

Expand All @@ -18,8 +18,8 @@ allprojects {

ext {
// Override the reader sdk version with the this parameter
// make sure the version is above min version 1.1.3
readerSdkVersion = "1.1.3"
// make sure the version is above min version 1.2.1
readerSdkVersion = "[1.2.1, 2.0)"
}

rootProject.buildDir = '../build'
Expand Down
2 changes: 2 additions & 0 deletions example/android/gradle.properties
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

android.enableJetifier=true
android.useAndroidX=true
android.useDeprecatedNdk=true
org.gradle.jvmargs=-Xmx4g

Expand Down
Binary file modified example/android/gradle.properties.enc
Binary file not shown.
4 changes: 2 additions & 2 deletions example/android/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
#Fri Jun 23 08:50:38 CEST 2017
#Wed Mar 27 17:21:14 PDT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
18 changes: 9 additions & 9 deletions example/ios/Podfile.lock
Expand Up @@ -3,16 +3,16 @@ PODS:
- Flutter
- MTBBarcodeScanner
- Flutter (1.0.0)
- MTBBarcodeScanner (5.0.6)
- simple_permissions (0.0.1):
- MTBBarcodeScanner (5.0.8)
- permission_handler (3.0.0):
- Flutter
- square_reader_sdk (1.1.0):
- square_reader_sdk (2.0.0):
- Flutter

DEPENDENCIES:
- barcode_scan (from `.symlinks/plugins/barcode_scan/ios`)
- Flutter (from `.symlinks/flutter/ios`)
- simple_permissions (from `.symlinks/plugins/simple_permissions/ios`)
- permission_handler (from `.symlinks/plugins/permission_handler/ios`)
- square_reader_sdk (from `.symlinks/plugins/square_reader_sdk/ios`)

SPEC REPOS:
Expand All @@ -24,17 +24,17 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/barcode_scan/ios"
Flutter:
:path: ".symlinks/flutter/ios"
simple_permissions:
:path: ".symlinks/plugins/simple_permissions/ios"
permission_handler:
:path: ".symlinks/plugins/permission_handler/ios"
square_reader_sdk:
:path: ".symlinks/plugins/square_reader_sdk/ios"

SPEC CHECKSUMS:
barcode_scan: 8288e70cb430072003bce2c794a1431e7adbcb4d
Flutter: 9d0fac939486c9aba2809b7982dfdbb47a7b0296
MTBBarcodeScanner: bb0bb62e18b57f8a571a482248adc20722b70a91
simple_permissions: 8ea52208b437f8fae29d97a55fe00b705a53246b
square_reader_sdk: 5bf5f55d7b689f475d80d8b9fd51be395bff383a
MTBBarcodeScanner: 5b97f10a037e2560ff104da413343c5ce9413911
permission_handler: 03dcf3ade9d5f398b8854b366cb9de718d3daa76
square_reader_sdk: b211b55be3ba400ce2de50aa693b48152062447f

PODFILE CHECKSUM: cb6b50d323655cc2ec3bd136559937da3b86ed80

Expand Down
8 changes: 2 additions & 6 deletions example/ios/Runner.xcodeproj/project.pbxproj
Expand Up @@ -9,7 +9,6 @@
/* Begin PBXBuildFile section */
11556F642148EFC9008E499E /* SquareReaderSDK.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 11556F632148EFC9008E499E /* SquareReaderSDK.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
Expand Down Expand Up @@ -44,7 +43,6 @@
11556F632148EFC9008E499E /* SquareReaderSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = SquareReaderSDK.framework; sourceTree = "<group>"; };
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
6FD0E0B72C490B4355B3D2F6 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -86,7 +84,6 @@
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
2D5378251FAA1A9400D5DBA9 /* flutter_assets */,
3B80C3931E831B6300D905FE /* App.framework */,
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
9740EEBA1CF902C7004384FC /* Flutter.framework */,
Expand Down Expand Up @@ -216,7 +213,6 @@
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */,
87C5EE2B217E62B200C7D5DA /* LaunchScreen.xib in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -293,15 +289,15 @@
"${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework",
"${BUILT_PRODUCTS_DIR}/MTBBarcodeScanner/MTBBarcodeScanner.framework",
"${BUILT_PRODUCTS_DIR}/barcode_scan/barcode_scan.framework",
"${BUILT_PRODUCTS_DIR}/simple_permissions/simple_permissions.framework",
"${BUILT_PRODUCTS_DIR}/permission_handler/permission_handler.framework",
"${BUILT_PRODUCTS_DIR}/square_reader_sdk/square_reader_sdk.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MTBBarcodeScanner.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/barcode_scan.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/simple_permissions.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/permission_handler.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/square_reader_sdk.framework",
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down

0 comments on commit 96489ed

Please sign in to comment.