-
-
Notifications
You must be signed in to change notification settings - Fork 467
New User Feedback Widget #4450
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
Merged
New User Feedback Widget #4450
Changes from 47 commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
62e71ff
added Feedback class and extended Contexts with it
stefanosiano c9b4850
Added Sentry.captureFeedback API
stefanosiano 813ff1d
updated changelog
stefanosiano dd2d6a8
added tests
stefanosiano 6428dfa
added scope replay id and screen as url
stefanosiano 144bcca
added feedback as DataCategory for rate limit and client report
stefanosiano 509f992
Merge branch 'refs/heads/main' into feat/new-user-feedback-logic
stefanosiano 3c0a6fb
merged main
stefanosiano 9e1066e
added tests
stefanosiano eadb567
Merge branch 'refs/heads/main' into feat/new-user-feedback-logic
stefanosiano 8feeadc
fixed tests
stefanosiano 986772d
started adding resources for UF widget
stefanosiano e19d122
started SentryFeedbackOptions
stefanosiano 79052ad
Merge branch 'feat/new-user-feedback-logic' into feat/user-feedback-w…
stefanosiano 5a83bb8
added all form options
stefanosiano ee44b18
Merge branch 'main' into feat/new-user-feedback-logic
stefanosiano 212ffbf
merged main
stefanosiano 2bf99b5
Merge branch 'feat/new-user-feedback-logic' into feat/user-feedback-w…
stefanosiano 6eb876c
user feedback dialog now uses dialogTheme
stefanosiano a33ae00
Merge branch 'main' into feat/user-feedback-widget
stefanosiano d47f374
merged main
stefanosiano 1a758a2
removed java options for send button colors. Replaced with theme sett…
stefanosiano 9315f7b
added tests and UI tests
stefanosiano 62cea5e
added comments
stefanosiano 794bd66
added comments
stefanosiano f16ac66
added replay capturing on feedback dialog open
stefanosiano 5388b42
added cancel button ui test
stefanosiano 8aacd36
added cancel button ui test
stefanosiano 8750c8d
Merge branch 'refs/heads/main' into feat/user-feedback-widget
stefanosiano 6d14499
added Feedback.toString() and default values in javadoc of SentryFeed…
stefanosiano fb88c1f
merged main
stefanosiano b5eb64d
skipping replay in test when running on gh
stefanosiano d0ba126
skipping replay in test when running on gh
stefanosiano 202759f
Merge branch 'main' into feat/user-feedback-widget
markushi 6253aca
added SentryUserFeedbackWidget, with styles and icon
stefanosiano c6d1919
updated changelog
stefanosiano 7bc01eb
Merge branch 'main' into feat/user-feedback-widget
stefanosiano ce10336
Merge branch 'feat/user-feedback-widget' into feat/user-feedback-button
stefanosiano 933371d
Update CHANGELOG.md
stefanosiano eebaaf3
removed rtl properties and supportsRtl flag
stefanosiano 3fef7c4
updated changelog
stefanosiano 536d522
Merge branch 'main' into feat/user-feedback-widget
stefanosiano 6d9cee3
Merge branch 'feat/user-feedback-widget' into feat/user-feedback-button
stefanosiano 1bb3095
merged main
stefanosiano 67cbc0d
Merge branch 'main' into feat/user-feedback-button
stefanosiano 4e5ad3a
merged main
stefanosiano 5cdbaca
fixed ui tests
stefanosiano 8a1ef90
Renamed SentryUserFeedbackWidget to SentryUserFeedbackButton
stefanosiano b504f79
Merge branch 'main' into feat/user-feedback-button
stefanosiano 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
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
121 changes: 121 additions & 0 deletions
121
sentry-android-core/src/main/java/io/sentry/android/core/SentryUserFeedbackWidget.java
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,121 @@ | ||
| package io.sentry.android.core; | ||
|
|
||
| import android.annotation.SuppressLint; | ||
| import android.content.Context; | ||
| import android.content.res.TypedArray; | ||
| import android.os.Build; | ||
| import android.util.AttributeSet; | ||
| import android.util.TypedValue; | ||
| import android.widget.Button; | ||
| import org.jetbrains.annotations.NotNull; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| public class SentryUserFeedbackWidget extends Button { | ||
|
|
||
| private @Nullable OnClickListener delegate; | ||
|
|
||
| public SentryUserFeedbackWidget(Context context) { | ||
| super(context); | ||
| init(context, null, 0, 0); | ||
| } | ||
|
|
||
| public SentryUserFeedbackWidget(Context context, AttributeSet attrs) { | ||
| super(context, attrs); | ||
| init(context, attrs, 0, 0); | ||
| } | ||
|
|
||
| public SentryUserFeedbackWidget(Context context, AttributeSet attrs, int defStyleAttr) { | ||
| super(context, attrs, defStyleAttr); | ||
| init(context, attrs, defStyleAttr, 0); | ||
| } | ||
|
|
||
| public SentryUserFeedbackWidget( | ||
| Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { | ||
| super(context, attrs, defStyleAttr, defStyleRes); | ||
| init(context, attrs, defStyleAttr, defStyleRes); | ||
| } | ||
|
|
||
| @SuppressLint("SetTextI18n") | ||
| @SuppressWarnings("deprecation") | ||
| private void init( | ||
| final @NotNull Context context, | ||
| final @Nullable AttributeSet attrs, | ||
| final int defStyleAttr, | ||
| final int defStyleRes) { | ||
| try (final @NotNull TypedArray typedArray = | ||
| context.obtainStyledAttributes( | ||
| attrs, R.styleable.SentryUserFeedbackWidget, defStyleAttr, defStyleRes)) { | ||
| final float dimensionScale = context.getResources().getDisplayMetrics().density; | ||
| final float drawablePadding = | ||
| typedArray.getDimension(R.styleable.SentryUserFeedbackWidget_android_drawablePadding, -1); | ||
| final int drawableStart = | ||
| typedArray.getResourceId(R.styleable.SentryUserFeedbackWidget_android_drawableStart, -1); | ||
| final boolean textAllCaps = | ||
| typedArray.getBoolean(R.styleable.SentryUserFeedbackWidget_android_textAllCaps, false); | ||
| final int background = | ||
| typedArray.getResourceId(R.styleable.SentryUserFeedbackWidget_android_background, -1); | ||
| final float padding = | ||
| typedArray.getDimension(R.styleable.SentryUserFeedbackWidget_android_padding, -1); | ||
| final int textColor = | ||
| typedArray.getColor(R.styleable.SentryUserFeedbackWidget_android_textColor, -1); | ||
| final @Nullable String text = | ||
| typedArray.getString(R.styleable.SentryUserFeedbackWidget_android_text); | ||
|
|
||
| // If the drawable padding is not set, set it to 4dp | ||
| if (drawablePadding == -1) { | ||
| setCompoundDrawablePadding((int) (4 * dimensionScale)); | ||
| } | ||
|
|
||
| // If the drawable start is not set, set it to the default drawable | ||
| if (drawableStart == -1) { | ||
| setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.sentry_campaign_24, 0, 0, 0); | ||
| } | ||
|
|
||
| // Set the text all caps | ||
| setAllCaps(textAllCaps); | ||
|
|
||
| // If the background is not set, set it to the default background | ||
| if (background == -1) { | ||
| setBackgroundResource(R.drawable.sentry_oval_button_ripple_background); | ||
| } | ||
|
|
||
| // If the padding is not set, set it to 12dp | ||
| if (padding == -1) { | ||
| int defaultPadding = (int) (12 * dimensionScale); | ||
| setPadding(defaultPadding, defaultPadding, defaultPadding, defaultPadding); | ||
| } | ||
|
|
||
| // If the text color is not set, set it to the default text color | ||
| if (textColor == -1) { | ||
| // We need the TypedValue to resolve the color from the theme | ||
| final @NotNull TypedValue typedValue = new TypedValue(); | ||
| context.getTheme().resolveAttribute(android.R.attr.colorForeground, typedValue, true); | ||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | ||
| setTextColor(context.getResources().getColor(typedValue.resourceId, context.getTheme())); | ||
| } else { | ||
| setTextColor(context.getResources().getColor(typedValue.resourceId)); | ||
| } | ||
| } | ||
|
|
||
| // If the text is not set, set it to "Report a Bug" | ||
| if (text == null) { | ||
| setText("Report a Bug"); | ||
| } | ||
| } | ||
|
|
||
| // Set the default ClickListener to open the SentryUserFeedbackDialog | ||
| setOnClickListener(delegate); | ||
| } | ||
|
|
||
| @Override | ||
| public void setOnClickListener(final @Nullable OnClickListener listener) { | ||
| delegate = listener; | ||
| super.setOnClickListener( | ||
| v -> { | ||
| new SentryUserFeedbackDialog.Builder(getContext()).create().show(); | ||
| if (delegate != null) { | ||
| delegate.onClick(v); | ||
| } | ||
| }); | ||
| } | ||
| } | ||
5 changes: 5 additions & 0 deletions
5
sentry-android-core/src/main/res/drawable/sentry_campaign_24.xml
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,5 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="?android:attr/colorForeground" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp"> | ||
|
stefanosiano marked this conversation as resolved.
|
||
|
|
||
| <path android:fillColor="?android:attr/colorForeground" android:pathData="M18,11v2h4v-2h-4zM16,17.61c0.96,0.71 2.21,1.65 3.2,2.39 0.4,-0.53 0.8,-1.07 1.2,-1.6 -0.99,-0.74 -2.24,-1.68 -3.2,-2.4 -0.4,0.54 -0.8,1.08 -1.2,1.61zM20.4,5.6c-0.4,-0.53 -0.8,-1.07 -1.2,-1.6 -0.99,0.74 -2.24,1.68 -3.2,2.4 0.4,0.53 0.8,1.07 1.2,1.6 0.96,-0.72 2.21,-1.65 3.2,-2.4zM4,9c-1.1,0 -2,0.9 -2,2v2c0,1.1 0.9,2 2,2h1v4h2v-4h1l5,3L13,6L8,9L4,9zM15.5,12c0,-1.33 -0.58,-2.53 -1.5,-3.35v6.69c0.92,-0.81 1.5,-2.01 1.5,-3.34z"/> | ||
|
|
||
| </vector> | ||
10 changes: 10 additions & 0 deletions
10
sentry-android-core/src/main/res/drawable/sentry_oval_button_ripple_background.xml
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,10 @@ | ||
| <ripple xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:color="?android:attr/colorControlHighlight"> | ||
|
|
||
| <item> | ||
| <shape android:shape="rectangle"> | ||
| <solid android:color="?android:attr/colorBackground" /> | ||
| <corners android:radius="50dp" /> | ||
| </shape> | ||
| </item> | ||
| </ripple> |
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,12 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <resources> | ||
| <declare-styleable name="SentryUserFeedbackWidget" > | ||
| <attr name="android:drawableStart" format="reference" /> | ||
| <attr name="android:drawablePadding" format="dimension" /> | ||
| <attr name="android:padding" format="dimension" /> | ||
| <attr name="android:textAllCaps" format="boolean" /> | ||
| <attr name="android:background" format="reference|color" /> | ||
| <attr name="android:textColor" format="reference|color" /> | ||
| <attr name="android:text" format="string" /> | ||
| </declare-styleable> | ||
| </resources> |
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
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
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
Oops, something went wrong.
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.