From cc0ccdf56c86401e26a5bc8079e7ca3b86669674 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Tue, 12 Mar 2024 20:18:06 +0100 Subject: [PATCH 1/2] Update dependency com.github.nextcloud.android-common:ui to v0.18.0 Signed-off-by: Andy Scherzinger --- app/build.gradle | 2 +- gradle/verification-metadata.xml | 107 ++++++------------------------- 2 files changed, 21 insertions(+), 88 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 12fde2a51c..65d3b8e536 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -312,7 +312,7 @@ dependencies { implementation 'androidx.activity:activity-ktx:1.8.2' - implementation 'com.github.nextcloud.android-common:ui:0.17.0' + implementation 'com.github.nextcloud.android-common:ui:0.18.0' implementation 'com.github.nextcloud-deps:android-talk-webrtc:121.6167.0' } diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index 88a05f24cd..a2150475cc 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -454,6 +454,11 @@ + + + + + @@ -2475,100 +2480,28 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + From 13a5c9444fdc7ce9a74615f257f38b208a24f950 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Tue, 12 Mar 2024 20:19:47 +0100 Subject: [PATCH 2/2] Migrate to latest bottom sheet theming implementation Signed-off-by: Andy Scherzinger --- .../ConversationInfoActivity.kt | 1 + .../ui/bottom/sheet/ProfileBottomSheet.kt | 2 +- .../talk/ui/dialog/AttachmentDialog.kt | 3 +- .../dialog/ConversationsListBottomDialog.kt | 3 +- .../talk/ui/dialog/MessageActionsDialog.kt | 3 +- .../talk/ui/dialog/ShowReactionsDialog.kt | 3 +- .../ui/theme/TalkSpecificViewThemeUtils.kt | 80 +++++++++++-------- 7 files changed, 55 insertions(+), 40 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt b/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt index b3bb5f9f65..7405be5b57 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt @@ -1198,6 +1198,7 @@ class ConversationInfoActivity : cornerRadius(res = R.dimen.corner_radius) title(text = participant.displayName) + viewThemeUtils.material.colorBottomSheetBackground(this.view) listItemsWithImage(items = items) { _, index, _ -> if (index == 0) { removeAttendeeFromConversation(apiVersion, participant) diff --git a/app/src/main/java/com/nextcloud/talk/ui/bottom/sheet/ProfileBottomSheet.kt b/app/src/main/java/com/nextcloud/talk/ui/bottom/sheet/ProfileBottomSheet.kt index 70e655c1f2..a79289ef95 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/bottom/sheet/ProfileBottomSheet.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/bottom/sheet/ProfileBottomSheet.kt @@ -90,7 +90,7 @@ class ProfileBottomSheet(val ncApi: NcApi, val userModel: User, val viewThemeUti MaterialDialog(context, BottomSheet(LayoutMode.WRAP_CONTENT)).show { cornerRadius(res = R.dimen.corner_radius) - viewThemeUtils.platform.themeDialog(this.view) + viewThemeUtils.material.colorBottomSheetBackground(this.view) title(text = displayName) listItemsWithImage(items = items) { _, index, _ -> diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/AttachmentDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/AttachmentDialog.kt index 0db62cacff..31665aad56 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/AttachmentDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/AttachmentDialog.kt @@ -55,7 +55,8 @@ class AttachmentDialog(val activity: Activity, var chatActivity: ChatActivity) : setContentView(dialogAttachmentBinding.root) window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) - viewThemeUtils.platform.themeDialog(dialogAttachmentBinding.root) + viewThemeUtils.material.colorBottomSheetBackground(dialogAttachmentBinding.root) + viewThemeUtils.material.colorBottomSheetDragHandle(dialogAttachmentBinding.bottomSheetDragHandle) initItemsStrings() initItemsVisibility() initItemsClickListeners() diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt index 855030f2da..473527418f 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt @@ -82,7 +82,8 @@ class ConversationsListBottomDialog( setContentView(binding.root) window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) - viewThemeUtils.platform.themeDialog(binding.root) + viewThemeUtils.material.colorBottomSheetBackground(binding.root) + viewThemeUtils.material.colorBottomSheetDragHandle(binding.bottomSheetDragHandle) initHeaderDescription() initItemsVisibility() initClickListeners() diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt index a4a76816f6..d6a482ecf1 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt @@ -117,7 +117,8 @@ class MessageActionsDialog( setContentView(dialogMessageActionsBinding.root) window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) - viewThemeUtils.platform.themeDialog(dialogMessageActionsBinding.root) + viewThemeUtils.material.colorBottomSheetBackground(dialogMessageActionsBinding.root) + viewThemeUtils.material.colorBottomSheetDragHandle(dialogMessageActionsBinding.bottomSheetDragHandle) initEmojiBar(hasChatPermission) initMenuItemCopy(!message.isDeleted) val apiVersion = ApiUtils.getConversationApiVersion(user!!, intArrayOf(ApiUtils.API_V4, ApiUtils.API_V3, 1)) diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/ShowReactionsDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/ShowReactionsDialog.kt index 72d691cdad..a1c57f58d5 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/ShowReactionsDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/ShowReactionsDialog.kt @@ -81,7 +81,8 @@ class ShowReactionsDialog( binding = DialogMessageReactionsBinding.inflate(layoutInflater) setContentView(binding.root) window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) - viewThemeUtils.platform.themeDialog(binding.root) + viewThemeUtils.material.colorBottomSheetBackground(binding.root) + viewThemeUtils.material.colorBottomSheetDragHandle(binding.bottomSheetDragHandle) adapter = ReactionsAdapter(this, user) binding.reactionsList.adapter = adapter binding.reactionsList.layoutManager = LinearLayoutManager(context) diff --git a/app/src/main/java/com/nextcloud/talk/ui/theme/TalkSpecificViewThemeUtils.kt b/app/src/main/java/com/nextcloud/talk/ui/theme/TalkSpecificViewThemeUtils.kt index 98794590b8..ec9f2e2b23 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/theme/TalkSpecificViewThemeUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/theme/TalkSpecificViewThemeUtils.kt @@ -64,6 +64,7 @@ import com.nextcloud.talk.utils.DrawableUtils import com.nextcloud.talk.utils.message.MessageUtils import com.vanniktech.emoji.EmojiTextView import com.wooplr.spotlight.SpotlightView +import dynamiccolor.MaterialDynamicColors import eu.davidea.flexibleadapter.utils.FlexibleUtils import javax.inject.Inject import kotlin.math.roundToInt @@ -78,6 +79,7 @@ class TalkSpecificViewThemeUtils @Inject constructor( private val appcompat: AndroidXViewThemeUtils ) : ViewThemeUtilsBase(schemes) { + private val dynamicColor = MaterialDynamicColors() fun themeIncomingMessageBubble(bubble: View, grouped: Boolean, deleted: Boolean) { val resources = bubble.resources @@ -104,9 +106,9 @@ class TalkSpecificViewThemeUtils @Inject constructor( fun themeOutgoingMessageBubble(bubble: View, grouped: Boolean, deleted: Boolean) { withScheme(bubble) { scheme -> val bgBubbleColor = if (deleted) { - ColorUtils.setAlphaComponent(scheme.surfaceVariant, HALF_ALPHA_INT) + ColorUtils.setAlphaComponent(dynamicColor.surfaceVariant().getArgb(scheme), HALF_ALPHA_INT) } else { - scheme.surfaceVariant + dynamicColor.surfaceVariant().getArgb(scheme) } val layout = if (grouped) { @@ -126,31 +128,31 @@ class TalkSpecificViewThemeUtils @Inject constructor( fun colorOutgoingQuoteText(textView: TextView) { withScheme(textView) { scheme -> - textView.setTextColor(scheme.onSurfaceVariant) + textView.setTextColor(dynamicColor.onSurfaceVariant().getArgb(scheme)) } } fun colorOutgoingQuoteAuthorText(textView: TextView) { withScheme(textView) { scheme -> - ColorUtils.setAlphaComponent(scheme.onSurfaceVariant, ALPHA_80_INT) + ColorUtils.setAlphaComponent(dynamicColor.onSurfaceVariant().getArgb(scheme), ALPHA_80_INT) } } fun colorOutgoingQuoteBackground(view: View) { withScheme(view) { scheme -> - view.setBackgroundColor(scheme.onSurfaceVariant) + view.setBackgroundColor(dynamicColor.onSurfaceVariant().getArgb(scheme)) } } fun colorContactChatItemName(contactName: androidx.emoji2.widget.EmojiTextView) { withScheme(contactName) { scheme -> - contactName.setTextColor(scheme.onPrimaryContainer) + contactName.setTextColor(dynamicColor.onPrimaryContainer().getArgb(scheme)) } } fun colorContactChatItemBackground(card: MaterialCardView) { withScheme(card) { scheme -> - card.setCardBackgroundColor(scheme.primaryContainer) + card.setCardBackgroundColor(dynamicColor.primaryContainer().getArgb(scheme)) } } @@ -166,7 +168,7 @@ class TalkSpecificViewThemeUtils @Inject constructor( .mutate() DrawableCompat.setTintList( drawable, - ColorStateList.valueOf(scheme.primary) + ColorStateList.valueOf(dynamicColor.primary().getArgb(scheme)) ) emoji.background = drawable } @@ -178,7 +180,7 @@ class TalkSpecificViewThemeUtils @Inject constructor( .getDrawable(linearLayout.context, R.drawable.reaction_self_background)!! .mutate() val backgroundColor = if (incoming) { - scheme.primaryContainer + dynamicColor.primaryContainer().getArgb(scheme) } else { ContextCompat.getColor( linearLayout.context, @@ -207,7 +209,7 @@ class TalkSpecificViewThemeUtils @Inject constructor( private fun colorDrawable(context: Context, drawable: Drawable) { withScheme(context) { scheme -> - drawable.setTint(scheme.primary) + drawable.setTint(dynamicColor.primary().getArgb(scheme)) } } @@ -217,9 +219,9 @@ class TalkSpecificViewThemeUtils @Inject constructor( withScheme(avatar) { scheme -> val layers = arrayOfNulls(2) layers[0] = ContextCompat.getDrawable(avatar.context, R.drawable.ic_avatar_background) - layers[0]?.setTint(scheme.surfaceVariant) + layers[0]?.setTint(dynamicColor.surfaceVariant().getArgb(scheme)) layers[1] = ContextCompat.getDrawable(avatar.context, foreground) - layers[1]?.setTint(scheme.onSurfaceVariant) + layers[1]?.setTint(dynamicColor.onSurfaceVariant().getArgb(scheme)) drawable = LayerDrawable(layers) } @@ -231,10 +233,10 @@ class TalkSpecificViewThemeUtils @Inject constructor( // hacky as no default way is provided val editText = searchView.findViewById(R.id.search_src_text) val searchPlate = searchView.findViewById(R.id.search_plate) - editText.setHintTextColor(scheme.onSurfaceVariant) - editText.setTextColor(scheme.onSurface) - editText.setBackgroundColor(scheme.surface) - searchPlate.setBackgroundColor(scheme.surface) + editText.setHintTextColor(dynamicColor.onSurfaceVariant().getArgb(scheme)) + editText.setTextColor(dynamicColor.onSurface().getArgb(scheme)) + editText.setBackgroundColor(dynamicColor.surface().getArgb(scheme)) + searchPlate.setBackgroundColor(dynamicColor.surface().getArgb(scheme)) } } @@ -248,7 +250,7 @@ class TalkSpecificViewThemeUtils @Inject constructor( intArrayOf(-android.R.attr.state_checked) ), intArrayOf( - scheme.secondaryContainer, + dynamicColor.secondaryContainer().getArgb(scheme), background ) ) @@ -259,8 +261,8 @@ class TalkSpecificViewThemeUtils @Inject constructor( intArrayOf(-android.R.attr.state_checked) ), intArrayOf( - scheme.onSecondaryContainer, - scheme.surface + dynamicColor.onSecondaryContainer().getArgb(scheme), + dynamicColor.surface().getArgb(scheme) ) ) ) @@ -269,29 +271,33 @@ class TalkSpecificViewThemeUtils @Inject constructor( fun themeMicInputCloud(micInputCloud: MicInputCloud) { withScheme(micInputCloud) { scheme -> - micInputCloud.setColor(scheme.primary) + micInputCloud.setColor(dynamicColor.primary().getArgb(scheme)) } } fun themeWaveFormSeekBar(waveformSeekBar: WaveformSeekBar) { withScheme(waveformSeekBar) { scheme -> waveformSeekBar.thumb.colorFilter = - PorterDuffColorFilter(scheme.inversePrimary, PorterDuff.Mode.SRC_IN) - waveformSeekBar.setColors(scheme.inversePrimary, scheme.onPrimaryContainer) + PorterDuffColorFilter(dynamicColor.inversePrimary().getArgb(scheme), PorterDuff.Mode.SRC_IN) + waveformSeekBar.setColors( + dynamicColor.inversePrimary().getArgb(scheme), + dynamicColor.onPrimaryContainer().getArgb(scheme) + ) waveformSeekBar.progressDrawable?.colorFilter = - PorterDuffColorFilter(scheme.primary, PorterDuff.Mode.SRC_IN) + PorterDuffColorFilter(dynamicColor.primary().getArgb(scheme), PorterDuff.Mode.SRC_IN) } } fun themeForegroundColorSpan(context: Context): ForegroundColorSpan { return withScheme(context) { scheme -> - return@withScheme ForegroundColorSpan(scheme.primary) + return@withScheme ForegroundColorSpan(dynamicColor.primary().getArgb(scheme)) } } fun themeSpotlightView(context: Context, builder: SpotlightView.Builder): SpotlightView.Builder { return withScheme(context) { scheme -> - return@withScheme builder.headingTvColor(scheme.primary).lineAndArcColor(scheme.primary) + return@withScheme builder.headingTvColor(dynamicColor.primary().getArgb(scheme)) + .lineAndArcColor(dynamicColor.primary().getArgb(scheme)) } } @@ -305,7 +311,7 @@ class TalkSpecificViewThemeUtils @Inject constructor( do { val end = start + constraint.length spanText.setSpan( - ForegroundColorSpan(scheme.primary), + ForegroundColorSpan(dynamicColor.primary().getArgb(scheme)), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE @@ -323,34 +329,34 @@ class TalkSpecificViewThemeUtils @Inject constructor( fun themeSortButton(sortButton: MaterialButton) { withScheme(sortButton) { scheme -> - sortButton.iconTint = ColorStateList.valueOf(scheme.onSurface) - sortButton.setTextColor(scheme.onSurface) + sortButton.iconTint = ColorStateList.valueOf(dynamicColor.onSurface().getArgb(scheme)) + sortButton.setTextColor(dynamicColor.onSurface().getArgb(scheme)) } } fun themePathNavigationButton(navigationBtn: MaterialButton) { withScheme(navigationBtn) { scheme -> - navigationBtn.iconTint = ColorStateList.valueOf(scheme.onSurface) - navigationBtn.setTextColor(scheme.onSurface) + navigationBtn.iconTint = ColorStateList.valueOf(dynamicColor.onSurface().getArgb(scheme)) + navigationBtn.setTextColor(dynamicColor.onSurface().getArgb(scheme)) } } fun themeSortListButtonGroup(relativeLayout: RelativeLayout) { withScheme(relativeLayout) { scheme -> - relativeLayout.setBackgroundColor(scheme.surface) + relativeLayout.setBackgroundColor(dynamicColor.surface().getArgb(scheme)) } } fun themeStatusDrawable(context: Context, statusDrawable: StatusDrawable) { withScheme(context) { scheme -> - statusDrawable.colorStatusDrawable(scheme.surface) + statusDrawable.colorStatusDrawable(dynamicColor.surface().getArgb(scheme)) } } fun themeMessageCheckMark(imageView: ImageView) { withScheme(imageView) { scheme -> imageView.setColorFilter( - scheme.onSurfaceVariant, + dynamicColor.onSurfaceVariant().getArgb(scheme), PorterDuff.Mode.SRC_ATOP ) } @@ -365,7 +371,11 @@ class TalkSpecificViewThemeUtils @Inject constructor( context.getColor(R.color.nc_incoming_text_default) ) } else { - MessageUtils(context).getRenderedMarkdownText(context, message, scheme.onSurfaceVariant) + MessageUtils(context).getRenderedMarkdownText( + context, + message, + dynamicColor.onSurfaceVariant().getArgb(scheme) + ) } } } @@ -375,7 +385,7 @@ class TalkSpecificViewThemeUtils @Inject constructor( return@withScheme if (!isOutgoingMessage || isSelfReaction) { ContextCompat.getColor(binding.root.context, R.color.high_emphasis_text) } else { - scheme.onSurfaceVariant + dynamicColor.onSurfaceVariant().getArgb(scheme) } } }