mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-22 20:25:01 +01:00
create a note to self
Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
parent
bcd0216fca
commit
22e6eb35f1
@ -256,8 +256,6 @@ class ChatActivity :
|
|||||||
lateinit var chatViewModel: ChatViewModel
|
lateinit var chatViewModel: ChatViewModel
|
||||||
lateinit var messageInputViewModel: MessageInputViewModel
|
lateinit var messageInputViewModel: MessageInputViewModel
|
||||||
|
|
||||||
private var noteToSelfRoomToken: String = ""
|
|
||||||
|
|
||||||
private val startSelectContactForResult = registerForActivityResult(
|
private val startSelectContactForResult = registerForActivityResult(
|
||||||
ActivityResultContracts
|
ActivityResultContracts
|
||||||
.StartActivityForResult()
|
.StartActivityForResult()
|
||||||
@ -436,24 +434,6 @@ class ChatActivity :
|
|||||||
|
|
||||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||||
|
|
||||||
val apiVersion = ApiUtils.getConversationApiVersion(
|
|
||||||
conversationUser!!,
|
|
||||||
intArrayOf(
|
|
||||||
ApiUtils.API_V4,
|
|
||||||
ApiUtils
|
|
||||||
.API_V3,
|
|
||||||
1
|
|
||||||
)
|
|
||||||
)
|
|
||||||
chatViewModel.checkForNoteToSelf(
|
|
||||||
ApiUtils.getCredentials(conversationUser?.username, conversationUser?.token)!!,
|
|
||||||
ApiUtils.getUrlForRooms(
|
|
||||||
apiVersion,
|
|
||||||
conversationUser?.baseUrl
|
|
||||||
),
|
|
||||||
false
|
|
||||||
)
|
|
||||||
|
|
||||||
initObservers()
|
initObservers()
|
||||||
|
|
||||||
pickMultipleMedia = registerForActivityResult(
|
pickMultipleMedia = registerForActivityResult(
|
||||||
@ -789,19 +769,6 @@ class ChatActivity :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
chatViewModel.getNoteToSelfAvailability.observe(this) { state ->
|
|
||||||
when (state) {
|
|
||||||
is ChatViewModel.NoteToSelfAvailableState -> {
|
|
||||||
this.lifecycleScope.launch {
|
|
||||||
noteToSelfRoomToken = state.roomToken
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
noteToSelfRoomToken = ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
chatViewModel.chatMessageViewState.observe(this) { state ->
|
chatViewModel.chatMessageViewState.observe(this) { state ->
|
||||||
when (state) {
|
when (state) {
|
||||||
is ChatViewModel.ChatMessageStartState -> {
|
is ChatViewModel.ChatMessageStartState -> {
|
||||||
@ -3159,8 +3126,7 @@ class ChatActivity :
|
|||||||
currentConversation,
|
currentConversation,
|
||||||
isShowMessageDeletionButton(message),
|
isShowMessageDeletionButton(message),
|
||||||
participantPermissions.hasChatPermission(),
|
participantPermissions.hasChatPermission(),
|
||||||
spreedCapabilities,
|
spreedCapabilities
|
||||||
noteToSelfRoomToken
|
|
||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import com.nextcloud.talk.models.json.capabilities.SpreedCapability
|
|||||||
import com.nextcloud.talk.models.json.chat.ChatMessageJson
|
import com.nextcloud.talk.models.json.chat.ChatMessageJson
|
||||||
import com.nextcloud.talk.models.json.chat.ChatOverallSingleMessage
|
import com.nextcloud.talk.models.json.chat.ChatOverallSingleMessage
|
||||||
import com.nextcloud.talk.models.json.conversations.RoomOverall
|
import com.nextcloud.talk.models.json.conversations.RoomOverall
|
||||||
import com.nextcloud.talk.models.json.conversations.RoomsOverall
|
|
||||||
import com.nextcloud.talk.models.json.generic.GenericOverall
|
import com.nextcloud.talk.models.json.generic.GenericOverall
|
||||||
import com.nextcloud.talk.models.json.opengraph.Reference
|
import com.nextcloud.talk.models.json.opengraph.Reference
|
||||||
import com.nextcloud.talk.models.json.reminder.Reminder
|
import com.nextcloud.talk.models.json.reminder.Reminder
|
||||||
@ -42,7 +41,7 @@ interface ChatNetworkDataSource {
|
|||||||
displayName: String
|
displayName: String
|
||||||
): Observable<ChatOverallSingleMessage>
|
): Observable<ChatOverallSingleMessage>
|
||||||
|
|
||||||
fun checkForNoteToSelf(credentials: String, url: String, includeStatus: Boolean): Observable<RoomsOverall>
|
fun checkForNoteToSelf(user: User): Observable<RoomOverall>
|
||||||
fun shareLocationToNotes(
|
fun shareLocationToNotes(
|
||||||
credentials: String,
|
credentials: String,
|
||||||
url: String,
|
url: String,
|
||||||
|
@ -14,7 +14,6 @@ import com.nextcloud.talk.models.json.capabilities.SpreedCapability
|
|||||||
import com.nextcloud.talk.models.json.chat.ChatMessageJson
|
import com.nextcloud.talk.models.json.chat.ChatMessageJson
|
||||||
import com.nextcloud.talk.models.json.chat.ChatOverallSingleMessage
|
import com.nextcloud.talk.models.json.chat.ChatOverallSingleMessage
|
||||||
import com.nextcloud.talk.models.json.conversations.RoomOverall
|
import com.nextcloud.talk.models.json.conversations.RoomOverall
|
||||||
import com.nextcloud.talk.models.json.conversations.RoomsOverall
|
|
||||||
import com.nextcloud.talk.models.json.generic.GenericOverall
|
import com.nextcloud.talk.models.json.generic.GenericOverall
|
||||||
import com.nextcloud.talk.models.json.opengraph.Reference
|
import com.nextcloud.talk.models.json.opengraph.Reference
|
||||||
import com.nextcloud.talk.models.json.reminder.Reminder
|
import com.nextcloud.talk.models.json.reminder.Reminder
|
||||||
@ -124,11 +123,15 @@ class RetrofitChatNetwork(
|
|||||||
it
|
it
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun checkForNoteToSelf(
|
override fun checkForNoteToSelf(user: User): Observable<RoomOverall> {
|
||||||
credentials: String,
|
val credentials: String = ApiUtils.getCredentials(user.username, user.token)!!
|
||||||
url: String,
|
val apiVersion = ApiUtils.getConversationApiVersion(user, intArrayOf(ApiUtils.API_V4))
|
||||||
includeStatus: Boolean
|
|
||||||
): Observable<RoomsOverall> = ncApi.getRooms(credentials, url, includeStatus).map { it }
|
return ncApi.getRoom(
|
||||||
|
credentials,
|
||||||
|
ApiUtils.getUrlForRoom(apiVersion, user.baseUrl!!, "note-to-self")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
override fun shareLocationToNotes(
|
override fun shareLocationToNotes(
|
||||||
credentials: String,
|
credentials: String,
|
||||||
|
@ -34,14 +34,12 @@ import com.nextcloud.talk.models.json.capabilities.SpreedCapability
|
|||||||
import com.nextcloud.talk.models.json.chat.ChatMessageJson
|
import com.nextcloud.talk.models.json.chat.ChatMessageJson
|
||||||
import com.nextcloud.talk.models.json.chat.ChatOverallSingleMessage
|
import com.nextcloud.talk.models.json.chat.ChatOverallSingleMessage
|
||||||
import com.nextcloud.talk.models.json.conversations.RoomOverall
|
import com.nextcloud.talk.models.json.conversations.RoomOverall
|
||||||
import com.nextcloud.talk.models.json.conversations.RoomsOverall
|
|
||||||
import com.nextcloud.talk.models.json.generic.GenericOverall
|
import com.nextcloud.talk.models.json.generic.GenericOverall
|
||||||
import com.nextcloud.talk.models.json.opengraph.Reference
|
import com.nextcloud.talk.models.json.opengraph.Reference
|
||||||
import com.nextcloud.talk.models.json.reminder.Reminder
|
import com.nextcloud.talk.models.json.reminder.Reminder
|
||||||
import com.nextcloud.talk.models.json.userAbsence.UserAbsenceData
|
import com.nextcloud.talk.models.json.userAbsence.UserAbsenceData
|
||||||
import com.nextcloud.talk.repositories.reactions.ReactionsRepository
|
import com.nextcloud.talk.repositories.reactions.ReactionsRepository
|
||||||
import com.nextcloud.talk.ui.PlaybackSpeed
|
import com.nextcloud.talk.ui.PlaybackSpeed
|
||||||
import com.nextcloud.talk.utils.ConversationUtils
|
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys
|
import com.nextcloud.talk.utils.bundle.BundleKeys
|
||||||
import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
|
import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
|
||||||
import com.nextcloud.talk.utils.preferences.AppPreferences
|
import com.nextcloud.talk.utils.preferences.AppPreferences
|
||||||
@ -538,8 +536,8 @@ class ChatViewModel @Inject constructor(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fun checkForNoteToSelf(credentials: String, baseUrl: String, includeStatus: Boolean) {
|
fun checkForNoteToSelf(user: User) {
|
||||||
chatNetworkDataSource.checkForNoteToSelf(credentials, baseUrl, includeStatus).subscribeOn(Schedulers.io())
|
chatNetworkDataSource.checkForNoteToSelf(user).subscribeOn(Schedulers.io())
|
||||||
?.observeOn(AndroidSchedulers.mainThread())
|
?.observeOn(AndroidSchedulers.mainThread())
|
||||||
?.subscribe(CheckForNoteToSelfObserver())
|
?.subscribe(CheckForNoteToSelfObserver())
|
||||||
}
|
}
|
||||||
@ -784,25 +782,13 @@ class ChatViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class CheckForNoteToSelfObserver : Observer<RoomsOverall> {
|
inner class CheckForNoteToSelfObserver : Observer<RoomOverall> {
|
||||||
override fun onSubscribe(d: Disposable) {
|
override fun onSubscribe(d: Disposable) {
|
||||||
disposableSet.add(d)
|
disposableSet.add(d)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNext(roomsOverall: RoomsOverall) {
|
override fun onNext(roomOverall: RoomOverall) {
|
||||||
val rooms = roomsOverall.ocs?.data
|
val room = roomOverall.ocs?.data
|
||||||
rooms?.let {
|
|
||||||
try {
|
|
||||||
val noteToSelf = rooms.first {
|
|
||||||
val model = ConversationModel.mapToConversationModel(it, userProvider.currentUser.blockingGet())
|
|
||||||
ConversationUtils.isNoteToSelfConversation(model)
|
|
||||||
}
|
|
||||||
_getNoteToSelfAvailability.value = NoteToSelfAvailableState(noteToSelf.token)
|
|
||||||
} catch (e: NoSuchElementException) {
|
|
||||||
_getNoteToSelfAvailability.value = NoteToSelfNotAvailableState
|
|
||||||
Log.e(TAG, "Note to self not found $e")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onError(e: Throwable) {
|
override fun onError(e: Throwable) {
|
||||||
|
@ -60,8 +60,7 @@ class MessageActionsDialog(
|
|||||||
private val currentConversation: ConversationModel?,
|
private val currentConversation: ConversationModel?,
|
||||||
private val showMessageDeletionButton: Boolean,
|
private val showMessageDeletionButton: Boolean,
|
||||||
private val hasChatPermission: Boolean,
|
private val hasChatPermission: Boolean,
|
||||||
private val spreedCapabilities: SpreedCapability,
|
private val spreedCapabilities: SpreedCapability
|
||||||
private val noteToSelfRoomToken: String
|
|
||||||
) : BottomSheetDialog(chatActivity) {
|
) : BottomSheetDialog(chatActivity) {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@ -125,8 +124,7 @@ class MessageActionsDialog(
|
|||||||
initMenuAddToNote(
|
initMenuAddToNote(
|
||||||
networkMonitor.isOnline.value &&
|
networkMonitor.isOnline.value &&
|
||||||
!message.isDeleted &&
|
!message.isDeleted &&
|
||||||
currentConversation?.type != ConversationEnums.ConversationType.NOTE_TO_SELF,
|
currentConversation?.type != ConversationEnums.ConversationType.NOTE_TO_SELF
|
||||||
noteToSelfRoomToken
|
|
||||||
)
|
)
|
||||||
|
|
||||||
initMenuItems(networkMonitor.isOnline.value)
|
initMenuItems(networkMonitor.isOnline.value)
|
||||||
@ -452,10 +450,12 @@ class MessageActionsDialog(
|
|||||||
private fun initMenuAddToNote(visible: Boolean, roomToken: String = "") {
|
private fun initMenuAddToNote(visible: Boolean, roomToken: String = "") {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
dialogMessageActionsBinding.menuShareToNote.setOnClickListener {
|
dialogMessageActionsBinding.menuShareToNote.setOnClickListener {
|
||||||
|
chatActivity.chatViewModel.checkForNoteToSelf(user!!)
|
||||||
chatActivity.shareToNotes(message, roomToken)
|
chatActivity.shareToNotes(message, roomToken)
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dialogMessageActionsBinding.menuShareToNote.visibility = getVisibility(visible)
|
dialogMessageActionsBinding.menuShareToNote.visibility = getVisibility(visible)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user