diff --git a/shaky-sample/src/main/java/com/linkedin/android/shaky/app/ShakyDemo.java b/shaky-sample/src/main/java/com/linkedin/android/shaky/app/ShakyDemo.java
index 951cfd8..f7bba5b 100644
--- a/shaky-sample/src/main/java/com/linkedin/android/shaky/app/ShakyDemo.java
+++ b/shaky-sample/src/main/java/com/linkedin/android/shaky/app/ShakyDemo.java
@@ -13,6 +13,7 @@
import android.graphics.Color;
import android.os.Bundle;
+import android.util.Log;
import android.view.View;
import android.widget.CheckBox;
import android.widget.Toast;
@@ -29,6 +30,7 @@
public class ShakyDemo extends FragmentActivity {
private static final int RGB_MAX = 256;
+ public static final String TAG = "ShakyDemo";
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -101,5 +103,18 @@ public void onClick(View v) {
((ShakyApplication) getApplication()).getShaky().startEditScreenshotFlow(null);
}
});
+
+ findViewById(R.id.demo_capture_screenshot_collect_data_button).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ ((ShakyApplication) getApplication()).getShaky().captureScreenshotAndCollectData(result -> {
+ Toast.makeText(v.getContext(),
+ "Data collection complete. Check logs for complete data.",
+ Toast.LENGTH_LONG).show();
+ Log.d(TAG, "Screenshot URI: " + (result != null ? result.getScreenshotUri() : "null"));
+ Log.d(TAG, "Collected data: " + (result != null ? result.getData() : "null"));
+ });
+ }
+ });
}
}
diff --git a/shaky-sample/src/main/res/layout/activity_demo.xml b/shaky-sample/src/main/res/layout/activity_demo.xml
index 8553bb3..a667498 100644
--- a/shaky-sample/src/main/res/layout/activity_demo.xml
+++ b/shaky-sample/src/main/res/layout/activity_demo.xml
@@ -64,4 +64,11 @@
android:layout_height="wrap_content"
android:text="@string/manual_edit_screenshot"/>
+
+
diff --git a/shaky-sample/src/main/res/values/strings.xml b/shaky-sample/src/main/res/values/strings.xml
index 8cc80c4..774eaa9 100644
--- a/shaky-sample/src/main/res/values/strings.xml
+++ b/shaky-sample/src/main/res/values/strings.xml
@@ -5,6 +5,7 @@
Manually start bug report
Manually launch bottom sheet
Manually launch edit screenshot
+ Capture screenshot and collect data
Show Toast
This is a toast.
Use Christmas theme
diff --git a/shaky/src/main/java/com/linkedin/android/shaky/DataCollectionCallback.java b/shaky/src/main/java/com/linkedin/android/shaky/DataCollectionCallback.java
new file mode 100644
index 0000000..28b5cad
--- /dev/null
+++ b/shaky/src/main/java/com/linkedin/android/shaky/DataCollectionCallback.java
@@ -0,0 +1,16 @@
+package com.linkedin.android.shaky;
+
+
+import androidx.annotation.Nullable;
+
+/**
+ * Callback interface for screenshot capture and data collection.
+ */
+public interface DataCollectionCallback {
+ /**
+ * Called when screenshot capture and data collection is complete.
+ *
+ * @param result the collected data and screenshot URI, or null if some failure occurred
+ */
+ void onDataCollected(@Nullable Result result);
+}
diff --git a/shaky/src/main/java/com/linkedin/android/shaky/Shaky.java b/shaky/src/main/java/com/linkedin/android/shaky/Shaky.java
index 33db569..99bd769 100644
--- a/shaky/src/main/java/com/linkedin/android/shaky/Shaky.java
+++ b/shaky/src/main/java/com/linkedin/android/shaky/Shaky.java
@@ -168,6 +168,26 @@ public void startEditScreenshotFlow(@Nullable Uri screenshotUri) {
}
}
+ /**
+ * Capture a screenshot and collect data without starting the feedback flow UI.
+ * This is for consumers to use their own custom UI with the captured data.
+ *
+ * @param callback called when the screenshot and data collection is complete
+ */
+ public void captureScreenshotAndCollectData(@NonNull final DataCollectionCallback callback) {
+ if (activity == null) {
+ callback.onDataCollected(null);
+ return;
+ }
+
+ Bitmap screenshotBitmap = getScreenshotBitmap();
+ collectDataTask = new CollectDataTask(activity, delegate, result -> {
+ collectDataTask = null;
+ callback.onDataCollected(result);
+ });
+ collectDataTask.execute(screenshotBitmap);
+ }
+
public void setSensitivity(@ShakeDelegate.SensitivityLevel int sensitivityLevel) {
delegate.setSensitivityLevel(sensitivityLevel);
shakeDetector.setSensitivity(getDetectorSensitivityLevel());