mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 12:09:45 +01:00
Various fixes & move to Coil
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
9bd06e63b5
commit
5141abeecc
@ -19,6 +19,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "androidx.work:work-gcm:$work_version"
|
implementation "androidx.work:work-gcm:2.3.0-alpha02"
|
||||||
implementation "com.google.firebase:firebase-messaging:20.0.0"
|
implementation "com.google.firebase:firebase-messaging:20.0.0"
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,14 @@ import eu.davidea.flexibleadapter.items.IFilterable
|
|||||||
import eu.davidea.flexibleadapter.items.IFlexible
|
import eu.davidea.flexibleadapter.items.IFlexible
|
||||||
import eu.davidea.flexibleadapter.utils.FlexibleUtils
|
import eu.davidea.flexibleadapter.utils.FlexibleUtils
|
||||||
import eu.davidea.viewholders.FlexibleViewHolder
|
import eu.davidea.viewholders.FlexibleViewHolder
|
||||||
|
import kotlinx.android.synthetic.main.rv_item_conversation_with_last_message.view.actionProgressBar
|
||||||
|
import kotlinx.android.synthetic.main.rv_item_conversation_with_last_message.view.dialogAvatar
|
||||||
|
import kotlinx.android.synthetic.main.rv_item_conversation_with_last_message.view.dialogDate
|
||||||
|
import kotlinx.android.synthetic.main.rv_item_conversation_with_last_message.view.dialogLastMessage
|
||||||
|
import kotlinx.android.synthetic.main.rv_item_conversation_with_last_message.view.dialogName
|
||||||
|
import kotlinx.android.synthetic.main.rv_item_conversation_with_last_message.view.dialogUnreadBubble
|
||||||
|
import kotlinx.android.synthetic.main.rv_item_conversation_with_last_message.view.favoriteConversationImageView
|
||||||
|
import kotlinx.android.synthetic.main.rv_item_conversation_with_last_message.view.passwordProtectedRoomImageView
|
||||||
import java.util.Objects
|
import java.util.Objects
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
@ -104,57 +112,57 @@ class ConversationItem(
|
|||||||
val appContext = NextcloudTalkApplication.sharedApplication!!.applicationContext
|
val appContext = NextcloudTalkApplication.sharedApplication!!.applicationContext
|
||||||
|
|
||||||
if (model.changing) {
|
if (model.changing) {
|
||||||
holder.progressBar!!.visibility = View.VISIBLE
|
holder.itemView.actionProgressBar!!.visibility = View.VISIBLE
|
||||||
} else {
|
} else {
|
||||||
holder.progressBar!!.visibility = View.GONE
|
holder.itemView.actionProgressBar!!.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
if (adapter.hasFilter()) {
|
if (adapter.hasFilter()) {
|
||||||
FlexibleUtils.highlightText(
|
FlexibleUtils.highlightText(
|
||||||
holder.dialogName!!, model.displayName,
|
holder.itemView.dialogName!!, model.displayName,
|
||||||
adapter.getFilter(String::class.java).toString(),
|
adapter.getFilter(String::class.java).toString(),
|
||||||
NextcloudTalkApplication.sharedApplication!!
|
NextcloudTalkApplication.sharedApplication!!
|
||||||
.resources.getColor(R.color.colorPrimary)
|
.resources.getColor(R.color.colorPrimary)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
holder.dialogName!!.text = model.displayName
|
holder.itemView.dialogName!!.text = model.displayName
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.unreadMessages > 0) {
|
if (model.unreadMessages > 0) {
|
||||||
holder.dialogUnreadBubble!!.visibility = View.VISIBLE
|
holder.itemView.dialogUnreadBubble!!.visibility = View.VISIBLE
|
||||||
if (model.unreadMessages < 100) {
|
if (model.unreadMessages < 100) {
|
||||||
holder.dialogUnreadBubble!!.text = model.unreadMessages.toLong()
|
holder.itemView.dialogUnreadBubble!!.text = model.unreadMessages.toLong()
|
||||||
.toString()
|
.toString()
|
||||||
} else {
|
} else {
|
||||||
holder.dialogUnreadBubble!!.text = context.getString(R.string.nc_99_plus)
|
holder.itemView.dialogUnreadBubble!!.text = context.getString(R.string.nc_99_plus)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.unreadMention) {
|
if (model.unreadMention) {
|
||||||
holder.dialogUnreadBubble!!.background =
|
holder.itemView.dialogUnreadBubble!!.background =
|
||||||
context.getDrawable(R.drawable.bubble_circle_unread_mention)
|
context.getDrawable(R.drawable.bubble_circle_unread_mention)
|
||||||
} else {
|
} else {
|
||||||
holder.dialogUnreadBubble!!.background =
|
holder.itemView.dialogUnreadBubble!!.background =
|
||||||
context.getDrawable(R.drawable.bubble_circle_unread)
|
context.getDrawable(R.drawable.bubble_circle_unread)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
holder.dialogUnreadBubble!!.visibility = View.GONE
|
holder.itemView.dialogUnreadBubble!!.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.hasPassword) {
|
if (model.hasPassword) {
|
||||||
holder.passwordProtectedRoomImageView!!.visibility = View.VISIBLE
|
holder.itemView.passwordProtectedRoomImageView!!.visibility = View.VISIBLE
|
||||||
} else {
|
} else {
|
||||||
holder.passwordProtectedRoomImageView!!.visibility = View.GONE
|
holder.itemView.passwordProtectedRoomImageView!!.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.favorite) {
|
if (model.favorite) {
|
||||||
holder.pinnedConversationImageView!!.visibility = View.VISIBLE
|
holder.itemView.favoriteConversationImageView!!.visibility = View.VISIBLE
|
||||||
} else {
|
} else {
|
||||||
holder.pinnedConversationImageView!!.visibility = View.GONE
|
holder.itemView.favoriteConversationImageView!!.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.lastMessage != null) {
|
if (model.lastMessage != null) {
|
||||||
holder.dialogDate!!.visibility = View.VISIBLE
|
holder.itemView.dialogDate!!.visibility = View.VISIBLE
|
||||||
holder.dialogDate!!.text = DateUtils.getRelativeTimeSpanString(
|
holder.itemView.dialogDate!!.text = DateUtils.getRelativeTimeSpanString(
|
||||||
model.lastActivity * 1000L,
|
model.lastActivity * 1000L,
|
||||||
System.currentTimeMillis(), 0, DateUtils.FORMAT_ABBREV_RELATIVE
|
System.currentTimeMillis(), 0, DateUtils.FORMAT_ABBREV_RELATIVE
|
||||||
)
|
)
|
||||||
@ -163,7 +171,7 @@ class ConversationItem(
|
|||||||
model.lastMessage!!.systemMessage
|
model.lastMessage!!.systemMessage
|
||||||
) || Conversation.ConversationType.SYSTEM_CONVERSATION == model.type
|
) || Conversation.ConversationType.SYSTEM_CONVERSATION == model.type
|
||||||
) {
|
) {
|
||||||
holder.dialogLastMessage!!.text = model.lastMessage!!.text
|
holder.itemView.dialogLastMessage!!.text = model.lastMessage!!.text
|
||||||
} else {
|
} else {
|
||||||
var authorDisplayName = ""
|
var authorDisplayName = ""
|
||||||
model.lastMessage!!.activeUser = userEntity
|
model.lastMessage!!.activeUser = userEntity
|
||||||
@ -194,14 +202,14 @@ class ConversationItem(
|
|||||||
text = model.lastMessage!!.lastMessageDisplayText
|
text = model.lastMessage!!.lastMessageDisplayText
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.dialogLastMessage?.text = text
|
holder.itemView.dialogLastMessage.text = text
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
holder.dialogDate?.visibility = View.GONE
|
holder.itemView.dialogDate.visibility = View.GONE
|
||||||
holder.dialogLastMessage!!.setText(R.string.nc_no_messages_yet)
|
holder.itemView.dialogLastMessage.setText(R.string.nc_no_messages_yet)
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.dialogAvatar?.visibility = View.VISIBLE
|
holder.itemView.dialogAvatar.visibility = View.VISIBLE
|
||||||
|
|
||||||
var shouldLoadAvatar = true
|
var shouldLoadAvatar = true
|
||||||
val objectType: String? = model.objectType
|
val objectType: String? = model.objectType
|
||||||
@ -209,13 +217,13 @@ class ConversationItem(
|
|||||||
when (objectType) {
|
when (objectType) {
|
||||||
"share:password" -> {
|
"share:password" -> {
|
||||||
shouldLoadAvatar = false
|
shouldLoadAvatar = false
|
||||||
holder.dialogAvatar?.load(R.drawable.ic_file_password_request) {
|
holder.itemView.dialogAvatar.load(R.drawable.ic_file_password_request) {
|
||||||
transformations(CircleCropTransformation())
|
transformations(CircleCropTransformation())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"file" -> {
|
"file" -> {
|
||||||
shouldLoadAvatar = false
|
shouldLoadAvatar = false
|
||||||
holder.dialogAvatar?.load(R.drawable.ic_file_icon) {
|
holder.itemView.dialogAvatar.load(R.drawable.ic_file_icon) {
|
||||||
transformations(CircleCropTransformation())
|
transformations(CircleCropTransformation())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,7 +239,7 @@ class ConversationItem(
|
|||||||
layers[1] = context.getDrawable(R.drawable.ic_launcher_foreground)
|
layers[1] = context.getDrawable(R.drawable.ic_launcher_foreground)
|
||||||
val layerDrawable = LayerDrawable(layers)
|
val layerDrawable = LayerDrawable(layers)
|
||||||
|
|
||||||
holder.dialogAvatar?.load(layerDrawable) {
|
holder.itemView.dialogAvatar.load(layerDrawable) {
|
||||||
transformations(CircleCropTransformation())
|
transformations(CircleCropTransformation())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,11 +248,11 @@ class ConversationItem(
|
|||||||
|
|
||||||
if (shouldLoadAvatar) {
|
if (shouldLoadAvatar) {
|
||||||
when (model.type) {
|
when (model.type) {
|
||||||
Conversation.ConversationType.ONE_TO_ONE_CONVERSATION -> if (!TextUtils.isEmpty(
|
ONE_TO_ONE_CONVERSATION -> if (!TextUtils.isEmpty(
|
||||||
model.name
|
model.name
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
holder.dialogAvatar?.load(
|
holder.itemView.dialogAvatar.load(
|
||||||
ApiUtils.getUrlForAvatarWithName(
|
ApiUtils.getUrlForAvatarWithName(
|
||||||
userEntity.baseUrl,
|
userEntity.baseUrl,
|
||||||
model.name, R.dimen.avatar_size
|
model.name, R.dimen.avatar_size
|
||||||
@ -254,17 +262,17 @@ class ConversationItem(
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
holder.dialogAvatar?.visibility = View.GONE
|
holder.itemView.dialogAvatar.visibility = View.GONE
|
||||||
}
|
}
|
||||||
Conversation.ConversationType.GROUP_CONVERSATION ->
|
Conversation.ConversationType.GROUP_CONVERSATION ->
|
||||||
holder.dialogAvatar?.load(R.drawable.ic_people_group_white_24px) {
|
holder.itemView.dialogAvatar.load(R.drawable.ic_people_group_white_24px) {
|
||||||
transformations(CircleCropTransformation())
|
transformations(CircleCropTransformation())
|
||||||
}
|
}
|
||||||
Conversation.ConversationType.PUBLIC_CONVERSATION ->
|
Conversation.ConversationType.PUBLIC_CONVERSATION ->
|
||||||
holder.dialogAvatar?.load(R.drawable.ic_link_white_24px) {
|
holder.itemView.dialogAvatar.load(R.drawable.ic_link_white_24px) {
|
||||||
transformations(CircleCropTransformation())
|
transformations(CircleCropTransformation())
|
||||||
}
|
}
|
||||||
else -> holder.dialogAvatar?.visibility = View.GONE
|
else -> holder.itemView.dialogAvatar.visibility = View.GONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -281,33 +289,5 @@ class ConversationItem(
|
|||||||
view: View,
|
view: View,
|
||||||
adapter: FlexibleAdapter<*>
|
adapter: FlexibleAdapter<*>
|
||||||
) : FlexibleViewHolder(view, adapter) {
|
) : FlexibleViewHolder(view, adapter) {
|
||||||
@JvmField
|
|
||||||
@BindView(R.id.dialogAvatar)
|
|
||||||
var dialogAvatar: ImageView? = null
|
|
||||||
@JvmField
|
|
||||||
@BindView(R.id.dialogName)
|
|
||||||
var dialogName: EmojiTextView? = null
|
|
||||||
@JvmField
|
|
||||||
@BindView(R.id.dialogDate)
|
|
||||||
var dialogDate: TextView? = null
|
|
||||||
@JvmField
|
|
||||||
@BindView(R.id.dialogLastMessage)
|
|
||||||
var dialogLastMessage: EmojiTextView? = null
|
|
||||||
@JvmField
|
|
||||||
@BindView(R.id.dialogUnreadBubble)
|
|
||||||
var dialogUnreadBubble: TextView? = null
|
|
||||||
@JvmField
|
|
||||||
@BindView(R.id.passwordProtectedRoomImageView)
|
|
||||||
var passwordProtectedRoomImageView: ImageView? = null
|
|
||||||
@JvmField
|
|
||||||
@BindView(R.id.favoriteConversationImageView)
|
|
||||||
var pinnedConversationImageView: ImageView? = null
|
|
||||||
@JvmField
|
|
||||||
@BindView(R.id.actionProgressBar)
|
|
||||||
var progressBar: ProgressBar? = null
|
|
||||||
|
|
||||||
init {
|
|
||||||
ButterKnife.bind(this, view)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* Nextcloud Talk application
|
|
||||||
*
|
|
||||||
* @author Mario Danic
|
|
||||||
* Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
|
|
||||||
*
|
|
||||||
* 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;
|
|
||||||
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.graphics.drawable.ColorDrawable;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import com.facebook.drawee.view.SimpleDraweeView;
|
|
||||||
import com.nextcloud.talk.R;
|
|
||||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter;
|
|
||||||
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem;
|
|
||||||
import eu.davidea.flexibleadapter.items.IFlexible;
|
|
||||||
import eu.davidea.viewholders.FlexibleViewHolder;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class NotificationSoundItem
|
|
||||||
extends AbstractFlexibleItem<NotificationSoundItem.NotificationSoundItemViewHolder> {
|
|
||||||
|
|
||||||
private String notificationSoundName;
|
|
||||||
private String notificationSoundUri;
|
|
||||||
|
|
||||||
public NotificationSoundItem(String notificationSoundName, String notificationSoundUri) {
|
|
||||||
this.notificationSoundName = notificationSoundName;
|
|
||||||
this.notificationSoundUri = notificationSoundUri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNotificationSoundUri() {
|
|
||||||
return notificationSoundUri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNotificationSoundName() {
|
|
||||||
return notificationSoundName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLayoutRes() {
|
|
||||||
return R.layout.rv_item_notification_sound;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NotificationSoundItemViewHolder createViewHolder(View view,
|
|
||||||
FlexibleAdapter<IFlexible> adapter) {
|
|
||||||
return new NotificationSoundItemViewHolder(view, adapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void bindViewHolder(FlexibleAdapter<IFlexible> adapter,
|
|
||||||
NotificationSoundItemViewHolder holder, int position, List<Object> payloads) {
|
|
||||||
holder.notificationName.setText(notificationSoundName);
|
|
||||||
|
|
||||||
if (adapter.isSelected(position)) {
|
|
||||||
holder.checkedImageView.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
holder.checkedImageView.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
Resources resources = NextcloudTalkApplication.Companion.getSharedApplication().getResources();
|
|
||||||
holder.simpleDraweeView.getHierarchy()
|
|
||||||
.setBackgroundImage(new ColorDrawable(resources.getColor(R.color.colorPrimary)));
|
|
||||||
if (position == 0) {
|
|
||||||
holder.simpleDraweeView.getHierarchy()
|
|
||||||
.setImage(resources.getDrawable(R.drawable.ic_stop_white_24dp), 100,
|
|
||||||
true);
|
|
||||||
} else {
|
|
||||||
holder.simpleDraweeView.getHierarchy()
|
|
||||||
.setImage(resources.getDrawable(R.drawable.ic_play_circle_outline_white_24dp), 100,
|
|
||||||
true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static class NotificationSoundItemViewHolder extends FlexibleViewHolder {
|
|
||||||
@BindView(R.id.notificationNameTextView)
|
|
||||||
public TextView notificationName;
|
|
||||||
@BindView(R.id.simpleDraweeView)
|
|
||||||
SimpleDraweeView simpleDraweeView;
|
|
||||||
@BindView(R.id.checkedImageView)
|
|
||||||
ImageView checkedImageView;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default constructor.
|
|
||||||
*/
|
|
||||||
NotificationSoundItemViewHolder(View view, FlexibleAdapter adapter) {
|
|
||||||
super(view, adapter);
|
|
||||||
ButterKnife.bind(this, view);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,114 @@
|
|||||||
|
/*
|
||||||
|
* Nextcloud Talk application
|
||||||
|
*
|
||||||
|
* @author Mario Danic
|
||||||
|
* Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
import android.content.res.Resources
|
||||||
|
import android.graphics.drawable.ColorDrawable
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
|
import android.view.View
|
||||||
|
import android.widget.ImageView
|
||||||
|
import android.widget.TextView
|
||||||
|
import butterknife.BindView
|
||||||
|
import butterknife.ButterKnife
|
||||||
|
import coil.Coil
|
||||||
|
import coil.api.load
|
||||||
|
import coil.request.LoadRequest
|
||||||
|
import coil.request.Request
|
||||||
|
import coil.request.RequestBuilder
|
||||||
|
import coil.target.Target
|
||||||
|
import coil.transform.CircleCropTransformation
|
||||||
|
import com.nextcloud.talk.R
|
||||||
|
import com.nextcloud.talk.R.color
|
||||||
|
import com.nextcloud.talk.R.drawable
|
||||||
|
import com.nextcloud.talk.R.id
|
||||||
|
import com.nextcloud.talk.R.layout
|
||||||
|
import com.nextcloud.talk.adapters.items.NotificationSoundItem.NotificationSoundItemViewHolder
|
||||||
|
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
|
||||||
|
import com.nextcloud.talk.newarch.utils.Images
|
||||||
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
|
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
|
||||||
|
import eu.davidea.flexibleadapter.items.IFlexible
|
||||||
|
import eu.davidea.viewholders.FlexibleViewHolder
|
||||||
|
|
||||||
|
class NotificationSoundItem(
|
||||||
|
val notificationSoundName: String,
|
||||||
|
val notificationSoundUri: String?
|
||||||
|
) : AbstractFlexibleItem<NotificationSoundItemViewHolder>() {
|
||||||
|
|
||||||
|
override fun equals(o: Any?): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getLayoutRes(): Int {
|
||||||
|
return layout.rv_item_notification_sound
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun createViewHolder(
|
||||||
|
view: View,
|
||||||
|
adapter: FlexibleAdapter<IFlexible<*>?>
|
||||||
|
): NotificationSoundItemViewHolder {
|
||||||
|
return NotificationSoundItemViewHolder(view, adapter)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun bindViewHolder(
|
||||||
|
adapter: FlexibleAdapter<IFlexible<*>?>,
|
||||||
|
holder: NotificationSoundItemViewHolder,
|
||||||
|
position: Int,
|
||||||
|
payloads: List<Any>
|
||||||
|
) {
|
||||||
|
holder.notificationName!!.text = notificationSoundName
|
||||||
|
if (adapter.isSelected(position)) {
|
||||||
|
holder.checkedImageView!!.visibility = View.VISIBLE
|
||||||
|
} else {
|
||||||
|
holder.checkedImageView!!.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
if (position == 0) {
|
||||||
|
holder.imageView!!.load(drawable.ic_stop_white_24dp)
|
||||||
|
} else {
|
||||||
|
holder.imageView!!.load(drawable.ic_play_circle_outline_white_24dp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class NotificationSoundItemViewHolder(
|
||||||
|
view: View,
|
||||||
|
adapter: FlexibleAdapter<*>
|
||||||
|
) : FlexibleViewHolder(view, adapter) {
|
||||||
|
@JvmField
|
||||||
|
@BindView(id.notificationNameTextView)
|
||||||
|
var notificationName: TextView? = null
|
||||||
|
@JvmField
|
||||||
|
@BindView(id.imageView)
|
||||||
|
var imageView: ImageView? = null
|
||||||
|
@JvmField
|
||||||
|
@BindView(id.checkedImageView)
|
||||||
|
var checkedImageView: ImageView? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
init {
|
||||||
|
ButterKnife.bind(this, view)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -21,8 +21,6 @@
|
|||||||
package com.nextcloud.talk.adapters.items
|
package com.nextcloud.talk.adapters.items
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.res.Resources
|
|
||||||
import android.graphics.drawable.BitmapDrawable
|
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
@ -32,16 +30,12 @@ import butterknife.BindView
|
|||||||
import butterknife.ButterKnife
|
import butterknife.ButterKnife
|
||||||
import coil.api.load
|
import coil.api.load
|
||||||
import coil.transform.CircleCropTransformation
|
import coil.transform.CircleCropTransformation
|
||||||
import com.facebook.drawee.backends.pipeline.Fresco
|
|
||||||
import com.facebook.drawee.interfaces.DraweeController
|
|
||||||
import com.facebook.drawee.view.SimpleDraweeView
|
|
||||||
import com.nextcloud.talk.R
|
import com.nextcloud.talk.R
|
||||||
import com.nextcloud.talk.application.NextcloudTalkApplication
|
import com.nextcloud.talk.application.NextcloudTalkApplication
|
||||||
import com.nextcloud.talk.models.database.UserEntity
|
import com.nextcloud.talk.models.database.UserEntity
|
||||||
import com.nextcloud.talk.models.json.converters.EnumParticipantTypeConverter
|
import com.nextcloud.talk.models.json.converters.EnumParticipantTypeConverter
|
||||||
import com.nextcloud.talk.models.json.participants.Participant
|
import com.nextcloud.talk.models.json.participants.Participant
|
||||||
import com.nextcloud.talk.utils.ApiUtils
|
import com.nextcloud.talk.utils.ApiUtils
|
||||||
import com.nextcloud.talk.utils.DisplayUtils
|
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
|
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
|
||||||
import eu.davidea.flexibleadapter.items.IFilterable
|
import eu.davidea.flexibleadapter.items.IFilterable
|
||||||
|
@ -72,10 +72,10 @@ class MagicPreviewMessageViewHolder(itemView: View?) : IncomingImageMessageViewH
|
|||||||
var messageText: EmojiTextView? = null
|
var messageText: EmojiTextView? = null
|
||||||
@JvmField
|
@JvmField
|
||||||
@Inject
|
@Inject
|
||||||
internal var context: Context? = null
|
var context: Context? = null
|
||||||
@JvmField
|
@JvmField
|
||||||
@Inject
|
@Inject
|
||||||
internal var okHttpClient: OkHttpClient? = null
|
var okHttpClient: OkHttpClient? = null
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onBind(message: ChatMessage) {
|
override fun onBind(message: ChatMessage) {
|
||||||
|
26
app/src/main/res/drawable/primary_circle.xml
Normal file
26
app/src/main/res/drawable/primary_circle.xml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Nextcloud Talk application
|
||||||
|
~
|
||||||
|
~ @author Mario Danic
|
||||||
|
~ Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
|
||||||
|
~
|
||||||
|
~ 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">
|
||||||
|
<solid
|
||||||
|
android:color="@color/colorPrimary"/>
|
||||||
|
</shape>
|
@ -32,11 +32,10 @@
|
|||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_marginStart="@dimen/activity_horizontal_margin">
|
android:layout_marginStart="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
<com.facebook.drawee.view.SimpleDraweeView
|
<ImageView
|
||||||
android:id="@+id/simple_drawee_view"
|
android:id="@+id/avatarImageView"
|
||||||
android:layout_width="@dimen/avatar_size"
|
android:layout_width="@dimen/avatar_size"
|
||||||
android:layout_height="@dimen/avatar_size"
|
android:layout_height="@dimen/avatar_size"
|
||||||
app:roundAsCircle="true"
|
|
||||||
tools:background="@tools:sample/avatars[1]"
|
tools:background="@tools:sample/avatars[1]"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?><!--
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
~ Nextcloud Talk application
|
~ Nextcloud Talk application
|
||||||
~
|
~
|
||||||
~ @author Mario Danic
|
~ @author Mario Danic
|
||||||
@ -17,24 +18,15 @@
|
|||||||
~ You should have received a copy of the GNU General Public License
|
~ You should have received a copy of the GNU General Public License
|
||||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
~
|
~
|
||||||
~
|
|
||||||
~
|
|
||||||
~ Adapted from https://github.com/stfalcon-studio/ChatKit/blob/master/chatkit/src/main/res/layout/item_dialog.xml
|
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/rv_item_view_height"
|
android:layout_height="@dimen/rv_item_view_height"
|
||||||
android:layout_margin="@dimen/double_margin_between_elements"
|
android:layout_margin="@dimen/double_margin_between_elements"
|
||||||
android:animateLayoutChanges="true">
|
android:animateLayoutChanges="true">
|
||||||
|
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/dialogAvatarFrameLayout"
|
android:id="@+id/dialogAvatarFrameLayout"
|
||||||
android:layout_width="@dimen/small_item_height"
|
android:layout_width="@dimen/small_item_height"
|
||||||
@ -47,7 +39,6 @@
|
|||||||
android:layout_width="@dimen/small_item_height"
|
android:layout_width="@dimen/small_item_height"
|
||||||
android:layout_height="@dimen/small_item_height"
|
android:layout_height="@dimen/small_item_height"
|
||||||
android:contentDescription="@null"
|
android:contentDescription="@null"
|
||||||
app:roundAsCircle="true"
|
|
||||||
tools:src="@drawable/ic_call_black_24dp" />
|
tools:src="@drawable/ic_call_black_24dp" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
@ -140,5 +131,4 @@
|
|||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
tools:text="Best conversation" />
|
tools:text="Best conversation" />
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/item_height"
|
android:layout_height="@dimen/item_height"
|
||||||
@ -35,7 +34,7 @@
|
|||||||
android:layout_marginStart="@dimen/activity_horizontal_margin">
|
android:layout_marginStart="@dimen/activity_horizontal_margin">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/AvatarImageView"
|
android:id="@+id/avatarImageView"
|
||||||
android:layout_width="@dimen/avatar_size"
|
android:layout_width="@dimen/avatar_size"
|
||||||
android:layout_height="@dimen/avatar_size"/>
|
android:layout_height="@dimen/avatar_size"/>
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
android:animateLayoutChanges="true"
|
android:animateLayoutChanges="true"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/checkedImageView"
|
android:id="@+id/checkedImageView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -42,16 +41,16 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_toStartOf="@id/checkedImageView"
|
android:layout_toStartOf="@id/checkedImageView"
|
||||||
android:layout_toEndOf="@id/simpleDraweeView"
|
android:layout_toEndOf="@id/imageView"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:textAppearance="?android:attr/textAppearanceListItem" />
|
android:textAppearance="?android:attr/textAppearanceListItem" />
|
||||||
|
|
||||||
<com.facebook.drawee.view.SimpleDraweeView
|
<ImageView
|
||||||
android:id="@+id/simpleDraweeView"
|
android:id="@+id/imageView"
|
||||||
android:layout_width="@dimen/small_item_height"
|
android:layout_width="@dimen/small_item_height"
|
||||||
android:layout_height="@dimen/small_item_height"
|
android:layout_height="@dimen/small_item_height"
|
||||||
|
android:background="@drawable/primary_circle"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp" />
|
||||||
app:roundAsCircle="true" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
Loading…
Reference in New Issue
Block a user