diff options
author | steckbrief <steckbrief@chefmail.de> | 2016-04-07 15:36:16 +0200 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2016-04-07 15:36:16 +0200 |
commit | 36f3bed2eccb3dfd5266304c482497eff0d25c7c (patch) | |
tree | a43598541a1a4ea92142d17e02c02033e49fa8a3 /src/main/java/de/thedevstack/conversationsplus/ui/listeners | |
parent | 4ace80d39ade18934d310ba37559c9c7ec8004dd (diff) | |
parent | 8c3245dd1f257053b8ec2bf7c5e03a3a98b282c3 (diff) |
Merge remote-tracking branch 'remotes/origin/trz/rename' into trz/rebase
Conflicts:
src/main/java/de/thedevstack/conversationsplus/ui/LogCatOutputActivity.java
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/ui/listeners/LogCatOutputCopyOnClickListener.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/listeners/LogCatOutputCopyOnClickListener.java b/src/main/java/de/thedevstack/conversationsplus/ui/listeners/LogCatOutputCopyOnClickListener.java new file mode 100644 index 00000000..f71c67db --- /dev/null +++ b/src/main/java/de/thedevstack/conversationsplus/ui/listeners/LogCatOutputCopyOnClickListener.java @@ -0,0 +1,41 @@ +package de.thedevstack.conversationsplus.ui.listeners; + +import android.view.View; + +import java.util.List; + +import de.thedevstack.android.logcat.Logging; +import de.thedevstack.android.logcat.adapters.LogCatArrayAdapter; +import de.thedevstack.conversationsplus.utils.ClipboardUtil; + +/** + * OnClickListener to copy logcat entries from LogCatArrayAdapter to clipboard. + */ +public class LogCatOutputCopyOnClickListener implements View.OnClickListener { + private final LogCatArrayAdapter logCatOutputAdapter; + + public LogCatOutputCopyOnClickListener(LogCatArrayAdapter logCatOutputAdapter) { + this.logCatOutputAdapter = logCatOutputAdapter; + } + + /** + * Copies the entries of LogCatArrayAdapter separated by a new line to the clipboard. + * + * @param v The view that was clicked. + */ + @Override + public void onClick(View v) { + Logging.d("copylogcat", "Start Copying log cat"); + List<String> items = this.logCatOutputAdapter.getItems(); + String textToCopy = null; + if (null != items && !items.isEmpty()) { + StringBuilder sb = new StringBuilder(); + for (String item : items) { + sb.append(item); + sb.append("\n"); + } + textToCopy = sb.toString(); + } + ClipboardUtil.copyToClipboard("c+logcat", textToCopy); + } +} |