diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt index 4df9366ba..f6c6ca4fc 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt @@ -29,6 +29,7 @@ import android.view.View import android.view.ViewGroup import android.view.inputmethod.InputMethodManager import androidx.annotation.NonNull +import androidx.appcompat.content.res.AppCompatResources import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetDialog 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.utils.ApiUtils import com.vanniktech.emoji.EmojiPopup +import com.vanniktech.emoji.EmojiTextView import io.reactivex.Observer import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.Disposable @@ -123,24 +125,31 @@ class MessageActionsDialog( private fun initEmojiBar() { if (CapabilitiesUtil.hasSpreedFeatureCapability(user, "reactions")) { + checkAndSetEmojiSelfReaction(dialogMessageActionsBinding.emojiThumbsUp) dialogMessageActionsBinding.emojiThumbsUp.setOnClickListener { sendReaction(message, dialogMessageActionsBinding.emojiThumbsUp.text.toString()) } + checkAndSetEmojiSelfReaction(dialogMessageActionsBinding.emojiThumbsDown) dialogMessageActionsBinding.emojiThumbsDown.setOnClickListener { sendReaction(message, dialogMessageActionsBinding.emojiThumbsDown.text.toString()) } + checkAndSetEmojiSelfReaction(dialogMessageActionsBinding.emojiLaugh) dialogMessageActionsBinding.emojiLaugh.setOnClickListener { sendReaction(message, dialogMessageActionsBinding.emojiLaugh.text.toString()) } + checkAndSetEmojiSelfReaction(dialogMessageActionsBinding.emojiHeart) dialogMessageActionsBinding.emojiHeart.setOnClickListener { sendReaction(message, dialogMessageActionsBinding.emojiHeart.text.toString()) } + checkAndSetEmojiSelfReaction(dialogMessageActionsBinding.emojiConfused) dialogMessageActionsBinding.emojiConfused.setOnClickListener { sendReaction(message, dialogMessageActionsBinding.emojiConfused.text.toString()) } + checkAndSetEmojiSelfReaction(dialogMessageActionsBinding.emojiSad) dialogMessageActionsBinding.emojiSad.setOnClickListener { sendReaction(message, dialogMessageActionsBinding.emojiSad.text.toString()) } + dialogMessageActionsBinding.emojiMore.setOnClickListener { 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) { if (visible) { dialogMessageActionsBinding.menuMarkAsUnread.setOnClickListener { @@ -271,7 +286,6 @@ class MessageActionsDialog( private const val TAG = "MessageActionsDialog" private const val ACTOR_LENGTH = 6 private const val NO_PREVIOUS_MESSAGE_ID: Int = -1 - private const val HTTP_OK: Int = 200 private const val HTTP_CREATED: Int = 201 } } diff --git a/app/src/main/res/drawable/inset_reaction_self_bottom_sheet_background.xml b/app/src/main/res/drawable/inset_reaction_self_bottom_sheet_background.xml new file mode 100644 index 000000000..fc9234d5d --- /dev/null +++ b/app/src/main/res/drawable/inset_reaction_self_bottom_sheet_background.xml @@ -0,0 +1,4 @@ + + diff --git a/app/src/main/res/drawable/reaction_self_bottom_sheet_background.xml b/app/src/main/res/drawable/reaction_self_bottom_sheet_background.xml new file mode 100644 index 000000000..bc830ec62 --- /dev/null +++ b/app/src/main/res/drawable/reaction_self_bottom_sheet_background.xml @@ -0,0 +1,29 @@ + + + + + + + + diff --git a/app/src/main/res/layout/dialog_message_actions.xml b/app/src/main/res/layout/dialog_message_actions.xml index f79ccbb41..67c55bff9 100644 --- a/app/src/main/res/layout/dialog_message_actions.xml +++ b/app/src/main/res/layout/dialog_message_actions.xml @@ -29,8 +29,9 @@ @@ -39,7 +40,8 @@ android:id="@+id/emojiThumbsUp" android:layout_width="@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:gravity="center" android:text="@string/emoji_thumbsUp" @@ -49,7 +51,8 @@ android:id="@+id/emojiThumbsDown" android:layout_width="@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:gravity="center" android:text="@string/emoji_thumbsDown" @@ -59,7 +62,8 @@ android:id="@+id/emojiHeart" android:layout_width="@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:gravity="center" android:text="@string/default_emoji" @@ -69,7 +73,8 @@ android:id="@+id/emojiLaugh" android:layout_width="@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:gravity="center" android:text="@string/emoji_heart" @@ -79,7 +84,8 @@ android:id="@+id/emojiConfused" android:layout_width="@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:gravity="center" android:text="@string/emoji_confused" @@ -89,7 +95,8 @@ android:id="@+id/emojiSad" android:layout_width="@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:gravity="center" android:text="@string/emoji_sad" @@ -99,6 +106,7 @@ android:id="@+id/emojiMore" android:layout_width="@dimen/activity_row_layout_height" android:layout_height="@dimen/activity_row_layout_height" + android:layout_marginEnd="2dp" android:layout_weight="1" android:background="@android:color/transparent" android:contentDescription="@string/emoji_more" @@ -111,8 +119,6 @@ android:id="@+id/message_actions" android:layout_width="match_parent" android:layout_height="wrap_content" - android:paddingStart="@dimen/standard_padding" - android:paddingEnd="@dimen/standard_padding" android:orientation="vertical"> @@ -138,7 +146,7 @@ android:layout_height="wrap_content" android:layout_gravity="start|center_vertical" android:paddingStart="@dimen/standard_double_padding" - android:paddingEnd="@dimen/zero" + android:paddingEnd="@dimen/standard_padding" android:text="@string/nc_reply" android:textAlignment="viewStart" android:textColor="@color/high_emphasis_text" @@ -160,6 +168,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="@null" + android:paddingStart="@dimen/standard_padding" + android:paddingEnd="@dimen/zero" android:src="@drawable/ic_reply" app:tint="@color/high_emphasis_menu_icon" /> @@ -169,7 +179,7 @@ android:layout_height="wrap_content" android:layout_gravity="start|center_vertical" android:paddingStart="@dimen/standard_double_padding" - android:paddingEnd="@dimen/zero" + android:paddingEnd="@dimen/standard_padding" android:text="@string/nc_reply_privately" android:textAlignment="viewStart" android:textColor="@color/high_emphasis_text" @@ -191,6 +201,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="@null" + android:paddingStart="@dimen/standard_padding" + android:paddingEnd="@dimen/zero" android:src="@drawable/ic_share_action" app:tint="@color/high_emphasis_menu_icon" /> @@ -200,7 +212,7 @@ android:layout_height="wrap_content" android:layout_gravity="start|center_vertical" android:paddingStart="@dimen/standard_double_padding" - android:paddingEnd="@dimen/zero" + android:paddingEnd="@dimen/standard_padding" android:text="@string/nc_forward_message" android:textAlignment="viewStart" android:textColor="@color/high_emphasis_text" @@ -222,6 +234,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="@null" + android:paddingStart="@dimen/standard_padding" + android:paddingEnd="@dimen/zero" android:src="@drawable/ic_eye_off" app:tint="@color/high_emphasis_menu_icon" /> @@ -231,7 +245,7 @@ android:layout_height="wrap_content" android:layout_gravity="start|center_vertical" android:paddingStart="@dimen/standard_double_padding" - android:paddingEnd="@dimen/zero" + android:paddingEnd="@dimen/standard_padding" android:text="@string/nc_mark_as_unread" android:textAlignment="viewStart" android:textColor="@color/high_emphasis_text" @@ -253,6 +267,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="@null" + android:paddingStart="@dimen/standard_padding" + android:paddingEnd="@dimen/zero" android:src="@drawable/ic_content_copy" app:tint="@color/high_emphasis_menu_icon" /> @@ -262,7 +278,7 @@ android:layout_height="wrap_content" android:layout_gravity="start|center_vertical" android:paddingStart="@dimen/standard_double_padding" - android:paddingEnd="@dimen/zero" + android:paddingEnd="@dimen/standard_padding" android:text="@string/nc_copy_message" android:textAlignment="viewStart" android:textColor="@color/high_emphasis_text" @@ -284,6 +300,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="@null" + android:paddingStart="@dimen/standard_padding" + android:paddingEnd="@dimen/zero" android:src="@drawable/ic_delete" app:tint="@color/high_emphasis_menu_icon" /> @@ -293,7 +311,7 @@ android:layout_height="wrap_content" android:layout_gravity="start|center_vertical" android:paddingStart="@dimen/standard_double_padding" - android:paddingEnd="@dimen/zero" + android:paddingEnd="@dimen/standard_padding" android:text="@string/nc_delete_message" android:textAlignment="viewStart" android:textColor="@color/high_emphasis_text" diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 753129d95..b60c1994d 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -68,5 +68,6 @@ 4dp 16sp 48dp + 32dp 2dp