diff options
author | Christian Schneppe <christian.schneppe@pix-art.de> | 2019-11-15 16:00:09 +0100 |
---|---|---|
committer | Christian Schneppe <christian.schneppe@pix-art.de> | 2019-11-15 17:14:10 +0100 |
commit | 345e2b7da1f1bc39a2e6d2274813adc7b6a410c0 (patch) | |
tree | 3edbc81dc4d94a124cc132f27b9f508d5d3af6c4 /src/main/java/de/pixart | |
parent | 6c083786f1fe49b9052c9e8712c7e859f0f1ad49 (diff) |
rework no write access hint in moderated public mucs
Diffstat (limited to 'src/main/java/de/pixart')
3 files changed, 39 insertions, 6 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index e8ade33de..ecf7d68b5 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -4274,6 +4274,10 @@ public class XmppConnectionService extends Service { return getBooleanPreference(SettingsActivity.WARN_UNENCRYPTED_CHAT, R.bool.warn_unencrypted_chat); } + + public boolean hideYouAreNotParticipating() { + return getBooleanPreference(SettingsActivity.HIDE_YOU_ARE_NOT_PARTICIPATING, R.bool.hide_you_are_not_participating); + } public boolean broadcastLastActivity() { return getBooleanPreference(SettingsActivity.BROADCAST_LAST_ACTIVITY, R.bool.last_activity); } diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 362bd4495..fdeb4a56f 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -124,6 +124,7 @@ import de.pixart.messenger.xmpp.jingle.JingleConnection; import rocks.xmpp.addr.Jid; import static de.pixart.messenger.entities.Message.DELETED_MESSAGE_BODY; +import static de.pixart.messenger.ui.SettingsActivity.HIDE_YOU_ARE_NOT_PARTICIPATING; import static de.pixart.messenger.ui.SettingsActivity.WARN_UNENCRYPTED_CHAT; import static de.pixart.messenger.ui.XmppActivity.EXTRA_ACCOUNT; import static de.pixart.messenger.ui.XmppActivity.REQUEST_INVITE_TO_CONVERSATION; @@ -503,6 +504,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } } }; + private View.OnLongClickListener mSendButtonLongListener = new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { @@ -513,6 +515,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke return true; } }; + private int completionIndex = 0; private int lastCompletionLength = 0; private String incomplete; @@ -931,7 +934,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke R.string.send_private_message_to, conversation.getNextCounterpart().getResource())); } else if (multi && !conversation.getMucOptions().participating()) { - this.binding.textInputHint.setVisibility(View.GONE); + this.binding.textInputHint.setVisibility(View.VISIBLE); + this.binding.textInputHint.setText(R.string.ask_for_writeaccess); this.binding.textinput.setHint(R.string.you_are_not_participating); } else { this.binding.textInputHint.setVisibility(View.GONE); @@ -2226,7 +2230,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke messageListAdapter.updatePreferences(); refresh(false); this.conversation.messagesLoaded.set(true); - + hasWriteAccessInMUC(); Log.d(Config.LOGTAG, "scrolledToBottomAndNoPending=" + Boolean.toString(scrolledToBottomAndNoPending)); if (hasExtras || scrolledToBottomAndNoPending) { @@ -2255,6 +2259,34 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke return true; } + private void hasWriteAccessInMUC() { + if ((conversation.getMode() == Conversation.MODE_MULTI && !conversation.getMucOptions().participating()) && !activity.xmppConnectionService.hideYouAreNotParticipating()) { + activity.runOnUiThread(() -> { + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + builder.setTitle(getString(R.string.you_are_not_participating)); + builder.setMessage(getString(R.string.no_write_access_in_public_muc)); + builder.setNegativeButton(getString(R.string.hide_warning), + (dialog, which) -> { + SharedPreferences preferences = activity.getPreferences(); + preferences.edit().putBoolean(HIDE_YOU_ARE_NOT_PARTICIPATING, true).apply(); + hideSnackbar(); + }); + builder.setPositiveButton(getString(R.string.ok), + (dialog, which) -> { + Intent intent = new Intent(getActivity(), ConferenceDetailsActivity.class); + intent.setAction(ConferenceDetailsActivity.ACTION_VIEW_MUC); + intent.putExtra("uuid", conversation.getUuid()); + startActivity(intent); + activity.overridePendingTransition(R.animator.fade_in, R.animator.fade_out); + }); + builder.create().show(); + }); + + + showSnackbar(R.string.no_write_access_in_public_muc, R.string.ok, clickToMuc); + } + } + private void resetUnreadMessagesCount() { lastMessageUuid = null; hideUnreadMessagesCount(); @@ -2455,9 +2487,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke hideSnackbar(); break; } - } else if ((mode == Conversation.MODE_MULTI - && !conversation.getMucOptions().participating())) { - showSnackbar(R.string.no_write_access_in_public_muc, R.string.ok, clickToMuc); } else if (account.hasPendingPgpIntent(conversation)) { showSnackbar(R.string.openpgp_messages_found, R.string.decrypt, clickToDecryptListener); } else if (mode == Conversation.MODE_SINGLE @@ -2541,7 +2570,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke binding.unreadCountCustomView.setUnreadCount(conversation.getReceivedMessagesCountSinceUuid(lastMessageUuid)); } this.messageListAdapter.notifyDataSetChanged(); - updateChatMsgHint(); if (notifyConversationRead && activity != null) { binding.messagesView.post(this::fireReadEvent); } diff --git a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java index 419785ecf..a9ffe12bd 100644 --- a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java @@ -53,6 +53,7 @@ public class SettingsActivity extends XmppActivity implements public static final String AUTOMATIC_MESSAGE_DELETION = "automatic_message_deletion"; public static final String BROADCAST_LAST_ACTIVITY = "last_activity"; public static final String WARN_UNENCRYPTED_CHAT = "warn_unencrypted_chat"; + public static final String HIDE_YOU_ARE_NOT_PARTICIPATING = "hide_you_are_not_participating"; public static final String THEME = "theme"; public static final String SHOW_DYNAMIC_TAGS = "show_dynamic_tags"; public static final String OMEMO_SETTING = "omemo"; |