Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration away from getScheme() calls #3235

Merged
merged 2 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
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
Expand All @@ -65,8 +64,7 @@ public AdvancedUserItem(Participant participant,

@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;
Expand Down Expand Up @@ -107,11 +105,10 @@ public UserItemViewHolder createViewHolder(View view, FlexibleAdapter adapter) {
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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
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
Expand Down Expand Up @@ -74,8 +73,7 @@ public ContactItem(Participant participant,

@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());
}
Expand Down Expand Up @@ -135,10 +133,9 @@ public void bindViewHolder(FlexibleAdapter adapter, ContactItemViewHolder holder
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()) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
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> {
Expand Down Expand Up @@ -103,8 +102,7 @@ public String getDisplayName() {

@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));
}

Expand Down Expand Up @@ -138,18 +136,12 @@ public void bindViewHolder(FlexibleAdapter<IFlexible> adapter,
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
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
Expand Down Expand Up @@ -81,8 +80,7 @@ public Participant getModel() {

@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());
}
Expand Down Expand Up @@ -129,9 +127,8 @@ public void bindViewHolder(FlexibleAdapter adapter, ParticipantItemViewHolder ho
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()) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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(
Expand All @@ -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)
Expand Down Expand Up @@ -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)")
Expand All @@ -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))
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
}
Expand All @@ -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) {
Expand All @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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)
}
}

Expand Down Expand Up @@ -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)
Expand Down
Loading
Loading