fix getNextEncryption

Daniel Gultsch created

Change summary

src/main/java/eu/siacs/conversations/entities/Conversation.java   |  2 
src/main/java/eu/siacs/conversations/ui/ConversationFragment.java | 18 
2 files changed, 8 insertions(+), 12 deletions(-)

Detailed changes

src/main/java/eu/siacs/conversations/entities/Conversation.java 🔗

@@ -600,7 +600,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
 			defaultEncryption = Message.ENCRYPTION_NONE;
 		}
 		int encryption = this.getIntAttribute(ATTRIBUTE_NEXT_ENCRYPTION, defaultEncryption);
-		if (encryption == Message.ENCRYPTION_OTR) {
+		if (encryption == Message.ENCRYPTION_OTR || encryption < 0) {
 			return defaultEncryption;
 		} else {
 			return encryption;

src/main/java/eu/siacs/conversations/ui/ConversationFragment.java 🔗

@@ -884,7 +884,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
 							}
 							highlightInConference(user.getResource());
 						} else {
-							Toast.makeText(getActivity(),R.string.you_are_not_participating, Toast.LENGTH_SHORT).show();
+							Toast.makeText(getActivity(), R.string.you_are_not_participating, Toast.LENGTH_SHORT).show();
 						}
 					}
 					return;
@@ -972,7 +972,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
 		InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
 		View view = activity.getCurrentFocus();
 		if (view != null && imm != null) {
-			imm.hideSoftInputFromWindow(view.getWindowToken(),0);
+			imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
 		}
 	}
 
@@ -1272,15 +1272,11 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
 					}
 					selectPresenceToAttachFile(attachmentChoice);
 				} else {
-					final ConversationFragment fragment = (ConversationFragment) getFragmentManager()
-							.findFragmentByTag("conversation");
-					if (fragment != null) {
-						fragment.showNoPGPKeyDialog(false, (dialog, which) -> {
-							conversation.setNextEncryption(Message.ENCRYPTION_NONE);
-							activity.xmppConnectionService.updateConversation(conversation);
-							selectPresenceToAttachFile(attachmentChoice);
-						});
-					}
+					showNoPGPKeyDialog(false, (dialog, which) -> {
+						conversation.setNextEncryption(Message.ENCRYPTION_NONE);
+						activity.xmppConnectionService.updateConversation(conversation);
+						selectPresenceToAttachFile(attachmentChoice);
+					});
 				}
 			} else {
 				activity.showInstallPgpDialog();