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

Update JDK, Gradle and libraries #492

Closed
wants to merge 9 commits into from
Closed
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
4 changes: 2 additions & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: set up JDK 1.8
- name: set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 17
- name: Build with Gradle
run: ./gradlew build
35 changes: 18 additions & 17 deletions androidbrowserhelper/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ apply plugin: 'maven-publish'
def VERSION = "2.5.0";

android {
compileSdkVersion 31
namespace "com.google.androidbrowserhelper"
compileSdk 35

defaultConfig {
minSdkVersion 16
targetSdkVersion 31
minSdkVersion 21
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume minSdk has raised because targetCompatibility is Java 17. Can we update jdk version that runs gradle, but keep existing build configuration for demos and especially androidbrowserhelper? AFAIK, most of the AndroidX libraries use jdk 1.8, so we should be fine with updating only gradle.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@orbital17 as I remember these changes would cause bubblewrap update, right?

versionCode 1
versionName VERSION
targetSdkVersion 35
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a big jump, are we sure that we covered all changes?


testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -39,8 +40,8 @@ android {
}

compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

testOptions {
Expand All @@ -51,23 +52,23 @@ android {
}

dependencies {
api 'androidx.browser:browser:1.4.0'
api 'androidx.browser:browser:1.8.0'

implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.core:core:1.0.2'
implementation 'androidx.annotation:annotation:1.9.1'
implementation 'androidx.core:core:1.15.0'

testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:3.0.0'
testImplementation 'org.robolectric:robolectric:4.4'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:3.12.4'
testImplementation 'org.robolectric:robolectric:4.11'

androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'org.mockito:mockito-core:3.0.0'
androidTestImplementation 'com.linkedin.dexmaker:dexmaker-mockito:2.19.0'
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.6.2'
androidTestImplementation 'androidx.test:rules:1.6.1'
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation 'org.mockito:mockito-core:3.12.4'
androidTestImplementation 'com.linkedin.dexmaker:dexmaker-mockito:2.28.3'
androidTestImplementation 'junit:junit:4.13.2'
}

publishing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import androidx.browser.customtabs.CustomTabsIntent;
import androidx.browser.customtabs.CustomTabsSessionToken;
import androidx.browser.trusted.TrustedWebActivityIntentBuilder;
import androidx.test.InstrumentationRegistry;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.filters.MediumTest;
import androidx.test.rule.ActivityTestRule;
import androidx.test.ext.junit.runners.AndroidJUnit4;
Expand All @@ -69,7 +69,7 @@
public class TwaLauncherTest {
private static final Uri URL = Uri.parse("https://www.test.com/default_url/");

private Context mContext = InstrumentationRegistry.getContext();
private final Context mContext = InstrumentationRegistry.getInstrumentation().getContext();
private static final CustomTabsCallback mCustomTabsCallback = new QualityEnforcer();

@Rule
Expand Down Expand Up @@ -231,7 +231,7 @@ public void notifiesSplashScreenStrategyOfLaunchInitiation() {
TrustedWebActivityIntentBuilder builder = makeBuilder();
mTwaLauncher.launch(builder, mCustomTabsCallback, strategy, null);
verify(strategy).onTwaLaunchInitiated(
eq(InstrumentationRegistry.getContext().getPackageName()),
eq(InstrumentationRegistry.getInstrumentation().getContext().getPackageName()),
eq(builder));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@

package com.google.androidbrowserhelper.trusted.testcomponents;

import android.app.Activity;
import android.os.Bundle;
import android.os.Looper;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

/**
* A fake Browser that accepts browsable Intents.
*/
public class TestBrowser extends AppCompatActivity {
public class TestBrowser extends Activity {

private final CountDownLatch mResumeLatch = new CountDownLatch(1);

Expand Down
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.android.tools.build:gradle:8.7.3'
}
}

allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
tasks.register('clean', Delete) {
delete rootProject.layout.buildDirectory
}
20 changes: 10 additions & 10 deletions demos/custom-tabs-example-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 33
buildToolsVersion "30.0.3"
namespace "org.chromium.customtabsdemos"
compileSdk 35

defaultConfig {
applicationId "org.chromium.customtabsdemos"
minSdkVersion 26
targetSdkVersion 31
targetSdkVersion 35
versionCode 1
versionName "1.0"
}
Expand All @@ -35,18 +35,18 @@ android {
}

compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(path: ':androidbrowserhelper')

implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.browser:browser:1.6.0-alpha01'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.core:core:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.browser:browser:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.2.0'
implementation 'androidx.core:core:1.15.0'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
}
1 change: 1 addition & 0 deletions demos/custom-tabs-example-app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</intent>
</queries>

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,8 @@ protected void onStop() {
@Override
public void onClick(View v) {
int viewId = v.getId();
switch (viewId) {
case R.id.start_custom_tab:
openCustomTab();
break;
default:
//Unknown View Clicked
if (viewId == R.id.start_custom_tab) {
openCustomTab();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ private static class ActivityDesc {
private static class ViewHolder extends RecyclerView.ViewHolder {
/* package */ TextView mTitleTextView;
/* package */ TextView mDescriptionTextView;
/* package */ int mPosition;

public ViewHolder(View itemView) {
super(itemView);
Expand All @@ -117,7 +116,7 @@ public ActivityListAdapter(Context context, List<ActivityDesc> activityDescs) {

@Override
public void onClick(View v) {
int position = ((ViewHolder)v.getTag()).mPosition;
int position = ((ViewHolder)v.getTag()).getAdapterPosition();
ActivityDesc activityDesc = mActivityDescs.get(position);
Intent intent = new Intent(mContext, activityDesc.mActivity);
mContext.startActivity(intent);
Expand All @@ -141,7 +140,6 @@ public void onBindViewHolder(ViewHolder viewHolder, int position) {

viewHolder.mTitleTextView.setText(title);
viewHolder.mDescriptionTextView.setText(description);
viewHolder.mPosition = position;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,8 @@ private void unbindCustomTabsService() {
@Override
public void onClick(View v) {
int viewId = v.getId();
switch (viewId) {
case R.id.start_custom_tab:
openCustomTab();
break;
default:
// Unknown View Clicked
if (viewId == R.id.start_custom_tab) {
openCustomTab();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,9 @@ protected void onNewIntent(Intent intent) {
@Override
public void onClick(View v) {
int viewId = v.getId();
switch (viewId) {
case R.id.create_notification:
createAndShowNotification();
finish();
break;
default:
//Unknown view clicked
if (viewId == R.id.create_notification) {
createAndShowNotification();
finish();
}
}

Expand All @@ -81,7 +77,7 @@ private void createAndShowNotification() {
}
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this, CT_NOTIFICATION_CHANNEL_ID)
.setSmallIcon(R.drawable.abc_popup_background_mtrl_mult)
.setSmallIcon(R.drawable.ic_launcher_foreground)
.setContentTitle(getString(R.string.notification_title))
.setContentText(getString(R.string.notification_text));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,8 @@ protected void onStop() {
@Override
public void onClick(View v) {
int viewId = v.getId();
switch (viewId) {
case R.id.start_custom_tab:
openCustomTab();
break;
default:
// Unknown View Clicked
if (viewId == R.id.start_custom_tab) {
openCustomTab();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,14 @@ public void onCustomTabsDisconnected() {
public void onClick(View view) {
int viewId = view.getId();
Uri uri = Uri.parse(mUrlEditText.getText().toString());
switch (viewId) {
case R.id.button_may_launch_url:
customTabActivityHelper.mayLaunchUrl(uri, null, null);
break;
case R.id.start_custom_tab:
CustomTabsIntent customTabsIntent =
new CustomTabsIntent.Builder(customTabActivityHelper.getSession())
.build();
CustomTabActivityHelper.openCustomTab(
this, customTabsIntent, uri, new WebviewFallback());
break;
default:
//Unkown View Clicked
if (viewId == R.id.button_may_launch_url) {
customTabActivityHelper.mayLaunchUrl(uri, null, null);
} else if (viewId == R.id.start_custom_tab) {
CustomTabsIntent customTabsIntent =
new CustomTabsIntent.Builder(customTabActivityHelper.getSession())
.build();
CustomTabActivityHelper.openCustomTab(
this, customTabsIntent, uri, new WebviewFallback());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,11 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void onClick(View v) {
int viewId = v.getId();

switch (viewId) {
case R.id.start_custom_tab:
String url = mUrlEditText.getText().toString();
CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder().build();
CustomTabActivityHelper.openCustomTab(
this, customTabsIntent, Uri.parse(url), new WebviewFallback());
break;
default:
//Unknown View Clicked
if (viewId == R.id.start_custom_tab) {
String url = mUrlEditText.getText().toString();
CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder().build();
CustomTabActivityHelper.openCustomTab(
this, customTabsIntent, Uri.parse(url), new WebviewFallback());
}
}
}
14 changes: 7 additions & 7 deletions demos/custom-tabs-headers/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 31
buildToolsVersion "30.0.3"
namespace "com.google.androidbrowserhelper.demos.customtabsheaders"
compileSdk 35

defaultConfig {
applicationId "com.google.androidbrowserhelper.demos.customtabsheaders"
minSdkVersion 25
targetSdkVersion 31
targetSdkVersion 35
versionCode 1
versionName "1.0"

Expand All @@ -37,14 +37,14 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.browser:browser:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.2.0'
implementation 'androidx.browser:browser:1.8.0'
}

Loading
Loading