diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index eabe87f1d..da508e009 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -135,6 +135,9 @@
+
syncOfflineQueue(ActionRequest actionRequest) {
} catch(Exception e) {
Log.e(TAG, "syncOfflineQueue() item processing exception", e);
- itemResult = new ActionResult(ActionResult.ErrorType.UNKNOWN, e.toString());
+ itemResult = new ActionResult(ActionResult.ErrorType.UNKNOWN, e);
}
if(itemResult != null && !itemResult.isSuccess() && canTolerateNotFound
@@ -440,6 +440,7 @@ public void onSuccess(long latestUpdatedItemTimestamp) {
result.setErrorType(ActionResult.ErrorType.UNKNOWN);
result.setMessage(e.toString());
+ result.setException(e);
}
} else {
result.setErrorType(ActionResult.ErrorType.NO_NETWORK);
@@ -478,6 +479,7 @@ public void onProgress(int current, int total) {
result.setErrorType(ActionResult.ErrorType.UNKNOWN);
result.setMessage(e.toString());
+ result.setException(e);
}
} else {
result.setErrorType(ActionResult.ErrorType.NO_NETWORK);
diff --git a/app/src/main/java/fr/gaulupeau/apps/Poche/service/NotificationActionReceiver.java b/app/src/main/java/fr/gaulupeau/apps/Poche/service/NotificationActionReceiver.java
new file mode 100644
index 000000000..746fef10d
--- /dev/null
+++ b/app/src/main/java/fr/gaulupeau/apps/Poche/service/NotificationActionReceiver.java
@@ -0,0 +1,50 @@
+package fr.gaulupeau.apps.Poche.service;
+
+import android.app.PendingIntent;
+import android.content.BroadcastReceiver;
+import android.content.ClipData;
+import android.content.ClipboardManager;
+import android.content.Context;
+import android.content.Intent;
+import android.widget.Toast;
+
+import java.util.concurrent.ThreadLocalRandom;
+
+import fr.gaulupeau.apps.InThePoche.R;
+
+public class NotificationActionReceiver extends BroadcastReceiver {
+
+ public static final String ACTION_COPY_TO_CLIPBOARD = "copy_to_clipboard";
+
+ public static final String EXTRA_COPY_TO_CLIPBOARD_LABEL = "copy_to_clipboard_label";
+ public static final String EXTRA_COPY_TO_CLIPBOARD_TEXT = "copy_to_clipboard_text";
+
+ public static PendingIntent getCopyToClipboardPendingIntent(
+ Context context, String label, String text) {
+ Intent intent = new Intent(context, NotificationActionReceiver.class);
+ intent.setAction(ACTION_COPY_TO_CLIPBOARD);
+ intent.putExtra(EXTRA_COPY_TO_CLIPBOARD_LABEL, label);
+ intent.putExtra(EXTRA_COPY_TO_CLIPBOARD_TEXT, text);
+
+ int code = ThreadLocalRandom.current().nextInt(); // so `PendingIntent` creates a **new** pending intent
+ return PendingIntent.getBroadcast(context, code, intent, 0);
+ }
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ if(ACTION_COPY_TO_CLIPBOARD.equals(action)) {
+ ClipboardManager clipboardManager = (ClipboardManager) context
+ .getSystemService(Context.CLIPBOARD_SERVICE);
+
+ ClipData data = ClipData.newPlainText(
+ intent.getStringExtra(EXTRA_COPY_TO_CLIPBOARD_LABEL),
+ intent.getStringExtra(EXTRA_COPY_TO_CLIPBOARD_TEXT));
+
+ clipboardManager.setPrimaryClip(data);
+
+ Toast.makeText(context, context.getString(R.string.copiedToClipboard), Toast.LENGTH_SHORT).show();
+ }
+ }
+
+}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index c1b80fd8f..2a50fde17 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -318,4 +318,9 @@
Back
Save settings
Remove tag
+
+ Stacktrace:
+ Copy to clipboard
+ Error details
+ Copied to clipboard