aboutsummaryrefslogtreecommitdiffstats
path: root/libs/thedevstacklogcat/src/main
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2016-04-07 14:10:25 +0200
committersteckbrief <steckbrief@chefmail.de>2016-04-07 14:28:19 +0200
commit8c3245dd1f257053b8ec2bf7c5e03a3a98b282c3 (patch)
treef66fa0e5fd657035e5f022f706708d6d5ba3ce01 /libs/thedevstacklogcat/src/main
parent18548e9ebb246071f0bc46ca3bb07a300176cf24 (diff)
Implements FS#187: Add single line copy to logcat view
Diffstat (limited to '')
-rw-r--r--libs/thedevstacklogcat/src/main/java/de/thedevstack/android/logcat/adapters/LogCatArrayAdapter.java8
-rw-r--r--libs/thedevstacklogcat/src/main/java/de/thedevstack/android/logcat/ui/LogCatOutputCopyOnClickListener.java48
2 files changed, 6 insertions, 50 deletions
diff --git a/libs/thedevstacklogcat/src/main/java/de/thedevstack/android/logcat/adapters/LogCatArrayAdapter.java b/libs/thedevstacklogcat/src/main/java/de/thedevstack/android/logcat/adapters/LogCatArrayAdapter.java
index c8a96ea3..eb4efc98 100644
--- a/libs/thedevstacklogcat/src/main/java/de/thedevstack/android/logcat/adapters/LogCatArrayAdapter.java
+++ b/libs/thedevstacklogcat/src/main/java/de/thedevstack/android/logcat/adapters/LogCatArrayAdapter.java
@@ -116,7 +116,11 @@ public class LogCatArrayAdapter extends ArrayAdapter<String> {
logcatItems.remove(object);
}
- public ArrayList<String> getItems() {
- return this.logcatItems;
+ /**
+ * Returns an unmodifiable copy of the log cat entries.
+ * @return UnmodifiableList of logcat entries.
+ */
+ public List<String> getItems() {
+ return Collections.unmodifiableList(this.logcatItems);
}
}
diff --git a/libs/thedevstacklogcat/src/main/java/de/thedevstack/android/logcat/ui/LogCatOutputCopyOnClickListener.java b/libs/thedevstacklogcat/src/main/java/de/thedevstack/android/logcat/ui/LogCatOutputCopyOnClickListener.java
deleted file mode 100644
index 1be04c9c..00000000
--- a/libs/thedevstacklogcat/src/main/java/de/thedevstack/android/logcat/ui/LogCatOutputCopyOnClickListener.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package de.thedevstack.android.logcat.ui;
-
-import android.content.ClipData;
-import android.content.ClipboardManager;
-import android.content.Context;
-import android.view.View;
-import android.widget.Toast;
-
-import java.util.ArrayList;
-
-import de.thedevstack.android.logcat.Logging;
-import de.thedevstack.android.logcat.adapters.LogCatArrayAdapter;
-
-/**
- * Created by tzur on 20.11.2015.
- */
-public class LogCatOutputCopyOnClickListener implements View.OnClickListener {
- private final LogCatArrayAdapter logCatOutputAdapter;
- private final Context context;
- private final int resIdLogcatCopied;
- private final int resIdLogcatNotCopied;
-
- public LogCatOutputCopyOnClickListener(Context context, LogCatArrayAdapter logCatOutputAdapter, int resIdLogcatCopied, int resIdLogcatNotCopied) {
- this.logCatOutputAdapter = logCatOutputAdapter;
- this.context = context;
- this.resIdLogcatCopied = resIdLogcatCopied;
- this.resIdLogcatNotCopied = resIdLogcatNotCopied;
- }
-
- @Override
- public void onClick(View v) {
- Logging.d("copylogcat", "Start Copying log cat");
- ArrayList<String> items = this.logCatOutputAdapter.getItems();
- if (null != items && !items.isEmpty()) {
- StringBuilder sb = new StringBuilder();
- for (String item : items) {
- sb.append(item);
- sb.append("\n");
- }
- ClipboardManager clipboard = (ClipboardManager) this.context.getSystemService(Context.CLIPBOARD_SERVICE);
- ClipData clip = ClipData.newPlainText("c+logcat", sb.toString());
- clipboard.setPrimaryClip(clip);
- Toast.makeText(this.context, this.context.getText(this.resIdLogcatCopied), Toast.LENGTH_LONG).show();
- } else {
- Toast.makeText(this.context, this.context.getText(this.resIdLogcatNotCopied), Toast.LENGTH_LONG).show();
- }
- }
-}