From c6a353a1319e84f68ffffbecb53eed43eb61c143 Mon Sep 17 00:00:00 2001 From: luyi Date: Fri, 25 Oct 2024 11:24:11 +0200 Subject: [PATCH] RUM-6945: Add Tab fragment in sample application for Session Replay --- .../sessionreplay/SessionReplayFragment.kt | 1 + .../sample/sessionreplay/TabsFragment.kt | 63 +++++++++++++++++++ .../ic_bookmark_border_white_24dp.xml | 9 +++ .../res/drawable/ic_bookmark_white_24dp.xml | 9 +++ .../main/res/drawable/ic_menu_white_24dp.xml | 9 +++ .../res/drawable/ic_mode_edit_white_24dp.xml | 10 +++ .../res/drawable/ic_search_white_24dp.xml | 9 +++ .../src/main/res/drawable/outline_edit_24.xml | 10 +++ .../src/main/res/drawable/search_bold.xml | 9 +++ .../main/res/drawable/selector_nav_edits.xml | 5 ++ .../main/res/drawable/selector_nav_saved.xml | 5 ++ .../main/res/drawable/selector_nav_search.xml | 5 ++ .../res/layout/fragment_session_replay.xml | 10 +++ .../src/main/res/layout/fragment_tabs.xml | 26 ++++++++ .../src/main/res/navigation/nav_graph.xml | 5 ++ sample/kotlin/src/main/res/values/ids.xml | 7 +++ sample/kotlin/src/main/res/values/strings.xml | 6 ++ 17 files changed, 198 insertions(+) create mode 100644 sample/kotlin/src/main/kotlin/com/datadog/android/sample/sessionreplay/TabsFragment.kt create mode 100644 sample/kotlin/src/main/res/drawable/ic_bookmark_border_white_24dp.xml create mode 100644 sample/kotlin/src/main/res/drawable/ic_bookmark_white_24dp.xml create mode 100644 sample/kotlin/src/main/res/drawable/ic_menu_white_24dp.xml create mode 100644 sample/kotlin/src/main/res/drawable/ic_mode_edit_white_24dp.xml create mode 100644 sample/kotlin/src/main/res/drawable/ic_search_white_24dp.xml create mode 100644 sample/kotlin/src/main/res/drawable/outline_edit_24.xml create mode 100644 sample/kotlin/src/main/res/drawable/search_bold.xml create mode 100644 sample/kotlin/src/main/res/drawable/selector_nav_edits.xml create mode 100644 sample/kotlin/src/main/res/drawable/selector_nav_saved.xml create mode 100644 sample/kotlin/src/main/res/drawable/selector_nav_search.xml create mode 100644 sample/kotlin/src/main/res/layout/fragment_tabs.xml create mode 100644 sample/kotlin/src/main/res/values/ids.xml diff --git a/sample/kotlin/src/main/kotlin/com/datadog/android/sample/sessionreplay/SessionReplayFragment.kt b/sample/kotlin/src/main/kotlin/com/datadog/android/sample/sessionreplay/SessionReplayFragment.kt index d8fdf395b2..e71608e088 100644 --- a/sample/kotlin/src/main/kotlin/com/datadog/android/sample/sessionreplay/SessionReplayFragment.kt +++ b/sample/kotlin/src/main/kotlin/com/datadog/android/sample/sessionreplay/SessionReplayFragment.kt @@ -64,6 +64,7 @@ internal class SessionReplayFragment : R.id.navigation_image_scaling -> R.id.fragment_image_scaling R.id.navigation_webview_recording -> R.id.fragment_webview_record R.id.navigation_view_group -> R.id.fragment_view_group_components + R.id.navigation_tabs -> R.id.fragment_tabs else -> null } if (destination != null) { diff --git a/sample/kotlin/src/main/kotlin/com/datadog/android/sample/sessionreplay/TabsFragment.kt b/sample/kotlin/src/main/kotlin/com/datadog/android/sample/sessionreplay/TabsFragment.kt new file mode 100644 index 0000000000..7e9859744f --- /dev/null +++ b/sample/kotlin/src/main/kotlin/com/datadog/android/sample/sessionreplay/TabsFragment.kt @@ -0,0 +1,63 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2016-Present Datadog, Inc. + */ + +package com.datadog.android.sample.sessionreplay + +import android.os.Bundle +import android.view.Menu +import android.view.View +import androidx.annotation.DrawableRes +import androidx.annotation.StringRes +import androidx.fragment.app.Fragment +import com.datadog.android.sample.R +import com.google.android.material.bottomnavigation.BottomNavigationView + +internal class TabsFragment : Fragment(R.layout.fragment_tabs) { + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + val bottomNavigationView = view.findViewById(R.id.main_nav_tab_layout) + bottomNavigationView.menu.clear() + NavTab.values().forEachIndexed { index, tab -> + bottomNavigationView.menu.add(Menu.NONE, tab.id, index, tab.text).setIcon(tab.icon) + } + } + + enum class NavTab( + @StringRes val text: Int, + val id: Int, + @DrawableRes val icon: Int + ) { + + READING_LISTS( + R.string.nav_item_saved, + R.id.nav_tab_reading_lists, + R.drawable.selector_nav_saved + ), + + SEARCH( + R.string.nav_item_search, + R.id.nav_tab_search, + R.drawable.selector_nav_search + ), + EDITS( + R.string.nav_item_suggested_edits, + R.id.nav_tab_edits, + R.drawable.selector_nav_edits + ), + MORE( + R.string.nav_item_more, + R.id.nav_tab_more, + R.drawable.ic_menu_white_24dp + ); + + companion object { + fun of(code: Int): NavTab { + return values()[code] + } + } + } +} diff --git a/sample/kotlin/src/main/res/drawable/ic_bookmark_border_white_24dp.xml b/sample/kotlin/src/main/res/drawable/ic_bookmark_border_white_24dp.xml new file mode 100644 index 0000000000..b25a9120d6 --- /dev/null +++ b/sample/kotlin/src/main/res/drawable/ic_bookmark_border_white_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/sample/kotlin/src/main/res/drawable/ic_bookmark_white_24dp.xml b/sample/kotlin/src/main/res/drawable/ic_bookmark_white_24dp.xml new file mode 100644 index 0000000000..4a32f37e72 --- /dev/null +++ b/sample/kotlin/src/main/res/drawable/ic_bookmark_white_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/sample/kotlin/src/main/res/drawable/ic_menu_white_24dp.xml b/sample/kotlin/src/main/res/drawable/ic_menu_white_24dp.xml new file mode 100644 index 0000000000..100ae0dad7 --- /dev/null +++ b/sample/kotlin/src/main/res/drawable/ic_menu_white_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/sample/kotlin/src/main/res/drawable/ic_mode_edit_white_24dp.xml b/sample/kotlin/src/main/res/drawable/ic_mode_edit_white_24dp.xml new file mode 100644 index 0000000000..20f6eadfce --- /dev/null +++ b/sample/kotlin/src/main/res/drawable/ic_mode_edit_white_24dp.xml @@ -0,0 +1,10 @@ + + + diff --git a/sample/kotlin/src/main/res/drawable/ic_search_white_24dp.xml b/sample/kotlin/src/main/res/drawable/ic_search_white_24dp.xml new file mode 100644 index 0000000000..c927d3d226 --- /dev/null +++ b/sample/kotlin/src/main/res/drawable/ic_search_white_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/sample/kotlin/src/main/res/drawable/outline_edit_24.xml b/sample/kotlin/src/main/res/drawable/outline_edit_24.xml new file mode 100644 index 0000000000..47ea705d1b --- /dev/null +++ b/sample/kotlin/src/main/res/drawable/outline_edit_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/sample/kotlin/src/main/res/drawable/search_bold.xml b/sample/kotlin/src/main/res/drawable/search_bold.xml new file mode 100644 index 0000000000..b2f6e4e90a --- /dev/null +++ b/sample/kotlin/src/main/res/drawable/search_bold.xml @@ -0,0 +1,9 @@ + + + diff --git a/sample/kotlin/src/main/res/drawable/selector_nav_edits.xml b/sample/kotlin/src/main/res/drawable/selector_nav_edits.xml new file mode 100644 index 0000000000..b27d740360 --- /dev/null +++ b/sample/kotlin/src/main/res/drawable/selector_nav_edits.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/sample/kotlin/src/main/res/drawable/selector_nav_saved.xml b/sample/kotlin/src/main/res/drawable/selector_nav_saved.xml new file mode 100644 index 0000000000..dc84ad32ec --- /dev/null +++ b/sample/kotlin/src/main/res/drawable/selector_nav_saved.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/sample/kotlin/src/main/res/drawable/selector_nav_search.xml b/sample/kotlin/src/main/res/drawable/selector_nav_search.xml new file mode 100644 index 0000000000..6ab34e4fb9 --- /dev/null +++ b/sample/kotlin/src/main/res/drawable/selector_nav_search.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/sample/kotlin/src/main/res/layout/fragment_session_replay.xml b/sample/kotlin/src/main/res/layout/fragment_session_replay.xml index 5bcd57f5ca..8ef71d65bb 100644 --- a/sample/kotlin/src/main/res/layout/fragment_session_replay.xml +++ b/sample/kotlin/src/main/res/layout/fragment_session_replay.xml @@ -140,5 +140,15 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/navigation_webview_recording" /> + + diff --git a/sample/kotlin/src/main/res/layout/fragment_tabs.xml b/sample/kotlin/src/main/res/layout/fragment_tabs.xml new file mode 100644 index 0000000000..2e444c22a8 --- /dev/null +++ b/sample/kotlin/src/main/res/layout/fragment_tabs.xml @@ -0,0 +1,26 @@ + + + + + + + diff --git a/sample/kotlin/src/main/res/navigation/nav_graph.xml b/sample/kotlin/src/main/res/navigation/nav_graph.xml index 6807943c0f..b307634a77 100644 --- a/sample/kotlin/src/main/res/navigation/nav_graph.xml +++ b/sample/kotlin/src/main/res/navigation/nav_graph.xml @@ -81,6 +81,11 @@ android:name="com.datadog.android.sample.sessionreplay.RadioCheckBoxesFragment" android:label="@string/radio_and_check_box_components"/> + + diff --git a/sample/kotlin/src/main/res/values/ids.xml b/sample/kotlin/src/main/res/values/ids.xml new file mode 100644 index 0000000000..c4cad097ff --- /dev/null +++ b/sample/kotlin/src/main/res/values/ids.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/sample/kotlin/src/main/res/values/strings.xml b/sample/kotlin/src/main/res/values/strings.xml index cd9fb8365e..34ceec3d88 100644 --- a/sample/kotlin/src/main/res/values/strings.xml +++ b/sample/kotlin/src/main/res/values/strings.xml @@ -149,6 +149,7 @@ Material CheckBox Disabled Checked With custom tint Material CheckBox With Disabled Not Checked custom tint Radio and CheckBox Components + Tabs Default Radio App Compat Radio Material Radio @@ -183,10 +184,15 @@ Chained Otel Contexts Test Web View Recording View Groups + Tabs Start Custom Rum View WebView Recording Linked Spans Test Start Linked Spans Test Card view Material Card view + Saved + Search + Edits + More