Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Android 15 #111

Merged
merged 5 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# browser-switch-android Release Notes

## unreleased

* Upgrade `compileSdkVersion` and `targetSdkVersion` to API 35
* Breaking Changes
* Bump target Java version to Java 17

## 3.0.0-beta1

* Make `BrowserSwitchClient.assertCanPerformBrowserSwitch()` public
Expand Down
3 changes: 0 additions & 3 deletions browser-switch/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ android {
sourceCompatibility versions.javaSourceCompatibility
targetCompatibility versions.javaTargetCompatibility
}
kotlinOptions {
jvmTarget = "11"
}

// robolectric
testOptions {
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
}
}

def sdkTargetJavaVersion = JavaVersion.VERSION_11
def sdkTargetJavaVersion = JavaVersion.VERSION_17
ext.versions = [
"javaSourceCompatibility": sdkTargetJavaVersion,
"javaTargetCompatibility": sdkTargetJavaVersion,
Expand All @@ -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'
}
Expand All @@ -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
}
Expand Down
3 changes: 0 additions & 3 deletions demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ android {
sourceCompatibility versions.javaSourceCompatibility
targetCompatibility versions.javaTargetCompatibility
}
kotlinOptions {
jvmTarget = "11"
}
buildFeatures {
compose true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -35,7 +37,7 @@ class ComposeActivity : ComponentActivity() {
browserSwitchClient = BrowserSwitchClient()

setContent {
Column(modifier = Modifier.padding(10.dp)) {
Column(modifier = Modifier.safeGesturesPadding()) {
BrowserSwitchButton {
startBrowserSwitch()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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) {
Expand Down
19 changes: 7 additions & 12 deletions demo/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,35 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical"
android:padding="10dp"
android:gravity="top"
>
android:orientation="vertical"
tools:context="com.braintreepayments.api.browserswitch.demo.MainActivity">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Browser Switch"
android:textSize="40sp"
android:layout_marginBottom="8dp"
/>
android:text="Browser Switch"
android:textSize="40sp" />

<Button
android:id="@+id/standard_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Launch Mode: Standard"
/>
android:text="Launch Mode: Standard" />

<Button
android:id="@+id/single_top_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Launch Mode: Single Top"
/>
android:text="Launch Mode: Single Top" />

</LinearLayout>
2 changes: 1 addition & 1 deletion demo/src/main/res/layout/demo_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="16dp"
tools:context=".DemoFragment"
tools:context="com.braintreepayments.api.browserswitch.demo.DemoActivitySingleTop"
>

<TextView
Expand Down
2 changes: 1 addition & 1 deletion demo/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="Theme.AppCompat" />
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar" />
</resources>
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
Loading