add visual to reactions bottom sheet if self is true

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2022-04-21 15:46:42 +02:00 committed by Marcel Hibbe
parent 2df414cb63
commit 6f246a1001
No known key found for this signature in database
GPG key ID: C793F8B59F43CE7B
5 changed files with 82 additions and 16 deletions

View file

@ -29,6 +29,7 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodManager
import androidx.annotation.NonNull import androidx.annotation.NonNull
import androidx.appcompat.content.res.AppCompatResources
import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.bottomsheet.BottomSheetDialog
import com.nextcloud.talk.BuildConfig import com.nextcloud.talk.BuildConfig
@ -43,6 +44,7 @@ import com.nextcloud.talk.models.json.conversations.Conversation
import com.nextcloud.talk.models.json.generic.GenericOverall import com.nextcloud.talk.models.json.generic.GenericOverall
import com.nextcloud.talk.utils.ApiUtils import com.nextcloud.talk.utils.ApiUtils
import com.vanniktech.emoji.EmojiPopup import com.vanniktech.emoji.EmojiPopup
import com.vanniktech.emoji.EmojiTextView
import io.reactivex.Observer import io.reactivex.Observer
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable import io.reactivex.disposables.Disposable
@ -123,24 +125,31 @@ class MessageActionsDialog(
private fun initEmojiBar() { private fun initEmojiBar() {
if (CapabilitiesUtil.hasSpreedFeatureCapability(user, "reactions")) { if (CapabilitiesUtil.hasSpreedFeatureCapability(user, "reactions")) {
checkAndSetEmojiSelfReaction(dialogMessageActionsBinding.emojiThumbsUp)
dialogMessageActionsBinding.emojiThumbsUp.setOnClickListener { dialogMessageActionsBinding.emojiThumbsUp.setOnClickListener {
sendReaction(message, dialogMessageActionsBinding.emojiThumbsUp.text.toString()) sendReaction(message, dialogMessageActionsBinding.emojiThumbsUp.text.toString())
} }
checkAndSetEmojiSelfReaction(dialogMessageActionsBinding.emojiThumbsDown)
dialogMessageActionsBinding.emojiThumbsDown.setOnClickListener { dialogMessageActionsBinding.emojiThumbsDown.setOnClickListener {
sendReaction(message, dialogMessageActionsBinding.emojiThumbsDown.text.toString()) sendReaction(message, dialogMessageActionsBinding.emojiThumbsDown.text.toString())
} }
checkAndSetEmojiSelfReaction(dialogMessageActionsBinding.emojiLaugh)
dialogMessageActionsBinding.emojiLaugh.setOnClickListener { dialogMessageActionsBinding.emojiLaugh.setOnClickListener {
sendReaction(message, dialogMessageActionsBinding.emojiLaugh.text.toString()) sendReaction(message, dialogMessageActionsBinding.emojiLaugh.text.toString())
} }
checkAndSetEmojiSelfReaction(dialogMessageActionsBinding.emojiHeart)
dialogMessageActionsBinding.emojiHeart.setOnClickListener { dialogMessageActionsBinding.emojiHeart.setOnClickListener {
sendReaction(message, dialogMessageActionsBinding.emojiHeart.text.toString()) sendReaction(message, dialogMessageActionsBinding.emojiHeart.text.toString())
} }
checkAndSetEmojiSelfReaction(dialogMessageActionsBinding.emojiConfused)
dialogMessageActionsBinding.emojiConfused.setOnClickListener { dialogMessageActionsBinding.emojiConfused.setOnClickListener {
sendReaction(message, dialogMessageActionsBinding.emojiConfused.text.toString()) sendReaction(message, dialogMessageActionsBinding.emojiConfused.text.toString())
} }
checkAndSetEmojiSelfReaction(dialogMessageActionsBinding.emojiSad)
dialogMessageActionsBinding.emojiSad.setOnClickListener { dialogMessageActionsBinding.emojiSad.setOnClickListener {
sendReaction(message, dialogMessageActionsBinding.emojiSad.text.toString()) sendReaction(message, dialogMessageActionsBinding.emojiSad.text.toString())
} }
dialogMessageActionsBinding.emojiMore.setOnClickListener { dialogMessageActionsBinding.emojiMore.setOnClickListener {
dismiss() dismiss()
} }
@ -150,6 +159,12 @@ class MessageActionsDialog(
} }
} }
private fun checkAndSetEmojiSelfReaction(emoji: EmojiTextView) {
if (emoji.text?.toString() != null && message.reactionsSelf?.contains(emoji.text?.toString()) == true) {
emoji.background = AppCompatResources.getDrawable(context, R.drawable.reaction_self_bottom_sheet_background)
}
}
private fun initMenuMarkAsUnread(visible: Boolean) { private fun initMenuMarkAsUnread(visible: Boolean) {
if (visible) { if (visible) {
dialogMessageActionsBinding.menuMarkAsUnread.setOnClickListener { dialogMessageActionsBinding.menuMarkAsUnread.setOnClickListener {
@ -271,7 +286,6 @@ class MessageActionsDialog(
private const val TAG = "MessageActionsDialog" private const val TAG = "MessageActionsDialog"
private const val ACTOR_LENGTH = 6 private const val ACTOR_LENGTH = 6
private const val NO_PREVIOUS_MESSAGE_ID: Int = -1 private const val NO_PREVIOUS_MESSAGE_ID: Int = -1
private const val HTTP_OK: Int = 200
private const val HTTP_CREATED: Int = 201 private const val HTTP_CREATED: Int = 201
} }
} }

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/reaction_self_bottom_sheet_background"
android:insetBottom="8dp" />

View file

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Nextcloud Talk application
~
~ @author Andy Scherzinger
~ Copyright (C) 2022 Andy Scherzinger <info@andy-scherzinger.de>
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<stroke
android:width="1dp"
android:color="@color/colorPrimary" />
<solid android:color="@color/bg_message_own_reaction" />
</shape>

View file

@ -29,8 +29,9 @@
<LinearLayout <LinearLayout
android:id="@+id/emojiBar" android:id="@+id/emojiBar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_item_height" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/standard_eighth_margin" android:layout_marginStart="@dimen/standard_eighth_margin"
android:layout_marginTop="@dimen/standard_half_margin"
android:layout_marginEnd="@dimen/zero" android:layout_marginEnd="@dimen/zero"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal"> android:orientation="horizontal">
@ -39,7 +40,8 @@
android:id="@+id/emojiThumbsUp" android:id="@+id/emojiThumbsUp"
android:layout_width="@dimen/activity_row_layout_height" android:layout_width="@dimen/activity_row_layout_height"
android:layout_height="@dimen/activity_row_layout_height" android:layout_height="@dimen/activity_row_layout_height"
android:layout_weight="1" android:layout_marginLeft="@dimen/standard_quarter_margin"
android:layout_marginRight="@dimen/standard_quarter_margin"
android:cursorVisible="false" android:cursorVisible="false"
android:gravity="center" android:gravity="center"
android:text="@string/emoji_thumbsUp" android:text="@string/emoji_thumbsUp"
@ -49,7 +51,8 @@
android:id="@+id/emojiThumbsDown" android:id="@+id/emojiThumbsDown"
android:layout_width="@dimen/activity_row_layout_height" android:layout_width="@dimen/activity_row_layout_height"
android:layout_height="@dimen/activity_row_layout_height" android:layout_height="@dimen/activity_row_layout_height"
android:layout_weight="1" android:layout_marginLeft="@dimen/standard_quarter_margin"
android:layout_marginRight="@dimen/standard_quarter_margin"
android:cursorVisible="false" android:cursorVisible="false"
android:gravity="center" android:gravity="center"
android:text="@string/emoji_thumbsDown" android:text="@string/emoji_thumbsDown"
@ -59,7 +62,8 @@
android:id="@+id/emojiHeart" android:id="@+id/emojiHeart"
android:layout_width="@dimen/activity_row_layout_height" android:layout_width="@dimen/activity_row_layout_height"
android:layout_height="@dimen/activity_row_layout_height" android:layout_height="@dimen/activity_row_layout_height"
android:layout_weight="1" android:layout_marginLeft="@dimen/standard_quarter_margin"
android:layout_marginRight="@dimen/standard_quarter_margin"
android:cursorVisible="false" android:cursorVisible="false"
android:gravity="center" android:gravity="center"
android:text="@string/default_emoji" android:text="@string/default_emoji"
@ -69,7 +73,8 @@
android:id="@+id/emojiLaugh" android:id="@+id/emojiLaugh"
android:layout_width="@dimen/activity_row_layout_height" android:layout_width="@dimen/activity_row_layout_height"
android:layout_height="@dimen/activity_row_layout_height" android:layout_height="@dimen/activity_row_layout_height"
android:layout_weight="1" android:layout_marginLeft="@dimen/standard_quarter_margin"
android:layout_marginRight="@dimen/standard_quarter_margin"
android:cursorVisible="false" android:cursorVisible="false"
android:gravity="center" android:gravity="center"
android:text="@string/emoji_heart" android:text="@string/emoji_heart"
@ -79,7 +84,8 @@
android:id="@+id/emojiConfused" android:id="@+id/emojiConfused"
android:layout_width="@dimen/activity_row_layout_height" android:layout_width="@dimen/activity_row_layout_height"
android:layout_height="@dimen/activity_row_layout_height" android:layout_height="@dimen/activity_row_layout_height"
android:layout_weight="1" android:layout_marginLeft="@dimen/standard_quarter_margin"
android:layout_marginRight="@dimen/standard_quarter_margin"
android:cursorVisible="false" android:cursorVisible="false"
android:gravity="center" android:gravity="center"
android:text="@string/emoji_confused" android:text="@string/emoji_confused"
@ -89,7 +95,8 @@
android:id="@+id/emojiSad" android:id="@+id/emojiSad"
android:layout_width="@dimen/activity_row_layout_height" android:layout_width="@dimen/activity_row_layout_height"
android:layout_height="@dimen/activity_row_layout_height" android:layout_height="@dimen/activity_row_layout_height"
android:layout_weight="1" android:layout_marginLeft="@dimen/standard_quarter_margin"
android:layout_marginRight="@dimen/standard_quarter_margin"
android:cursorVisible="false" android:cursorVisible="false"
android:gravity="center" android:gravity="center"
android:text="@string/emoji_sad" android:text="@string/emoji_sad"
@ -99,6 +106,7 @@
android:id="@+id/emojiMore" android:id="@+id/emojiMore"
android:layout_width="@dimen/activity_row_layout_height" android:layout_width="@dimen/activity_row_layout_height"
android:layout_height="@dimen/activity_row_layout_height" android:layout_height="@dimen/activity_row_layout_height"
android:layout_marginEnd="2dp"
android:layout_weight="1" android:layout_weight="1"
android:background="@android:color/transparent" android:background="@android:color/transparent"
android:contentDescription="@string/emoji_more" android:contentDescription="@string/emoji_more"
@ -111,8 +119,6 @@
android:id="@+id/message_actions" android:id="@+id/message_actions"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="@dimen/standard_padding"
android:paddingEnd="@dimen/standard_padding"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
@ -129,6 +135,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:contentDescription="@null" android:contentDescription="@null"
android:paddingStart="@dimen/standard_padding"
android:paddingEnd="@dimen/zero"
android:src="@drawable/ic_reply" android:src="@drawable/ic_reply"
app:tint="@color/high_emphasis_menu_icon" /> app:tint="@color/high_emphasis_menu_icon" />
@ -138,7 +146,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical" android:layout_gravity="start|center_vertical"
android:paddingStart="@dimen/standard_double_padding" android:paddingStart="@dimen/standard_double_padding"
android:paddingEnd="@dimen/zero" android:paddingEnd="@dimen/standard_padding"
android:text="@string/nc_reply" android:text="@string/nc_reply"
android:textAlignment="viewStart" android:textAlignment="viewStart"
android:textColor="@color/high_emphasis_text" android:textColor="@color/high_emphasis_text"
@ -160,6 +168,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:contentDescription="@null" android:contentDescription="@null"
android:paddingStart="@dimen/standard_padding"
android:paddingEnd="@dimen/zero"
android:src="@drawable/ic_reply" android:src="@drawable/ic_reply"
app:tint="@color/high_emphasis_menu_icon" /> app:tint="@color/high_emphasis_menu_icon" />
@ -169,7 +179,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical" android:layout_gravity="start|center_vertical"
android:paddingStart="@dimen/standard_double_padding" android:paddingStart="@dimen/standard_double_padding"
android:paddingEnd="@dimen/zero" android:paddingEnd="@dimen/standard_padding"
android:text="@string/nc_reply_privately" android:text="@string/nc_reply_privately"
android:textAlignment="viewStart" android:textAlignment="viewStart"
android:textColor="@color/high_emphasis_text" android:textColor="@color/high_emphasis_text"
@ -191,6 +201,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:contentDescription="@null" android:contentDescription="@null"
android:paddingStart="@dimen/standard_padding"
android:paddingEnd="@dimen/zero"
android:src="@drawable/ic_share_action" android:src="@drawable/ic_share_action"
app:tint="@color/high_emphasis_menu_icon" /> app:tint="@color/high_emphasis_menu_icon" />
@ -200,7 +212,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical" android:layout_gravity="start|center_vertical"
android:paddingStart="@dimen/standard_double_padding" android:paddingStart="@dimen/standard_double_padding"
android:paddingEnd="@dimen/zero" android:paddingEnd="@dimen/standard_padding"
android:text="@string/nc_forward_message" android:text="@string/nc_forward_message"
android:textAlignment="viewStart" android:textAlignment="viewStart"
android:textColor="@color/high_emphasis_text" android:textColor="@color/high_emphasis_text"
@ -222,6 +234,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:contentDescription="@null" android:contentDescription="@null"
android:paddingStart="@dimen/standard_padding"
android:paddingEnd="@dimen/zero"
android:src="@drawable/ic_eye_off" android:src="@drawable/ic_eye_off"
app:tint="@color/high_emphasis_menu_icon" /> app:tint="@color/high_emphasis_menu_icon" />
@ -231,7 +245,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical" android:layout_gravity="start|center_vertical"
android:paddingStart="@dimen/standard_double_padding" android:paddingStart="@dimen/standard_double_padding"
android:paddingEnd="@dimen/zero" android:paddingEnd="@dimen/standard_padding"
android:text="@string/nc_mark_as_unread" android:text="@string/nc_mark_as_unread"
android:textAlignment="viewStart" android:textAlignment="viewStart"
android:textColor="@color/high_emphasis_text" android:textColor="@color/high_emphasis_text"
@ -253,6 +267,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:contentDescription="@null" android:contentDescription="@null"
android:paddingStart="@dimen/standard_padding"
android:paddingEnd="@dimen/zero"
android:src="@drawable/ic_content_copy" android:src="@drawable/ic_content_copy"
app:tint="@color/high_emphasis_menu_icon" /> app:tint="@color/high_emphasis_menu_icon" />
@ -262,7 +278,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical" android:layout_gravity="start|center_vertical"
android:paddingStart="@dimen/standard_double_padding" android:paddingStart="@dimen/standard_double_padding"
android:paddingEnd="@dimen/zero" android:paddingEnd="@dimen/standard_padding"
android:text="@string/nc_copy_message" android:text="@string/nc_copy_message"
android:textAlignment="viewStart" android:textAlignment="viewStart"
android:textColor="@color/high_emphasis_text" android:textColor="@color/high_emphasis_text"
@ -284,6 +300,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:contentDescription="@null" android:contentDescription="@null"
android:paddingStart="@dimen/standard_padding"
android:paddingEnd="@dimen/zero"
android:src="@drawable/ic_delete" android:src="@drawable/ic_delete"
app:tint="@color/high_emphasis_menu_icon" /> app:tint="@color/high_emphasis_menu_icon" />
@ -293,7 +311,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical" android:layout_gravity="start|center_vertical"
android:paddingStart="@dimen/standard_double_padding" android:paddingStart="@dimen/standard_double_padding"
android:paddingEnd="@dimen/zero" android:paddingEnd="@dimen/standard_padding"
android:text="@string/nc_delete_message" android:text="@string/nc_delete_message"
android:textAlignment="viewStart" android:textAlignment="viewStart"
android:textColor="@color/high_emphasis_text" android:textColor="@color/high_emphasis_text"

View file

@ -68,5 +68,6 @@
<dimen name="standard_quarter_margin">4dp</dimen> <dimen name="standard_quarter_margin">4dp</dimen>
<dimen name="activity_list_item_title_header_text_size">16sp</dimen> <dimen name="activity_list_item_title_header_text_size">16sp</dimen>
<dimen name="activity_row_layout_height">48dp</dimen> <dimen name="activity_row_layout_height">48dp</dimen>
<dimen name="reaction_bottom_sheet_layout_size">32dp</dimen>
<dimen name="standard_eighth_margin">2dp</dimen> <dimen name="standard_eighth_margin">2dp</dimen>
</resources> </resources>