mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-28 20:45:17 +00:00
Feedback
This commit is contained in:
parent
517f8ca62f
commit
e68f69a555
@ -19,7 +19,6 @@ import kotlinx.coroutines.launch
|
||||
import network.loki.messenger.BuildConfig
|
||||
import network.loki.messenger.libsession_util.util.ExpiryMode
|
||||
import org.session.libsession.messaging.messages.ExpirationConfiguration
|
||||
import org.session.libsession.utilities.SSKEnvironment.MessageExpirationManagerProtocol
|
||||
import org.session.libsession.utilities.TextSecurePreferences
|
||||
import org.thoughtcrime.securesms.conversation.disappearingmessages.ui.ExpiryCallbacks
|
||||
import org.thoughtcrime.securesms.conversation.disappearingmessages.ui.UiState
|
||||
@ -32,7 +31,6 @@ class DisappearingMessagesViewModel(
|
||||
private val threadId: Long,
|
||||
private val application: Application,
|
||||
private val textSecurePreferences: TextSecurePreferences,
|
||||
private val messageExpirationManager: MessageExpirationManagerProtocol,
|
||||
private val disappearingMessages: DisappearingMessages,
|
||||
private val threadDb: ThreadDatabase,
|
||||
private val groupDb: GroupDatabase,
|
||||
@ -60,8 +58,6 @@ class DisappearingMessagesViewModel(
|
||||
viewModelScope.launch {
|
||||
val expiryMode = storage.getExpirationConfiguration(threadId)?.expiryMode ?: ExpiryMode.NONE
|
||||
val recipient = threadDb.getRecipientForThreadId(threadId)?: return@launch
|
||||
val groupRecord = recipient.takeIf { it.isLegacyGroupRecipient || it.isGroupV2Recipient }
|
||||
?.run { groupDb.getGroup(address.toGroupString()).orNull() }
|
||||
|
||||
val isAdmin = when {
|
||||
recipient.isGroupV2Recipient -> {
|
||||
@ -69,6 +65,7 @@ class DisappearingMessagesViewModel(
|
||||
storage.getMembers(recipient.address.serialize()).any { it.sessionId == textSecurePreferences.getLocalNumber() && it.admin }
|
||||
}
|
||||
recipient.isLegacyGroupRecipient -> {
|
||||
val groupRecord = groupDb.getGroup(recipient.address.toGroupString()).orNull()
|
||||
// Handle as legacy group
|
||||
groupRecord?.admins?.any{ it.serialize() == textSecurePreferences.getLocalNumber() } == true
|
||||
}
|
||||
@ -78,7 +75,7 @@ class DisappearingMessagesViewModel(
|
||||
_state.update {
|
||||
it.copy(
|
||||
address = recipient.address,
|
||||
isGroup = recipient.isGroupOrCommunityRecipient,
|
||||
isGroup = recipient.isGroupRecipient,
|
||||
isNoteToSelf = recipient.address.serialize() == textSecurePreferences.getLocalNumber(),
|
||||
isSelfAdmin = isAdmin,
|
||||
expiryMode = expiryMode,
|
||||
@ -114,7 +111,6 @@ class DisappearingMessagesViewModel(
|
||||
@Assisted private val threadId: Long,
|
||||
private val application: Application,
|
||||
private val textSecurePreferences: TextSecurePreferences,
|
||||
private val messageExpirationManager: MessageExpirationManagerProtocol,
|
||||
private val disappearingMessages: DisappearingMessages,
|
||||
private val threadDb: ThreadDatabase,
|
||||
private val groupDb: GroupDatabase,
|
||||
@ -125,7 +121,6 @@ class DisappearingMessagesViewModel(
|
||||
threadId,
|
||||
application,
|
||||
textSecurePreferences,
|
||||
messageExpirationManager,
|
||||
disappearingMessages,
|
||||
threadDb,
|
||||
groupDb,
|
||||
|
@ -70,7 +70,6 @@ import network.loki.messenger.databinding.ActivityConversationV2Binding
|
||||
import network.loki.messenger.libsession_util.util.ExpiryMode
|
||||
import nl.komponents.kovenant.ui.successUi
|
||||
import org.session.libsession.database.StorageProtocol
|
||||
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||
import org.session.libsession.messaging.groups.GroupManagerV2
|
||||
import org.session.libsession.messaging.messages.ExpirationConfiguration
|
||||
import org.session.libsession.messaging.messages.applyExpiryMode
|
||||
@ -279,7 +278,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
}
|
||||
|
||||
private val viewModel: ConversationViewModel by viewModels {
|
||||
viewModelFactory.create(threadId, MessagingModuleConfiguration.shared.storage.getUserED25519KeyPair())
|
||||
viewModelFactory.create(threadId, storage.getUserED25519KeyPair())
|
||||
}
|
||||
private var actionMode: ActionMode? = null
|
||||
private var unreadCount = Int.MAX_VALUE
|
||||
@ -578,10 +577,6 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
}
|
||||
}
|
||||
|
||||
override fun finish() {
|
||||
super.finish()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
ApplicationContext.getInstance(this).messageNotifier.setVisibleThread(-1)
|
||||
|
@ -3,8 +3,8 @@ package org.thoughtcrime.securesms.conversation.v2
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.view.MenuItem
|
||||
import androidx.annotation.StringRes
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.viewModelScope
|
||||
@ -20,7 +20,6 @@ import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import network.loki.messenger.R
|
||||
import network.loki.messenger.libsession_util.util.GroupMember
|
||||
import org.session.libsession.database.MessageDataProvider
|
||||
import org.session.libsession.database.StorageProtocol
|
||||
import org.session.libsession.messaging.groups.GroupManagerV2
|
||||
@ -33,12 +32,12 @@ import org.session.libsession.utilities.Address
|
||||
import org.session.libsession.utilities.Address.Companion.fromSerialized
|
||||
import org.session.libsession.utilities.TextSecurePreferences
|
||||
import org.session.libsession.utilities.getGroup
|
||||
import org.session.libsession.utilities.recipients.Recipient
|
||||
import org.session.libsession.utilities.recipients.MessageType
|
||||
import org.session.libsession.utilities.recipients.Recipient
|
||||
import org.session.libsession.utilities.recipients.getType
|
||||
import org.session.libsignal.utilities.AccountId
|
||||
import org.session.libsignal.utilities.IdPrefix
|
||||
import org.session.libsignal.utilities.Log
|
||||
import org.session.libsignal.utilities.AccountId
|
||||
import org.thoughtcrime.securesms.audio.AudioSlidePlayer
|
||||
import org.thoughtcrime.securesms.conversation.v2.menus.ConversationMenuHelper
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase
|
||||
@ -148,20 +147,6 @@ class ConversationViewModel(
|
||||
val openGroup: OpenGroup?
|
||||
get() = _openGroup.value
|
||||
|
||||
private val closedGroupMembers: List<GroupMember>
|
||||
get() {
|
||||
val recipient = recipient ?: return emptyList()
|
||||
if (!recipient.isGroupV2Recipient) return emptyList()
|
||||
return storage.getMembers(recipient.address.serialize())
|
||||
}
|
||||
|
||||
val isClosedGroupAdmin: Boolean
|
||||
get() {
|
||||
val recipient = recipient ?: return false
|
||||
return !recipient.isGroupV2Recipient ||
|
||||
(closedGroupMembers.firstOrNull { it.sessionId == storage.getUserPublicKey() }?.admin ?: false)
|
||||
}
|
||||
|
||||
val serverCapabilities: List<String>
|
||||
get() = openGroup?.let { storage.getServerCapabilities(it.server) } ?: listOf()
|
||||
|
||||
@ -767,7 +752,7 @@ class ConversationViewModel(
|
||||
}
|
||||
}
|
||||
.onFailure {
|
||||
showMessage("Couldn't accept message request due to error: $it")
|
||||
Log.w("Loki", "Couldn't accept message request due to error", it)
|
||||
|
||||
_uiState.update { state ->
|
||||
state.copy(messageRequestState = currentState)
|
||||
@ -781,7 +766,7 @@ class ConversationViewModel(
|
||||
_uiState.update { it.copy(shouldExit = true) }
|
||||
}
|
||||
.onFailure {
|
||||
showMessage("Couldn't decline message request due to error: $it")
|
||||
Log.w("Loki", "Couldn't decline message request due to error", it)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,76 +0,0 @@
|
||||
package org.thoughtcrime.securesms.conversation.v2
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.view.isVisible
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import network.loki.messenger.R
|
||||
import network.loki.messenger.databinding.FragmentDeleteMessageBottomSheetBinding
|
||||
import org.session.libsession.messaging.contacts.Contact
|
||||
import org.session.libsession.utilities.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.database.SessionContactDatabase
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
class DeleteOptionsBottomSheet : BottomSheetDialogFragment(), View.OnClickListener {
|
||||
|
||||
@Inject
|
||||
lateinit var contactDatabase: SessionContactDatabase
|
||||
|
||||
lateinit var recipient: Recipient
|
||||
private lateinit var binding: FragmentDeleteMessageBottomSheetBinding
|
||||
val contact by lazy {
|
||||
val senderId = recipient.address.serialize()
|
||||
// this dialog won't show for open group contacts
|
||||
contactDatabase.getContactWithAccountID(senderId)
|
||||
?.displayName(Contact.ContactContext.REGULAR)
|
||||
}
|
||||
|
||||
var onDeleteForMeTapped: (() -> Unit?)? = null
|
||||
var onDeleteForEveryoneTapped: (() -> Unit)? = null
|
||||
var onCancelTapped: (() -> Unit)? = null
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
binding = FragmentDeleteMessageBottomSheetBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
when (v) {
|
||||
binding.deleteForMeTextView -> onDeleteForMeTapped?.invoke()
|
||||
binding.deleteForEveryoneTextView -> onDeleteForEveryoneTapped?.invoke()
|
||||
binding.cancelTextView -> onCancelTapped?.invoke()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
if (!this::recipient.isInitialized) {
|
||||
return dismiss()
|
||||
}
|
||||
if (recipient.isLocalNumber) {
|
||||
binding.deleteForEveryoneTextView.text =
|
||||
getString(R.string.clearMessagesForMe)
|
||||
} else if (!recipient.isGroupOrCommunityRecipient && !contact.isNullOrEmpty()) {
|
||||
binding.deleteForEveryoneTextView.text =
|
||||
resources.getString(R.string.clearMessagesForEveryone)
|
||||
}
|
||||
binding.deleteForEveryoneTextView.isVisible = !recipient.isLegacyGroupRecipient
|
||||
binding.deleteForMeTextView.setOnClickListener(this)
|
||||
binding.deleteForEveryoneTextView.setOnClickListener(this)
|
||||
binding.cancelTextView.setOnClickListener(this)
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
val window = dialog?.window ?: return
|
||||
window.setDimAmount(0.6f)
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ import com.squareup.phrase.Phrase
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import network.loki.messenger.R
|
||||
import org.session.libsession.database.StorageProtocol
|
||||
import org.session.libsession.messaging.contacts.Contact
|
||||
import org.session.libsession.messaging.jobs.JobQueue
|
||||
import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachment
|
||||
import org.session.libsession.utilities.recipients.Recipient
|
||||
@ -28,21 +27,10 @@ class AutoDownloadDialog(private val threadRecipient: Recipient,
|
||||
@Inject lateinit var contactDB: SessionContactDatabase
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog = createSessionDialog {
|
||||
val threadId = storage.getThreadId(threadRecipient) ?: run {
|
||||
dismiss()
|
||||
return@createSessionDialog
|
||||
}
|
||||
|
||||
val displayName = when {
|
||||
threadRecipient.isCommunityRecipient -> storage.getOpenGroup(threadId)?.name ?: "UNKNOWN"
|
||||
threadRecipient.isLegacyGroupRecipient -> storage.getGroup(threadRecipient.address.toGroupString())?.title ?: "UNKNOWN"
|
||||
threadRecipient.isGroupV2Recipient -> threadRecipient.name ?: "UNKNOWN"
|
||||
else -> storage.getContactWithAccountID(threadRecipient.address.serialize())?.displayName(Contact.ContactContext.REGULAR) ?: "UNKNOWN"
|
||||
}
|
||||
title(getString(R.string.attachmentsAutoDownloadModalTitle))
|
||||
|
||||
val explanation = Phrase.from(context, R.string.attachmentsAutoDownloadModalDescription)
|
||||
.put(CONVERSATION_NAME_KEY, displayName)
|
||||
.put(CONVERSATION_NAME_KEY, threadRecipient.toShortString())
|
||||
.format()
|
||||
text(explanation)
|
||||
|
||||
|
@ -76,7 +76,7 @@ class ControlMessageView : LinearLayout {
|
||||
|
||||
val threadRecipient = DatabaseComponent.get(context).threadDatabase().getRecipientForThreadId(message.threadId)
|
||||
|
||||
if (threadRecipient?.isGroupV2Recipient == true) {
|
||||
if (threadRecipient?.isGroupRecipient == true) {
|
||||
expirationTimerView.setTimerIcon()
|
||||
} else {
|
||||
expirationTimerView.setExpirationTime(message.expireStarted, message.expiresIn)
|
||||
|
@ -87,8 +87,7 @@ class SessionContactDatabase(context: Context, helper: SQLCipherOpenHelper) : Da
|
||||
}
|
||||
|
||||
fun contactFromCursor(cursor: Cursor): Contact {
|
||||
val sessionID = cursor.getString(accountID)
|
||||
val contact = Contact(sessionID)
|
||||
val contact = Contact(cursor.getString(accountID))
|
||||
contact.name = cursor.getStringOrNull(name)
|
||||
contact.nickname = cursor.getStringOrNull(nickname)
|
||||
contact.profilePictureURL = cursor.getStringOrNull(profilePictureURL)
|
||||
|
@ -1549,16 +1549,12 @@ open class Storage @Inject constructor(
|
||||
|| (userPublicKey == recipientPublicKey && userPublicKey == senderPublicKey)
|
||||
) return
|
||||
|
||||
val recipientDb = recipientDatabase
|
||||
val threadDB = threadDatabase
|
||||
if (userPublicKey == senderPublicKey) {
|
||||
val requestRecipient = Recipient.from(context, fromSerialized(recipientPublicKey), false)
|
||||
recipientDb.setApproved(requestRecipient, true)
|
||||
val threadId = threadDB.getOrCreateThreadIdFor(requestRecipient)
|
||||
threadDB.setHasSent(threadId, true)
|
||||
recipientDatabase.setApproved(requestRecipient, true)
|
||||
val threadId = threadDatabase.getOrCreateThreadIdFor(requestRecipient)
|
||||
threadDatabase.setHasSent(threadId, true)
|
||||
} else {
|
||||
val mmsDb = mmsDatabase
|
||||
val smsDb = smsDatabase
|
||||
val sender = Recipient.from(context, fromSerialized(senderPublicKey), false)
|
||||
val threadId = getOrCreateThreadIdFor(sender.address)
|
||||
val profile = response.profile
|
||||
@ -1578,10 +1574,10 @@ open class Storage @Inject constructor(
|
||||
profileManager.setUnidentifiedAccessMode(context, sender, Recipient.UnidentifiedAccessMode.UNKNOWN)
|
||||
}
|
||||
}
|
||||
threadDB.setHasSent(threadId, true)
|
||||
threadDatabase.setHasSent(threadId, true)
|
||||
val mappingDb = blindedIdMappingDatabase
|
||||
val mappings = mutableMapOf<String, BlindedIdMapping>()
|
||||
threadDB.readerFor(threadDB.conversationList).use { reader ->
|
||||
threadDatabase.readerFor(threadDatabase.conversationList).use { reader ->
|
||||
while (reader.next != null) {
|
||||
val recipient = reader.current.recipient
|
||||
val address = recipient.address.serialize()
|
||||
@ -1601,10 +1597,10 @@ open class Storage @Inject constructor(
|
||||
}
|
||||
mappingDb.addBlindedIdMapping(mapping.value.copy(accountId = senderPublicKey))
|
||||
|
||||
val blindedThreadId = threadDB.getOrCreateThreadIdFor(Recipient.from(context, fromSerialized(mapping.key), false))
|
||||
mmsDb.updateThreadId(blindedThreadId, threadId)
|
||||
smsDb.updateThreadId(blindedThreadId, threadId)
|
||||
threadDB.deleteConversation(blindedThreadId)
|
||||
val blindedThreadId = threadDatabase.getOrCreateThreadIdFor(Recipient.from(context, fromSerialized(mapping.key), false))
|
||||
mmsDatabase.updateThreadId(blindedThreadId, threadId)
|
||||
smsDatabase.updateThreadId(blindedThreadId, threadId)
|
||||
threadDatabase.deleteConversation(blindedThreadId)
|
||||
}
|
||||
setRecipientApproved(sender, true)
|
||||
setRecipientApprovedMe(sender, true)
|
||||
@ -1635,7 +1631,7 @@ open class Storage @Inject constructor(
|
||||
Optional.absent(),
|
||||
Optional.absent()
|
||||
)
|
||||
mmsDb.insertSecureDecryptedMessageInbox(message, threadId, runThreadUpdate = true)
|
||||
mmsDatabase.insertSecureDecryptedMessageInbox(message, threadId, runThreadUpdate = true)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1645,7 +1641,6 @@ open class Storage @Inject constructor(
|
||||
override fun insertMessageRequestResponseFromYou(threadId: Long){
|
||||
val userPublicKey = getUserPublicKey() ?: return
|
||||
|
||||
val mmsDb = mmsDatabase
|
||||
val message = IncomingMediaMessage(
|
||||
fromSerialized(userPublicKey),
|
||||
clock.currentTimeMills(),
|
||||
@ -1664,7 +1659,7 @@ open class Storage @Inject constructor(
|
||||
Optional.absent(),
|
||||
Optional.absent()
|
||||
)
|
||||
mmsDb.insertSecureDecryptedMessageInbox(message, threadId, runThreadUpdate = false)
|
||||
mmsDatabase.insertSecureDecryptedMessageInbox(message, threadId, runThreadUpdate = false)
|
||||
}
|
||||
|
||||
override fun getRecipientApproved(address: Address): Boolean {
|
||||
|
@ -470,7 +470,6 @@ class DisappearingMessagesViewModelTest {
|
||||
THREAD_ID,
|
||||
application,
|
||||
textSecurePreferences,
|
||||
messageExpirationManager,
|
||||
disappearingMessages,
|
||||
threadDb,
|
||||
groupDb,
|
||||
|
@ -75,6 +75,8 @@ class MentionViewModelTest {
|
||||
on { getRecipientForThreadId(threadID) } doAnswer {
|
||||
mock<Recipient> {
|
||||
on { isGroupV2Recipient } doReturn false
|
||||
on { isLegacyGroupRecipient } doReturn false
|
||||
on { isGroupRecipient } doReturn false
|
||||
on { isCommunityRecipient } doReturn true
|
||||
on { isContactRecipient } doReturn false
|
||||
}
|
||||
|
@ -71,10 +71,6 @@ object GroupUtil {
|
||||
return decodedGroupId
|
||||
}
|
||||
|
||||
fun isEncodedGroup(groupId: String): Boolean {
|
||||
return groupId.startsWith(LEGACY_CLOSED_GROUP_PREFIX) || groupId.startsWith(COMMUNITY_PREFIX)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun isCommunity(groupId: String): Boolean {
|
||||
return groupId.startsWith(COMMUNITY_PREFIX)
|
||||
|
@ -15,7 +15,6 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asSharedFlow
|
||||
import org.session.libsession.R
|
||||
import org.session.libsession.utilities.TextSecurePreferences.Companion
|
||||
import org.session.libsession.utilities.TextSecurePreferences.Companion.AUTOPLAY_AUDIO_MESSAGES
|
||||
import org.session.libsession.utilities.TextSecurePreferences.Companion.CALL_NOTIFICATIONS_ENABLED
|
||||
import org.session.libsession.utilities.TextSecurePreferences.Companion.CLASSIC_DARK
|
||||
@ -308,16 +307,6 @@ interface TextSecurePreferences {
|
||||
// for the lifetime of the Session installation.
|
||||
const val HAVE_WARNED_USER_ABOUT_SAVING_ATTACHMENTS = "libsession.HAVE_WARNED_USER_ABOUT_SAVING_ATTACHMENTS"
|
||||
|
||||
// @JvmStatic
|
||||
// fun getLastConfigurationSyncTime(context: Context): Long {
|
||||
// return getLongPreference(context, LAST_CONFIGURATION_SYNC_TIME, 0)
|
||||
// }
|
||||
//
|
||||
// @JvmStatic
|
||||
// fun setLastConfigurationSyncTime(context: Context, value: Long) {
|
||||
// setLongPreference(context, LAST_CONFIGURATION_SYNC_TIME, value)
|
||||
// }
|
||||
//
|
||||
@JvmStatic
|
||||
fun getConfigurationMessageSynced(context: Context): Boolean {
|
||||
return getBooleanPreference(context, CONFIGURATION_SYNCED, false)
|
||||
|
Loading…
Reference in New Issue
Block a user