diff --git a/build.gradle b/build.gradle index e8add7b3..9cd8b661 100644 --- a/build.gradle +++ b/build.gradle @@ -20,6 +20,9 @@ buildscript { repositories { google() jcenter() + maven { + url = "https://androidx.dev/snapshots/builds/12711855/artifacts/repository" + } } dependencies { classpath 'com.android.tools.build:gradle:8.7.3' @@ -31,6 +34,12 @@ allprojects { google() jcenter() + // AndroidX snapshots repository + maven { + url = "https://androidx.dev/snapshots/builds/12815573/artifacts/repository" + } + + // Repository for DexMaker maven { url = "https://linkedin.jfrog.io/artifactory/open-source/" content { diff --git a/demos/custom-tabs-ephemeral/.gitignore b/demos/custom-tabs-ephemeral/.gitignore new file mode 100644 index 00000000..a7747886 --- /dev/null +++ b/demos/custom-tabs-ephemeral/.gitignore @@ -0,0 +1,2 @@ +/build + diff --git a/demos/custom-tabs-ephemeral/README.md b/demos/custom-tabs-ephemeral/README.md new file mode 100644 index 00000000..edc6c902 --- /dev/null +++ b/demos/custom-tabs-ephemeral/README.md @@ -0,0 +1,3 @@ +# Custom Tabs Ephemeral Demo + +This demo shows how to launch a Custom Tab with ephemeral browsing enabled. \ No newline at end of file diff --git a/demos/custom-tabs-ephemeral/build.gradle b/demos/custom-tabs-ephemeral/build.gradle new file mode 100644 index 00000000..c11649a9 --- /dev/null +++ b/demos/custom-tabs-ephemeral/build.gradle @@ -0,0 +1,52 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +apply plugin: 'com.android.application' + +android { + namespace 'com.google.androidbrowserhelper.demos.customtabsephemeral' + compileSdkVersion 35 + defaultConfig { + applicationId "com.google.androidbrowserhelper.demos.customtabsephemeral" + minSdkVersion 26 + targetSdkVersion 35 + versionCode 1 + versionName "1.0" + } + + buildTypes { + release { + minifyEnabled false + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 + } +} + +dependencies { + implementation project(path: ':androidbrowserhelper') + implementation fileTree(dir: "libs", include: ["*.jar"]) + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'androidx.activity:activity:1.9.3' + implementation 'androidx.browser:browser:1.9.0-SNAPSHOT' + implementation 'com.google.android.material:material:1.12.0' + implementation 'androidx.annotation:annotation:1.9.1' + implementation 'androidx.constraintlayout:constraintlayout:2.2.0' +} diff --git a/demos/custom-tabs-ephemeral/proguard-rules.pro b/demos/custom-tabs-ephemeral/proguard-rules.pro new file mode 100644 index 00000000..cf504086 --- /dev/null +++ b/demos/custom-tabs-ephemeral/proguard-rules.pro @@ -0,0 +1,22 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile + diff --git a/demos/custom-tabs-ephemeral/src/main/AndroidManifest.xml b/demos/custom-tabs-ephemeral/src/main/AndroidManifest.xml new file mode 100644 index 00000000..94e67844 --- /dev/null +++ b/demos/custom-tabs-ephemeral/src/main/AndroidManifest.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + diff --git a/demos/custom-tabs-ephemeral/src/main/java/com/google/androidbrowserhelper/demos/customtabsephemeral/MainActivity.java b/demos/custom-tabs-ephemeral/src/main/java/com/google/androidbrowserhelper/demos/customtabsephemeral/MainActivity.java new file mode 100644 index 00000000..8308bd50 --- /dev/null +++ b/demos/custom-tabs-ephemeral/src/main/java/com/google/androidbrowserhelper/demos/customtabsephemeral/MainActivity.java @@ -0,0 +1,53 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.androidbrowserhelper.demos.customtabsephemeral; + +import androidx.annotation.OptIn; +import androidx.browser.customtabs.CustomTabsIntent; +import androidx.browser.customtabs.ExperimentalEphemeralBrowsing; + +import android.app.Activity; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.widget.Button; + +public class MainActivity extends Activity { + private static final Uri URL = Uri.parse("https://xchrdw.github.io/browsing-data/siteDataTester.html"); + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + Button mLaunchButton = findViewById(R.id.launch); + mLaunchButton.setOnClickListener(view -> { + launchTab(); + }); + } + + @OptIn(markerClass = ExperimentalEphemeralBrowsing.class) + private void launchTab() { + Intent customTabsIntent = new CustomTabsIntent.Builder() + .setEphemeralBrowsingEnabled(true) + .build() + .intent; + customTabsIntent.setData(URL); + startActivity(customTabsIntent); + } +} + diff --git a/demos/custom-tabs-ephemeral/src/main/res/drawable-anydpi/ic_notification_icon.xml b/demos/custom-tabs-ephemeral/src/main/res/drawable-anydpi/ic_notification_icon.xml new file mode 100644 index 00000000..4c5c8a73 --- /dev/null +++ b/demos/custom-tabs-ephemeral/src/main/res/drawable-anydpi/ic_notification_icon.xml @@ -0,0 +1,28 @@ + + + + + + diff --git a/demos/custom-tabs-ephemeral/src/main/res/drawable-v24/ic_launcher_foreground.xml b/demos/custom-tabs-ephemeral/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 00000000..5a8f0381 --- /dev/null +++ b/demos/custom-tabs-ephemeral/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + diff --git a/demos/custom-tabs-ephemeral/src/main/res/drawable/ic_launcher_background.xml b/demos/custom-tabs-ephemeral/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 00000000..7806d1dc --- /dev/null +++ b/demos/custom-tabs-ephemeral/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,183 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/custom-tabs-ephemeral/src/main/res/layout/activity_main.xml b/demos/custom-tabs-ephemeral/src/main/res/layout/activity_main.xml new file mode 100644 index 00000000..6876cae7 --- /dev/null +++ b/demos/custom-tabs-ephemeral/src/main/res/layout/activity_main.xml @@ -0,0 +1,31 @@ + + + + +