mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-27 12:58:24 +00:00
Add invite friends action button and text.
This commit is contained in:
@@ -233,6 +233,15 @@ public final class ConversationUpdateItem extends LinearLayout
|
|||||||
actionButton.setVisibility(GONE);
|
actionButton.setVisibility(GONE);
|
||||||
actionButton.setOnClickListener(null);
|
actionButton.setOnClickListener(null);
|
||||||
}
|
}
|
||||||
|
} else if (conversationMessage.getMessageRecord().isSelfCreatedGroup()) {
|
||||||
|
actionButton.setText(R.string.ConversationUpdateItem_invite_friends);
|
||||||
|
actionButton.setVisibility(VISIBLE);
|
||||||
|
actionButton.setOnClickListener(v -> {
|
||||||
|
if (batchSelected.isEmpty() && eventListener != null) {
|
||||||
|
// TODO [alan]
|
||||||
|
Log.i(TAG, "TODO");
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
actionButton.setVisibility(GONE);
|
actionButton.setVisibility(GONE);
|
||||||
actionButton.setOnClickListener(null);
|
actionButton.setOnClickListener(null);
|
||||||
|
@@ -32,6 +32,7 @@ import com.annimon.stream.Stream;
|
|||||||
|
|
||||||
import org.signal.core.util.logging.Log;
|
import org.signal.core.util.logging.Log;
|
||||||
import org.signal.storageservice.protos.groups.local.DecryptedGroup;
|
import org.signal.storageservice.protos.groups.local.DecryptedGroup;
|
||||||
|
import org.signal.storageservice.protos.groups.local.DecryptedGroupChange;
|
||||||
import org.thoughtcrime.securesms.R;
|
import org.thoughtcrime.securesms.R;
|
||||||
import org.thoughtcrime.securesms.database.MmsSmsColumns;
|
import org.thoughtcrime.securesms.database.MmsSmsColumns;
|
||||||
import org.thoughtcrime.securesms.database.SmsDatabase;
|
import org.thoughtcrime.securesms.database.SmsDatabase;
|
||||||
@@ -56,6 +57,7 @@ import org.whispersystems.signalservice.api.util.UuidUtil;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@@ -194,6 +196,26 @@ public abstract class MessageRecord extends DisplayRecord {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isSelfCreatedGroup() {
|
||||||
|
if (!isGroupUpdate() || !isGroupV2()) return false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
byte[] decoded = Base64.decode(getBody());
|
||||||
|
DecryptedGroupChange change = DecryptedGroupV2Context.parseFrom(decoded)
|
||||||
|
.getChange();
|
||||||
|
|
||||||
|
return selfCreatedGroup(change);
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.w(TAG, "GV2 Message update detail could not be read", e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean selfCreatedGroup(@NonNull DecryptedGroupChange change) {
|
||||||
|
return change.getRevision() == 0 &&
|
||||||
|
change.getEditor().equals(UuidUtil.toByteString(Recipient.self().requireUuid()));
|
||||||
|
}
|
||||||
|
|
||||||
public static @NonNull UpdateDescription getGv2ChangeDescription(@NonNull Context context, @NonNull String body) {
|
public static @NonNull UpdateDescription getGv2ChangeDescription(@NonNull Context context, @NonNull String body) {
|
||||||
try {
|
try {
|
||||||
ShortStringDescriptionStrategy descriptionStrategy = new ShortStringDescriptionStrategy(context);
|
ShortStringDescriptionStrategy descriptionStrategy = new ShortStringDescriptionStrategy(context);
|
||||||
@@ -203,6 +225,9 @@ public abstract class MessageRecord extends DisplayRecord {
|
|||||||
|
|
||||||
if (decryptedGroupV2Context.hasChange() && (decryptedGroupV2Context.getGroupState().getRevision() != 0 || decryptedGroupV2Context.hasPreviousGroupState())) {
|
if (decryptedGroupV2Context.hasChange() && (decryptedGroupV2Context.getGroupState().getRevision() != 0 || decryptedGroupV2Context.hasPreviousGroupState())) {
|
||||||
return UpdateDescription.concatWithNewLines(updateMessageProducer.describeChanges(decryptedGroupV2Context.getPreviousGroupState(), decryptedGroupV2Context.getChange()));
|
return UpdateDescription.concatWithNewLines(updateMessageProducer.describeChanges(decryptedGroupV2Context.getPreviousGroupState(), decryptedGroupV2Context.getChange()));
|
||||||
|
} else if (selfCreatedGroup(decryptedGroupV2Context.getChange())) {
|
||||||
|
return UpdateDescription.concatWithNewLines(Arrays.asList(updateMessageProducer.describeNewGroup(decryptedGroupV2Context.getGroupState(), decryptedGroupV2Context.getChange()),
|
||||||
|
staticUpdateDescription(context.getString(R.string.MessageRecord_invite_friends_to_this_group), 0)));
|
||||||
} else {
|
} else {
|
||||||
return updateMessageProducer.describeNewGroup(decryptedGroupV2Context.getGroupState(), decryptedGroupV2Context.getChange());
|
return updateMessageProducer.describeNewGroup(decryptedGroupV2Context.getGroupState(), decryptedGroupV2Context.getChange());
|
||||||
}
|
}
|
||||||
|
@@ -1081,6 +1081,7 @@
|
|||||||
<!-- GV2 specific -->
|
<!-- GV2 specific -->
|
||||||
<string name="MessageRecord_you_created_the_group">You created the group.</string>
|
<string name="MessageRecord_you_created_the_group">You created the group.</string>
|
||||||
<string name="MessageRecord_group_updated">Group updated.</string>
|
<string name="MessageRecord_group_updated">Group updated.</string>
|
||||||
|
<string name="MessageRecord_invite_friends_to_this_group">Invite friends to this group via a group link</string>
|
||||||
|
|
||||||
<!-- GV2 member additions -->
|
<!-- GV2 member additions -->
|
||||||
<string name="MessageRecord_you_added_s">You added %1$s.</string>
|
<string name="MessageRecord_you_added_s">You added %1$s.</string>
|
||||||
@@ -1954,6 +1955,7 @@
|
|||||||
<string name="ConversationUpdateItem_join_call">Join call</string>
|
<string name="ConversationUpdateItem_join_call">Join call</string>
|
||||||
<string name="ConversationUpdateItem_return_to_call">Return to call</string>
|
<string name="ConversationUpdateItem_return_to_call">Return to call</string>
|
||||||
<string name="ConversationUpdateItem_call_is_full">Call is full</string>
|
<string name="ConversationUpdateItem_call_is_full">Call is full</string>
|
||||||
|
<string name="ConversationUpdateItem_invite_friends">Invite friends</string>
|
||||||
|
|
||||||
<!-- audio_view -->
|
<!-- audio_view -->
|
||||||
<string name="audio_view__play_pause_accessibility_description">Play … Pause</string>
|
<string name="audio_view__play_pause_accessibility_description">Play … Pause</string>
|
||||||
|
Reference in New Issue
Block a user