Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions shaky/src/main/java/com/linkedin/android/shaky/ShakeDelegate.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,31 @@ public void enableCustomHandlingOfShake(boolean enableCustomHandlingOfShake) {
}

/**
* This method can be overridden to provide custom action to be performed on shake when
* {@link #enableCustomHandlingOfShake} is enabled.
* Called immediately when shake is detected and custom handling is enabled.
*
* @param activity the current activity
* @deprecated Use {@link #performCustomActionOnShake(Activity, Result)} instead.
* This method is called before data collection and does not provide access
* to screenshots or collected debug data. The new method is called after
* data collection completes with full access to the Result object.
*/
public void performCustomActionOnShake(@NonNull Activity activity){}
@Deprecated
public void performCustomActionOnShake(@NonNull Activity activity) {
// Default: do nothing
}

/**
* Called after data collection is complete when custom shake handling is enabled.
* Override this method to perform custom actions with access to collected data including
* screenshots, debug info, and attachments.
*
* @param activity the current activity
* @param result the collected data including screenshots, attachments, and debug info
*/
public void performCustomActionOnShake(@NonNull Activity activity, @NonNull Result result) {
// Default implementation: fall back to the deprecated method for backward compatibility
performCustomActionOnShake(activity);
}

/**
* @return if the dialog should be shown on shake or the shake-to-feedback bottom sheet.
Expand Down
19 changes: 14 additions & 5 deletions shaky/src/main/java/com/linkedin/android/shaky/Shaky.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,8 @@ public void hearShake() {
return;
}

delegate.performCustomActionOnShake(activity);

if (shakyFlowCallback != null) {
shakyFlowCallback.onUserPromptShown();
}
actionThatStartedTheActivity = ActionConstants.ACTION_START_FEEDBACK_FLOW;
doStartFeedbackFlow();
} else {
launchShakeBottomSheet(ShakyFlowCallback.SHAKY_STARTED_BY_SHAKE);
}
Expand Down Expand Up @@ -511,6 +508,18 @@ public void onDataReady(@Nullable Result result) {
dismissCollectFeedbackDialogIfNecessary();
Result safeResult = result != null ? result : new Result();

// Handle custom shake flow
if (delegate.isCustomHandlingOfShakeEnabled()) {
if (activity != null) {
delegate.performCustomActionOnShake(activity, safeResult);
}

if (shakyFlowCallback != null) {
shakyFlowCallback.onShakyStarted(ShakyFlowCallback.SHAKY_STARTED_BY_SHAKE);
}
return;
}

if (shouldStartFeedbackActivity && !isBottomSheetFlowActive) {
startFeedbackActivity(safeResult);
return;
Expand Down
Loading