theme Mentions filter

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2022-08-02 13:08:11 +02:00
parent 9a7ef3ca6c
commit 37d88b7ea5
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
2 changed files with 46 additions and 61 deletions

View file

@ -32,7 +32,6 @@ import android.view.View;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.interfaces.DraweeController;
import com.nextcloud.talk.R;
import com.nextcloud.talk.application.NextcloudTalkApplication;
import com.nextcloud.talk.data.user.model.User;
import com.nextcloud.talk.models.json.mention.Mention;
import com.nextcloud.talk.models.json.status.StatusType;
@ -42,7 +41,6 @@ import com.nextcloud.talk.utils.ApiUtils;
import com.nextcloud.talk.utils.DisplayUtils;
import java.util.List;
import java.util.Objects;
import java.util.regex.Pattern;
import androidx.constraintlayout.widget.ConstraintLayout;
@ -137,35 +135,28 @@ public class MentionAutocompleteItem extends AbstractFlexibleItem<ParticipantIte
FlexibleUtils.highlightText(holder.binding.nameText,
displayName,
String.valueOf(adapter.getFilter(String.class)),
Objects.requireNonNull(NextcloudTalkApplication
.Companion
.getSharedApplication())
.getResources().getColor(R.color.colorPrimary));
if (holder.binding.secondaryText != null) {
FlexibleUtils.highlightText(holder.binding.secondaryText,
"@" + objectId,
String.valueOf(adapter.getFilter(String.class)),
NextcloudTalkApplication.Companion.getSharedApplication()
.getResources().getColor(R.color.colorPrimary));
}
viewThemeUtils
.getScheme(holder.binding.secondaryText.getContext())
.getPrimary());
FlexibleUtils.highlightText(holder.binding.secondaryText,
"@" + objectId,
String.valueOf(adapter.getFilter(String.class)),
viewThemeUtils
.getScheme(holder.binding.secondaryText.getContext())
.getPrimary());
} else {
holder.binding.nameText.setText(displayName);
if (holder.binding.secondaryText != null) {
holder.binding.secondaryText.setText("@" + objectId);
}
holder.binding.secondaryText.setText("@" + objectId);
}
if (SOURCE_CALLS.equals(source)) {
if (holder.binding.avatarDraweeView != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
holder.binding.avatarDraweeView.getHierarchy().setPlaceholderImage(
DisplayUtils.getRoundedDrawable(
viewThemeUtils.themePlaceholderAvatar(holder.binding.avatarDraweeView,
R.drawable.ic_avatar_group)));
} else {
holder.binding.avatarDraweeView.setImageResource(R.drawable.ic_circular_group);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
holder.binding.avatarDraweeView.getHierarchy().setPlaceholderImage(
DisplayUtils.getRoundedDrawable(
viewThemeUtils.themePlaceholderAvatar(holder.binding.avatarDraweeView,
R.drawable.ic_avatar_group)));
} else {
holder.binding.avatarDraweeView.setImageResource(R.drawable.ic_circular_group);
}
} else {
String avatarId = objectId;
@ -180,9 +171,7 @@ public class MentionAutocompleteItem extends AbstractFlexibleItem<ParticipantIte
false);
}
if (holder.binding.avatarDraweeView != null) {
holder.binding.avatarDraweeView.setController(null);
}
holder.binding.avatarDraweeView.setController(null);
DraweeController draweeController = Fresco.newDraweeControllerBuilder()
.setOldController(holder.binding.avatarDraweeView.getController())
@ -196,39 +185,35 @@ public class MentionAutocompleteItem extends AbstractFlexibleItem<ParticipantIte
}
private void drawStatus(ParticipantItem.ParticipantItemViewHolder holder) {
if (holder.binding.conversationInfoStatusMessage != null &&
holder.binding.participantStatusEmoji != null &&
holder.binding.userStatusImage != null) {
float size = DisplayUtils.convertDpToPixel(STATUS_SIZE_IN_DP, context);
holder.binding.userStatusImage.setImageDrawable(new StatusDrawable(
status,
NO_ICON,
size,
context.getResources().getColor(R.color.bg_default),
context));
float size = DisplayUtils.convertDpToPixel(STATUS_SIZE_IN_DP, context);
holder.binding.userStatusImage.setImageDrawable(new StatusDrawable(
status,
NO_ICON,
size,
context.getResources().getColor(R.color.bg_default),
context));
if (statusMessage != null) {
holder.binding.conversationInfoStatusMessage.setText(statusMessage);
alignUsernameVertical(holder, 0);
} else {
holder.binding.conversationInfoStatusMessage.setText("");
alignUsernameVertical(holder, 10);
if (statusMessage != null) {
holder.binding.conversationInfoStatusMessage.setText(statusMessage);
alignUsernameVertical(holder, 0);
} else {
holder.binding.conversationInfoStatusMessage.setText("");
alignUsernameVertical(holder, 10);
}
if (statusIcon != null && !statusIcon.isEmpty()) {
holder.binding.participantStatusEmoji.setText(statusIcon);
} else {
holder.binding.participantStatusEmoji.setVisibility(View.GONE);
}
if (status != null && status.equals(StatusType.DND.getString())) {
if (statusMessage == null || statusMessage.isEmpty()) {
holder.binding.conversationInfoStatusMessage.setText(R.string.dnd);
}
if (statusIcon != null && !statusIcon.isEmpty()) {
holder.binding.participantStatusEmoji.setText(statusIcon);
} else {
holder.binding.participantStatusEmoji.setVisibility(View.GONE);
}
if (status != null && status.equals(StatusType.DND.getString())) {
if (statusMessage == null || statusMessage.isEmpty()) {
holder.binding.conversationInfoStatusMessage.setText(R.string.dnd);
}
} else if (status != null && status.equals(StatusType.AWAY.getString())) {
if (statusMessage == null || statusMessage.isEmpty()) {
holder.binding.conversationInfoStatusMessage.setText(R.string.away);
}
} else if (status != null && status.equals(StatusType.AWAY.getString())) {
if (statusMessage == null || statusMessage.isEmpty()) {
holder.binding.conversationInfoStatusMessage.setText(R.string.away);
}
}
}

View file

@ -78,7 +78,7 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
/**
* Scheme for painting elements
*/
private fun getScheme(context: Context): Scheme = when {
fun getScheme(context: Context): Scheme = when {
isDarkMode(context) -> theme.darkScheme
else -> theme.lightScheme
}