mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
Fix isSignalGroup boolean check.
Set thread deletion delay to 1s for private chats and open groups.
This commit is contained in:
parent
55523b3baf
commit
7b267ee8b7
@ -111,7 +111,7 @@ public class Address implements Parcelable, Comparable<Address> {
|
|||||||
|
|
||||||
public boolean isGroup() { return GroupUtil.isEncodedGroup(address); }
|
public boolean isGroup() { return GroupUtil.isEncodedGroup(address); }
|
||||||
|
|
||||||
public boolean isSignalGroup() { return !isPublicChat() && !isRSSFeed(); }
|
public boolean isSignalGroup() { return GroupUtil.isSignalGroup(address); }
|
||||||
|
|
||||||
public boolean isPublicChat() { return GroupUtil.isPublicChat(address); }
|
public boolean isPublicChat() { return GroupUtil.isPublicChat(address); }
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe
|
|||||||
|
|
||||||
private fun openConversation(thread: ThreadRecord) {
|
private fun openConversation(thread: ThreadRecord) {
|
||||||
val intent = Intent(this, ConversationActivity::class.java)
|
val intent = Intent(this, ConversationActivity::class.java)
|
||||||
intent.putExtra(ConversationActivity.ADDRESS_EXTRA, thread.recipient.getAddress())
|
intent.putExtra(ConversationActivity.ADDRESS_EXTRA, thread.recipient.address)
|
||||||
intent.putExtra(ConversationActivity.THREAD_ID_EXTRA, thread.threadId)
|
intent.putExtra(ConversationActivity.THREAD_ID_EXTRA, thread.threadId)
|
||||||
intent.putExtra(ConversationActivity.DISTRIBUTION_TYPE_EXTRA, thread.distributionType)
|
intent.putExtra(ConversationActivity.DISTRIBUTION_TYPE_EXTRA, thread.distributionType)
|
||||||
intent.putExtra(ConversationActivity.TIMING_EXTRA, System.currentTimeMillis())
|
intent.putExtra(ConversationActivity.TIMING_EXTRA, System.currentTimeMillis())
|
||||||
@ -255,9 +255,9 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe
|
|||||||
val dialog = AlertDialog.Builder(activity)
|
val dialog = AlertDialog.Builder(activity)
|
||||||
dialog.setMessage(dialogMessage)
|
dialog.setMessage(dialogMessage)
|
||||||
dialog.setPositiveButton(R.string.yes) { _, _ ->
|
dialog.setPositiveButton(R.string.yes) { _, _ ->
|
||||||
val isGroup = recipient.isGroupRecipient
|
val isClosedGroup = recipient.address.isSignalGroup
|
||||||
// Send a leave group message if this is an active closed group
|
// Send a leave group message if this is an active closed group
|
||||||
if (isGroup && DatabaseFactory.getGroupDatabase(activity).isActive(recipient.address.toGroupString())) {
|
if (isClosedGroup && DatabaseFactory.getGroupDatabase(activity).isActive(recipient.address.toGroupString())) {
|
||||||
if (!GroupUtil.leaveGroup(activity, recipient)) {
|
if (!GroupUtil.leaveGroup(activity, recipient)) {
|
||||||
Toast.makeText(activity, "Couldn't leave group", Toast.LENGTH_LONG).show()
|
Toast.makeText(activity, "Couldn't leave group", Toast.LENGTH_LONG).show()
|
||||||
clearView(activity.recyclerView, viewHolder)
|
clearView(activity.recyclerView, viewHolder)
|
||||||
@ -267,10 +267,11 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe
|
|||||||
// Archive the conversation and then delete it after 10 seconds (the case where the
|
// Archive the conversation and then delete it after 10 seconds (the case where the
|
||||||
// app was closed before the conversation could be deleted is handled in onCreate)
|
// app was closed before the conversation could be deleted is handled in onCreate)
|
||||||
threadDatabase.archiveConversation(threadID)
|
threadDatabase.archiveConversation(threadID)
|
||||||
|
val delay = if (isClosedGroup) 10000L else 1000L
|
||||||
val handler = Handler()
|
val handler = Handler()
|
||||||
handler.postDelayed(deleteThread, 10000)
|
handler.postDelayed(deleteThread, delay)
|
||||||
// Notify the user
|
// Notify the user
|
||||||
val toastMessage = if (isGroup) R.string.MessageRecord_left_group else R.string.activity_home_conversation_deleted_message
|
val toastMessage = if (recipient.isGroupRecipient) R.string.MessageRecord_left_group else R.string.activity_home_conversation_deleted_message
|
||||||
Toast.makeText(activity, toastMessage, Toast.LENGTH_LONG).show()
|
Toast.makeText(activity, toastMessage, Toast.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
dialog.setNegativeButton(R.string.no) { _, _ ->
|
dialog.setNegativeButton(R.string.no) { _, _ ->
|
||||||
|
@ -87,6 +87,10 @@ public class GroupUtil {
|
|||||||
return groupId.startsWith(ENCODED_RSS_FEED_GROUP_PREFIX);
|
return groupId.startsWith(ENCODED_RSS_FEED_GROUP_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isSignalGroup(@NonNull String groupId) {
|
||||||
|
return groupId.startsWith(ENCODED_SIGNAL_GROUP_PREFIX);
|
||||||
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
public static Optional<OutgoingGroupMediaMessage> createGroupLeaveMessage(@NonNull Context context, @NonNull Recipient groupRecipient) {
|
public static Optional<OutgoingGroupMediaMessage> createGroupLeaveMessage(@NonNull Context context, @NonNull Recipient groupRecipient) {
|
||||||
String encodedGroupId = groupRecipient.getAddress().toGroupString();
|
String encodedGroupId = groupRecipient.getAddress().toGroupString();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user