aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/ui/ConversationFragment.java
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-09-03 19:35:45 +0200
committeriNPUTmice <daniel@gultsch.de>2014-09-03 19:35:45 +0200
commit6b9219c5f4b81172edafae31b705fec3ef56b3f6 (patch)
tree0eda281b2827ae8466e9e0c2036fcec4b2630187 /src/eu/siacs/conversations/ui/ConversationFragment.java
parentf19b1fb823db4fe1d132acc57f6dc7c368374644 (diff)
added support for password protected muc - fixed #203 and fixed #395
Diffstat (limited to '')
-rw-r--r--src/eu/siacs/conversations/ui/ConversationFragment.java64
1 files changed, 47 insertions, 17 deletions
diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java
index 86b5f21f..4ebeea19 100644
--- a/src/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/eu/siacs/conversations/ui/ConversationFragment.java
@@ -15,6 +15,7 @@ import eu.siacs.conversations.entities.MucOptions;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.ui.EditMessage.OnEnterPressed;
import eu.siacs.conversations.ui.XmppActivity.OnPresenceSelected;
+import eu.siacs.conversations.ui.XmppActivity.OnValueEdited;
import eu.siacs.conversations.ui.adapter.MessageAdapter;
import eu.siacs.conversations.ui.adapter.MessageAdapter.OnContactPictureClicked;
import eu.siacs.conversations.ui.adapter.MessageAdapter.OnContactPictureLongClicked;
@@ -128,6 +129,25 @@ public class ConversationFragment extends Fragment {
}
};
+ private OnClickListener enterPassword = new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ MucOptions muc = conversation.getMucOptions();
+ String password = muc.getPassword();
+ if (password==null) {
+ password = "";
+ }
+ activity.quickEdit(password, new OnValueEdited() {
+
+ @Override
+ public void onValueEdited(String value) {
+ activity.xmppConnectionService.providePasswordForMuc(conversation,value);
+ }
+ });
+ }
+ };
+
private OnScrollListener mOnScrollListener = new OnScrollListener() {
@Override
@@ -287,10 +307,12 @@ public class ConversationFragment extends Fragment {
if (oldString.isEmpty() || mEditMessage.getSelectionStart() == 0) {
mEditMessage.getText().insert(0, nick + ": ");
} else {
- if (mEditMessage.getText().charAt(mEditMessage.getSelectionStart()-1)!=' ') {
- nick = " "+nick;
+ if (mEditMessage.getText().charAt(
+ mEditMessage.getSelectionStart() - 1) != ' ') {
+ nick = " " + nick;
}
- mEditMessage.getText().insert(mEditMessage.getSelectionStart(), nick + " ");
+ mEditMessage.getText().insert(mEditMessage.getSelectionStart(),
+ nick + " ");
}
}
@@ -337,8 +359,7 @@ public class ConversationFragment extends Fragment {
activity.getSlidingPaneLayout().closePane();
activity.getActionBar().setDisplayHomeAsUpEnabled(true);
activity.getActionBar().setHomeButtonEnabled(true);
- activity.getActionBar().setTitle(
- conversation.getName());
+ activity.getActionBar().setTitle(conversation.getName());
activity.invalidateOptionsMenu();
}
}
@@ -385,14 +406,15 @@ public class ConversationFragment extends Fragment {
if (this.conversation != null) {
final Contact contact = this.conversation.getContact();
if (this.conversation.isMuted()) {
- showSnackbar(R.string.notifications_disabled, R.string.enable, new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- conversation.setMutedTill(0);
- updateMessages();
- }
- });
+ showSnackbar(R.string.notifications_disabled, R.string.enable,
+ new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ conversation.setMutedTill(0);
+ updateMessages();
+ }
+ });
} else if (!contact.showInRoster()
&& contact
.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
@@ -435,12 +457,20 @@ public class ConversationFragment extends Fragment {
} else {
if (!conversation.getMucOptions().online()
&& conversation.getAccount().getStatus() == Account.STATUS_ONLINE) {
- if (conversation.getMucOptions().getError() == MucOptions.ERROR_NICK_IN_USE) {
+ int error = conversation.getMucOptions().getError();
+ switch (error) {
+ case MucOptions.ERROR_NICK_IN_USE:
showSnackbar(R.string.nick_in_use, R.string.edit,
clickToMuc);
- } else if (conversation.getMucOptions().getError() == MucOptions.ERROR_ROOM_NOT_FOUND) {
+ break;
+ case MucOptions.ERROR_ROOM_NOT_FOUND:
showSnackbar(R.string.conference_not_found,
R.string.leave, leaveMuc);
+ case MucOptions.ERROR_PASSWORD_REQUIRED:
+ showSnackbar(R.string.conference_requires_password,
+ R.string.enter_password, enterPassword);
+ default:
+ break;
}
}
}
@@ -448,7 +478,6 @@ public class ConversationFragment extends Fragment {
updateChatMsgHint();
if (!activity.shouldPaneBeOpen()) {
activity.xmppConnectionService.markRead(conversation);
- // TODO update notifications
UIHelper.updateNotification(getActivity(),
activity.getConversationList(), null, false);
activity.updateConversationList();
@@ -493,7 +522,8 @@ public class ConversationFragment extends Fragment {
Set<String> knownFingerprints = conversation.getContact()
.getOtrFingerprints();
if ((latestEncryption == Message.ENCRYPTION_OTR)
- && (conversation.hasValidOtrSession() && (!conversation.isMuted())
+ && (conversation.hasValidOtrSession()
+ && (!conversation.isMuted())
&& (conversation.getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED) && (!knownFingerprints
.contains(conversation.getOtrFingerprint())))) {
showSnackbar(R.string.unknown_otr_fingerprint, R.string.verify,