Skip to content

Commit

Permalink
Updating shaky flow for custom dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
dsanghi committed Apr 24, 2024
1 parent e9630ad commit ce3f481
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions shaky/src/main/java/com/linkedin/android/shaky/Shaky.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import android.app.Activity;
import android.app.Application;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
Expand Down Expand Up @@ -51,9 +51,10 @@ public class Shaky implements ShakeDetector.Listener {

private static final String SEND_FEEDBACK_TAG = "SendFeedback";
private static final String COLLECT_DATA_TAG = "CollectFeedbackData";
private static final String CUSTOM_DIALOG_TAG = "CustomDialog";

private static final long SHAKE_COOLDOWN_MS = TimeUnit.SECONDS.toMillis(5);

private DialogFragment customFragment;
private final ShakeDelegate delegate;
private final ShakeDetector shakeDetector;
@Nullable
Expand Down Expand Up @@ -187,7 +188,11 @@ public void hearShake() {
arguments.putInt(ShakySettingDialog.SHAKY_CURRENT_SENSITIVITY, delegate.getSensitivityLevel());
SendFeedbackDialog sendFeedbackDialog = new SendFeedbackDialog();
sendFeedbackDialog.setArguments(arguments);
sendFeedbackDialog.show(activity.getFragmentManager(), SEND_FEEDBACK_TAG);
if (customFragment != null) {
customFragment.show(activity.getFragmentManager(), CUSTOM_DIALOG_TAG);
} else {
sendFeedbackDialog.show(activity.getFragmentManager(), SEND_FEEDBACK_TAG);
}
if (shakyFlowCallback != null) {
shakyFlowCallback.onUserPromptShown();
}
Expand All @@ -196,9 +201,8 @@ public void hearShake() {
/**
* Custom dialog to be shown before the feedback flow
*/
@VisibleForTesting
public void setCustomDialog(@NonNull Dialog customDialog) {
customDialog.show();
public void setCustomDialog(@NonNull DialogFragment fragment) {
customFragment = fragment;
}

/**
Expand Down

0 comments on commit ce3f481

Please sign in to comment.