am 412a76b0: am 91fbeb6a: Merge "Make CV Subject selectable again. b/17376132" into ub-gmail-ur14-dev
* commit '412a76b05a29be8ddb4f5c8733d361add33eaff8':
Make CV Subject selectable again. b/17376132
diff --git a/src/com/android/mail/browse/ConversationViewHeader.java b/src/com/android/mail/browse/ConversationViewHeader.java
index 68a1604..6475b7a 100644
--- a/src/com/android/mail/browse/ConversationViewHeader.java
+++ b/src/com/android/mail/browse/ConversationViewHeader.java
@@ -17,7 +17,15 @@
package com.android.mail.browse;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.DialogFragment;
+import android.content.ClipData;
+import android.content.ClipboardManager;
import android.content.Context;
+import android.content.DialogInterface;
+import android.os.Bundle;
import android.util.AttributeSet;
import android.view.View;
import android.view.View.OnClickListener;
@@ -39,7 +47,8 @@
* there is enough room to fit both without wrapping. If they overlap, it
* adjusts the layout to position the folders below the subject.
*/
-public class ConversationViewHeader extends LinearLayout implements OnClickListener {
+public class ConversationViewHeader extends LinearLayout implements OnClickListener,
+ View.OnLongClickListener {
public interface ConversationViewHeaderCallbacks {
/**
@@ -53,6 +62,8 @@
* @param newHeight the new height in px
*/
void onConversationViewHeaderHeightChange(int newHeight);
+
+ Activity getActivity();
}
private static final String LOG_TAG = LogTag.getLogTag();
@@ -82,6 +93,7 @@
mSubjectAndFolderView =
(SubjectAndFolderView) findViewById(R.id.subject_and_folder_view);
+ mSubjectAndFolderView.setOnLongClickListener(this);
mStarView = (StarView) findViewById(R.id.conversation_header_star);
mStarView.setOnClickListener(this);
}
@@ -154,6 +166,52 @@
mConversationUpdater.updateConversation(Conversation.listOf(mConversation),
UIProvider.ConversationColumns.STARRED, mConversation.starred);
}
+ }
+ @Override
+ public boolean onLongClick(View v) {
+ final DialogFragment frag =
+ CopySubjectDialog.newInstance(mSubjectAndFolderView.getSubject());
+ frag.show(mCallbacks.getActivity().getFragmentManager(), CopySubjectDialog.TAG);
+ return true;
+ }
+
+ public static class CopySubjectDialog extends DialogFragment
+ implements DialogInterface.OnClickListener {
+
+ public static final String TAG = "copy-subject-dialog";
+
+ private static final String ARG_SUBJECT = "subject";
+
+ private String mSubject;
+
+ public static CopySubjectDialog newInstance(String subject) {
+ final CopySubjectDialog frag = new CopySubjectDialog();
+ final Bundle args = new Bundle(1);
+ args.putString(ARG_SUBJECT, subject);
+ frag.setArguments(args);
+ return frag;
+ }
+
+ public CopySubjectDialog() {}
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ mSubject = getArguments().getString(ARG_SUBJECT);
+ return new AlertDialog.Builder(getActivity())
+ .setMessage(mSubject)
+ .setPositiveButton(R.string.contextmenu_copy, this)
+ .setNegativeButton(R.string.cancel, this)
+ .create();
+ }
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if (which == DialogInterface.BUTTON_POSITIVE) {
+ final ClipboardManager clipboard = (ClipboardManager)
+ getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
+ clipboard.setPrimaryClip(ClipData.newPlainText(null, mSubject));
+ }
+ }
}
}
diff --git a/src/com/android/mail/browse/SubjectAndFolderView.java b/src/com/android/mail/browse/SubjectAndFolderView.java
index 742d6af..fcfd5a6 100644
--- a/src/com/android/mail/browse/SubjectAndFolderView.java
+++ b/src/com/android/mail/browse/SubjectAndFolderView.java
@@ -199,6 +199,10 @@
return mBidiFormatter;
}
+ public String getSubject() {
+ return mSubject;
+ }
+
private static class ConversationFolderDisplayer extends FolderDisplayer {
private final FolderSpan.FolderSpanDimensions mDims;