mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
open group invitation sending part
This commit is contained in:
parent
2a436edbf8
commit
f51268b587
@ -88,6 +88,7 @@ import org.session.libsession.messaging.messages.control.ExpirationTimerUpdate;
|
||||
import org.session.libsession.messaging.messages.signal.OutgoingMediaMessage;
|
||||
import org.session.libsession.messaging.messages.signal.OutgoingSecureMediaMessage;
|
||||
import org.session.libsession.messaging.messages.signal.OutgoingTextMessage;
|
||||
import org.session.libsession.messaging.messages.visible.OpenGroupInvitation;
|
||||
import org.session.libsession.messaging.messages.visible.VisibleMessage;
|
||||
import org.session.libsession.messaging.open_groups.OpenGroup;
|
||||
import org.session.libsession.messaging.open_groups.OpenGroupV2;
|
||||
@ -157,6 +158,7 @@ import org.thoughtcrime.securesms.linkpreview.LinkPreviewUtil;
|
||||
import org.thoughtcrime.securesms.linkpreview.LinkPreviewViewModel;
|
||||
import org.thoughtcrime.securesms.loki.activities.EditClosedGroupActivity;
|
||||
import org.thoughtcrime.securesms.loki.activities.HomeActivity;
|
||||
import org.thoughtcrime.securesms.loki.activities.SelectContactsActivity;
|
||||
import org.thoughtcrime.securesms.loki.api.PublicChatInfoUpdateWorker;
|
||||
import org.thoughtcrime.securesms.loki.database.LokiThreadDatabase;
|
||||
import org.thoughtcrime.securesms.loki.database.LokiUserDatabase;
|
||||
@ -249,6 +251,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
private static final int PICK_GIF = 10;
|
||||
private static final int SMS_DEFAULT = 11;
|
||||
private static final int MEDIA_SENDER = 12;
|
||||
private static final int INVITE_CONTACTS = 124;
|
||||
|
||||
private GlideRequests glideRequests;
|
||||
protected ComposeText composeText;
|
||||
@ -593,6 +596,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
});
|
||||
|
||||
break;
|
||||
case INVITE_CONTACTS:
|
||||
if (data.getExtras() == null || !data.hasExtra(SelectContactsActivity.Companion.getSelectedContactsKey())) return;
|
||||
String[] selectedContacts = data.getExtras().getStringArray(SelectContactsActivity.Companion.getSelectedContactsKey());
|
||||
sendOpenGroupInvitations(selectedContacts);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -655,6 +663,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
} else if (isActiveGroup()) {
|
||||
inflater.inflate(R.menu.conversation_push_group_options, menu);
|
||||
}
|
||||
} else if (isOpenGroupOrRSSFeed) {
|
||||
inflater.inflate(R.menu.conversation_invite_open_group, menu);
|
||||
}
|
||||
|
||||
inflater.inflate(R.menu.conversation, menu);
|
||||
@ -763,6 +773,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
// case R.id.menu_conversation_settings: handleConversationSettings(); return true;
|
||||
case R.id.menu_expiring_messages_off:
|
||||
case R.id.menu_expiring_messages: handleSelectMessageExpiration(); return true;
|
||||
case R.id.menu_invite_to_open_group: handleInviteToOpenGroup(); return true;
|
||||
case android.R.id.home: handleReturnToConversationList(); return true;
|
||||
}
|
||||
|
||||
@ -1031,6 +1042,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
private void handleInviteToOpenGroup() {
|
||||
Intent intent = new Intent(this, SelectContactsActivity.class);
|
||||
startActivityForResult(intent, INVITE_CONTACTS);
|
||||
}
|
||||
|
||||
private void handleDistributionBroadcastEnabled(MenuItem item) {
|
||||
distributionType = DistributionTypes.BROADCAST;
|
||||
item.setChecked(true);
|
||||
@ -1838,6 +1854,24 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
sendComplete(allocatedThreadId);
|
||||
}
|
||||
|
||||
private void sendOpenGroupInvitations(String[] contactsID) {
|
||||
final Context context = getApplicationContext();
|
||||
OpenGroupV2 openGroup = DatabaseFactory.getLokiThreadDatabase(context).getOpenGroupChat(threadId);
|
||||
for (String contactId: contactsID) {
|
||||
Recipient recipient = Recipient.from(context, Address.fromSerialized(contactId), true);
|
||||
VisibleMessage message = new VisibleMessage();
|
||||
message.setSentTimestamp(System.currentTimeMillis());
|
||||
OpenGroupInvitation openGroupInvitationMessage = new OpenGroupInvitation();
|
||||
openGroupInvitationMessage.setGroupName(openGroup.getName());
|
||||
openGroupInvitationMessage.setGroupUrl(openGroup.toJoinUrl());
|
||||
message.setOpenGroupInvitation(openGroupInvitationMessage);
|
||||
OutgoingTextMessage outgoingTextMessage = OutgoingTextMessage.fromOpenGroupInvitation(openGroupInvitationMessage, recipient, message.getSentTimestamp());
|
||||
|
||||
DatabaseFactory.getSmsDatabase(context).insertMessageOutbox(-1, outgoingTextMessage, message.getSentTimestamp());
|
||||
MessageSender.send(message, recipient.getAddress());
|
||||
}
|
||||
}
|
||||
|
||||
private void updateToggleButtonState() {
|
||||
if (inputPanel.isRecordingInLockedMode()) {
|
||||
buttonToggle.display(sendButton);
|
||||
|
@ -77,6 +77,8 @@ public class ThreadRecord extends DisplayRecord {
|
||||
return emphasisAdded(context.getString(R.string.ThreadRecord_group_updated));
|
||||
} else if (isGroupQuit()) {
|
||||
return emphasisAdded(context.getString(R.string.ThreadRecord_left_the_group));
|
||||
} else if (isOpenGroupInvitation()) {
|
||||
return emphasisAdded(context.getString(R.string.ThreadRecord_open_group_invitation));
|
||||
} else if (isKeyExchange()) {
|
||||
return emphasisAdded(context.getString(R.string.ConversationListItem_key_exchange_message));
|
||||
} else if (SmsDatabase.Types.isFailedDecryptType(type)) {
|
||||
|
8
app/src/main/res/menu/conversation_invite_open_group.xml
Normal file
8
app/src/main/res/menu/conversation_invite_open_group.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:title="@string/ConversationActivity_invite_to_open_group"
|
||||
android:id="@+id/menu_invite_to_open_group"
|
||||
android:icon="?menu_accept_icon" />
|
||||
|
||||
</menu>
|
@ -151,6 +151,7 @@
|
||||
<string name="ConversationActivity_attachment_exceeds_size_limits">La pièce jointe dépasse la limite de taille autorisée.</string>
|
||||
<string name="ConversationActivity_quick_camera_unavailable">L’appareil photo n’est pas disponible</string>
|
||||
<string name="ConversationActivity_unable_to_record_audio">Impossible d’enregistrer l’audio !</string>
|
||||
<string name="ConversationActivity_invite_to_open_group">Ajouter des membres</string>
|
||||
<string name="ConversationActivity_there_is_no_app_available_to_handle_this_link_on_your_device">Il n’y a aucune appli pour gérer ce lien sur votre appareil.</string>
|
||||
<string name="ConversationActivity_to_send_audio_messages_allow_signal_access_to_your_microphone">Pour envoyer des messages audio, autorisez Session à accéder à votre microphone.</string>
|
||||
<string name="ConversationActivity_signal_requires_the_microphone_permission_in_order_to_send_audio_messages">Session exige l’autorisation Microphone afin d’envoyer des messages audio, mais elle a été refusée définitivement. Veuillez accéder au menu des paramètres des applis, sélectionner « Autorisations » et activer « Microphone ».</string>
|
||||
@ -599,6 +600,8 @@ Vous avez reçu un message d’échange de clés pour une version de protocole i
|
||||
<string name="ThreadRecord_your_safety_number_with_s_has_changed">Votre numéro de sécurité avec %s a changé</string>
|
||||
<string name="ThreadRecord_you_marked_verified">Vous avez marqué comme vérifié</string>
|
||||
<string name="ThreadRecord_you_marked_unverified">Vous avez marqué comme non vérifié</string>
|
||||
<string name="ThreadRecord_empty_message">Cette conversation est vide</string>
|
||||
<string name="ThreadRecord_open_group_invitation">Invitation à un groupe public</string>
|
||||
<!--UpdateApkReadyListener-->
|
||||
<string name="UpdateApkReadyListener_Signal_update">Mise à jour de Session</string>
|
||||
<string name="UpdateApkReadyListener_a_new_version_of_signal_is_available_tap_to_update">Une nouvelle version de Session est proposée. Touchez pour lancer la mise à jour</string>
|
||||
|
@ -175,6 +175,7 @@
|
||||
<string name="ConversationActivity_quick_camera_unavailable">Camera unavailable</string>
|
||||
<string name="ConversationActivity_unable_to_record_audio">Unable to record audio!</string>
|
||||
<string name="ConversationActivity_there_is_no_app_available_to_handle_this_link_on_your_device">There is no app available to handle this link on your device.</string>
|
||||
<string name="ConversationActivity_invite_to_open_group">Add members</string>
|
||||
|
||||
<string name="ConversationActivity_to_send_audio_messages_allow_signal_access_to_your_microphone">Session needs microphone access to send audio messages.</string>
|
||||
<string name="ConversationActivity_signal_requires_the_microphone_permission_in_order_to_send_audio_messages">Session needs microphone access to send audio messages, but it has been permanently denied. Please continue to app settings, select \"Permissions\", and enable \"Microphone\".</string>
|
||||
@ -722,6 +723,7 @@
|
||||
<string name="ThreadRecord_you_marked_verified">You marked verified</string>
|
||||
<string name="ThreadRecord_you_marked_unverified">You marked unverified</string>
|
||||
<string name="ThreadRecord_empty_message">This conversation is empty</string>
|
||||
<string name="ThreadRecord_open_group_invitation">Open group invitation</string>
|
||||
|
||||
<!-- UpdateApkReadyListener -->
|
||||
<string name="UpdateApkReadyListener_Signal_update">Session update</string>
|
||||
|
@ -70,9 +70,9 @@ class VisibleMessage : Message() {
|
||||
override fun isValid(): Boolean {
|
||||
if (!super.isValid()) return false
|
||||
if (attachmentIDs.isNotEmpty()) return true
|
||||
if (openGroupInvitation != null) return true
|
||||
val text = text?.trim() ?: return false
|
||||
if (text.isNotEmpty()) return true
|
||||
if (openGroupInvitation != null) return true
|
||||
return false
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user