diff --git a/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.kt b/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.kt index 85133c9d86b..4906bb7bcfa 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.kt @@ -41,13 +41,16 @@ import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedA import com.nextcloud.talk.data.user.model.User import com.nextcloud.talk.databinding.RvItemConversationWithLastMessageBinding import com.nextcloud.talk.extensions.loadConversationAvatar +import com.nextcloud.talk.extensions.loadNoteToSelfAvatar import com.nextcloud.talk.extensions.loadSystemAvatar import com.nextcloud.talk.extensions.loadUserAvatar +import com.nextcloud.talk.models.domain.ConversationModel import com.nextcloud.talk.models.json.chat.ChatMessage import com.nextcloud.talk.models.json.conversations.Conversation import com.nextcloud.talk.models.json.conversations.Conversation.ConversationType import com.nextcloud.talk.ui.StatusDrawable import com.nextcloud.talk.ui.theme.ViewThemeUtils +import com.nextcloud.talk.utils.ConversationUtils import com.nextcloud.talk.utils.DisplayUtils import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew.hasSpreedFeatureCapability import eu.davidea.flexibleadapter.FlexibleAdapter @@ -181,6 +184,15 @@ class ConversationItem( } } + ConversationType.DUMMY -> { + if (ConversationUtils.isNoteToSelfConversation( + ConversationModel.mapToConversationModel(model) + ) + ) { + holder.binding.dialogAvatar.loadNoteToSelfAvatar() + } + } + ConversationType.ROOM_GROUP_CALL, ConversationType.FORMER_ONE_TO_ONE, ConversationType.ROOM_PUBLIC_CALL -> diff --git a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt index 7074232b404..9be4792e6dd 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt @@ -2230,7 +2230,10 @@ class ChatActivity : } private fun checkShowCallButtons() { - if (isReadOnlyConversation() || shouldShowLobby() || isNoteToSelfConversation()) { + if (isReadOnlyConversation() || + shouldShowLobby() || + ConversationUtils.isNoteToSelfConversation(currentConversation) + ) { disableCallButtons() } else { enableCallButtons() @@ -2258,10 +2261,6 @@ class ChatActivity : return false } - private fun isNoteToSelfConversation() : Boolean { - return currentConversation != null && currentConversation!!.type == ConversationType.NOTE_TO_SELF - } - private fun disableCallButtons() { if (CapabilitiesUtilNew.isAbleToCall(conversationUser)) { if (conversationVoiceCallMenuItem != null && conversationVideoMenuItem != null) { diff --git a/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt b/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt index 631db4239ff..3d0b3f1f99d 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt @@ -65,10 +65,12 @@ import com.nextcloud.talk.data.user.model.User import com.nextcloud.talk.databinding.ActivityConversationInfoBinding import com.nextcloud.talk.events.EventStatus import com.nextcloud.talk.extensions.loadConversationAvatar +import com.nextcloud.talk.extensions.loadNoteToSelfAvatar import com.nextcloud.talk.extensions.loadSystemAvatar import com.nextcloud.talk.extensions.loadUserAvatar import com.nextcloud.talk.jobs.DeleteConversationWorker import com.nextcloud.talk.jobs.LeaveConversationWorker +import com.nextcloud.talk.models.domain.ConversationModel import com.nextcloud.talk.models.json.conversations.Conversation import com.nextcloud.talk.models.json.conversations.RoomOverall import com.nextcloud.talk.models.json.converters.EnumNotificationLevelConverter @@ -81,6 +83,7 @@ import com.nextcloud.talk.models.json.participants.ParticipantsOverall import com.nextcloud.talk.repositories.conversations.ConversationsRepository import com.nextcloud.talk.shareditems.activities.SharedItemsActivity import com.nextcloud.talk.utils.ApiUtils +import com.nextcloud.talk.utils.ConversationUtils import com.nextcloud.talk.utils.DateConstants import com.nextcloud.talk.utils.DateUtils import com.nextcloud.talk.utils.bundle.BundleKeys @@ -714,8 +717,14 @@ class ConversationInfoActivity : conversationUser ).setupGuestAccess() } - - binding.notificationSettingsView.notificationSettings.visibility = VISIBLE + if (ConversationUtils.isNoteToSelfConversation( + ConversationModel.mapToConversationModel(conversation!!) + ) + ) { + binding.notificationSettingsView.notificationSettings.visibility = GONE + } else { + binding.notificationSettingsView.notificationSettings.visibility = VISIBLE + } } } @@ -731,6 +740,7 @@ class ConversationInfoActivity : private fun initExpiringMessageOption() { if (conversation!!.isParticipantOwnerOrModerator && + !ConversationUtils.isNoteToSelfConversation(ConversationModel.mapToConversationModel(conversation!!)) && CapabilitiesUtilNew.hasSpreedFeatureCapability(conversationUser, "message-expiration") ) { databaseStorageModule?.setMessageExpiration(conversation!!.messageExpiration) @@ -828,6 +838,15 @@ class ConversationInfoActivity : binding.avatarImage.loadSystemAvatar() } + Conversation.ConversationType.DUMMY -> { + if (ConversationUtils.isNoteToSelfConversation( + ConversationModel.mapToConversationModel(conversation!!) + ) + ) { + binding.avatarImage.loadNoteToSelfAvatar() + } + } + else -> { // unused atm } diff --git a/app/src/main/java/com/nextcloud/talk/extensions/ImageViewExtensions.kt b/app/src/main/java/com/nextcloud/talk/extensions/ImageViewExtensions.kt index f2d6c439fe6..f58b42783b0 100644 --- a/app/src/main/java/com/nextcloud/talk/extensions/ImageViewExtensions.kt +++ b/app/src/main/java/com/nextcloud/talk/extensions/ImageViewExtensions.kt @@ -25,6 +25,7 @@ package com.nextcloud.talk.extensions +import android.graphics.Color import android.graphics.drawable.Drawable import android.graphics.drawable.LayerDrawable import android.os.Build @@ -267,6 +268,26 @@ fun ImageView.loadSystemAvatar(): io.reactivex.disposables.Disposable { ) } +fun ImageView.loadNoteToSelfAvatar(): io.reactivex.disposables.Disposable { + val data: Any = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + val layers = arrayOfNulls(2) + layers[0] = ContextCompat.getDrawable(context, R.drawable.ic_launcher_background) + layers[1] = ContextCompat.getDrawable(context, R.drawable.ic_note_to_self).apply { + this?.setTint(Color.WHITE) // TODO get this to fit right + } + val layerDrawable = LayerDrawable(layers) + layerDrawable + } else { + R.mipmap.ic_launcher + } + + return DisposableWrapper( + load(data) { + transformations(CircleCropTransformation()) + } + ) +} + fun ImageView.loadChangelogBotAvatar(): io.reactivex.disposables.Disposable { return loadSystemAvatar() } diff --git a/app/src/main/java/com/nextcloud/talk/models/domain/ConversationModel.kt b/app/src/main/java/com/nextcloud/talk/models/domain/ConversationModel.kt index fc4c2e26079..9859d3b8d49 100644 --- a/app/src/main/java/com/nextcloud/talk/models/domain/ConversationModel.kt +++ b/app/src/main/java/com/nextcloud/talk/models/domain/ConversationModel.kt @@ -109,8 +109,7 @@ enum class ConversationType { ROOM_GROUP_CALL, ROOM_PUBLIC_CALL, ROOM_SYSTEM, - FORMER_ONE_TO_ONE, - NOTE_TO_SELF + FORMER_ONE_TO_ONE } enum class ParticipantType { diff --git a/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.kt b/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.kt index b7b3f1547b7..057e5d72416 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.kt +++ b/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.kt @@ -29,6 +29,7 @@ import android.os.Parcelable import com.bluelinelabs.logansquare.annotation.JsonField import com.bluelinelabs.logansquare.annotation.JsonObject import com.nextcloud.talk.data.user.model.User +import com.nextcloud.talk.models.domain.ConversationModel import com.nextcloud.talk.models.json.chat.ChatMessage import com.nextcloud.talk.models.json.converters.ConversationObjectTypeConverter import com.nextcloud.talk.models.json.converters.EnumLobbyStateConverter @@ -37,6 +38,7 @@ import com.nextcloud.talk.models.json.converters.EnumParticipantTypeConverter import com.nextcloud.talk.models.json.converters.EnumReadOnlyConversationConverter import com.nextcloud.talk.models.json.converters.EnumRoomTypeConverter import com.nextcloud.talk.models.json.participants.Participant.ParticipantType +import com.nextcloud.talk.utils.ConversationUtils import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew import kotlinx.parcelize.Parcelize @@ -187,7 +189,8 @@ data class Conversation( fun canModerate(conversationUser: User): Boolean { return isParticipantOwnerOrModerator && !isLockedOneToOne(conversationUser) && - type != ConversationType.FORMER_ONE_TO_ONE + type != ConversationType.FORMER_ONE_TO_ONE && + !ConversationUtils.isNoteToSelfConversation(ConversationModel.mapToConversationModel(this)) } @Deprecated("Use ConversationUtil") diff --git a/app/src/main/java/com/nextcloud/talk/utils/ConversationUtils.kt b/app/src/main/java/com/nextcloud/talk/utils/ConversationUtils.kt index cc125ff0add..a4c2414a8ec 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/ConversationUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/ConversationUtils.kt @@ -27,6 +27,7 @@ import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew object ConversationUtils { private val TAG = ConversationUtils::class.java.simpleName + private const val NOTE_TO_SELF = "Note to self" fun isPublic(conversation: ConversationModel): Boolean { return ConversationType.ROOM_PUBLIC_CALL == conversation.type @@ -52,7 +53,8 @@ object ConversationUtils { fun canModerate(conversation: ConversationModel, conversationUser: User): Boolean { return isParticipantOwnerOrModerator(conversation) && !isLockedOneToOne(conversation, conversationUser) && - conversation.type != ConversationType.FORMER_ONE_TO_ONE + conversation.type != ConversationType.FORMER_ONE_TO_ONE && + !isNoteToSelfConversation(conversation) } fun isLobbyViewApplicable(conversation: ConversationModel, conversationUser: User): Boolean { @@ -86,4 +88,8 @@ object ConversationUtils { // Fallback for APIv1 } } + + fun isNoteToSelfConversation(currentConversation: ConversationModel?): Boolean { + return currentConversation != null && currentConversation.name == NOTE_TO_SELF + } } diff --git a/app/src/main/res/drawable/ic_note_to_self.xml b/app/src/main/res/drawable/ic_note_to_self.xml new file mode 100644 index 00000000000..830d2405ee6 --- /dev/null +++ b/app/src/main/res/drawable/ic_note_to_self.xml @@ -0,0 +1,36 @@ + + + + + + + \ No newline at end of file