mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-23 05:25:31 +03:00
add visual to reactions bottom sheet if self is true
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
2df414cb63
commit
6f246a1001
5 changed files with 82 additions and 16 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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" />
|
|
@ -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>
|
|
@ -29,8 +29,9 @@
|
|||
<LinearLayout
|
||||
android:id="@+id/emojiBar"
|
||||
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_marginTop="@dimen/standard_half_margin"
|
||||
android:layout_marginEnd="@dimen/zero"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
@ -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">
|
||||
|
||||
<LinearLayout
|
||||
|
@ -129,6 +135,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" />
|
||||
|
||||
|
@ -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"
|
||||
|
|
|
@ -68,5 +68,6 @@
|
|||
<dimen name="standard_quarter_margin">4dp</dimen>
|
||||
<dimen name="activity_list_item_title_header_text_size">16sp</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>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue