diff options
Diffstat (limited to '')
-rw-r--r-- | src/eu/siacs/conversations/ui/ConversationActivity.java | 63 | ||||
-rw-r--r-- | src/eu/siacs/conversations/ui/ConversationFragment.java | 8 |
2 files changed, 42 insertions, 29 deletions
diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java index 0409feda..df0112ae 100644 --- a/src/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/eu/siacs/conversations/ui/ConversationActivity.java @@ -14,6 +14,7 @@ import eu.siacs.conversations.utils.UIHelper; import android.net.Uri; import android.os.Bundle; import android.os.SystemClock; +import android.preference.PreferenceManager; import android.provider.MediaStore; import android.app.ActionBar; import android.app.AlertDialog; @@ -279,7 +280,7 @@ public class ConversationActivity extends XmppActivity { private void attachFile(final int attachmentChoice) { final Conversation conversation = getSelectedConversation(); - if (conversation.getNextEncryption() == Message.ENCRYPTION_PGP) { + if (conversation.getNextEncryption(forceEncryption()) == Message.ENCRYPTION_PGP) { if (hasPgp()) { if (conversation.getContact().getPgpKeyId() != 0) { xmppConnectionService.getPgpEngine().hasKey( @@ -323,7 +324,7 @@ public class ConversationActivity extends XmppActivity { } else { showInstallPgpDialog(); } - } else if (getSelectedConversation().getNextEncryption() == Message.ENCRYPTION_NONE) { + } else if (getSelectedConversation().getNextEncryption(forceEncryption()) == Message.ENCRYPTION_NONE) { selectPresenceToAttachFile(attachmentChoice); } else { selectPresenceToAttachFile(attachmentChoice); @@ -439,13 +440,17 @@ public class ConversationActivity extends XmppActivity { popup.inflate(R.menu.encryption_choices); MenuItem otr = popup.getMenu().findItem( R.id.encryption_choice_otr); + MenuItem none = popup.getMenu().findItem(R.id.encryption_choice_none); if (conversation.getMode() == Conversation.MODE_MULTI) { otr.setEnabled(false); + } else { + if (forceEncryption()) { + none.setVisible(false); + } } - switch (conversation.getNextEncryption()) { + switch (conversation.getNextEncryption(forceEncryption())) { case Message.ENCRYPTION_NONE: - popup.getMenu().findItem(R.id.encryption_choice_none) - .setChecked(true); + none.setChecked(true); break; case Message.ENCRYPTION_OTR: otr.setChecked(true); @@ -510,29 +515,32 @@ public class ConversationActivity extends XmppActivity { }); builder.create().show(); } - + protected void muteConversationDialog(final Conversation conversation) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.disable_notifications_for_this_conversation); - final int[] durations = getResources().getIntArray(R.array.mute_options_durations); - builder.setItems(R.array.mute_options_descriptions, new OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, int which) { - long till; - if (durations[which]==-1) { - till = Long.MAX_VALUE; - } else { - till = SystemClock.elapsedRealtime() + (durations[which] * 1000); - } - conversation.setMutedTill(till); - ConversationFragment selectedFragment = (ConversationFragment) getFragmentManager() - .findFragmentByTag("conversation"); - if (selectedFragment!=null) { - selectedFragment.updateMessages(); - } - } - }); + final int[] durations = getResources().getIntArray( + R.array.mute_options_durations); + builder.setItems(R.array.mute_options_descriptions, + new OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + long till; + if (durations[which] == -1) { + till = Long.MAX_VALUE; + } else { + till = SystemClock.elapsedRealtime() + + (durations[which] * 1000); + } + conversation.setMutedTill(till); + ConversationFragment selectedFragment = (ConversationFragment) getFragmentManager() + .findFragmentByTag("conversation"); + if (selectedFragment != null) { + selectedFragment.updateMessages(); + } + } + }); builder.create().show(); } @@ -794,4 +802,9 @@ public class ConversationActivity extends XmppActivity { } }); } + + public boolean forceEncryption() { + return PreferenceManager.getDefaultSharedPreferences( + getApplicationContext()).getBoolean("force_encryption", false); + } } diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java index 8157644c..04b2471e 100644 --- a/src/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/eu/siacs/conversations/ui/ConversationFragment.java @@ -188,7 +188,7 @@ public class ConversationFragment extends Fragment { return; } Message message = new Message(conversation, mEditMessage.getText() - .toString(), conversation.getNextEncryption()); + .toString(), conversation.getNextEncryption(activity.forceEncryption())); if (conversation.getMode() == Conversation.MODE_MULTI) { if (conversation.getNextPresence() != null) { message.setPresence(conversation.getNextPresence()); @@ -196,9 +196,9 @@ public class ConversationFragment extends Fragment { conversation.setNextPresence(null); } } - if (conversation.getNextEncryption() == Message.ENCRYPTION_OTR) { + if (conversation.getNextEncryption(activity.forceEncryption()) == Message.ENCRYPTION_OTR) { sendOtrMessage(message); - } else if (conversation.getNextEncryption() == Message.ENCRYPTION_PGP) { + } else if (conversation.getNextEncryption(activity.forceEncryption()) == Message.ENCRYPTION_PGP) { sendPgpMessage(message); } else { sendPlainTextMessage(message); @@ -212,7 +212,7 @@ public class ConversationFragment extends Fragment { R.string.send_private_message_to, conversation.getNextPresence())); } else { - switch (conversation.getNextEncryption()) { + switch (conversation.getNextEncryption(activity.forceEncryption())) { case Message.ENCRYPTION_NONE: mEditMessage .setHint(getString(R.string.send_plain_text_message)); |