-
Notifications
You must be signed in to change notification settings - Fork 2
MOBILE-16529-Add-examples-for-bottom-sheets-menus-and-dialogs #69
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
Merged
kavin-csquare
merged 4 commits into
master
from
MOBILE-16529-Add-examples-for-bottom-sheets-menus-and-dialogs
Jul 4, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0c602fc
feat(sr): add demo bottom sheets dialogs and menu items (MOBILE-16529)
kavin-csquare 989977a
chore(sr): cleanup imports
kavin-csquare 665d219
feat(sr): add extensions to apply masking (MOBILE-16529))
kavin-csquare f419655
chore(sr): removed unused interface (MOBILE-16529))
kavin-csquare File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
app/src/main/java/com/example/androidsampleapp/fragment/BottomSheetFragment.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package com.example.androidsampleapp.fragment | ||
|
|
||
| import android.os.Bundle | ||
| import android.view.LayoutInflater | ||
| import android.view.View | ||
| import android.view.ViewGroup | ||
| import android.widget.ImageView | ||
| import android.widget.TextView | ||
| import com.contentsquare.android.Contentsquare | ||
| import com.google.android.material.bottomsheet.BottomSheetDialogFragment | ||
| import com.example.androidsampleapp.R | ||
|
|
||
| class BottomSheetFragment : BottomSheetDialogFragment() { | ||
|
|
||
| override fun onCreateView( | ||
| inflater: LayoutInflater, | ||
| container: ViewGroup?, | ||
| savedInstanceState: Bundle? | ||
| ): View? { | ||
| return inflater.inflate(R.layout.fragment_bottom_sheet_dialog, container, false) | ||
| .also { | ||
| Contentsquare.mask(it.findViewById<ImageView>(R.id.bottom_sheet_image_view)) | ||
| Contentsquare.unMask(it.findViewById<TextView>(R.id.bottom_sheet_text_view)) | ||
| Contentsquare.mask(it.findViewById<TextView>(R.id.textTitle)) | ||
| } | ||
| } | ||
| } | ||
37 changes: 37 additions & 0 deletions
37
app/src/main/java/com/example/androidsampleapp/fragment/CustomAlertDialog.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package com.example.androidsampleapp.fragment | ||
|
|
||
| import android.app.Dialog | ||
| import android.content.Context | ||
| import android.os.Bundle | ||
| import android.widget.Button | ||
| import android.widget.ImageView | ||
| import android.widget.TextView | ||
| import com.contentsquare.android.Contentsquare | ||
| import com.example.androidsampleapp.R | ||
|
|
||
| class CustomAlertDialog( | ||
| context: Context, | ||
| private val message: String, | ||
| private val imageResId: Int = R.drawable.sense_ai_image, | ||
| private val onOkPressed: (() -> Unit)? = null | ||
| ) : Dialog(context) { | ||
|
|
||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| setContentView(R.layout.dialog_custom_alert) | ||
|
|
||
| val messageView = findViewById<TextView>(R.id.alert_message) | ||
| val imageView = findViewById<ImageView>(R.id.alert_image) | ||
| val okButton = findViewById<Button>(R.id.alert_ok_button) | ||
|
|
||
| messageView.text = message | ||
| imageView.setImageResource(imageResId) | ||
| okButton.setOnClickListener { | ||
| onOkPressed?.invoke() | ||
| dismiss() | ||
| } | ||
| // Apply Masking here | ||
| Contentsquare.mask(messageView) | ||
| Contentsquare.mask(imageView) | ||
kavin-csquare marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
27 changes: 27 additions & 0 deletions
27
app/src/main/java/com/example/androidsampleapp/fragment/DatePickerFragment.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package com.example.androidsampleapp.fragment | ||
|
|
||
| import android.app.DatePickerDialog | ||
| import android.app.Dialog | ||
| import android.os.Bundle | ||
| import androidx.fragment.app.DialogFragment | ||
| import com.contentsquare.android.api.sessionreplay.csqMaskButtonPanel | ||
| import com.contentsquare.android.api.sessionreplay.csqUnMaskHeader | ||
| import java.util.Calendar | ||
|
|
||
| class DatePickerFragment(private val onDateSelected: (year: Int, month: Int, day: Int) -> Unit) : | ||
| DialogFragment() { | ||
|
|
||
| override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
| val calendar = Calendar.getInstance() | ||
| val year = calendar.get(Calendar.YEAR) | ||
| val month = calendar.get(Calendar.MONTH) | ||
| val day = calendar.get(Calendar.DAY_OF_MONTH) | ||
|
|
||
| return DatePickerDialog(requireContext(), { _, selectedYear, selectedMonth, selectedDay -> | ||
| onDateSelected(selectedYear, selectedMonth, selectedDay) | ||
| }, year, month, day).also { | ||
| it.csqMaskButtonPanel() | ||
| it.csqUnMaskHeader() | ||
| } | ||
| } | ||
| } |
28 changes: 28 additions & 0 deletions
28
app/src/main/java/com/example/androidsampleapp/fragment/TimePickerFragment.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package com.example.androidsampleapp.fragment | ||
|
|
||
| import android.app.Dialog | ||
| import android.app.TimePickerDialog | ||
| import android.os.Bundle | ||
| import androidx.fragment.app.DialogFragment | ||
| import com.contentsquare.android.api.sessionreplay.csqMaskRadialPicker | ||
| import com.contentsquare.android.api.sessionreplay.csqUnMaskHeader | ||
| import java.util.Calendar | ||
|
|
||
|
|
||
| class TimePickerFragment( | ||
| private val onTimeSelected: (hourOfDay: Int, minute: Int) -> Unit | ||
| ) : DialogFragment() { | ||
|
|
||
| override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
| val c = Calendar.getInstance() | ||
| val hour = c.get(Calendar.HOUR_OF_DAY) | ||
| val minute = c.get(Calendar.MINUTE) | ||
|
|
||
| return TimePickerDialog(requireContext(), { _, selectedHour, selectedMinute -> | ||
| onTimeSelected(selectedHour, selectedMinute) | ||
| }, hour, minute, true).also { | ||
| it.csqMaskRadialPicker() | ||
| it.csqUnMaskHeader() | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| <shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| <solid android:color="@color/contentsquare_white" /> | ||
| <corners android:radius="16dp" /> | ||
| </shape> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,65 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <FrameLayout | ||
| xmlns:android="http://schemas.android.com/apk/res/android" | ||
| <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| xmlns:tools="http://schemas.android.com/tools" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="match_parent" | ||
| android:background="@color/content_bg" | ||
| android:fitsSystemWindows="true" | ||
| tools:context=".SimpleActivity"> | ||
|
|
||
| <FrameLayout | ||
| android:layout_width="match_parent" | ||
| android:layout_height="match_parent" | ||
| android:background="@color/content_bg" | ||
| tools:ignore="UselessParent"> | ||
| <Button | ||
| android:id="@+id/btnBottomSheets" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginTop="100dp" | ||
| android:onClick="openBottomSheets" | ||
| android:text="@string/bottom_sheets" | ||
| app:layout_constraintBottom_toTopOf="@+id/btnDatePicker" | ||
| app:layout_constraintEnd_toEndOf="parent" | ||
| app:layout_constraintStart_toStartOf="parent" | ||
| app:layout_constraintTop_toTopOf="parent" | ||
| app:layout_constraintVertical_chainStyle="packed" /> | ||
|
|
||
| <TextView | ||
| android:id="@+id/fragment_text" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_gravity="center" | ||
| android:text="@string/text_simple_activity" /> | ||
| <Button | ||
| android:id="@+id/btnDatePicker" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:onClick="openDatePicker" | ||
| android:text="@string/date_and_time_picker" | ||
| app:layout_constraintEnd_toEndOf="parent" | ||
| app:layout_constraintStart_toStartOf="parent" | ||
| app:layout_constraintTop_toBottomOf="@id/btnBottomSheets" /> | ||
|
|
||
| </FrameLayout> | ||
| <Button | ||
| android:id="@+id/btnTimePicker" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:onClick="openTimePicker" | ||
| android:text="@string/time_picker" | ||
| app:layout_constraintEnd_toEndOf="parent" | ||
| app:layout_constraintStart_toStartOf="parent" | ||
| app:layout_constraintTop_toBottomOf="@id/btnDatePicker" /> | ||
|
|
||
| </FrameLayout> | ||
|
|
||
| <Button | ||
| android:id="@+id/btnAlertDialog" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:onClick="openAlertDialog" | ||
| android:text="@string/alert_dialog" | ||
| app:layout_constraintEnd_toEndOf="parent" | ||
| app:layout_constraintStart_toStartOf="parent" | ||
| app:layout_constraintTop_toBottomOf="@id/btnTimePicker" /> | ||
|
|
||
| <Button | ||
| android:id="@+id/btnCustomDialog" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:onClick="openCustomAlertDialog" | ||
| android:text="@string/custom_dialog" | ||
| app:layout_constraintEnd_toEndOf="parent" | ||
| app:layout_constraintStart_toStartOf="parent" | ||
| app:layout_constraintTop_toBottomOf="@id/btnAlertDialog" /> | ||
|
|
||
| </androidx.constraintlayout.widget.ConstraintLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| android:layout_margin="36dp" | ||
| android:background="@drawable/dialog_background" | ||
| android:gravity="center_horizontal" | ||
| android:orientation="vertical" | ||
| android:padding="4dp"> | ||
|
|
||
| <ImageView | ||
| android:id="@+id/alert_image" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="48dp" | ||
| android:layout_marginBottom="16dp" | ||
| android:contentDescription="@string/alert_dialog" | ||
| android:src="@drawable/sense_ai_image" /> | ||
|
|
||
| <TextView | ||
| android:id="@+id/alert_message" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:padding="8dp" | ||
| android:text="@string/sense_ai_description_short" | ||
| android:textAlignment="center" | ||
| android:textSize="16sp" /> | ||
|
|
||
| <Button | ||
| android:id="@+id/alert_ok_button" | ||
| android:layout_width="120dp" | ||
| android:layout_height="wrap_content" | ||
| android:text="@string/ok" /> | ||
|
|
||
| </LinearLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <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="wrap_content" | ||
| android:background="@color/content_bg" | ||
| android:paddingBottom="16dp"> | ||
|
|
||
| <TextView | ||
| android:id="@+id/textTitle" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_margin="16dp" | ||
| android:gravity="center" | ||
| android:text="@string/sample_bottom_sheet" | ||
| app:layout_constraintEnd_toEndOf="parent" | ||
| app:layout_constraintStart_toStartOf="parent" | ||
| app:layout_constraintTop_toTopOf="parent" /> | ||
|
|
||
| <ImageView | ||
| android:id="@+id/bottom_sheet_image_view" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_margin="16dp" | ||
| android:contentDescription="@null" | ||
| android:padding="@dimen/contentsquare_value_12dp" | ||
| app:layout_constraintEnd_toEndOf="parent" | ||
| app:layout_constraintStart_toStartOf="parent" | ||
| app:layout_constraintTop_toBottomOf="@+id/textTitle" | ||
| app:srcCompat="@drawable/sense_ai_image" /> | ||
|
|
||
| <TextView | ||
| android:id="@+id/bottom_sheet_text_view" | ||
| android:layout_width="0dp" | ||
| android:layout_height="wrap_content" | ||
| android:layout_margin="16dp" | ||
| android:text="@string/sense_ai_description" | ||
| app:layout_constraintEnd_toEndOf="parent" | ||
| app:layout_constraintStart_toStartOf="parent" | ||
| app:layout_constraintTop_toBottomOf="@+id/bottom_sheet_image_view" /> | ||
| </androidx.constraintlayout.widget.ConstraintLayout> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.