Skip to content

Commit b23af9e

Browse files
authored
chore(samples): Add Custom Tabs screen (#4799)
1 parent cf708bd commit b23af9e

File tree

7 files changed

+56
-2
lines changed

7 files changed

+56
-2
lines changed

gradle/libs.versions.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ androidx-navigation-runtime = { module = "androidx.navigation:navigation-runtime
9191
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "androidxNavigation" }
9292
androidx-sqlite = { module = "androidx.sqlite:sqlite", version = "2.5.2" }
9393
androidx-recyclerview = { module = "androidx.recyclerview:recyclerview", version = "1.2.1" }
94+
androidx-browser = { module = "androidx.browser:browser", version = "1.8.0" }
9495
coil-compose = { module = "io.coil-kt:coil-compose", version = "2.6.0" }
9596
commons-compress = {module = "org.apache.commons:commons-compress", version = "1.25.0"}
9697
context-propagation = { module = "io.micrometer:context-propagation", version = "1.1.0" }

sentry-samples/sentry-samples-android/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ dependencies {
144144
implementation(libs.androidx.compose.material3)
145145
implementation(libs.androidx.navigation.compose)
146146
implementation(libs.androidx.recyclerview)
147+
implementation(libs.androidx.browser)
147148
implementation(libs.coil.compose)
148149
implementation(libs.kotlinx.coroutines.android)
149150
implementation(libs.retrofit)

sentry-samples/sentry-samples-android/src/main/AndroidManifest.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,12 @@
6969
android:exported="false" />
7070

7171
<activity
72-
android:name=".compose.ComposeActivity"
73-
android:exported="false" />
72+
android:name=".CustomTabsActivity"
73+
android:exported="false" />
74+
75+
<activity
76+
android:name=".compose.ComposeActivity"
77+
android:exported="false" />
7478

7579
<activity android:name=".FrameDataForSpansActivity"
7680
android:exported="false"/>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package io.sentry.samples.android;
2+
3+
import android.net.Uri;
4+
import android.os.Bundle;
5+
import androidx.appcompat.app.AppCompatActivity;
6+
import androidx.browser.customtabs.CustomTabColorSchemeParams;
7+
import androidx.browser.customtabs.CustomTabsIntent;
8+
import androidx.core.content.ContextCompat;
9+
10+
public class CustomTabsActivity extends AppCompatActivity {
11+
12+
private static final String DEMO_URL = "https://www.sentry.io/";
13+
14+
@Override
15+
protected void onCreate(Bundle savedInstanceState) {
16+
super.onCreate(savedInstanceState);
17+
18+
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
19+
20+
CustomTabColorSchemeParams params =
21+
new CustomTabColorSchemeParams.Builder()
22+
.setToolbarColor(ContextCompat.getColor(this, R.color.colorPrimary))
23+
.build();
24+
builder.setDefaultColorSchemeParams(params);
25+
26+
builder.setShowTitle(true);
27+
builder.setShareState(CustomTabsIntent.SHARE_STATE_ON);
28+
builder.setInstantAppsEnabled(true);
29+
30+
CustomTabsIntent customTabsIntent = builder.build();
31+
customTabsIntent.launchUrl(this, Uri.parse(DEMO_URL));
32+
33+
finish();
34+
}
35+
}

sentry-samples/sentry-samples-android/src/main/java/io/sentry/samples/android/MainActivity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,11 @@ public void run() {
272272
startActivity(new Intent(this, ProfilingActivity.class));
273273
});
274274

275+
binding.openCustomTabsActivity.setOnClickListener(
276+
view -> {
277+
startActivity(new Intent(this, CustomTabsActivity.class));
278+
});
279+
275280
binding.openFrameDataForSpans.setOnClickListener(
276281
view -> startActivity(new Intent(this, FrameDataForSpansActivity.class)));
277282

sentry-samples/sentry-samples-android/src/main/res/layout/activity_main.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@
146146
android:layout_height="wrap_content"
147147
android:text="@string/open_profiling_activity"/>
148148

149+
<Button
150+
android:id="@+id/open_custom_tabs_activity"
151+
android:layout_width="wrap_content"
152+
android:layout_height="wrap_content"
153+
android:text="@string/open_custom_tabs_activity"
154+
/>
155+
149156
<Button
150157
android:id="@+id/open_frame_data_for_spans"
151158
android:layout_width="wrap_content"

sentry-samples/sentry-samples-android/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<string name="open_permissions_activity">Open Permissions Activity</string>
2424
<string name="open_compose_activity">Open Compose Activity</string>
2525
<string name="open_profiling_activity">Open Profiling Activity</string>
26+
<string name="open_custom_tabs_activity">Open Custom Tabs Activity</string>
2627
<string name="open_frame_data_for_spans">Open Frame Data for Spans Activity</string>
2728
<string name="open_metrics">Delightful Developer Metrics</string>
2829
<string name="test_timber_integration">Test Timber</string>

0 commit comments

Comments
 (0)