Skip to content

Commit

Permalink
Updated the gradle version, target api and fix some code warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
moElbehiry authored and bobzettle committed Jun 29, 2022
1 parent ee86ae7 commit d16d226
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 47 deletions.
5 changes: 2 additions & 3 deletions Examples/Example-Java/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
compileSdkVersion 32

defaultConfig {
applicationId "com.izettle.payments.android.java_example"
minSdkVersion 21
targetSdkVersion 29
targetSdkVersion 32
versionCode 1
versionName "1.0"
multiDexEnabled true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.izettle.payments.android.ui.refunds.RefundResult;
import com.izettle.payments.android.ui.refunds.RefundsActivity;

import java.util.Objects;
import java.util.UUID;

public class CardReaderActivity extends AppCompatActivity {
Expand All @@ -52,13 +53,11 @@ public void onCreate(Bundle savedInstanceState) {
installmentsCheckBox = findViewById(R.id.installments_check_box);
lastPaymentTraceId = new MutableLiveData<>();

lastPaymentTraceId.observe(this, value -> {
refundButton.setEnabled(value != null);
});
lastPaymentTraceId.observe(this, value -> refundButton.setEnabled(value != null));

chargeButton.setOnClickListener( v -> { onChargeClicked(); });
refundButton.setOnClickListener( v -> { onRefundClicked(); });
settingsButton.setOnClickListener( v -> { onSettingsClicked(); });
chargeButton.setOnClickListener( v -> onChargeClicked());
refundButton.setOnClickListener( v -> onRefundClicked());
settingsButton.setOnClickListener( v -> onSettingsClicked());
}

private final ActivityResultLauncher<Intent> paymentLauncher = registerForActivityResult(new StartActivityForResult(), result -> {
Expand All @@ -67,10 +66,10 @@ public void onCreate(Bundle savedInstanceState) {
if(parsed instanceof CardPaymentResult.Completed) {
showToast("Payment completed");
CardPaymentResult.Completed casted = (CardPaymentResult.Completed) parsed;
lastPaymentTraceId.setValue(casted.getPayload().getReference().getId());
lastPaymentTraceId.setValue(Objects.requireNonNull(casted.getPayload().getReference()).getId());
}
else if(parsed instanceof CardPaymentResult.Failed) {
showToast("Payment failed "+ ((CardPaymentResult.Failed) parsed).getReason().toString());
showToast("Payment failed "+ ((CardPaymentResult.Failed) parsed).getReason());
}
else if(parsed instanceof CardPaymentResult.Canceled) {
showToast("Payment canceled");
Expand All @@ -85,7 +84,7 @@ else if(parsed instanceof CardPaymentResult.Canceled) {
showToast("Refund completed");
}
else if(parsed instanceof RefundResult.Failed) {
showToast("Refund failed "+ ((RefundResult.Failed) parsed).getReason().toString());
showToast("Refund failed "+ ((RefundResult.Failed) parsed).getReason());
}
else if(parsed instanceof RefundResult.Canceled) {
showToast("Refund canceled");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,13 @@ public void onCreate(Bundle savedInstanceState) {
openCardReaderButton = findViewById(R.id.open_card_reader_btn);
openPayPalQrcButton = findViewById(R.id.open_paypal_btn);

toLiveData(IZettleSDK.Instance.getUser().getState()).observe(this, state -> {
onAuthStateChanged(state instanceof User.AuthState.LoggedIn);
});
toLiveData(IZettleSDK.Instance.getUser().getState()).observe(this, state ->
onAuthStateChanged(state instanceof User.AuthState.LoggedIn));

loginButton.setOnClickListener( v -> {
IZettleSDK.Instance.getUser().login(this, Color.WHITE);
});
loginButton.setOnClickListener( v ->
IZettleSDK.Instance.getUser().login(this, Color.WHITE));

logoutButton.setOnClickListener( v -> {
IZettleSDK.Instance.getUser().logout();
});
logoutButton.setOnClickListener( v -> IZettleSDK.Instance.getUser().logout());

openCardReaderButton.setOnClickListener( v -> {
Intent intent = new Intent(this, CardReaderActivity.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public void onCreate(Bundle savedInstanceState) {
refundAmountEditText = findViewById(R.id.refund_amount_input);
lastPaymentTraceId = new MutableLiveData<>();

chargeButton.setOnClickListener( v -> { onChargeClicked(); } );
settingsButton.setOnClickListener( v -> { onSettingsClicked(); } );
refundButton.setOnClickListener( v -> { onRefundLastPayment(); } );
chargeButton.setOnClickListener( v -> onChargeClicked());
settingsButton.setOnClickListener( v -> onSettingsClicked());
refundButton.setOnClickListener( v -> onRefundLastPayment());
}

private final ActivityResultLauncher<Intent> paymentLauncher = registerForActivityResult(new StartActivityForResult(), result -> {
Expand All @@ -63,7 +63,7 @@ public void onCreate(Bundle savedInstanceState) {
.append(String.valueOf(casted.getPayment().getAmount())));
}
else if(parsed instanceof PayPalQrcPaymentResult.Failed) {
showToast("Payment failed " + ((PayPalQrcPaymentResult.Failed) parsed).getReason().toString());
showToast("Payment failed " + ((PayPalQrcPaymentResult.Failed) parsed).getReason());
}
else if(parsed instanceof PayPalQrcPaymentResult.Canceled) {
showToast("Payment canceled");
Expand All @@ -78,7 +78,7 @@ else if(parsed instanceof PayPalQrcPaymentResult.Canceled) {
showToast("Refund completed");
}
else if(parsed instanceof PayPalQrcRefundResult.Failed) {
showToast("Refund failed "+ ((PayPalQrcRefundResult.Failed) parsed).getReason().toString());
showToast("Refund failed "+ ((PayPalQrcRefundResult.Failed) parsed).getReason());
}
else if(parsed instanceof PayPalQrcRefundResult.Canceled) {
showToast("Refund canceled");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

<CheckBox
android:id="@+id/venmo_check_box"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_weight="1"
Expand Down
2 changes: 1 addition & 1 deletion Examples/Example-Java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath 'com.android.tools.build:gradle:4.2.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Jun 09 11:37:01 CEST 2020
#Mon Jun 27 15:23:40 CEST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
zipStoreBase=GRADLE_USER_HOME
6 changes: 2 additions & 4 deletions Examples/Example-Kotlin/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
compileSdkVersion 32

defaultConfig {
applicationId "com.izettle.payments.android.kotlin_example"
minSdkVersion 21
targetSdkVersion 29
targetSdkVersion 32
versionCode 1
versionName "1.0"
multiDexEnabled true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import android.widget.*
import androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer
import com.izettle.payments.android.payment.TransactionReference
import com.izettle.payments.android.payment.refunds.CardPaymentPayload
import com.izettle.payments.android.payment.refunds.RefundsManager
Expand Down Expand Up @@ -42,9 +41,9 @@ class CardReaderActivity : AppCompatActivity() {
installmentsCheckBox = findViewById(R.id.installments_check_box)
lastPaymentTraceId = MutableLiveData()

lastPaymentTraceId.observe(this, Observer { value: String? ->
lastPaymentTraceId.observe(this) { value: String? ->
refundButton.isEnabled = value != null
})
}

chargeButton.setOnClickListener { onChargeClicked() }
refundButton.setOnClickListener { onRefundClicked() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import android.os.Bundle
import android.widget.Button
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.Observer
import com.izettle.android.commons.ext.state.toLiveData
import com.izettle.payments.android.sdk.IZettleSDK
import com.izettle.payments.android.sdk.User.AuthState.LoggedIn
Expand All @@ -30,9 +29,9 @@ class MainActivity : AppCompatActivity() {
openCardReaderButton = findViewById(R.id.open_card_reader_btn)
openPayPalQrcButton = findViewById(R.id.open_paypal_btn)

IZettleSDK.user.state.toLiveData().observe(this, Observer { state ->
IZettleSDK.user.state.toLiveData().observe(this) { state ->
onAuthStateChanged(state is LoggedIn)
})
}

loginButton.setOnClickListener {
IZettleSDK.user.login(this, Color.WHITE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

<CheckBox
android:id="@+id/venmo_check_box"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_weight="1"
Expand Down
4 changes: 2 additions & 2 deletions Examples/Example-Kotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

buildscript {

ext.kotlin_version = '1.3.61'
ext.kotlin_version = '1.5.0'

apply from: 'iZettleSDK.gradle'

Expand All @@ -11,7 +11,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath 'com.android.tools.build:gradle:4.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Jun 09 11:37:01 CEST 2020
#Mon Jun 27 15:23:40 CEST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
zipStoreBase=GRADLE_USER_HOME

0 comments on commit d16d226

Please sign in to comment.