mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 12:09:45 +01:00
add ability to delete reactions
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
4e727924c2
commit
aa5046cf27
@ -112,7 +112,7 @@ class MessageActionsDialog(
|
|||||||
dialogMessageActionsBinding.emojiMore.clearFocus()
|
dialogMessageActionsBinding.emojiMore.clearFocus()
|
||||||
dialogMessageActionsBinding.messageActions.visibility = View.VISIBLE
|
dialogMessageActionsBinding.messageActions.visibility = View.VISIBLE
|
||||||
|
|
||||||
val imm: InputMethodManager = context?.getSystemService(Context.INPUT_METHOD_SERVICE) as
|
val imm: InputMethodManager = context.getSystemService(Context.INPUT_METHOD_SERVICE) as
|
||||||
InputMethodManager
|
InputMethodManager
|
||||||
imm.hideSoftInputFromWindow(dialogMessageActionsBinding.emojiMore.windowToken, 0)
|
imm.hideSoftInputFromWindow(dialogMessageActionsBinding.emojiMore.windowToken, 0)
|
||||||
}
|
}
|
||||||
@ -257,7 +257,7 @@ class MessageActionsDialog(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onError(e: Throwable) {
|
override fun onError(e: Throwable) {
|
||||||
Log.e(TAG, "error while sending emoji")
|
Log.e(TAG, "error while sending reaction")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onComplete() {
|
override fun onComplete() {
|
||||||
|
@ -45,6 +45,7 @@ import com.nextcloud.talk.databinding.DialogMessageReactionsBinding
|
|||||||
import com.nextcloud.talk.models.database.UserEntity
|
import com.nextcloud.talk.models.database.UserEntity
|
||||||
import com.nextcloud.talk.models.json.chat.ChatMessage
|
import com.nextcloud.talk.models.json.chat.ChatMessage
|
||||||
import com.nextcloud.talk.models.json.conversations.Conversation
|
import com.nextcloud.talk.models.json.conversations.Conversation
|
||||||
|
import com.nextcloud.talk.models.json.generic.GenericOverall
|
||||||
import com.nextcloud.talk.models.json.reactions.ReactionsOverall
|
import com.nextcloud.talk.models.json.reactions.ReactionsOverall
|
||||||
import com.nextcloud.talk.utils.ApiUtils
|
import com.nextcloud.talk.utils.ApiUtils
|
||||||
import com.nextcloud.talk.utils.DisplayUtils
|
import com.nextcloud.talk.utils.DisplayUtils
|
||||||
@ -56,11 +57,11 @@ import io.reactivex.schedulers.Schedulers
|
|||||||
|
|
||||||
@AutoInjector(NextcloudTalkApplication::class)
|
@AutoInjector(NextcloudTalkApplication::class)
|
||||||
class ShowReactionsDialog(
|
class ShowReactionsDialog(
|
||||||
val activity: Activity,
|
private val activity: Activity,
|
||||||
val currentConversation: Conversation?,
|
private val currentConversation: Conversation?,
|
||||||
val chatMessage: ChatMessage,
|
private val chatMessage: ChatMessage,
|
||||||
val userEntity: UserEntity?,
|
private val userEntity: UserEntity?,
|
||||||
val ncApi: NcApi
|
private val ncApi: NcApi
|
||||||
) : BottomSheetDialog(activity), ReactionItemClickListener {
|
) : BottomSheetDialog(activity), ReactionItemClickListener {
|
||||||
|
|
||||||
private lateinit var binding: DialogMessageReactionsBinding
|
private lateinit var binding: DialogMessageReactionsBinding
|
||||||
@ -162,12 +163,46 @@ class ShowReactionsDialog(
|
|||||||
|
|
||||||
override fun onClick(reactionItem: ReactionItem) {
|
override fun onClick(reactionItem: ReactionItem) {
|
||||||
Log.d(TAG, "onClick(reactionItem: ReactionItem): " + reactionItem.reaction)
|
Log.d(TAG, "onClick(reactionItem: ReactionItem): " + reactionItem.reaction)
|
||||||
// TODO implement removal of users reaction,
|
|
||||||
// ownership needs to be checked, so only owned
|
if (reactionItem.reactionVoter.actorId.equals(userEntity!!.userId)){
|
||||||
// reactions can be removed upon click
|
deleteReaction(chatMessage, reactionItem.reaction!!)
|
||||||
|
}
|
||||||
|
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun deleteReaction(message: ChatMessage, emoji: String) {
|
||||||
|
val credentials = ApiUtils.getCredentials(userEntity?.username, userEntity?.token)
|
||||||
|
|
||||||
|
ncApi.deleteReaction(
|
||||||
|
credentials,
|
||||||
|
ApiUtils.getUrlForMessageReaction(
|
||||||
|
userEntity?.baseUrl,
|
||||||
|
currentConversation!!.token,
|
||||||
|
message.id
|
||||||
|
),
|
||||||
|
emoji
|
||||||
|
)
|
||||||
|
?.subscribeOn(Schedulers.io())
|
||||||
|
?.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
?.subscribe(object : Observer<GenericOverall> {
|
||||||
|
override fun onSubscribe(d: Disposable) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onNext(@NonNull genericOverall: GenericOverall) {
|
||||||
|
Log.d(TAG, "deleted reaction: $emoji")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(e: Throwable) {
|
||||||
|
Log.e(TAG, "error while deleting reaction: $emoji")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onComplete() {
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "ShowReactionsDialog"
|
const val TAG = "ShowReactionsDialog"
|
||||||
const val EMOJI_MARGIN: Float = 8F
|
const val EMOJI_MARGIN: Float = 8F
|
||||||
|
Loading…
Reference in New Issue
Block a user