Skip to content

Commit

Permalink
Merge pull request #406 from Countly/feedback_wdig
Browse files Browse the repository at this point in the history
feat: new feedback function signatures
  • Loading branch information
turtledreams authored Oct 28, 2024
2 parents d139e66 + 223a466 commit 0663b48
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
* Added new functions to ease the presenting the feedback widgets. Functions present the first matching feedback widget from the list.
* presentNPS(Context)
* presentNPS(Context, String)
* presentNPS(Context, String, FeedbackCallback)
* presentSurvey(Context)
* presentSurvey(Context, String)
* presentSurvey(Context, String, FeedbackCallback)
* presentRating(Context)
* presentRating(Context, String)
* presentRating(Context, String, FeedbackCallback)

## 24.7.4
* Disabled caching for webviews.
Expand Down
61 changes: 47 additions & 14 deletions sdk/src/main/java/ly/count/android/sdk/ModuleFeedback.java
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ void reportFeedbackWidgetManuallyInternal(@Nullable CountlyFeedbackWidget widget
* @param type the type of the feedback widget to present
* @param nameIDorTag the widget id, widget name or widget tag of the feedback widget to present
*/
private void presentFeedbackWidgetNameIDorTag(@NonNull Context context, @NonNull FeedbackWidgetType type, @NonNull String nameIDorTag) {
private void presentFeedbackWidgetNameIDorTag(@NonNull Context context, @NonNull FeedbackWidgetType type, @NonNull String nameIDorTag, @Nullable FeedbackCallback devCallback) {
getAvailableFeedbackWidgetsInternal(new RetrieveFeedbackWidgets() {
@Override public void onFinished(List<CountlyFeedbackWidget> retrievedWidgets, String error) {
if (error != null) {
Expand Down Expand Up @@ -643,7 +643,7 @@ private void presentFeedbackWidgetNameIDorTag(@NonNull Context context, @NonNull
return;
}

presentFeedbackWidgetInternal(selectedWidget, context, null, null);
presentFeedbackWidgetInternal(selectedWidget, context, null, devCallback);
}
});
}
Expand Down Expand Up @@ -726,10 +726,7 @@ public void reportFeedbackWidgetManually(@Nullable CountlyFeedbackWidget widgetI
* @param nameIDorTag the widget id, widget name or widget tag of the NPS feedback widget to present, if empty, the top widget will be presented
*/
public void presentNPS(@NonNull Context context, @NonNull String nameIDorTag) {
synchronized (_cly) {
L.i("[Feedback] presentNPS, got nameIDorTag:[" + nameIDorTag + "]");
presentFeedbackWidgetNameIDorTag(context, FeedbackWidgetType.nps, nameIDorTag);
}
presentNPS(context, nameIDorTag, null);
}

/**
Expand All @@ -748,10 +745,7 @@ public void presentNPS(@NonNull Context context) {
* @param nameIDorTag the widget id, widget name or widget tag of the Survey feedback widget to present, if empty, the top widget will be presented
*/
public void presentSurvey(@NonNull Context context, @NonNull String nameIDorTag) {
synchronized (_cly) {
L.i("[Feedback] presentSurvey, got nameIDorTag:[" + nameIDorTag + "]");
presentFeedbackWidgetNameIDorTag(context, FeedbackWidgetType.survey, nameIDorTag);
}
presentSurvey(context, nameIDorTag, null);
}

/**
Expand All @@ -770,10 +764,7 @@ public void presentSurvey(@NonNull Context context) {
* @param nameIDorTag the widget id, widget name or widget tag of the Rating feedback widget to present, if empty, the top widget will be presented
*/
public void presentRating(@NonNull Context context, @NonNull String nameIDorTag) {
synchronized (_cly) {
L.i("[Feedback] presentRating, got nameIDorTag:[" + nameIDorTag + "]");
presentFeedbackWidgetNameIDorTag(context, FeedbackWidgetType.rating, nameIDorTag);
}
presentRating(context, nameIDorTag, null);
}

/**
Expand All @@ -784,5 +775,47 @@ public void presentRating(@NonNull Context context, @NonNull String nameIDorTag)
public void presentRating(@NonNull Context context) {
presentRating(context, "");
}

/**
* Present an NPS feedback widget from the top of the list of available NPS widgets by the nameIDorTag string
*
* @param context the context to use for displaying the feedback widget
* @param nameIDorTag the widget id, widget name or widget tag of the NPS feedback widget to present, if empty, the top widget will be presented
* @param devCallback callback to be called when the feedback widget is closed
*/
public void presentNPS(@NonNull Context context, @NonNull String nameIDorTag, @Nullable FeedbackCallback devCallback) {
synchronized (_cly) {
L.i("[Feedback] presentNPS, got nameIDorTag:[" + nameIDorTag + "], got callback:[" + (devCallback != null) + "]");
presentFeedbackWidgetNameIDorTag(context, FeedbackWidgetType.nps, nameIDorTag, devCallback);
}
}

/**
* Present a Survey feedback widget from the top of the list of available Survey widgets by the nameIDorTag string
*
* @param context the context to use for displaying the feedback widget
* @param nameIDorTag the widget id, widget name or widget tag of the Survey feedback widget to present, if empty, the top widget will be presented
* @param devCallback callback to be called when the feedback widget is closed
*/
public void presentSurvey(@NonNull Context context, @NonNull String nameIDorTag, @Nullable FeedbackCallback devCallback) {
synchronized (_cly) {
L.i("[Feedback] presentSurvey, got nameIDorTag:[" + nameIDorTag + "], got callback:[" + (devCallback != null) + "]");
presentFeedbackWidgetNameIDorTag(context, FeedbackWidgetType.survey, nameIDorTag, devCallback);
}
}

/**
* Present a Rating feedback widget from the top of the list of available Rating widgets by the nameIDorTag string
*
* @param context the context to use for displaying the feedback widget
* @param nameIDorTag the widget id, widget name or widget tag of the Rating feedback widget to present, if empty, the top widget will be presented
* @param devCallback callback to be called when the feedback widget is closed
*/
public void presentRating(@NonNull Context context, @NonNull String nameIDorTag, @Nullable FeedbackCallback devCallback) {
synchronized (_cly) {
L.i("[Feedback] presentRating, got nameIDorTag:[" + nameIDorTag + "], got callback:[" + (devCallback != null) + "]");
presentFeedbackWidgetNameIDorTag(context, FeedbackWidgetType.rating, nameIDorTag, devCallback);
}
}
}
}

0 comments on commit 0663b48

Please sign in to comment.