diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-09-27 20:26:31 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-09-27 20:26:31 +0200 |
commit | 7f77edb3bc01b9bd84bbae2be94390b34f9a03b2 (patch) | |
tree | be454fb388f4f23ae0f6891932659f3b1d8dd600 /src/main/java | |
parent | f7580c5e04b3235fd52825ed509d5915ad083f95 (diff) |
do not show 'paste as quote' if clip is NULL
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/util/EditMessageActionModeCallback.java | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/util/EditMessageActionModeCallback.java b/src/main/java/de/pixart/messenger/ui/util/EditMessageActionModeCallback.java index cb50e4164..79914001a 100644 --- a/src/main/java/de/pixart/messenger/ui/util/EditMessageActionModeCallback.java +++ b/src/main/java/de/pixart/messenger/ui/util/EditMessageActionModeCallback.java @@ -32,6 +32,7 @@ package de.pixart.messenger.ui.util; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; +import android.text.TextUtils; import android.view.ActionMode; import android.view.Menu; import android.view.MenuInflater; @@ -52,12 +53,14 @@ public class EditMessageActionModeCallback implements ActionMode.Callback { @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { - MenuInflater inflater = mode.getMenuInflater(); + final MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.edit_message_actions, menu); - MenuItem pasteAsQuote = menu.findItem(R.id.paste_as_quote); - ClipData primaryClip = clipboardManager.getPrimaryClip(); + final MenuItem pasteAsQuote = menu.findItem(R.id.paste_as_quote); + final ClipData primaryClip = clipboardManager.getPrimaryClip(); if (primaryClip != null && primaryClip.getItemCount() >= 0) { - pasteAsQuote.setVisible(primaryClip.getDescription().getMimeType(0).startsWith("text/") && primaryClip.getItemAt(0).getText() != null); + pasteAsQuote.setVisible(primaryClip.getDescription().getMimeType(0).startsWith("text/") && !TextUtils.isEmpty(primaryClip.getItemAt(0).getText())); + } else { + pasteAsQuote.setVisible(false); } return true; } |