From 064e5a4f0dbb59e28b6099a1c5d086bbca55d84b Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 15 Apr 2018 17:30:28 +0200 Subject: [PATCH] make text clickable in openkeychain missing message --- .../ui/adapter/MessageAdapter.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java index 160ed5f40..6c16c634b 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java @@ -377,19 +377,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); @@ -767,6 +754,8 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie loadAvatar(message, viewHolder.contact_picture, activity.getPixel(48)); } + resetClickListener(viewHolder.message_box, viewHolder.messageBody); + viewHolder.contact_picture.setOnClickListener(v -> { if (MessageAdapter.this.mOnContactPictureClickedListener != null) { MessageAdapter.this.mOnContactPictureClickedListener @@ -812,10 +801,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 { @@ -868,6 +858,16 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie return view; } + private void promptOpenKeychainInstall(View view) { + activity.showInstallPgpDialog(); + } + + private static void resetClickListener(View... views) { + for(View view : views) { + view.setOnClickListener(null); + } + } + @Override public void notifyDataSetChanged() { listSelectionManager.onBeforeNotifyDataSetChanged();