mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 11:39:42 +01:00
Migration away from getScheme() calls
Signed-off-by: Julius Linus <julius.linus@nextcloud.com>
This commit is contained in:
parent
1bb9faf1bc
commit
31cedf0da5
@ -1080,13 +1080,11 @@ class CallActivity : CallBaseActivity() {
|
||||
}
|
||||
|
||||
private fun getSpotlightView(): SpotlightView? {
|
||||
val primary = viewThemeUtils.getScheme(binding!!.audioOutputButton.context).primary
|
||||
return SpotlightView.Builder(this)
|
||||
val builder = SpotlightView.Builder(this)
|
||||
.introAnimationDuration(300)
|
||||
.enableRevealAnimation(true)
|
||||
.performClick(false)
|
||||
.fadeinTextDuration(400)
|
||||
.headingTvColor(primary)
|
||||
.headingTvSize(20)
|
||||
.headingTvText(resources.getString(R.string.nc_push_to_talk))
|
||||
.subHeadingTvColor(resources.getColor(R.color.bg_default, null))
|
||||
@ -1095,11 +1093,11 @@ class CallActivity : CallBaseActivity() {
|
||||
.maskColor(Color.parseColor("#dc000000"))
|
||||
.target(binding!!.microphoneButton)
|
||||
.lineAnimDuration(400)
|
||||
.lineAndArcColor(primary)
|
||||
.enableDismissAfterShown(true)
|
||||
.dismissOnBackPress(true)
|
||||
.usageId("pushToTalk")
|
||||
.show()
|
||||
|
||||
return viewThemeUtils.talk.themeSpotlightView(context, builder).show()
|
||||
}
|
||||
|
||||
private fun onCameraClick() {
|
||||
|
@ -41,7 +41,6 @@ import androidx.annotation.Nullable;
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter;
|
||||
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem;
|
||||
import eu.davidea.flexibleadapter.items.IFilterable;
|
||||
import eu.davidea.flexibleadapter.utils.FlexibleUtils;
|
||||
import eu.davidea.viewholders.FlexibleViewHolder;
|
||||
|
||||
public class AdvancedUserItem extends AbstractFlexibleItem<AdvancedUserItem.UserItemViewHolder> implements
|
||||
@ -65,8 +64,7 @@ public class AdvancedUserItem extends AbstractFlexibleItem<AdvancedUserItem.User
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof AdvancedUserItem) {
|
||||
AdvancedUserItem inItem = (AdvancedUserItem) o;
|
||||
if (o instanceof AdvancedUserItem inItem) {
|
||||
return participant.equals(inItem.getModel());
|
||||
}
|
||||
return false;
|
||||
@ -107,11 +105,10 @@ public class AdvancedUserItem extends AbstractFlexibleItem<AdvancedUserItem.User
|
||||
public void bindViewHolder(FlexibleAdapter adapter, UserItemViewHolder holder, int position, List payloads) {
|
||||
|
||||
if (adapter.hasFilter()) {
|
||||
FlexibleUtils.highlightText(
|
||||
holder.binding.userName,
|
||||
participant.getDisplayName(),
|
||||
String.valueOf(adapter.getFilter(String.class)),
|
||||
viewThemeUtils.getScheme(holder.binding.userName.getContext()).getPrimary());
|
||||
viewThemeUtils.talk.themeAndHighlightText(
|
||||
holder.binding.userName,
|
||||
participant.getDisplayName(),
|
||||
String.valueOf(adapter.getFilter(String.class)));
|
||||
} else {
|
||||
holder.binding.userName.setText(participant.getDisplayName());
|
||||
}
|
||||
|
@ -46,7 +46,6 @@ import eu.davidea.flexibleadapter.FlexibleAdapter;
|
||||
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem;
|
||||
import eu.davidea.flexibleadapter.items.IFilterable;
|
||||
import eu.davidea.flexibleadapter.items.ISectionable;
|
||||
import eu.davidea.flexibleadapter.utils.FlexibleUtils;
|
||||
import eu.davidea.viewholders.FlexibleViewHolder;
|
||||
|
||||
public class ContactItem extends AbstractFlexibleItem<ContactItem.ContactItemViewHolder> implements
|
||||
@ -74,8 +73,7 @@ public class ContactItem extends AbstractFlexibleItem<ContactItem.ContactItemVie
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof ContactItem) {
|
||||
ContactItem inItem = (ContactItem) o;
|
||||
if (o instanceof ContactItem inItem) {
|
||||
return participant.getCalculatedActorType() == inItem.getModel().getCalculatedActorType() &&
|
||||
participant.getCalculatedActorId().equals(inItem.getModel().getCalculatedActorId());
|
||||
}
|
||||
@ -135,10 +133,9 @@ public class ContactItem extends AbstractFlexibleItem<ContactItem.ContactItemVie
|
||||
holder.binding.nameText.setText(participant.getDisplayName());
|
||||
|
||||
if (adapter.hasFilter()) {
|
||||
FlexibleUtils.highlightText(holder.binding.nameText,
|
||||
participant.getDisplayName(),
|
||||
String.valueOf(adapter.getFilter(String.class)),
|
||||
viewThemeUtils.getScheme(holder.binding.nameText.getContext()).getPrimary());
|
||||
viewThemeUtils.talk.themeAndHighlightText(holder.binding.nameText,
|
||||
participant.getDisplayName(),
|
||||
String.valueOf(adapter.getFilter(String.class)));
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(participant.getDisplayName()) &&
|
||||
|
@ -48,7 +48,6 @@ import eu.davidea.flexibleadapter.FlexibleAdapter;
|
||||
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem;
|
||||
import eu.davidea.flexibleadapter.items.IFilterable;
|
||||
import eu.davidea.flexibleadapter.items.IFlexible;
|
||||
import eu.davidea.flexibleadapter.utils.FlexibleUtils;
|
||||
|
||||
public class MentionAutocompleteItem extends AbstractFlexibleItem<ParticipantItem.ParticipantItemViewHolder>
|
||||
implements IFilterable<String> {
|
||||
@ -103,8 +102,7 @@ public class MentionAutocompleteItem extends AbstractFlexibleItem<ParticipantIte
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof MentionAutocompleteItem) {
|
||||
MentionAutocompleteItem inItem = (MentionAutocompleteItem) o;
|
||||
if (o instanceof MentionAutocompleteItem inItem) {
|
||||
return (objectId.equals(inItem.objectId) && displayName.equals(inItem.displayName));
|
||||
}
|
||||
|
||||
@ -138,18 +136,12 @@ public class MentionAutocompleteItem extends AbstractFlexibleItem<ParticipantIte
|
||||
R.color.conversation_item_header,
|
||||
null));
|
||||
if (adapter.hasFilter()) {
|
||||
FlexibleUtils.highlightText(holder.binding.nameText,
|
||||
displayName,
|
||||
String.valueOf(adapter.getFilter(String.class)),
|
||||
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());
|
||||
viewThemeUtils.talk.themeAndHighlightText(holder.binding.nameText,
|
||||
displayName,
|
||||
String.valueOf(adapter.getFilter(String.class)));
|
||||
viewThemeUtils.talk.themeAndHighlightText(holder.binding.secondaryText,
|
||||
"@" + objectId,
|
||||
String.valueOf(adapter.getFilter(String.class)));
|
||||
} else {
|
||||
holder.binding.nameText.setText(displayName);
|
||||
holder.binding.secondaryText.setText("@" + objectId);
|
||||
|
@ -51,7 +51,6 @@ import androidx.core.content.res.ResourcesCompat;
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter;
|
||||
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem;
|
||||
import eu.davidea.flexibleadapter.items.IFilterable;
|
||||
import eu.davidea.flexibleadapter.utils.FlexibleUtils;
|
||||
import eu.davidea.viewholders.FlexibleViewHolder;
|
||||
|
||||
public class ParticipantItem extends AbstractFlexibleItem<ParticipantItem.ParticipantItemViewHolder> implements
|
||||
@ -81,8 +80,7 @@ public class ParticipantItem extends AbstractFlexibleItem<ParticipantItem.Partic
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof ParticipantItem) {
|
||||
ParticipantItem inItem = (ParticipantItem) o;
|
||||
if (o instanceof ParticipantItem inItem) {
|
||||
return participant.getCalculatedActorType() == inItem.getModel().getCalculatedActorType() &&
|
||||
participant.getCalculatedActorId().equals(inItem.getModel().getCalculatedActorId());
|
||||
}
|
||||
@ -129,9 +127,8 @@ public class ParticipantItem extends AbstractFlexibleItem<ParticipantItem.Partic
|
||||
holder.binding.nameText.setText(participant.getDisplayName());
|
||||
|
||||
if (adapter.hasFilter()) {
|
||||
FlexibleUtils.highlightText(holder.binding.nameText, participant.getDisplayName(),
|
||||
String.valueOf(adapter.getFilter(String.class)),
|
||||
viewThemeUtils.getScheme(holder.binding.nameText.getContext()).getPrimary());
|
||||
viewThemeUtils.talk.themeAndHighlightText(holder.binding.nameText, participant.getDisplayName(),
|
||||
String.valueOf(adapter.getFilter(String.class)));
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(participant.getDisplayName()) &&
|
||||
|
@ -84,7 +84,8 @@ class IncomingLinkPreviewMessageViewHolder(incomingView: View, payload: Any) :
|
||||
var processedMessageText = messageUtils.enrichChatMessageText(
|
||||
binding.messageText.context,
|
||||
message,
|
||||
binding.messageText.context.resources.getColor(R.color.nc_incoming_text_default)
|
||||
true,
|
||||
viewThemeUtils
|
||||
)
|
||||
|
||||
processedMessageText = messageUtils.processMessageParameters(
|
||||
@ -198,9 +199,8 @@ class IncomingLinkPreviewMessageViewHolder(incomingView: View, payload: Any) :
|
||||
.enrichChatReplyMessageText(
|
||||
binding.messageQuote.quotedMessage.context,
|
||||
parentChatMessage,
|
||||
binding.messageQuote.quotedMessage.context.resources.getColor(
|
||||
R.color.nc_incoming_text_default
|
||||
)
|
||||
true,
|
||||
viewThemeUtils
|
||||
)
|
||||
|
||||
binding.messageQuote.quotedMessageAuthor
|
||||
|
@ -96,7 +96,7 @@ class IncomingLocationMessageViewHolder(incomingView: View, payload: Any) :
|
||||
|
||||
itemView.isSelected = false
|
||||
|
||||
val textSize = context?.resources!!.getDimension(R.dimen.chat_text_size)
|
||||
val textSize = context.resources!!.getDimension(R.dimen.chat_text_size)
|
||||
binding.messageText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize)
|
||||
binding.messageText.text = message.text
|
||||
|
||||
@ -166,7 +166,7 @@ class IncomingLocationMessageViewHolder(incomingView: View, payload: Any) :
|
||||
if (!message.isDeleted && message.parentMessage != null) {
|
||||
val parentChatMessage = message.parentMessage
|
||||
parentChatMessage!!.activeUser = message.activeUser
|
||||
parentChatMessage!!.imageUrl?.let {
|
||||
parentChatMessage.imageUrl?.let {
|
||||
binding.messageQuote.quotedMessageImage.visibility = View.VISIBLE
|
||||
binding.messageQuote.quotedMessageImage.load(it) {
|
||||
addHeader(
|
||||
@ -178,18 +178,17 @@ class IncomingLocationMessageViewHolder(incomingView: View, payload: Any) :
|
||||
binding.messageQuote.quotedMessageImage.visibility = View.GONE
|
||||
}
|
||||
binding.messageQuote.quotedMessageAuthor.text = parentChatMessage.actorDisplayName
|
||||
?: context!!.getText(R.string.nc_nick_guest)
|
||||
?: context.getText(R.string.nc_nick_guest)
|
||||
binding.messageQuote.quotedMessage.text = messageUtils
|
||||
.enrichChatReplyMessageText(
|
||||
binding.messageQuote.quotedMessage.context,
|
||||
parentChatMessage,
|
||||
binding.messageQuote.quotedMessage.context.resources.getColor(
|
||||
R.color.nc_incoming_text_default
|
||||
)
|
||||
true,
|
||||
viewThemeUtils
|
||||
)
|
||||
|
||||
binding.messageQuote.quotedMessageAuthor
|
||||
.setTextColor(context!!.resources.getColor(R.color.textColorMaxContrast, null))
|
||||
.setTextColor(context.resources.getColor(R.color.textColorMaxContrast, null))
|
||||
|
||||
if (parentChatMessage.actorId?.equals(message.activeUser!!.userId) == true) {
|
||||
viewThemeUtils.platform.colorViewBackground(binding.messageQuote.quoteColoredView)
|
||||
@ -217,7 +216,7 @@ class IncomingLocationMessageViewHolder(incomingView: View, payload: Any) :
|
||||
}
|
||||
}
|
||||
|
||||
binding.webview.settings?.javaScriptEnabled = true
|
||||
binding.webview.settings.javaScriptEnabled = true
|
||||
|
||||
binding.webview.webViewClient = object : WebViewClient() {
|
||||
@Deprecated("Use shouldOverrideUrlLoading(WebView view, WebResourceRequest request)")
|
||||
@ -234,10 +233,10 @@ class IncomingLocationMessageViewHolder(incomingView: View, payload: Any) :
|
||||
|
||||
val urlStringBuffer = StringBuffer("file:///android_asset/leafletMapMessagePreview.html")
|
||||
urlStringBuffer.append(
|
||||
"?mapProviderUrl=" + URLEncoder.encode(context!!.getString(R.string.osm_tile_server_url))
|
||||
"?mapProviderUrl=" + URLEncoder.encode(context.getString(R.string.osm_tile_server_url))
|
||||
)
|
||||
urlStringBuffer.append(
|
||||
"&mapProviderAttribution=" + URLEncoder.encode(context!!.getString(R.string.osm_tile_server_attributation))
|
||||
"&mapProviderAttribution=" + URLEncoder.encode(context.getString(R.string.osm_tile_server_attributation))
|
||||
)
|
||||
urlStringBuffer.append("&locationLat=" + URLEncoder.encode(locationLat))
|
||||
urlStringBuffer.append("&locationLon=" + URLEncoder.encode(locationLon))
|
||||
@ -262,7 +261,7 @@ class IncomingLocationMessageViewHolder(incomingView: View, payload: Any) :
|
||||
val geoLinkWithMarker = addMarkerToGeoLink(locationGeoLink!!)
|
||||
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(geoLinkWithMarker))
|
||||
browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
context!!.startActivity(browserIntent)
|
||||
context.startActivity(browserIntent)
|
||||
} else {
|
||||
Toast.makeText(context, R.string.nc_common_error_sorry, Toast.LENGTH_LONG).show()
|
||||
Log.e(TAG, "locationGeoLink was null or empty")
|
||||
|
@ -206,9 +206,8 @@ class IncomingPollMessageViewHolder(incomingView: View, payload: Any) :
|
||||
.enrichChatReplyMessageText(
|
||||
binding.messageQuote.quotedMessage.context,
|
||||
parentChatMessage,
|
||||
binding.messageQuote.quotedMessage.context.resources.getColor(
|
||||
R.color.nc_incoming_text_default
|
||||
)
|
||||
true,
|
||||
viewThemeUtils
|
||||
)
|
||||
|
||||
binding.messageQuote.quotedMessageAuthor
|
||||
|
@ -88,7 +88,8 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) :
|
||||
var processedMessageText = messageUtils.enrichChatMessageText(
|
||||
binding.messageText.context,
|
||||
message,
|
||||
binding.messageText.context.resources.getColor(R.color.nc_incoming_text_default)
|
||||
true,
|
||||
viewThemeUtils
|
||||
)
|
||||
|
||||
processedMessageText = messageUtils.processMessageParameters(
|
||||
@ -197,7 +198,7 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) :
|
||||
binding.messageQuote.quotedMessageImage.visibility = View.GONE
|
||||
}
|
||||
binding.messageQuote.quotedMessageAuthor.text = if (parentChatMessage.actorDisplayName.isNullOrEmpty()) {
|
||||
context!!.getText(R.string.nc_nick_guest)
|
||||
context.getText(R.string.nc_nick_guest)
|
||||
} else {
|
||||
parentChatMessage.actorDisplayName
|
||||
}
|
||||
@ -206,7 +207,8 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) :
|
||||
.enrichChatReplyMessageText(
|
||||
binding.messageQuote.quotedMessage.context,
|
||||
parentChatMessage,
|
||||
binding.messageQuote.quotedMessage.context.resources.getColor(R.color.nc_incoming_text_default)
|
||||
true,
|
||||
viewThemeUtils
|
||||
)
|
||||
|
||||
if (parentChatMessage.actorId?.equals(message.activeUser!!.userId) == true) {
|
||||
@ -217,7 +219,7 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) :
|
||||
)
|
||||
}
|
||||
|
||||
binding.messageQuote.quotedChatMessageView.setOnClickListener() {
|
||||
binding.messageQuote.quotedChatMessageView.setOnClickListener {
|
||||
val chatActivity = commonMessageInterface as ChatActivity
|
||||
chatActivity.jumpToQuotedMessage(parentChatMessage)
|
||||
}
|
||||
|
@ -304,9 +304,8 @@ class IncomingVoiceMessageViewHolder(incomingView: View, payload: Any) :
|
||||
.enrichChatReplyMessageText(
|
||||
binding.messageQuote.quotedMessage.context,
|
||||
parentChatMessage,
|
||||
binding.messageQuote.quotedMessage.context.resources.getColor(
|
||||
R.color.nc_incoming_text_default
|
||||
)
|
||||
true,
|
||||
viewThemeUtils
|
||||
)
|
||||
|
||||
binding.messageQuote.quotedMessageAuthor
|
||||
|
@ -24,11 +24,11 @@ package com.nextcloud.talk.adapters.messages
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.graphics.PorterDuff
|
||||
import android.view.View
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import autodagger.AutoInjector
|
||||
import coil.load
|
||||
import com.nextcloud.android.common.ui.theme.utils.ColorRole
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.api.NcApi
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication
|
||||
@ -78,12 +78,12 @@ class OutcomingLinkPreviewMessageViewHolder(outcomingView: View, payload: Any) :
|
||||
super.onBind(message)
|
||||
this.message = message
|
||||
sharedApplication!!.componentApplication.inject(this)
|
||||
val textColor = viewThemeUtils.getScheme(binding.messageTime.context).onSurfaceVariant
|
||||
binding.messageTime.setTextColor(textColor)
|
||||
viewThemeUtils.platform.colorTextView(binding.messageTime, ColorRole.ON_SURFACE_VARIANT)
|
||||
binding.messageTime.text = dateUtils.getLocalTimeStringFromTimestamp(message.timestamp)
|
||||
|
||||
colorizeMessageBubble(message)
|
||||
var processedMessageText = messageUtils.enrichChatMessageText(binding.messageText.context, message, textColor)
|
||||
var processedMessageText =
|
||||
messageUtils.enrichChatMessageText(binding.messageText.context, message, false, viewThemeUtils)
|
||||
processedMessageText = messageUtils.processMessageParameters(
|
||||
binding.messageText.context,
|
||||
viewThemeUtils,
|
||||
@ -106,18 +106,15 @@ class OutcomingLinkPreviewMessageViewHolder(outcomingView: View, payload: Any) :
|
||||
}
|
||||
|
||||
val readStatusContentDescriptionString = when (message.readStatus) {
|
||||
ReadStatus.READ -> context?.resources?.getString(R.string.nc_message_read)
|
||||
ReadStatus.SENT -> context?.resources?.getString(R.string.nc_message_sent)
|
||||
ReadStatus.READ -> context.resources?.getString(R.string.nc_message_read)
|
||||
ReadStatus.SENT -> context.resources?.getString(R.string.nc_message_sent)
|
||||
else -> null
|
||||
}
|
||||
|
||||
readStatusDrawableInt?.let { drawableInt ->
|
||||
AppCompatResources.getDrawable(context, drawableInt)?.let {
|
||||
binding.checkMark.setImageDrawable(it)
|
||||
binding.checkMark.setColorFilter(
|
||||
viewThemeUtils.getScheme(binding.checkMark.context).onSurfaceVariant,
|
||||
PorterDuff.Mode.SRC_ATOP
|
||||
)
|
||||
viewThemeUtils.talk.themeMessageCheckMark(binding.checkMark)
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,7 +173,8 @@ class OutcomingLinkPreviewMessageViewHolder(outcomingView: View, payload: Any) :
|
||||
.enrichChatReplyMessageText(
|
||||
binding.messageQuote.quotedMessage.context,
|
||||
parentChatMessage,
|
||||
viewThemeUtils.getScheme(binding.messageQuote.quotedMessage.context).onSurfaceVariant
|
||||
false,
|
||||
viewThemeUtils
|
||||
)
|
||||
viewThemeUtils.talk.colorOutgoingQuoteText(binding.messageQuote.quotedMessage)
|
||||
viewThemeUtils.talk.colorOutgoingQuoteAuthorText(binding.messageQuote.quotedMessageAuthor)
|
||||
|
@ -25,7 +25,6 @@ package com.nextcloud.talk.adapters.messages
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.PorterDuff
|
||||
import android.net.Uri
|
||||
import android.util.Log
|
||||
import android.util.TypedValue
|
||||
@ -38,6 +37,7 @@ import androidx.appcompat.content.res.AppCompatResources
|
||||
import autodagger.AutoInjector
|
||||
import coil.load
|
||||
import com.google.android.flexbox.FlexboxLayout
|
||||
import com.nextcloud.android.common.ui.theme.utils.ColorRole
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
|
||||
@ -84,15 +84,14 @@ class OutcomingLocationMessageViewHolder(incomingView: View) :
|
||||
override fun onBind(message: ChatMessage) {
|
||||
super.onBind(message)
|
||||
sharedApplication!!.componentApplication.inject(this)
|
||||
val textColor = viewThemeUtils.getScheme(binding.messageTime.context).onSurfaceVariant
|
||||
binding.messageTime.setTextColor(textColor)
|
||||
viewThemeUtils.platform.colorTextView(binding.messageTime, ColorRole.ON_SURFACE_VARIANT)
|
||||
binding.messageTime.text = dateUtils.getLocalTimeStringFromTimestamp(message.timestamp)
|
||||
|
||||
realView.isSelected = false
|
||||
val layoutParams = binding.messageTime.layoutParams as FlexboxLayout.LayoutParams
|
||||
layoutParams.isWrapBefore = false
|
||||
|
||||
val textSize = context!!.resources.getDimension(R.dimen.chat_text_size)
|
||||
val textSize = context.resources.getDimension(R.dimen.chat_text_size)
|
||||
|
||||
colorizeMessageBubble(message)
|
||||
binding.messageText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize)
|
||||
@ -110,22 +109,19 @@ class OutcomingLocationMessageViewHolder(incomingView: View) :
|
||||
}
|
||||
|
||||
val readStatusContentDescriptionString = when (message.readStatus) {
|
||||
ReadStatus.READ -> context?.resources?.getString(R.string.nc_message_read)
|
||||
ReadStatus.SENT -> context?.resources?.getString(R.string.nc_message_sent)
|
||||
ReadStatus.READ -> context.resources?.getString(R.string.nc_message_read)
|
||||
ReadStatus.SENT -> context.resources?.getString(R.string.nc_message_sent)
|
||||
else -> null
|
||||
}
|
||||
|
||||
readStatusDrawableInt?.let { drawableInt ->
|
||||
AppCompatResources.getDrawable(context!!, drawableInt)?.let {
|
||||
AppCompatResources.getDrawable(context, drawableInt)?.let {
|
||||
binding.checkMark.setImageDrawable(it)
|
||||
binding.checkMark.setColorFilter(
|
||||
viewThemeUtils.getScheme(binding.checkMark.context).onSurfaceVariant,
|
||||
PorterDuff.Mode.SRC_ATOP
|
||||
)
|
||||
viewThemeUtils.talk.themeMessageCheckMark(binding.checkMark)
|
||||
}
|
||||
}
|
||||
|
||||
binding.checkMark.setContentDescription(readStatusContentDescriptionString)
|
||||
binding.checkMark.contentDescription = readStatusContentDescriptionString
|
||||
|
||||
// geo-location
|
||||
setLocationDataOnMessageItem(message)
|
||||
@ -163,7 +159,7 @@ class OutcomingLocationMessageViewHolder(incomingView: View) :
|
||||
}
|
||||
}
|
||||
|
||||
binding.webview.settings?.javaScriptEnabled = true
|
||||
binding.webview.settings.javaScriptEnabled = true
|
||||
|
||||
binding.webview.webViewClient = object : WebViewClient() {
|
||||
@Deprecated("Use shouldOverrideUrlLoading(WebView view, WebResourceRequest request)")
|
||||
@ -180,11 +176,11 @@ class OutcomingLocationMessageViewHolder(incomingView: View) :
|
||||
|
||||
val urlStringBuffer = StringBuffer("file:///android_asset/leafletMapMessagePreview.html")
|
||||
urlStringBuffer.append(
|
||||
"?mapProviderUrl=" + URLEncoder.encode(context!!.getString(R.string.osm_tile_server_url))
|
||||
"?mapProviderUrl=" + URLEncoder.encode(context.getString(R.string.osm_tile_server_url))
|
||||
)
|
||||
urlStringBuffer.append(
|
||||
"&mapProviderAttribution=" + URLEncoder.encode(
|
||||
context!!.getString(
|
||||
context.getString(
|
||||
R.string
|
||||
.osm_tile_server_attributation
|
||||
)
|
||||
@ -224,12 +220,13 @@ class OutcomingLocationMessageViewHolder(incomingView: View) :
|
||||
binding.messageQuote.quotedMessageImage.visibility = View.GONE
|
||||
}
|
||||
binding.messageQuote.quotedMessageAuthor.text = parentChatMessage.actorDisplayName
|
||||
?: context!!.getText(R.string.nc_nick_guest)
|
||||
?: context.getText(R.string.nc_nick_guest)
|
||||
binding.messageQuote.quotedMessage.text = messageUtils
|
||||
.enrichChatReplyMessageText(
|
||||
binding.messageQuote.quotedMessage.context,
|
||||
parentChatMessage,
|
||||
viewThemeUtils.getScheme(binding.messageQuote.quotedMessage.context).onSurfaceVariant
|
||||
false,
|
||||
viewThemeUtils
|
||||
)
|
||||
viewThemeUtils.talk.colorOutgoingQuoteText(binding.messageQuote.quotedMessage)
|
||||
viewThemeUtils.talk.colorOutgoingQuoteAuthorText(binding.messageQuote.quotedMessageAuthor)
|
||||
@ -250,7 +247,7 @@ class OutcomingLocationMessageViewHolder(incomingView: View) :
|
||||
val geoLinkWithMarker = addMarkerToGeoLink(locationGeoLink!!)
|
||||
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(geoLinkWithMarker))
|
||||
browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
context!!.startActivity(browserIntent)
|
||||
context.startActivity(browserIntent)
|
||||
} else {
|
||||
Toast.makeText(context, R.string.nc_common_error_sorry, Toast.LENGTH_LONG).show()
|
||||
Log.e(TAG, "locationGeoLink was null or empty")
|
||||
|
@ -23,11 +23,11 @@ package com.nextcloud.talk.adapters.messages
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.graphics.PorterDuff
|
||||
import android.view.View
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import autodagger.AutoInjector
|
||||
import coil.load
|
||||
import com.nextcloud.android.common.ui.theme.utils.ColorRole
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.api.NcApi
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication
|
||||
@ -78,8 +78,7 @@ class OutcomingPollMessageViewHolder(outcomingView: View, payload: Any) :
|
||||
super.onBind(message)
|
||||
this.message = message
|
||||
sharedApplication!!.componentApplication.inject(this)
|
||||
val textColor = viewThemeUtils.getScheme(binding.messageTime.context).onSurfaceVariant
|
||||
binding.messageTime.setTextColor(textColor)
|
||||
viewThemeUtils.platform.colorTextView(binding.messageTime, ColorRole.ON_SURFACE_VARIANT)
|
||||
binding.messageTime.text = dateUtils.getLocalTimeStringFromTimestamp(message.timestamp)
|
||||
|
||||
colorizeMessageBubble(message)
|
||||
@ -96,18 +95,15 @@ class OutcomingPollMessageViewHolder(outcomingView: View, payload: Any) :
|
||||
}
|
||||
|
||||
val readStatusContentDescriptionString = when (message.readStatus) {
|
||||
ReadStatus.READ -> context?.resources?.getString(R.string.nc_message_read)
|
||||
ReadStatus.SENT -> context?.resources?.getString(R.string.nc_message_sent)
|
||||
ReadStatus.READ -> context.resources?.getString(R.string.nc_message_read)
|
||||
ReadStatus.SENT -> context.resources?.getString(R.string.nc_message_sent)
|
||||
else -> null
|
||||
}
|
||||
|
||||
readStatusDrawableInt?.let { drawableInt ->
|
||||
AppCompatResources.getDrawable(context, drawableInt)?.let {
|
||||
binding.checkMark.setImageDrawable(it)
|
||||
binding.checkMark.setColorFilter(
|
||||
viewThemeUtils.getScheme(binding.checkMark.context).onSurfaceVariant,
|
||||
PorterDuff.Mode.SRC_ATOP
|
||||
)
|
||||
viewThemeUtils.talk.themeMessageCheckMark(binding.checkMark)
|
||||
}
|
||||
}
|
||||
|
||||
@ -191,7 +187,8 @@ class OutcomingPollMessageViewHolder(outcomingView: View, payload: Any) :
|
||||
.enrichChatReplyMessageText(
|
||||
binding.messageQuote.quotedMessage.context,
|
||||
parentChatMessage,
|
||||
viewThemeUtils.getScheme(binding.messageQuote.quotedMessage.context).onSurfaceVariant
|
||||
false,
|
||||
viewThemeUtils
|
||||
)
|
||||
viewThemeUtils.talk.colorOutgoingQuoteText(binding.messageQuote.quotedMessage)
|
||||
viewThemeUtils.talk.colorOutgoingQuoteAuthorText(binding.messageQuote.quotedMessageAuthor)
|
||||
|
@ -24,13 +24,13 @@
|
||||
package com.nextcloud.talk.adapters.messages
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.PorterDuff
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import autodagger.AutoInjector
|
||||
import coil.load
|
||||
import com.google.android.flexbox.FlexboxLayout
|
||||
import com.nextcloud.android.common.ui.theme.utils.ColorRole
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
|
||||
@ -71,11 +71,12 @@ class OutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessageViewH
|
||||
realView.isSelected = false
|
||||
val layoutParams = binding.messageTime.layoutParams as FlexboxLayout.LayoutParams
|
||||
layoutParams.isWrapBefore = false
|
||||
var textSize = context!!.resources.getDimension(R.dimen.chat_text_size)
|
||||
val textColor = viewThemeUtils.getScheme(binding.messageText.context).onSurfaceVariant
|
||||
binding.messageTime.setTextColor(textColor)
|
||||
|
||||
var processedMessageText = messageUtils.enrichChatMessageText(binding.messageText.context, message, textColor)
|
||||
var textSize = context.resources.getDimension(R.dimen.chat_text_size)
|
||||
viewThemeUtils.platform.colorTextView(binding.messageTime, ColorRole.ON_SURFACE_VARIANT)
|
||||
var processedMessageText = messageUtils.enrichChatMessageText(
|
||||
binding.messageText.context, message, false,
|
||||
viewThemeUtils
|
||||
)
|
||||
processedMessageText = messageUtils.processMessageParameters(
|
||||
binding.messageText.context,
|
||||
viewThemeUtils,
|
||||
@ -98,7 +99,7 @@ class OutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessageViewH
|
||||
|
||||
binding.messageText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize)
|
||||
binding.messageTime.layoutParams = layoutParams
|
||||
binding.messageText.setTextColor(textColor)
|
||||
viewThemeUtils.platform.colorTextView(binding.messageText, ColorRole.ON_SURFACE_VARIANT)
|
||||
binding.messageText.text = processedMessageText
|
||||
|
||||
binding.messageTime.text = dateUtils.getLocalTimeStringFromTimestamp(message.timestamp)
|
||||
@ -118,22 +119,19 @@ class OutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessageViewH
|
||||
}
|
||||
|
||||
val readStatusContentDescriptionString = when (message.readStatus) {
|
||||
ReadStatus.READ -> context?.resources?.getString(R.string.nc_message_read)
|
||||
ReadStatus.SENT -> context?.resources?.getString(R.string.nc_message_sent)
|
||||
ReadStatus.READ -> context.resources?.getString(R.string.nc_message_read)
|
||||
ReadStatus.SENT -> context.resources?.getString(R.string.nc_message_sent)
|
||||
else -> null
|
||||
}
|
||||
|
||||
readStatusDrawableInt?.let { drawableInt ->
|
||||
ResourcesCompat.getDrawable(context!!.resources, drawableInt, null)?.let {
|
||||
ResourcesCompat.getDrawable(context.resources, drawableInt, null)?.let {
|
||||
binding.checkMark.setImageDrawable(it)
|
||||
binding.checkMark.setColorFilter(
|
||||
viewThemeUtils.getScheme(binding.messageText.context).onSurfaceVariant,
|
||||
PorterDuff.Mode.SRC_ATOP
|
||||
)
|
||||
viewThemeUtils.talk.themeMessageCheckMark(binding.checkMark)
|
||||
}
|
||||
}
|
||||
|
||||
binding.checkMark.setContentDescription(readStatusContentDescriptionString)
|
||||
binding.checkMark.contentDescription = readStatusContentDescriptionString
|
||||
|
||||
itemView.setTag(R.string.replyable_message_view_tag, message.replyable)
|
||||
|
||||
@ -158,7 +156,6 @@ class OutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessageViewH
|
||||
|
||||
private fun processParentMessage(message: ChatMessage) {
|
||||
val parentChatMessage = message.parentMessage
|
||||
val textColor = viewThemeUtils.getScheme(binding.messageQuote.quotedMessage.context).onSurfaceVariant
|
||||
parentChatMessage!!.activeUser = message.activeUser
|
||||
parentChatMessage.imageUrl?.let {
|
||||
binding.messageQuote.quotedMessageImage.visibility = View.VISIBLE
|
||||
@ -172,19 +169,20 @@ class OutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessageViewH
|
||||
binding.messageQuote.quotedMessageImage.visibility = View.GONE
|
||||
}
|
||||
binding.messageQuote.quotedMessageAuthor.text = parentChatMessage.actorDisplayName
|
||||
?: context!!.getText(R.string.nc_nick_guest)
|
||||
?: context.getText(R.string.nc_nick_guest)
|
||||
binding.messageQuote.quotedMessage.text = messageUtils
|
||||
.enrichChatReplyMessageText(
|
||||
binding.messageQuote.quotedMessage.context,
|
||||
parentChatMessage,
|
||||
textColor
|
||||
false,
|
||||
viewThemeUtils
|
||||
)
|
||||
|
||||
binding.messageQuote.quotedMessageAuthor.setTextColor(textColor)
|
||||
binding.messageQuote.quotedMessage.setTextColor(textColor)
|
||||
binding.messageQuote.quoteColoredView.setBackgroundColor(textColor)
|
||||
viewThemeUtils.talk.colorOutgoingQuoteText(binding.messageQuote.quotedMessage)
|
||||
viewThemeUtils.talk.colorOutgoingQuoteAuthorText(binding.messageQuote.quotedMessageAuthor)
|
||||
viewThemeUtils.talk.colorOutgoingQuoteBackground(binding.messageQuote.quoteColoredView)
|
||||
|
||||
binding.messageQuote.quotedChatMessageView.setOnClickListener() {
|
||||
binding.messageQuote.quotedChatMessageView.setOnClickListener {
|
||||
val chatActivity = commonMessageInterface as ChatActivity
|
||||
chatActivity.jumpToQuotedMessage(parentChatMessage)
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ package com.nextcloud.talk.adapters.messages
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.graphics.PorterDuff
|
||||
import android.os.Handler
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
@ -86,8 +85,7 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) :
|
||||
super.onBind(message)
|
||||
this.message = message
|
||||
sharedApplication!!.componentApplication.inject(this)
|
||||
val textColor = viewThemeUtils.getScheme(binding.messageTime.context).onSurfaceVariant
|
||||
binding.messageTime.setTextColor(textColor)
|
||||
viewThemeUtils.platform.colorTextView(binding.messageTime, ColorRole.ON_SURFACE_VARIANT)
|
||||
binding.messageTime.text = dateUtils.getLocalTimeStringFromTimestamp(message.timestamp)
|
||||
|
||||
colorizeMessageBubble(message)
|
||||
@ -139,10 +137,7 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) :
|
||||
readStatusDrawableInt?.let { drawableInt ->
|
||||
AppCompatResources.getDrawable(context!!, drawableInt)?.let {
|
||||
binding.checkMark.setImageDrawable(it)
|
||||
binding.checkMark.setColorFilter(
|
||||
viewThemeUtils.getScheme(binding.checkMark.context).onSurfaceVariant,
|
||||
PorterDuff.Mode.SRC_ATOP
|
||||
)
|
||||
viewThemeUtils.talk.themeMessageCheckMark(binding.checkMark)
|
||||
}
|
||||
}
|
||||
|
||||
@ -291,7 +286,8 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) :
|
||||
.enrichChatReplyMessageText(
|
||||
binding.messageQuote.quotedMessage.context,
|
||||
parentChatMessage,
|
||||
viewThemeUtils.getScheme(binding.messageQuote.quotedMessage.context).onSurfaceVariant
|
||||
false,
|
||||
viewThemeUtils
|
||||
)
|
||||
viewThemeUtils.talk.colorOutgoingQuoteText(binding.messageQuote.quotedMessage)
|
||||
viewThemeUtils.talk.colorOutgoingQuoteAuthorText(binding.messageQuote.quotedMessageAuthor)
|
||||
|
@ -28,7 +28,6 @@ package com.nextcloud.talk.adapters.messages
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.PorterDuff
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.net.Uri
|
||||
import android.os.Handler
|
||||
@ -235,17 +234,14 @@ abstract class PreviewMessageViewHolder(itemView: View?, payload: Any?) :
|
||||
if (message.selectedIndividualHashMap!!.containsKey(KEY_MIMETYPE)) {
|
||||
val mimetype = message.selectedIndividualHashMap!![KEY_MIMETYPE]
|
||||
val drawableResourceId = getDrawableResourceIdForMimeType(mimetype)
|
||||
val drawable = ContextCompat.getDrawable(context!!, drawableResourceId)
|
||||
var drawable = ContextCompat.getDrawable(context!!, drawableResourceId)
|
||||
if (drawable != null &&
|
||||
(
|
||||
drawableResourceId == R.drawable.ic_mimetype_folder ||
|
||||
drawableResourceId == R.drawable.ic_mimetype_package_x_generic
|
||||
)
|
||||
) {
|
||||
drawable.setColorFilter(
|
||||
viewThemeUtils!!.getScheme(image.context).primary,
|
||||
PorterDuff.Mode.SRC_ATOP
|
||||
)
|
||||
drawable = viewThemeUtils?.platform?.tintDrawable(context!!, drawable)
|
||||
}
|
||||
placeholder = drawable
|
||||
} else {
|
||||
|
@ -25,8 +25,6 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.databinding.ReactionsInsideMessageBinding
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage
|
||||
import com.nextcloud.talk.ui.theme.ViewThemeUtils
|
||||
@ -65,7 +63,7 @@ class Reaction {
|
||||
val isSelfReaction = message.reactionsSelf != null &&
|
||||
message.reactionsSelf!!.isNotEmpty() &&
|
||||
message.reactionsSelf!!.contains(emoji)
|
||||
val textColor = getTextColor(isOutgoingMessage, isSelfReaction, binding, viewThemeUtils)
|
||||
val textColor = viewThemeUtils.talk.getTextColor(isOutgoingMessage, isSelfReaction, binding)
|
||||
val emojiWithAmountWrapper = getEmojiWithAmountWrapperLayout(
|
||||
binding.reactionsEmojiWrapper.context,
|
||||
emoji,
|
||||
@ -112,15 +110,7 @@ class Reaction {
|
||||
emojiWithAmountWrapper.layoutParams = layoutInfo.wrapperParams
|
||||
|
||||
if (layoutInfo.isSelfReaction) {
|
||||
val color = if (layoutInfo.isOutgoingMessage) {
|
||||
ContextCompat.getColor(
|
||||
emojiWithAmountWrapper.context,
|
||||
R.color.bg_message_list_incoming_bubble
|
||||
)
|
||||
} else {
|
||||
layoutInfo.viewThemeUtils.getScheme(emojiWithAmountWrapper.context).primaryContainer
|
||||
}
|
||||
layoutInfo.viewThemeUtils.talk.setCheckedBackground(emojiWithAmountWrapper, color)
|
||||
layoutInfo.viewThemeUtils.talk.setCheckedBackground(emojiWithAmountWrapper, layoutInfo.isOutgoingMessage)
|
||||
|
||||
emojiWithAmountWrapper.setPaddingRelative(
|
||||
layoutInfo.paddingSide,
|
||||
@ -176,19 +166,6 @@ class Reaction {
|
||||
return amountParams
|
||||
}
|
||||
|
||||
private fun getTextColor(
|
||||
isOutgoingMessage: Boolean,
|
||||
isSelfReaction: Boolean,
|
||||
binding: ReactionsInsideMessageBinding,
|
||||
viewThemeUtils: ViewThemeUtils
|
||||
): Int {
|
||||
var textColor = viewThemeUtils.getScheme(binding.root.context).onSurfaceVariant
|
||||
if (!isOutgoingMessage || isSelfReaction) {
|
||||
textColor = ContextCompat.getColor(binding.root.context, R.color.high_emphasis_text)
|
||||
}
|
||||
return textColor
|
||||
}
|
||||
|
||||
private data class EmojiWithAmountWrapperLayoutInfo(
|
||||
val textColor: Int,
|
||||
val amountParams: LinearLayout.LayoutParams,
|
||||
|
@ -1618,9 +1618,10 @@ class ChatActivity :
|
||||
currentConversation!!.status,
|
||||
null,
|
||||
size,
|
||||
viewThemeUtils.platform.getScheme(binding.chatToolbar.context).surface,
|
||||
0,
|
||||
binding.chatToolbar.context
|
||||
)
|
||||
viewThemeUtils.talk.themeStatusDrawable(context, status)
|
||||
binding.chatToolbar.findViewById<ImageView>(R.id.chat_toolbar_avatar)
|
||||
.setImageDrawable(BitmapDrawable(resources, bitmap))
|
||||
binding.chatToolbar.findViewById<ImageView>(R.id.chat_toolbar_status)
|
||||
|
@ -26,7 +26,6 @@ package com.nextcloud.talk.remotefilebrowser.activities
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.content.res.ColorStateList
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.Menu
|
||||
@ -90,13 +89,10 @@ class RemoteFileBrowserActivity : AppCompatActivity(), SelectionInterface, Swipe
|
||||
binding = ActivityRemoteFileBrowserBinding.inflate(layoutInflater)
|
||||
setSupportActionBar(binding.remoteFileBrowserItemsToolbar)
|
||||
viewThemeUtils.material.themeToolbar(binding.remoteFileBrowserItemsToolbar)
|
||||
val scheme = viewThemeUtils.getScheme(binding.sortListButtonGroup.context)
|
||||
binding.sortListButtonGroup.setBackgroundColor(scheme.surface)
|
||||
binding.sortButton.iconTint = ColorStateList.valueOf(scheme.onSurface)
|
||||
binding.sortButton.setTextColor(scheme.onSurface)
|
||||
viewThemeUtils.talk.themeSortListButtonGroup(binding.sortListButtonGroup)
|
||||
viewThemeUtils.talk.themeSortButton(binding.sortButton)
|
||||
viewThemeUtils.material.colorMaterialTextButton(binding.sortButton)
|
||||
binding.pathNavigationBackButton.iconTint = ColorStateList.valueOf(scheme.onSurface)
|
||||
binding.pathNavigationBackButton.setTextColor(scheme.onSurface)
|
||||
viewThemeUtils.talk.themePathNavigationButton(binding.pathNavigationBackButton)
|
||||
viewThemeUtils.material.colorMaterialTextButton(binding.pathNavigationBackButton)
|
||||
viewThemeUtils.platform.themeStatusBar(this)
|
||||
setContentView(binding.root)
|
||||
@ -199,7 +195,7 @@ class RemoteFileBrowserActivity : AppCompatActivity(), SelectionInterface, Swipe
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
super.onCreateOptionsMenu(menu)
|
||||
menuInflater.inflate(R.menu.menu_share_files, menu)
|
||||
filesSelectionDoneMenuItem = menu?.findItem(R.id.files_selection_done)
|
||||
filesSelectionDoneMenuItem = menu.findItem(R.id.files_selection_done)
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@ import android.text.TextUtils;
|
||||
|
||||
import com.nextcloud.talk.R;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
@ -44,11 +45,17 @@ public class StatusDrawable extends Drawable {
|
||||
private String text;
|
||||
private StatusDrawableType icon = StatusDrawableType.UNDEFINED;
|
||||
private Paint textPaint;
|
||||
private final int backgroundColor;
|
||||
private int backgroundColor;
|
||||
private final float radius;
|
||||
private Context context;
|
||||
|
||||
public StatusDrawable(String status, String statusIcon, float statusSize, int backgroundColor, Context context) {
|
||||
public void colorStatusDrawable(@ColorInt int color) {
|
||||
backgroundColor = color;
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
public StatusDrawable(String status, String statusIcon, float statusSize, int backgroundColor,
|
||||
Context context) {
|
||||
radius = statusSize;
|
||||
this.backgroundColor = backgroundColor;
|
||||
|
||||
@ -58,19 +65,17 @@ public class StatusDrawable extends Drawable {
|
||||
this.context = context;
|
||||
} else if (TextUtils.isEmpty(statusIcon) && status != null) {
|
||||
switch (status) {
|
||||
case "online":
|
||||
case "online" -> {
|
||||
icon = StatusDrawableType.ONLINE;
|
||||
this.context = context;
|
||||
break;
|
||||
|
||||
case "away":
|
||||
}
|
||||
case "away" -> {
|
||||
icon = StatusDrawableType.AWAY;
|
||||
this.context = context;
|
||||
break;
|
||||
|
||||
default:
|
||||
// do not show
|
||||
break;
|
||||
}
|
||||
default -> {
|
||||
}
|
||||
// do not show
|
||||
}
|
||||
} else {
|
||||
text = statusIcon;
|
||||
|
@ -329,12 +329,14 @@ public class ChooseAccountDialogFragment extends DialogFragment {
|
||||
private void drawStatus() {
|
||||
float size = DisplayUtils.convertDpToPixel(STATUS_SIZE_IN_DP, getContext());
|
||||
binding.currentAccount.ticker.setBackground(null);
|
||||
binding.currentAccount.ticker.setImageDrawable(new StatusDrawable(
|
||||
StatusDrawable drawable = new StatusDrawable(
|
||||
status.getStatus(),
|
||||
status.getIcon(),
|
||||
size,
|
||||
viewThemeUtils.getScheme(binding.currentAccount.ticker.getContext()).getSurface(),
|
||||
getContext()));
|
||||
0,
|
||||
getContext());
|
||||
viewThemeUtils.talk.themeStatusDrawable(binding.currentAccount.ticker.getContext(), drawable);
|
||||
binding.currentAccount.ticker.setImageDrawable(drawable);
|
||||
binding.currentAccount.ticker.setVisibility(View.VISIBLE);
|
||||
|
||||
|
||||
|
@ -26,13 +26,19 @@ import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.PorterDuff
|
||||
import android.graphics.PorterDuffColorFilter
|
||||
import android.graphics.Typeface
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.LayerDrawable
|
||||
import android.os.Build
|
||||
import android.text.Spannable
|
||||
import android.text.Spanned
|
||||
import android.text.style.ForegroundColorSpan
|
||||
import android.text.style.StyleSpan
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import androidx.appcompat.widget.SearchView
|
||||
@ -42,17 +48,23 @@ import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.core.graphics.ColorUtils
|
||||
import androidx.core.graphics.drawable.DrawableCompat
|
||||
import androidx.core.view.ViewCompat
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import com.google.android.material.card.MaterialCardView
|
||||
import com.google.android.material.materialswitch.MaterialSwitch
|
||||
import com.nextcloud.android.common.ui.theme.MaterialSchemes
|
||||
import com.nextcloud.android.common.ui.theme.ViewThemeUtilsBase
|
||||
import com.nextcloud.android.common.ui.theme.utils.AndroidXViewThemeUtils
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.databinding.ReactionsInsideMessageBinding
|
||||
import com.nextcloud.talk.ui.MicInputCloud
|
||||
import com.nextcloud.talk.ui.StatusDrawable
|
||||
import com.nextcloud.talk.ui.WaveformSeekBar
|
||||
import com.nextcloud.talk.utils.DisplayUtils
|
||||
import com.nextcloud.talk.utils.DrawableUtils
|
||||
import com.nextcloud.talk.utils.message.MessageUtils
|
||||
import com.vanniktech.emoji.EmojiTextView
|
||||
import com.wooplr.spotlight.SpotlightView
|
||||
import eu.davidea.flexibleadapter.utils.FlexibleUtils
|
||||
import javax.inject.Inject
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
@ -160,11 +172,19 @@ class TalkSpecificViewThemeUtils @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun setCheckedBackground(linearLayout: LinearLayout, @ColorInt backgroundColor: Int) {
|
||||
fun setCheckedBackground(linearLayout: LinearLayout, incoming: Boolean) {
|
||||
withScheme(linearLayout) { scheme ->
|
||||
val drawable = AppCompatResources
|
||||
.getDrawable(linearLayout.context, R.drawable.reaction_self_background)!!
|
||||
.mutate()
|
||||
val backgroundColor = if (incoming) {
|
||||
scheme.primaryContainer
|
||||
} else {
|
||||
ContextCompat.getColor(
|
||||
linearLayout.context,
|
||||
R.color.bg_message_list_incoming_bubble
|
||||
)
|
||||
}
|
||||
DrawableCompat.setTintList(
|
||||
drawable,
|
||||
ColorStateList.valueOf(backgroundColor)
|
||||
@ -263,6 +283,107 @@ class TalkSpecificViewThemeUtils @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun themeForegroundColorSpan(context: Context): ForegroundColorSpan {
|
||||
return withScheme(context) { scheme ->
|
||||
return@withScheme ForegroundColorSpan(scheme.primary)
|
||||
}
|
||||
}
|
||||
|
||||
fun themeSpotlightView(context: Context, builder: SpotlightView.Builder): SpotlightView.Builder {
|
||||
return withScheme(context) { scheme ->
|
||||
return@withScheme builder.headingTvColor(scheme.primary).lineAndArcColor(scheme.primary)
|
||||
}
|
||||
}
|
||||
|
||||
fun themeAndHighlightText(
|
||||
textView: TextView,
|
||||
originalText: String?,
|
||||
c: String?
|
||||
) {
|
||||
withScheme(textView) { scheme ->
|
||||
var constraint = c
|
||||
constraint = FlexibleUtils.toLowerCase(constraint)
|
||||
var start = FlexibleUtils.toLowerCase(originalText).indexOf(constraint)
|
||||
if (start != -1) {
|
||||
val spanText = Spannable.Factory.getInstance().newSpannable(originalText)
|
||||
do {
|
||||
val end = start + constraint.length
|
||||
spanText.setSpan(
|
||||
ForegroundColorSpan(scheme.primary),
|
||||
start,
|
||||
end,
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
)
|
||||
spanText.setSpan(StyleSpan(Typeface.BOLD), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
start = FlexibleUtils.toLowerCase(originalText)
|
||||
.indexOf(constraint, end + 1) // +1 skips the consecutive span
|
||||
} while (start != -1)
|
||||
textView.setText(spanText, TextView.BufferType.SPANNABLE)
|
||||
} else {
|
||||
textView.setText(originalText, TextView.BufferType.NORMAL)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun themeSortButton(sortButton: MaterialButton) {
|
||||
withScheme(sortButton) { scheme ->
|
||||
sortButton.iconTint = ColorStateList.valueOf(scheme.onSurface)
|
||||
sortButton.setTextColor(scheme.onSurface)
|
||||
}
|
||||
}
|
||||
|
||||
fun themePathNavigationButton(navigationBtn: MaterialButton) {
|
||||
withScheme(navigationBtn) { scheme ->
|
||||
navigationBtn.iconTint = ColorStateList.valueOf(scheme.onSurface)
|
||||
navigationBtn.setTextColor(scheme.onSurface)
|
||||
}
|
||||
}
|
||||
|
||||
fun themeSortListButtonGroup(relativeLayout: RelativeLayout) {
|
||||
withScheme(relativeLayout) { scheme ->
|
||||
relativeLayout.setBackgroundColor(scheme.surface)
|
||||
}
|
||||
}
|
||||
|
||||
fun themeStatusDrawable(context: Context, statusDrawable: StatusDrawable) {
|
||||
withScheme(context) { scheme ->
|
||||
statusDrawable.colorStatusDrawable(scheme.surface)
|
||||
}
|
||||
}
|
||||
|
||||
fun themeMessageCheckMark(imageView: ImageView) {
|
||||
withScheme(imageView) { scheme ->
|
||||
imageView.setColorFilter(
|
||||
scheme.onSurfaceVariant,
|
||||
PorterDuff.Mode.SRC_ATOP
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun themeMarkdown(context: Context, message: String, incoming: Boolean): Spanned {
|
||||
return withScheme(context) { scheme ->
|
||||
return@withScheme if (incoming) {
|
||||
MessageUtils(context).getRenderedMarkdownText(context, message, R.color.nc_incoming_text_default)
|
||||
} else {
|
||||
MessageUtils(context).getRenderedMarkdownText(context, message, scheme.onSurfaceVariant)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getTextColor(
|
||||
isOutgoingMessage: Boolean,
|
||||
isSelfReaction: Boolean,
|
||||
binding: ReactionsInsideMessageBinding,
|
||||
): Int {
|
||||
return withScheme(binding.root) { scheme ->
|
||||
return@withScheme if (!isOutgoingMessage || isSelfReaction) {
|
||||
ContextCompat.getColor(binding.root.context, R.color.high_emphasis_text)
|
||||
} else {
|
||||
scheme.onSurfaceVariant
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val THEMEABLE_PLACEHOLDER_IDS = listOf(
|
||||
R.drawable.ic_mimetype_package_x_generic,
|
||||
|
@ -292,7 +292,7 @@ public class DisplayUtils {
|
||||
|
||||
if (chipXmlRes == R.xml.chip_you) {
|
||||
spannableString.setSpan(
|
||||
new ForegroundColorSpan(viewThemeUtils.getScheme(context).getOnPrimary()),
|
||||
viewThemeUtils.talk.themeForegroundColorSpan(context),
|
||||
start,
|
||||
end,
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
|
@ -40,28 +40,48 @@ import io.noties.markwon.ext.tasklist.TaskListDrawable
|
||||
import io.noties.markwon.ext.tasklist.TaskListPlugin
|
||||
|
||||
class MessageUtils(val context: Context) {
|
||||
fun enrichChatReplyMessageText(context: Context, message: ChatMessage, textColor: Int): Spanned? {
|
||||
fun enrichChatReplyMessageText(
|
||||
context: Context,
|
||||
message: ChatMessage,
|
||||
incoming: Boolean,
|
||||
viewThemeUtils: ViewThemeUtils
|
||||
): Spanned? {
|
||||
return if (message.message == null) {
|
||||
null
|
||||
} else if (message.renderMarkdown == false) {
|
||||
SpannableString(DisplayUtils.ellipsize(message.text, MAX_REPLY_LENGTH))
|
||||
} else {
|
||||
enrichChatMessageText(context, DisplayUtils.ellipsize(message.text, MAX_REPLY_LENGTH), textColor)
|
||||
enrichChatMessageText(
|
||||
context,
|
||||
DisplayUtils.ellipsize(message.text, MAX_REPLY_LENGTH),
|
||||
incoming,
|
||||
viewThemeUtils
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun enrichChatMessageText(context: Context, message: ChatMessage, textColor: Int): Spanned? {
|
||||
fun enrichChatMessageText(
|
||||
context: Context,
|
||||
message: ChatMessage,
|
||||
incoming: Boolean,
|
||||
viewThemeUtils: ViewThemeUtils
|
||||
): Spanned? {
|
||||
return if (message.message == null) {
|
||||
null
|
||||
} else if (message.renderMarkdown == false) {
|
||||
SpannableString(message.message)
|
||||
} else {
|
||||
enrichChatMessageText(context, message.message!!, textColor)
|
||||
enrichChatMessageText(context, message.text, incoming, viewThemeUtils)
|
||||
}
|
||||
}
|
||||
|
||||
private fun enrichChatMessageText(context: Context, message: String, textColor: Int): Spanned {
|
||||
return getRenderedMarkdownText(context, message, textColor)
|
||||
private fun enrichChatMessageText(
|
||||
context: Context,
|
||||
message: String,
|
||||
incoming: Boolean,
|
||||
viewThemeUtils: ViewThemeUtils
|
||||
): Spanned {
|
||||
return viewThemeUtils.talk.themeMarkdown(context, message, incoming)
|
||||
}
|
||||
|
||||
fun processMessageParameters(
|
||||
@ -131,7 +151,7 @@ class MessageUtils(val context: Context) {
|
||||
return messageStringInternal
|
||||
}
|
||||
|
||||
private fun getRenderedMarkdownText(context: Context, markdown: String, textColor: Int): Spanned {
|
||||
fun getRenderedMarkdownText(context: Context, markdown: String, textColor: Int): Spanned {
|
||||
val drawable = TaskListDrawable(textColor, textColor, context.getColor(R.color.bg_default))
|
||||
val markwon = Markwon.builder(context).usePlugin(object : AbstractMarkwonPlugin() {
|
||||
override fun configureTheme(builder: MarkwonTheme.Builder) {
|
||||
|
Loading…
Reference in New Issue
Block a user