aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorChristian Schneppe <christian.schneppe@pix-art.de>2019-11-15 16:00:09 +0100
committerChristian Schneppe <christian.schneppe@pix-art.de>2019-11-15 17:14:10 +0100
commit345e2b7da1f1bc39a2e6d2274813adc7b6a410c0 (patch)
tree3edbc81dc4d94a124cc132f27b9f508d5d3af6c4 /src/main
parent6c083786f1fe49b9052c9e8712c7e859f0f1ad49 (diff)
rework no write access hint in moderated public mucs
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java4
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java40
-rw-r--r--src/main/java/de/pixart/messenger/ui/SettingsActivity.java1
-rw-r--r--src/main/res/values/defaults.xml1
-rw-r--r--src/main/res/values/strings.xml3
5 files changed, 42 insertions, 7 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";
diff --git a/src/main/res/values/defaults.xml b/src/main/res/values/defaults.xml
index e1e39fbe5..26d1179ae 100644
--- a/src/main/res/values/defaults.xml
+++ b/src/main/res/values/defaults.xml
@@ -39,6 +39,7 @@
<bool name="validate_hostname">false</bool>
<bool name="show_foreground_service">true</bool>
<bool name="warn_unencrypted_chat">true</bool>
+ <bool name="hide_you_are_not_participating">false</bool>
<bool name="use_bundled_emoji">true</bool>
<bool name="enable_multi_accounts">false</bool>
<bool name="show_qr_code_scan">true</bool>
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 7c899ecd4..e0d3b9120 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -702,7 +702,7 @@
<string name="destroy_room_dialog">Would you like to destroy the group chat %s? This will remove this group chat permanently.</string>
<string name="destroy_room_succeed">Group chat successfully destroyed</string>
<string name="destroy_room_failed">Group chat could not be destroyed</string>
- <string name="no_write_access_in_public_muc">You are not participating this group chat and have no write access at the moment.\nPlease go to the group chat details by pressing <b>OK</b> and send a private message to a moderator, administrator or owner by long clicking one of the members name at the top of the list to ask for write access.</string>
+ <string name="no_write_access_in_public_muc">You are not participating this group chat and have no write access at the moment.\nPlease go to the group chat details by pressing <b>OK</b> and send a private message to a moderator, administrator or owner by long clicking one of the members name at the top/front of the list to ask for write access.</string>
<string name="snooze">Snooze</string>
<string name="huawei_protected_apps">Protected Apps</string>
<string name="huawei_protected_apps_summary">To keep receiving notifications, even when the screen is turned off, you need to add Pix-Art Messenger to the list of protected apps.</string>
@@ -988,4 +988,5 @@
<string name="gp_long">Long</string>
<string name="pref_notification_grace_period">Grace Period</string>
<string name="pref_notification_grace_period_summary">The length of time notifications are silenced after detecting activity on one of your other devices.</string>
+ <string name="ask_for_writeaccess">Please ask for write access</string>
</resources>