From 8cf430a7ba6c6c45b3b5a18ece512b62bd276619 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sun, 29 Apr 2018 13:29:06 +0200 Subject: make text clickable in openkeychain missing message --- .../messenger/ui/adapter/MessageAdapter.java | 33 +++++++++++----------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java index 1b343aa67..4cdce8aca 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java @@ -411,19 +411,6 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie viewHolder.messageBody.setTextIsSelectable(false); } - private void displayDecryptionFailed(ViewHolder viewHolder, boolean darkBackground) { - viewHolder.download_button.setVisibility(View.GONE); - viewHolder.image.setVisibility(View.GONE); - viewHolder.audioPlayer.setVisibility(View.GONE); - viewHolder.messageBody.setVisibility(View.VISIBLE); - if (darkBackground) { - viewHolder.messageBody.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Body1_Secondary_OnDark); - } else { - viewHolder.messageBody.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Body1_Secondary); - } - viewHolder.messageBody.setTextIsSelectable(false); - } - private void displayEmojiMessage(final ViewHolder viewHolder, final String body, final boolean darkBackground) { viewHolder.download_button.setVisibility(View.GONE); viewHolder.audioPlayer.setVisibility(View.GONE); @@ -915,8 +902,9 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie loadAvatar(message, viewHolder.contact_picture, activity.getPixel(48)); } - viewHolder.contact_picture - .setOnClickListener(v -> { + resetClickListener(viewHolder.message_box, viewHolder.messageBody); + + viewHolder.contact_picture.setOnClickListener(v -> { if (MessageAdapter.this.mOnContactPictureClickedListener != null) { MessageAdapter.this.mOnContactPictureClickedListener .onContactPictureClicked(message); @@ -962,10 +950,11 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie } } else { displayInfoMessage(viewHolder, activity.getString(R.string.install_openkeychain), darkBackground); - viewHolder.message_box.setOnClickListener(v -> activity.showInstallPgpDialog()); + viewHolder.message_box.setOnClickListener(this::promptOpenKeychainInstall); + viewHolder.messageBody.setOnClickListener(this::promptOpenKeychainInstall); } } else if (message.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) { - displayDecryptionFailed(viewHolder, darkBackground); + displayInfoMessage(viewHolder, activity.getString(R.string.decryption_failed), darkBackground); } else if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL_NOT_FOR_THIS_DEVICE) { displayInfoMessage(viewHolder, activity.getString(R.string.not_encrypted_for_this_device), darkBackground); } else { @@ -1019,6 +1008,16 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie return view; } + private static void resetClickListener(View... views) { + for (View view : views) { + view.setOnClickListener(null); + } + } + + private void promptOpenKeychainInstall(View view) { + activity.showInstallPgpDialog(); + } + @Override public void notifyDataSetChanged() { listSelectionManager.onBeforeNotifyDataSetChanged(); -- cgit v1.2.3