From 8e99d6ef6b01264f2b0e80af10fb8e9f8ea5d13a Mon Sep 17 00:00:00 2001 From: sshropshire Date: Thu, 22 Aug 2024 11:12:37 -0500 Subject: [PATCH 1/5] Update compileSdkVersion to 35. --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 139327ec..b8c67ed9 100644 --- a/build.gradle +++ b/build.gradle @@ -43,9 +43,9 @@ plugins { version = '3.0.0-beta2-SNAPSHOT' group = "com.braintreepayments" ext { - compileSdkVersion = 34 + compileSdkVersion = 35 minSdkVersion = 23 - targetSdkVersion = 34 + targetSdkVersion = 35 versionCode = 71 versionName = version } From d150e5693e6e7e1c345ded239c09e405fee4cfe5 Mon Sep 17 00:00:00 2001 From: sshropshire Date: Thu, 22 Aug 2024 14:54:17 -0500 Subject: [PATCH 2/5] Update project to use JDK 17. --- browser-switch/build.gradle | 3 --- build.gradle | 4 ++-- demo/build.gradle | 3 --- gradle/wrapper/gradle-wrapper.properties | 2 +- 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/browser-switch/build.gradle b/browser-switch/build.gradle index fa40cbb9..ba335cc7 100644 --- a/browser-switch/build.gradle +++ b/browser-switch/build.gradle @@ -19,9 +19,6 @@ android { sourceCompatibility versions.javaSourceCompatibility targetCompatibility versions.javaTargetCompatibility } - kotlinOptions { - jvmTarget = "11" - } // robolectric testOptions { diff --git a/build.gradle b/build.gradle index b8c67ed9..62f7bedb 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { } } - def sdkTargetJavaVersion = JavaVersion.VERSION_11 + def sdkTargetJavaVersion = JavaVersion.VERSION_17 ext.versions = [ "javaSourceCompatibility": sdkTargetJavaVersion, "javaTargetCompatibility": sdkTargetJavaVersion, @@ -28,7 +28,7 @@ buildscript { ] dependencies { - classpath 'com.android.tools.build:gradle:8.1.4' + classpath 'com.android.tools.build:gradle:8.5.2' classpath 'org.jetbrains.dokka:dokka-gradle-plugin:1.9.10' classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0' } diff --git a/demo/build.gradle b/demo/build.gradle index 7a322625..726e269b 100644 --- a/demo/build.gradle +++ b/demo/build.gradle @@ -30,9 +30,6 @@ android { sourceCompatibility versions.javaSourceCompatibility targetCompatibility versions.javaTargetCompatibility } - kotlinOptions { - jvmTarget = "11" - } buildFeatures { compose true } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 413faf00..cdfd13ff 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Mon Jul 17 09:55:05 CDT 2023 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 1dc3bb63d0cb6398580875164825853201080a3a Mon Sep 17 00:00:00 2001 From: sshropshire Date: Thu, 22 Aug 2024 14:54:55 -0500 Subject: [PATCH 3/5] Adjust demo for edge-to-edge displays. --- .../api/browserswitch/demo/ComposeActivity.kt | 4 +++- .../demo/DemoActivitySingleTop.java | 18 ++++++++++++++++++ .../api/browserswitch/demo/MainActivity.java | 16 ++++++++++++++++ demo/src/main/res/layout/activity_main.xml | 19 +++++++------------ demo/src/main/res/layout/demo_fragment.xml | 2 +- demo/src/main/res/values/styles.xml | 2 +- 6 files changed, 46 insertions(+), 15 deletions(-) diff --git a/demo/src/main/java/com/braintreepayments/api/browserswitch/demo/ComposeActivity.kt b/demo/src/main/java/com/braintreepayments/api/browserswitch/demo/ComposeActivity.kt index 0853740d..a14c0c55 100644 --- a/demo/src/main/java/com/braintreepayments/api/browserswitch/demo/ComposeActivity.kt +++ b/demo/src/main/java/com/braintreepayments/api/browserswitch/demo/ComposeActivity.kt @@ -8,6 +8,8 @@ import androidx.activity.viewModels import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.safeDrawingPadding +import androidx.compose.foundation.layout.safeGesturesPadding import androidx.compose.material3.Button import androidx.compose.material3.Text import androidx.compose.runtime.Composable @@ -35,7 +37,7 @@ class ComposeActivity : ComponentActivity() { browserSwitchClient = BrowserSwitchClient() setContent { - Column(modifier = Modifier.padding(10.dp)) { + Column(modifier = Modifier.safeGesturesPadding()) { BrowserSwitchButton { startBrowserSwitch() } diff --git a/demo/src/main/java/com/braintreepayments/api/browserswitch/demo/DemoActivitySingleTop.java b/demo/src/main/java/com/braintreepayments/api/browserswitch/demo/DemoActivitySingleTop.java index 15caaa77..8ac4888e 100644 --- a/demo/src/main/java/com/braintreepayments/api/browserswitch/demo/DemoActivitySingleTop.java +++ b/demo/src/main/java/com/braintreepayments/api/browserswitch/demo/DemoActivitySingleTop.java @@ -2,10 +2,14 @@ import android.content.Intent; import android.os.Bundle; +import android.view.View; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import androidx.appcompat.app.AppCompatActivity; +import androidx.core.graphics.Insets; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowInsetsCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; @@ -15,6 +19,7 @@ import com.braintreepayments.api.BrowserSwitchOptions; import com.braintreepayments.api.BrowserSwitchStartResult; import com.braintreepayments.api.browserswitch.demo.utils.PendingRequestStore; +import com.braintreepayments.api.demo.R; import java.util.Objects; @@ -37,6 +42,19 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { .add(android.R.id.content, new DemoFragment(), FRAGMENT_TAG) .commit(); } + + // Support Edge-to-Edge layout in Android 15 + // Ref: https://developer.android.com/develop/ui/views/layout/edge-to-edge#cutout-insets + View navHostView = findViewById(android.R.id.content); + ViewCompat.setOnApplyWindowInsetsListener(navHostView, (v, insets) -> { + @WindowInsetsCompat.Type.InsetsType int insetTypeMask = + WindowInsetsCompat.Type.systemBars() + | WindowInsetsCompat.Type.displayCutout() + | WindowInsetsCompat.Type.systemGestures(); + Insets bars = insets.getInsets(insetTypeMask); + v.setPadding(bars.left, bars.top, bars.right, bars.bottom); + return WindowInsetsCompat.CONSUMED; + }); } @Override diff --git a/demo/src/main/java/com/braintreepayments/api/browserswitch/demo/MainActivity.java b/demo/src/main/java/com/braintreepayments/api/browserswitch/demo/MainActivity.java index c8ea4c3f..d2cf6528 100644 --- a/demo/src/main/java/com/braintreepayments/api/browserswitch/demo/MainActivity.java +++ b/demo/src/main/java/com/braintreepayments/api/browserswitch/demo/MainActivity.java @@ -1,6 +1,9 @@ package com.braintreepayments.api.browserswitch.demo; import androidx.appcompat.app.AppCompatActivity; +import androidx.core.graphics.Insets; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowInsetsCompat; import android.content.Intent; import android.os.Bundle; @@ -21,6 +24,19 @@ protected void onCreate(Bundle savedInstanceState) { Button singleTopButton = findViewById(R.id.single_top_button); singleTopButton.setOnClickListener(this::launchSingleTopBrowserSwitch); + + // Support Edge-to-Edge layout in Android 15 + // Ref: https://developer.android.com/develop/ui/views/layout/edge-to-edge#cutout-insets + View navHostView = findViewById(R.id.content); + ViewCompat.setOnApplyWindowInsetsListener(navHostView, (v, insets) -> { + @WindowInsetsCompat.Type.InsetsType int insetTypeMask = + WindowInsetsCompat.Type.systemBars() + | WindowInsetsCompat.Type.displayCutout() + | WindowInsetsCompat.Type.systemGestures(); + Insets bars = insets.getInsets(insetTypeMask); + v.setPadding(bars.left, bars.top, bars.right, bars.bottom); + return WindowInsetsCompat.CONSUMED; + }); } public void launchStandardBrowserSwitch(View view) { diff --git a/demo/src/main/res/layout/activity_main.xml b/demo/src/main/res/layout/activity_main.xml index d4cf47f2..5e6a043f 100644 --- a/demo/src/main/res/layout/activity_main.xml +++ b/demo/src/main/res/layout/activity_main.xml @@ -1,35 +1,30 @@ + android:orientation="vertical" + tools:context="com.braintreepayments.api.browserswitch.demo.MainActivity"> + android:text="Browser Switch" + android:textSize="40sp" />