Skip to content

Commit

Permalink
RUM-6945: Add Tab fragment in sample application for Session Replay
Browse files Browse the repository at this point in the history
  • Loading branch information
ambushwork committed Oct 29, 2024
1 parent 72455be commit c6a353a
Show file tree
Hide file tree
Showing 17 changed files with 198 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<BottomNavigationView>(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]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M17,3L7,3c-1.1,0 -1.99,0.9 -1.99,2L5,21l7,-3 7,3L19,5c0,-1.1 -0.9,-2 -2,-2zM17,18l-5,-2.18L7,18L7,5h10v13z"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M17,3H7c-1.1,0 -1.99,0.9 -1.99,2L5,21l7,-3 7,3V5c0,-1.1 -0.9,-2 -2,-2z"/>
</vector>
9 changes: 9 additions & 0 deletions sample/kotlin/src/main/res/drawable/ic_menu_white_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M3,18h18v-2L3,16v2zM3,13h18v-2L3,11v2zM3,6v2h18L21,6L3,6z"/>
</vector>
10 changes: 10 additions & 0 deletions sample/kotlin/src/main/res/drawable/ic_mode_edit_white_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/black"
android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z" />
</vector>
9 changes: 9 additions & 0 deletions sample/kotlin/src/main/res/drawable/ic_search_white_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"/>
</vector>
10 changes: 10 additions & 0 deletions sample/kotlin/src/main/res/drawable/outline_edit_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M14.06,9.02l0.92,0.92L5.92,19L5,19v-0.92l9.06,-9.06M17.66,3c-0.25,0 -0.51,0.1 -0.7,0.29l-1.83,1.83 3.75,3.75 1.83,-1.83c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.2,-0.2 -0.45,-0.29 -0.71,-0.29zM14.06,6.19L3,17.25L3,21h3.75L17.81,9.94l-3.75,-3.75z"/>
</vector>
9 changes: 9 additions & 0 deletions sample/kotlin/src/main/res/drawable/search_bold.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="m9.5,2.75c-3.728,0 -6.75,3.022 -6.75,6.75 0,3.728 3.022,6.75 6.75,6.75 1.594,0 3.056,-0.556 4.21,-1.479l0.041,0.041v0.792l5.248,5.241 1.844,-1.844 -5.238,-5.25h-0.795l-0.041,-0.041c0.923,-1.154 1.48,-2.616 1.48,-4.209 0,-3.728 -3.022,-6.75 -6.75,-6.75zM5.25,9.5c0,-2.347 1.902,-4.25 4.25,-4.25 2.347,0 4.25,1.903 4.25,4.25 0,2.348 -1.903,4.25 -4.25,4.25 -2.348,0 -4.25,-1.902 -4.25,-4.25z"
android:fillColor="#202122"/>
</vector>
5 changes: 5 additions & 0 deletions sample/kotlin/src/main/res/drawable/selector_nav_edits.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_mode_edit_white_24dp" android:state_checked="true"/>
<item android:drawable="@drawable/outline_edit_24" android:state_checked="false"/>
</selector>
5 changes: 5 additions & 0 deletions sample/kotlin/src/main/res/drawable/selector_nav_saved.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_bookmark_white_24dp" android:state_checked="true"/>
<item android:drawable="@drawable/ic_bookmark_border_white_24dp" android:state_checked="false"/>
</selector>
5 changes: 5 additions & 0 deletions sample/kotlin/src/main/res/drawable/selector_nav_search.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/search_bold" android:state_checked="true"/>
<item android:drawable="@drawable/ic_search_white_24dp" android:state_checked="false"/>
</selector>
10 changes: 10 additions & 0 deletions sample/kotlin/src/main/res/layout/fragment_session_replay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,15 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/navigation_webview_recording" />

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/navigation_tabs"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:text="@string/tabs_component"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/navigation_view_group" />

</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
26 changes: 26 additions & 0 deletions sample/kotlin/src/main/res/layout/fragment_tabs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ 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.
-->

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/main_nav_tab_layout"
android:layout_width="match_parent"
android:layout_height="72dp"
android:background="@android:color/background_dark"
app:elevation="0dp"
app:itemIconTint="@color/white"
app:itemTextColor="@color/white"
app:labelVisibilityMode="labeled"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:tabGravity="fill" />

</androidx.constraintlayout.widget.ConstraintLayout>
5 changes: 5 additions & 0 deletions sample/kotlin/src/main/res/navigation/nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@
android:name="com.datadog.android.sample.sessionreplay.RadioCheckBoxesFragment"
android:label="@string/radio_and_check_box_components"/>

<fragment
android:id="@+id/fragment_tabs"
android:name="com.datadog.android.sample.sessionreplay.TabsFragment"
android:label="@string/tab_component" />

<fragment android:id="@+id/fragment_dropdowns_switchers_components"
android:name="com.datadog.android.sample.sessionreplay.DropDownSwitchersFragment"
android:label="@string/dropdowns_and_switchers_components"/>
Expand Down
7 changes: 7 additions & 0 deletions sample/kotlin/src/main/res/values/ids.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="nav_tab_reading_lists" type="id" />
<item name="nav_tab_search" type="id" />
<item name="nav_tab_edits" type="id" />
<item name="nav_tab_more" type="id" />
</resources>
6 changes: 6 additions & 0 deletions sample/kotlin/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
<string name="material_checkbox_disabled_checked">Material CheckBox Disabled Checked With custom tint</string>
<string name="material_checkbox_disabled_not_checked">Material CheckBox With Disabled Not Checked custom tint</string>
<string name="radio_and_check_box_components">Radio and CheckBox Components</string>
<string name="tab_component">Tabs</string>
<string name="default_radio">Default Radio</string>
<string name="app_compat_radio">App Compat Radio</string>
<string name="material_radio">Material Radio</string>
Expand Down Expand Up @@ -183,10 +184,15 @@
<string name="chained_contexts_test">Chained Otel Contexts Test</string>
<string name="web_view_recording">Web View Recording</string>
<string name="view_group_button">View Groups</string>
<string name="tabs_component">Tabs</string>
<string name="start_custom_rum_view">Start Custom Rum View</string>
<string name="webview_recording">WebView Recording</string>
<string name="linked_spans_test">Linked Spans Test</string>
<string name="start_linked_spans_test">Start Linked Spans Test</string>
<string name="card_view">Card view</string>
<string name="material_card_view">Material Card view</string>
<string name="nav_item_saved">Saved</string>
<string name="nav_item_search">Search</string>
<string name="nav_item_suggested_edits">Edits</string>
<string name="nav_item_more">More</string>
</resources>

0 comments on commit c6a353a

Please sign in to comment.