mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 11:39:42 +01:00
lint: move from resource IDs to fixed, unique Int values for view types
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
f52fd59125
commit
cd38c8dbb6
@ -339,7 +339,7 @@ class ConversationItem(
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val VIEW_TYPE = R.layout.rv_item_conversation_with_last_message
|
||||
const val VIEW_TYPE = FlexibleItemViewType.CONVERSATION_ITEM
|
||||
private const val MILLIES = 1000L
|
||||
private const val STATUS_SIZE_IN_DP = 9f
|
||||
private const val UNREAD_BUBBLE_STROKE_WIDTH = 6.0f
|
||||
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Andy Scherzinger
|
||||
* Copyright (C) 2023 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/>.
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.adapters.items
|
||||
|
||||
class FlexibleItemViewType {
|
||||
companion object {
|
||||
const val CONVERSATION_ITEM: Int = 1120391230
|
||||
const val LOAD_MORE_RESULTS_ITEM: Int = 1120391231
|
||||
const val MESSAGE_RESULT_ITEM: Int = 1120391232
|
||||
const val MESSAGES_TEXT_HEADER_ITEM: Int = 1120391233
|
||||
const val POLL_RESULT_HEADER_ITEM: Int = 1120391234
|
||||
const val POLL_RESULT_VOTER_ITEM: Int = 1120391235
|
||||
const val POLL_RESULT_VOTERS_OVERVIEW_ITEM: Int = 1120391236
|
||||
}
|
||||
}
|
@ -36,7 +36,7 @@ object LoadMoreResultsItem :
|
||||
IFilterable<String> {
|
||||
|
||||
// layout is used as view type for uniqueness
|
||||
const val VIEW_TYPE: Int = R.layout.rv_item_load_more
|
||||
const val VIEW_TYPE = FlexibleItemViewType.LOAD_MORE_RESULTS_ITEM
|
||||
|
||||
class ViewHolder(view: View, adapter: FlexibleAdapter<*>) :
|
||||
FlexibleViewHolder(view, adapter) {
|
||||
|
@ -92,8 +92,7 @@ data class MessageResultItem constructor(
|
||||
}
|
||||
|
||||
companion object {
|
||||
// layout is used as view type for uniqueness
|
||||
const val VIEW_TYPE: Int = R.layout.rv_item_search_message
|
||||
const val VIEW_TYPE = FlexibleItemViewType.MESSAGE_RESULT_ITEM
|
||||
}
|
||||
|
||||
override fun getHeader(): GenericTextHeaderItem = MessagesTextHeaderItem(context, viewThemeUtils)
|
||||
|
@ -28,10 +28,7 @@ import com.nextcloud.talk.ui.theme.ViewThemeUtils
|
||||
class MessagesTextHeaderItem(context: Context, viewThemeUtils: ViewThemeUtils) :
|
||||
GenericTextHeaderItem(context.getString(R.string.messages), viewThemeUtils) {
|
||||
companion object {
|
||||
/**
|
||||
* "Random" value, just has to be different than other view types
|
||||
*/
|
||||
const val VIEW_TYPE = 1120391230
|
||||
const val VIEW_TYPE = FlexibleItemViewType.MESSAGES_TEXT_HEADER_ITEM
|
||||
}
|
||||
|
||||
override fun getItemViewType(): Int = VIEW_TYPE
|
||||
|
@ -37,7 +37,6 @@ import com.nextcloud.talk.databinding.ItemCustomIncomingLinkPreviewMessageBindin
|
||||
import com.nextcloud.talk.extensions.loadBotsAvatar
|
||||
import com.nextcloud.talk.extensions.loadChangelogBotAvatar
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage
|
||||
import com.nextcloud.talk.ui.recyclerview.MessageSwipeCallback
|
||||
import com.nextcloud.talk.ui.theme.ViewThemeUtils
|
||||
import com.nextcloud.talk.utils.ApiUtils
|
||||
import com.nextcloud.talk.utils.DateUtils
|
||||
@ -98,7 +97,7 @@ class IncomingLinkPreviewMessageViewHolder(incomingView: View, payload: Any) : M
|
||||
true
|
||||
}
|
||||
|
||||
itemView.setTag(MessageSwipeCallback.REPLYABLE_VIEW_TAG, message.replyable)
|
||||
itemView.setTag(R.string.replyable_message_view_tag, message.replyable)
|
||||
|
||||
Reaction().showReactions(
|
||||
message,
|
||||
|
@ -45,7 +45,6 @@ import com.nextcloud.talk.databinding.ItemCustomIncomingTextMessageBinding
|
||||
import com.nextcloud.talk.extensions.loadBotsAvatar
|
||||
import com.nextcloud.talk.extensions.loadChangelogBotAvatar
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage
|
||||
import com.nextcloud.talk.ui.recyclerview.MessageSwipeCallback
|
||||
import com.nextcloud.talk.ui.theme.ViewThemeUtils
|
||||
import com.nextcloud.talk.utils.ApiUtils
|
||||
import com.nextcloud.talk.utils.DateUtils
|
||||
@ -111,7 +110,7 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) : MessageHolde
|
||||
binding.messageQuote.quotedChatMessageView.visibility = View.GONE
|
||||
}
|
||||
|
||||
itemView.setTag(MessageSwipeCallback.REPLYABLE_VIEW_TAG, message.replyable)
|
||||
itemView.setTag(R.string.replyable_message_view_tag, message.replyable)
|
||||
|
||||
Reaction().showReactions(
|
||||
message,
|
||||
|
@ -36,7 +36,6 @@ import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedA
|
||||
import com.nextcloud.talk.databinding.ItemCustomOutcomingLinkPreviewMessageBinding
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage
|
||||
import com.nextcloud.talk.models.json.chat.ReadStatus
|
||||
import com.nextcloud.talk.ui.recyclerview.MessageSwipeCallback
|
||||
import com.nextcloud.talk.ui.theme.ViewThemeUtils
|
||||
import com.nextcloud.talk.utils.ApiUtils
|
||||
import com.nextcloud.talk.utils.DateUtils
|
||||
@ -121,7 +120,7 @@ class OutcomingLinkPreviewMessageViewHolder(outcomingView: View, payload: Any) :
|
||||
true
|
||||
}
|
||||
|
||||
itemView.setTag(MessageSwipeCallback.REPLYABLE_VIEW_TAG, message.replyable)
|
||||
itemView.setTag(R.string.replyable_message_view_tag, message.replyable)
|
||||
|
||||
Reaction().showReactions(
|
||||
message,
|
||||
|
@ -42,7 +42,6 @@ import com.nextcloud.talk.chat.ChatActivity
|
||||
import com.nextcloud.talk.databinding.ItemCustomOutcomingTextMessageBinding
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage
|
||||
import com.nextcloud.talk.models.json.chat.ReadStatus
|
||||
import com.nextcloud.talk.ui.recyclerview.MessageSwipeCallback
|
||||
import com.nextcloud.talk.ui.theme.ViewThemeUtils
|
||||
import com.nextcloud.talk.utils.ApiUtils
|
||||
import com.nextcloud.talk.utils.DateUtils
|
||||
@ -127,7 +126,7 @@ class OutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessageViewH
|
||||
|
||||
binding.checkMark.setContentDescription(readStatusContentDescriptionString)
|
||||
|
||||
itemView.setTag(MessageSwipeCallback.REPLYABLE_VIEW_TAG, message.replyable)
|
||||
itemView.setTag(R.string.replyable_message_view_tag, message.replyable)
|
||||
|
||||
Reaction().showReactions(
|
||||
message,
|
||||
|
@ -54,7 +54,6 @@ import com.nextcloud.talk.data.user.model.User
|
||||
import com.nextcloud.talk.databinding.ReactionsInsideMessageBinding
|
||||
import com.nextcloud.talk.extensions.loadChangelogBotAvatar
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage
|
||||
import com.nextcloud.talk.ui.recyclerview.MessageSwipeCallback
|
||||
import com.nextcloud.talk.ui.theme.ViewThemeUtils
|
||||
import com.nextcloud.talk.utils.DateUtils
|
||||
import com.nextcloud.talk.utils.DisplayUtils
|
||||
@ -159,7 +158,7 @@ abstract class PreviewMessageViewHolder(itemView: View?, payload: Any?) :
|
||||
}
|
||||
messageText.text = ""
|
||||
}
|
||||
itemView.setTag(MessageSwipeCallback.REPLYABLE_VIEW_TAG, message.replyable)
|
||||
itemView.setTag(R.string.replyable_message_view_tag, message.replyable)
|
||||
Reaction().showReactions(
|
||||
message,
|
||||
::clickOnReaction,
|
||||
|
@ -43,8 +43,6 @@ import javax.inject.Inject;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import autodagger.AutoInjector;
|
||||
|
||||
import static com.nextcloud.talk.ui.recyclerview.MessageSwipeCallback.REPLYABLE_VIEW_TAG;
|
||||
|
||||
@AutoInjector(NextcloudTalkApplication.class)
|
||||
public class SystemMessageViewHolder extends MessageHolders.IncomingTextMessageViewHolder<ChatMessage> {
|
||||
|
||||
@ -109,6 +107,6 @@ public class SystemMessageViewHolder extends MessageHolders.IncomingTextMessageV
|
||||
time.setText(dateUtils.getLocalTimeStringFromTimestamp(message.getTimestamp()));
|
||||
}
|
||||
|
||||
itemView.setTag(REPLYABLE_VIEW_TAG, message.getReplyable());
|
||||
itemView.setTag(R.string.replyable_message_view_tag, message.getReplyable());
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
package com.nextcloud.talk.polls.adapters
|
||||
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.adapters.items.FlexibleItemViewType
|
||||
|
||||
data class PollResultHeaderItem(
|
||||
val name: String,
|
||||
@ -33,7 +33,6 @@ data class PollResultHeaderItem(
|
||||
}
|
||||
|
||||
companion object {
|
||||
// layout is used as view type for uniqueness
|
||||
const val VIEW_TYPE: Int = R.layout.poll_result_header_item
|
||||
const val VIEW_TYPE = FlexibleItemViewType.POLL_RESULT_HEADER_ITEM
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
package com.nextcloud.talk.polls.adapters
|
||||
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.adapters.items.FlexibleItemViewType
|
||||
import com.nextcloud.talk.polls.model.PollDetails
|
||||
|
||||
data class PollResultVoterItem(
|
||||
@ -32,7 +32,6 @@ data class PollResultVoterItem(
|
||||
}
|
||||
|
||||
companion object {
|
||||
// layout is used as view type for uniqueness
|
||||
const val VIEW_TYPE: Int = R.layout.poll_result_voter_item
|
||||
const val VIEW_TYPE = FlexibleItemViewType.POLL_RESULT_VOTER_ITEM
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
package com.nextcloud.talk.polls.adapters
|
||||
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.adapters.items.FlexibleItemViewType
|
||||
import com.nextcloud.talk.polls.model.PollDetails
|
||||
|
||||
data class PollResultVotersOverviewItem(
|
||||
@ -33,6 +33,6 @@ data class PollResultVotersOverviewItem(
|
||||
|
||||
companion object {
|
||||
// layout is used as view type for uniqueness
|
||||
const val VIEW_TYPE: Int = R.layout.poll_result_voters_overview_item
|
||||
const val VIEW_TYPE = FlexibleItemViewType.POLL_RESULT_VOTERS_OVERVIEW_ITEM
|
||||
}
|
||||
}
|
||||
|
@ -74,8 +74,8 @@ class MessageSwipeCallback(private val context: Context, private val messageSwip
|
||||
|
||||
override fun getMovementFlags(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder): Int {
|
||||
view = viewHolder.itemView
|
||||
if (viewHolder.itemView.getTag(REPLYABLE_VIEW_TAG) != null &&
|
||||
viewHolder.itemView.getTag(REPLYABLE_VIEW_TAG) as Boolean
|
||||
if (viewHolder.itemView.getTag(R.string.replyable_message_view_tag) != null &&
|
||||
viewHolder.itemView.getTag(R.string.replyable_message_view_tag) as Boolean
|
||||
) {
|
||||
imageDrawable = AppCompatResources.getDrawable(context, R.drawable.ic_reply)!!
|
||||
shareRound = AppCompatResources.getDrawable(context, R.drawable.round_bgnd)!!
|
||||
@ -291,6 +291,5 @@ class MessageSwipeCallback(private val context: Context, private val messageSwip
|
||||
const val ICON_BOUNDS_PIXEL_TOP: Int = 13
|
||||
const val ICON_BOUNDS_PIXEL_RIGHT: Int = 12
|
||||
const val ICON_BOUNDS_PIXEL_BOTTOM: Int = 11
|
||||
const val REPLYABLE_VIEW_TAG: Int = R.string.replyable_message_view_tag
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user