aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2016-01-30 12:03:37 -0800
committerScott Jackson <daneren2005@gmail.com>2016-01-30 12:03:37 -0800
commitfa713ccbe28d5ec50fdbbf69ebc8802fe2cf1417 (patch)
tree456bc4054b6f782e45a156282720e15f88b7c103 /app/src/main/java
parent821c2c90b9c805c92815676e874a2b83c59b583d (diff)
parenta43b8e31adcbe4bdf067d05ddd4db835fafbd52f (diff)
downloaddsub-fa713ccbe28d5ec50fdbbf69ebc8802fe2cf1417.tar.gz
dsub-fa713ccbe28d5ec50fdbbf69ebc8802fe2cf1417.tar.bz2
dsub-fa713ccbe28d5ec50fdbbf69ebc8802fe2cf1417.zip
Merge branch 'long-press-copy-on-details' of https://github.com/fxthomas/Subsonic into fxthomas-long-press-copy-on-details
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/Util.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/util/Util.java b/app/src/main/java/github/daneren2005/dsub/util/Util.java
index 98bbe1df..be9536ed 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/Util.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/Util.java
@@ -22,6 +22,8 @@ import android.app.Activity;
import android.graphics.Color;
import android.support.annotation.StringRes;
import android.support.v7.app.AlertDialog;
+import android.content.ClipboardManager;
+import android.content.ClipData;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
@@ -46,9 +48,11 @@ import android.text.method.LinkMovementMethod;
import android.text.util.Linkify;
import android.util.Log;
import android.util.SparseArray;
+import android.view.View;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;
+import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
@@ -1247,6 +1251,27 @@ public final class Util {
listView.setDivider(null);
listView.setScrollbarFadingEnabled(false);
+ // Let the user long-click on a row to copy its value to the clipboard
+ final Context contextRef = context;
+ listView.setOnItemLongClickListener(new ListView.OnItemLongClickListener() {
+ @Override
+ public boolean onItemLongClick(AdapterView<?> parent, View view, int pos, long id) {
+
+ TextView nameView = (TextView) view.findViewById(R.id.detail_name);
+ TextView detailsView = (TextView) view.findViewById(R.id.detail_value);
+ CharSequence name = nameView.getText();
+ CharSequence value = detailsView.getText();
+
+ ClipboardManager clipboard = (ClipboardManager) contextRef.getSystemService(Context.CLIPBOARD_SERVICE);
+ ClipData clip = ClipData.newPlainText(name, value);
+ clipboard.setPrimaryClip(clip);
+
+ toast(contextRef, "Copied " + name + " to clipboard");
+
+ return true;
+ }
+ });
+
new AlertDialog.Builder(context)
// .setIcon(android.R.drawable.ic_dialog_info)
.setTitle(title)