From cc852a167e81e7ccc90d39ea3d3ed9c13a709771 Mon Sep 17 00:00:00 2001 From: Amy Tang Date: Wed, 9 Sep 2020 16:10:09 -0700 Subject: [PATCH 1/2] ANDROID: Upgrade from 2.x to 3.0.0 --- app/build.gradle | 11 ++++---- .../plaid/linksample/LinkSampleApplication.kt | 1 - .../linksample/LinkSampleApplicationJava.java | 1 - .../java/com/plaid/linksample/MainActivity.kt | 16 ++++------- .../plaid/linksample/MainActivityJava.java | 28 ++++++++++--------- 5 files changed, 27 insertions(+), 30 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index e95b84b..d3c7f72 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -23,12 +23,13 @@ android { } dependencies { - implementation "com.plaid.link:sdk-core:2.2.0" - implementation 'androidx.appcompat:appcompat:1.2.0' + implementation "com.plaid.link:sdk-core:3.0.0" + + implementation "androidx.appcompat:appcompat:1.2.0" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - implementation 'androidx.core:core-ktx:1.3.1' - implementation 'androidx.constraintlayout:constraintlayout:1.1.3' - implementation 'com.google.android.material:material:1.2.0' + implementation "androidx.core:core-ktx:1.3.1" + implementation "androidx.constraintlayout:constraintlayout:1.1.3" + implementation "com.google.android.material:material:1.2.0" implementation "com.squareup.retrofit2:retrofit:2.9.0" implementation "com.squareup.retrofit2:converter-gson:2.9.0" diff --git a/app/src/main/java/com/plaid/linksample/LinkSampleApplication.kt b/app/src/main/java/com/plaid/linksample/LinkSampleApplication.kt index fd97e42..c39daac 100644 --- a/app/src/main/java/com/plaid/linksample/LinkSampleApplication.kt +++ b/app/src/main/java/com/plaid/linksample/LinkSampleApplication.kt @@ -13,6 +13,5 @@ class LinkSampleApplication : Application() { override fun onCreate() { super.onCreate() - Plaid.initialize(this) } } diff --git a/app/src/main/java/com/plaid/linksample/LinkSampleApplicationJava.java b/app/src/main/java/com/plaid/linksample/LinkSampleApplicationJava.java index 2d69692..9530121 100644 --- a/app/src/main/java/com/plaid/linksample/LinkSampleApplicationJava.java +++ b/app/src/main/java/com/plaid/linksample/LinkSampleApplicationJava.java @@ -15,6 +15,5 @@ public class LinkSampleApplicationJava extends Application { public void onCreate() { super.onCreate(); - Plaid.initialize(this); } } diff --git a/app/src/main/java/com/plaid/linksample/MainActivity.kt b/app/src/main/java/com/plaid/linksample/MainActivity.kt index 93605cb..bffa38c 100644 --- a/app/src/main/java/com/plaid/linksample/MainActivity.kt +++ b/app/src/main/java/com/plaid/linksample/MainActivity.kt @@ -14,9 +14,8 @@ import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import com.plaid.link.Plaid -import com.plaid.link.linkTokenConfiguration -import com.plaid.link.openPlaidLink -import com.plaid.link.result.PlaidLinkResultHandler +import com.plaid.link.configuration.LinkTokenConfiguration +import com.plaid.link.result.LinkResultHandler import com.plaid.linksample.network.LinkTokenRequester class MainActivity : AppCompatActivity() { @@ -25,7 +24,7 @@ class MainActivity : AppCompatActivity() { private lateinit var tokenResult: TextView private val myPlaidResultHandler by lazy { - PlaidLinkResultHandler( + LinkResultHandler( onSuccess = { tokenResult.text = getString(R.string.public_token_result, it.publicToken) result.text = getString(R.string.content_success) @@ -52,7 +51,7 @@ class MainActivity : AppCompatActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) result = findViewById(R.id.result) - tokenResult = findViewById(R.id.public_token_result) + tokenResult = findViewById(R.id.public_token_result) val button = findViewById(R.id.open_link) button.setOnClickListener { @@ -77,11 +76,8 @@ class MainActivity : AppCompatActivity() { } private fun onLinkTokenSuccess(linkToken: String) { - this@MainActivity.openPlaidLink( - linkTokenConfiguration = linkTokenConfiguration { - token = linkToken - } - ) + Plaid.create(this.application, LinkTokenConfiguration.Builder().token(linkToken).build()) + .open(this) } private fun onLinkTokenError(error: Throwable) { diff --git a/app/src/main/java/com/plaid/linksample/MainActivityJava.java b/app/src/main/java/com/plaid/linksample/MainActivityJava.java index 392482b..137c352 100644 --- a/app/src/main/java/com/plaid/linksample/MainActivityJava.java +++ b/app/src/main/java/com/plaid/linksample/MainActivityJava.java @@ -16,20 +16,24 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; + import com.plaid.link.Plaid; import com.plaid.link.configuration.LinkTokenConfiguration; import com.plaid.link.configuration.PlaidProduct; -import com.plaid.link.result.PlaidLinkResultHandler; +import com.plaid.link.result.LinkResultHandler; import com.plaid.linksample.network.LinkTokenRequester; -import java.util.ArrayList; + import kotlin.Unit; +import java.util.ArrayList; + + public class MainActivityJava extends AppCompatActivity { private TextView result; private TextView tokenResult; - private final PlaidLinkResultHandler myPlaidResultHandler = new PlaidLinkResultHandler( + private LinkResultHandler myPlaidResultHandler = new LinkResultHandler( linkSuccess -> { tokenResult.setText(getString( R.string.public_token_result, @@ -40,15 +44,17 @@ public class MainActivityJava extends AppCompatActivity { }, linkExit -> { tokenResult.setText(""); - if (linkExit.error != null) { + if (linkExit.getError() != null) { result.setText(getString( R.string.content_exit, - linkExit.error.getDisplayMessage(), - linkExit.error.getErrorCode())); + linkExit.getError().getDisplayMessage(), + linkExit.getError().getErrorCode())); } else { result.setText(getString( R.string.content_cancel, - linkExit.metadata.status != null ? linkExit.metadata.status.jsonValue : "unknown")); + linkExit.getMetadata().getStatus() != null ? linkExit.getMetadata() + .getStatus() + .getJsonValue() : "unknown")); } return Unit.INSTANCE; } @@ -90,12 +96,8 @@ private void openLink() { } private void onLinkTokenSuccess(String token) { - Plaid.openLink( - this, - new LinkTokenConfiguration.Builder() - .token(token) - .build() - .toLinkConfiguration()); + Plaid.create(getApplication(), new LinkTokenConfiguration.Builder().token(token).build()) + .open(this); } private void onLinkTokenError(Throwable error) { From ec273fc1ca31dac8acb8c7bdcb888d884e449633 Mon Sep 17 00:00:00 2001 From: Amy Tang Date: Wed, 23 Sep 2020 12:22:56 -0700 Subject: [PATCH 2/2] Update formatting and remove import --- .../main/java/com/plaid/linksample/MainActivity.kt | 9 +++++++-- .../java/com/plaid/linksample/MainActivityJava.java | 11 +++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/plaid/linksample/MainActivity.kt b/app/src/main/java/com/plaid/linksample/MainActivity.kt index bffa38c..e7c8a5c 100644 --- a/app/src/main/java/com/plaid/linksample/MainActivity.kt +++ b/app/src/main/java/com/plaid/linksample/MainActivity.kt @@ -51,7 +51,7 @@ class MainActivity : AppCompatActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) result = findViewById(R.id.result) - tokenResult = findViewById(R.id.public_token_result) + tokenResult = findViewById(R.id.public_token_result) val button = findViewById(R.id.open_link) button.setOnClickListener { @@ -76,7 +76,12 @@ class MainActivity : AppCompatActivity() { } private fun onLinkTokenSuccess(linkToken: String) { - Plaid.create(this.application, LinkTokenConfiguration.Builder().token(linkToken).build()) + Plaid.create( + this.application, + LinkTokenConfiguration.Builder() + .token(linkToken) + .build() + ) .open(this) } diff --git a/app/src/main/java/com/plaid/linksample/MainActivityJava.java b/app/src/main/java/com/plaid/linksample/MainActivityJava.java index 137c352..fb95349 100644 --- a/app/src/main/java/com/plaid/linksample/MainActivityJava.java +++ b/app/src/main/java/com/plaid/linksample/MainActivityJava.java @@ -19,14 +19,11 @@ import com.plaid.link.Plaid; import com.plaid.link.configuration.LinkTokenConfiguration; -import com.plaid.link.configuration.PlaidProduct; import com.plaid.link.result.LinkResultHandler; import com.plaid.linksample.network.LinkTokenRequester; import kotlin.Unit; -import java.util.ArrayList; - public class MainActivityJava extends AppCompatActivity { @@ -89,14 +86,16 @@ private void setOptionalEventListener() { * parameter reference */ private void openLink() { - ArrayList products = new ArrayList<>(); - products.add(PlaidProduct.TRANSACTIONS); LinkTokenRequester.INSTANCE.getToken() .subscribe(this::onLinkTokenSuccess, this::onLinkTokenError); } private void onLinkTokenSuccess(String token) { - Plaid.create(getApplication(), new LinkTokenConfiguration.Builder().token(token).build()) + Plaid.create( + getApplication(), + new LinkTokenConfiguration.Builder() + .token(token) + .build()) .open(this); }