ViewThemeUtils: split material utilities into a separate class

Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
Álvaro Brey 2022-08-29 17:26:13 +02:00
parent a2caf425a6
commit 1f32b35117
No known key found for this signature in database
GPG Key ID: 2585783189A62105
44 changed files with 477 additions and 422 deletions

View File

@ -128,11 +128,11 @@ open class BaseActivity : AppCompatActivity() {
sslErrorHandler?.cancel() sslErrorHandler?.cancel()
} }
viewThemeUtils.colorMaterialAlertDialogBackground(context, dialogBuilder) viewThemeUtils.material.colorMaterialAlertDialogBackground(context, dialogBuilder)
val dialog = dialogBuilder.show() val dialog = dialogBuilder.show()
viewThemeUtils.androidViewThemeUtils.colorTextButtons( viewThemeUtils.platform.colorTextButtons(
dialog.getButton(AlertDialog.BUTTON_POSITIVE), dialog.getButton(AlertDialog.BUTTON_POSITIVE),
dialog.getButton(AlertDialog.BUTTON_NEGATIVE) dialog.getButton(AlertDialog.BUTTON_NEGATIVE)
) )

View File

@ -104,7 +104,7 @@ class FullScreenTextViewerActivity : AppCompatActivity() {
supportActionBar?.title = fileName supportActionBar?.title = fileName
supportActionBar?.setDisplayHomeAsUpEnabled(true) supportActionBar?.setDisplayHomeAsUpEnabled(true)
viewThemeUtils.androidViewThemeUtils.themeStatusBar(this, binding.textviewToolbar) viewThemeUtils.platform.themeStatusBar(this, binding.textviewToolbar)
if (resources != null) { if (resources != null) {
DisplayUtils.applyColorToNavigationBar( DisplayUtils.applyColorToNavigationBar(

View File

@ -105,8 +105,8 @@ public class TakePhotoActivity extends AppCompatActivity {
setContentView(binding.getRoot()); setContentView(binding.getRoot());
viewThemeUtils.themeFAB(binding.takePhoto); viewThemeUtils.material.themeFAB(binding.takePhoto);
viewThemeUtils.colorMaterialButtonPrimaryFilled(binding.send); viewThemeUtils.material.colorMaterialButtonPrimaryFilled(binding.send);
cameraProviderFuture = ProcessCameraProvider.getInstance(this); cameraProviderFuture = ProcessCameraProvider.getInstance(this);
cameraProviderFuture.addListener(() -> { cameraProviderFuture.addListener(() -> {

View File

@ -113,7 +113,7 @@ public class ContactItem extends AbstractFlexibleItem<ContactItem.ContactItemVie
holder.binding.avatarDraweeView.setController(null); holder.binding.avatarDraweeView.setController(null);
if (participant.getSelected()) { if (participant.getSelected()) {
viewThemeUtils.androidViewThemeUtils.colorImageView(holder.binding.checkedImageView); viewThemeUtils.platform.colorImageView(holder.binding.checkedImageView);
holder.binding.checkedImageView.setVisibility(View.VISIBLE); holder.binding.checkedImageView.setVisibility(View.VISIBLE);
} else { } else {
holder.binding.checkedImageView.setVisibility(View.GONE); holder.binding.checkedImageView.setVisibility(View.GONE);

View File

@ -168,16 +168,16 @@ public class ConversationItem extends AbstractFlexibleItem<ConversationItem.Conv
R.color.conversation_unread_bubble_text); R.color.conversation_unread_bubble_text);
if (conversation.getType() == Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL) { if (conversation.getType() == Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL) {
viewThemeUtils.colorChipBackground(holder.binding.dialogUnreadBubble); viewThemeUtils.material.colorChipBackground(holder.binding.dialogUnreadBubble);
} else if (conversation.getUnreadMention()) { } else if (conversation.getUnreadMention()) {
if (CapabilitiesUtilNew.hasSpreedFeatureCapability(user, "direct-mention-flag")) { if (CapabilitiesUtilNew.hasSpreedFeatureCapability(user, "direct-mention-flag")) {
if (conversation.getUnreadMentionDirect()) { if (conversation.getUnreadMentionDirect()) {
viewThemeUtils.colorChipBackground(holder.binding.dialogUnreadBubble); viewThemeUtils.material.colorChipBackground(holder.binding.dialogUnreadBubble);
} else { } else {
viewThemeUtils.colorChipOutlined(holder.binding.dialogUnreadBubble, 6.0f); viewThemeUtils.material.colorChipOutlined(holder.binding.dialogUnreadBubble, 6.0f);
} }
} else { } else {
viewThemeUtils.colorChipBackground(holder.binding.dialogUnreadBubble); viewThemeUtils.material.colorChipBackground(holder.binding.dialogUnreadBubble);
} }
} else { } else {
holder.binding.dialogUnreadBubble.setChipBackgroundColor(lightBubbleFillColor); holder.binding.dialogUnreadBubble.setChipBackgroundColor(lightBubbleFillColor);

View File

@ -74,7 +74,7 @@ public class GenericTextHeaderItem extends AbstractHeaderItem<GenericTextHeaderI
Log.d(TAG, "We have payloads, so ignoring!"); Log.d(TAG, "We have payloads, so ignoring!");
} else { } else {
holder.binding.titleTextView.setText(title); holder.binding.titleTextView.setText(title);
viewThemeUtils.androidViewThemeUtils.colorPrimaryTextViewElement(holder.binding.titleTextView); viewThemeUtils.platform.colorPrimaryTextViewElement(holder.binding.titleTextView);
} }
} }

View File

@ -187,7 +187,7 @@ class IncomingLocationMessageViewHolder(incomingView: View, payload: Any) : Mess
.setTextColor(context!!.resources.getColor(R.color.textColorMaxContrast)) .setTextColor(context!!.resources.getColor(R.color.textColorMaxContrast))
if (parentChatMessage.actorId?.equals(message.activeUser!!.userId) == true) { if (parentChatMessage.actorId?.equals(message.activeUser!!.userId) == true) {
viewThemeUtils.androidViewThemeUtils.colorPrimaryView(binding.messageQuote.quoteColoredView) viewThemeUtils.platform.colorPrimaryView(binding.messageQuote.quoteColoredView)
} else { } else {
binding.messageQuote.quoteColoredView.setBackgroundResource(R.color.textColorMaxContrast) binding.messageQuote.quoteColoredView.setBackgroundResource(R.color.textColorMaxContrast)
} }

View File

@ -217,7 +217,7 @@ class IncomingPollMessageViewHolder(incomingView: View, payload: Any) : MessageH
.setTextColor(ContextCompat.getColor(context, R.color.textColorMaxContrast)) .setTextColor(ContextCompat.getColor(context, R.color.textColorMaxContrast))
if (parentChatMessage.actorId?.equals(message.activeUser!!.userId) == true) { if (parentChatMessage.actorId?.equals(message.activeUser!!.userId) == true) {
viewThemeUtils.androidViewThemeUtils.colorPrimaryView(binding.messageQuote.quoteColoredView) viewThemeUtils.platform.colorPrimaryView(binding.messageQuote.quoteColoredView)
} else { } else {
binding.messageQuote.quoteColoredView.setBackgroundResource(R.color.textColorMaxContrast) binding.messageQuote.quoteColoredView.setBackgroundResource(R.color.textColorMaxContrast)
} }

View File

@ -95,8 +95,8 @@ class IncomingVoiceMessageViewHolder(incomingView: View, payload: Any) : Message
updateDownloadState(message) updateDownloadState(message)
binding.seekbar.max = message.voiceMessageDuration binding.seekbar.max = message.voiceMessageDuration
viewThemeUtils.androidViewThemeUtils.themeHorizontalSeekBar(binding.seekbar) viewThemeUtils.platform.themeHorizontalSeekBar(binding.seekbar)
viewThemeUtils.androidViewThemeUtils.colorCircularProgressBarOnSurfaceVariant(binding.progressBar) viewThemeUtils.platform.colorCircularProgressBarOnSurfaceVariant(binding.progressBar)
if (message.isPlayingVoiceMessage) { if (message.isPlayingVoiceMessage) {
showPlayButton() showPlayButton()
@ -292,7 +292,7 @@ class IncomingVoiceMessageViewHolder(incomingView: View, payload: Any) : Message
.setTextColor(ContextCompat.getColor(context!!, R.color.textColorMaxContrast)) .setTextColor(ContextCompat.getColor(context!!, R.color.textColorMaxContrast))
if (parentChatMessage.actorId?.equals(message.activeUser!!.userId) == true) { if (parentChatMessage.actorId?.equals(message.activeUser!!.userId) == true) {
viewThemeUtils.androidViewThemeUtils.colorPrimaryView(binding.messageQuote.quoteColoredView) viewThemeUtils.platform.colorPrimaryView(binding.messageQuote.quoteColoredView)
} else { } else {
binding.messageQuote.quoteColoredView.setBackgroundResource(R.color.textColorMaxContrast) binding.messageQuote.quoteColoredView.setBackgroundResource(R.color.textColorMaxContrast)
} }

View File

@ -163,7 +163,7 @@ class MagicIncomingTextMessageViewHolder(itemView: View, payload: Any) : Message
binding.messageQuote.quotedMessage.text = parentChatMessage.text binding.messageQuote.quotedMessage.text = parentChatMessage.text
if (parentChatMessage.actorId?.equals(message.activeUser!!.userId) == true) { if (parentChatMessage.actorId?.equals(message.activeUser!!.userId) == true) {
viewThemeUtils.androidViewThemeUtils.colorPrimaryView(binding.messageQuote.quoteColoredView) viewThemeUtils.platform.colorPrimaryView(binding.messageQuote.quoteColoredView)
} else { } else {
binding.messageQuote.quoteColoredView.setBackgroundColor( binding.messageQuote.quoteColoredView.setBackgroundColor(
ContextCompat.getColor(binding.messageQuote.quoteColoredView.context, R.color.high_emphasis_text) ContextCompat.getColor(binding.messageQuote.quoteColoredView.context, R.color.high_emphasis_text)

View File

@ -150,7 +150,7 @@ public abstract class MagicPreviewMessageViewHolder extends MessageHolders.Incom
} }
progressBar = getProgressBar(); progressBar = getProgressBar();
viewThemeUtils.androidViewThemeUtils.colorCircularProgressBar(getProgressBar()); viewThemeUtils.platform.colorCircularProgressBar(getProgressBar());
image = getImage(); image = getImage();
clickView = getImage(); clickView = getImage();
getMessageText().setVisibility(View.VISIBLE); getMessageText().setVisibility(View.VISIBLE);
@ -169,7 +169,7 @@ public abstract class MagicPreviewMessageViewHolder extends MessageHolders.Incom
clickView = getPreviewContactContainer(); clickView = getPreviewContactContainer();
viewThemeUtils.colorContactChatItemBackground(getPreviewContactContainer()); viewThemeUtils.colorContactChatItemBackground(getPreviewContactContainer());
viewThemeUtils.colorContactChatItemName(getPreviewContactName()); viewThemeUtils.colorContactChatItemName(getPreviewContactName());
viewThemeUtils.androidViewThemeUtils.colorCircularProgressBarOnPrimaryContainer(getPreviewContactProgressBar()); viewThemeUtils.platform.colorCircularProgressBarOnPrimaryContainer(getPreviewContactProgressBar());
} else { } else {
getPreviewContainer().setVisibility(View.VISIBLE); getPreviewContainer().setVisibility(View.VISIBLE);
getPreviewContactContainer().setVisibility(View.GONE); getPreviewContactContainer().setVisibility(View.GONE);

View File

@ -90,8 +90,8 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) : MessageHolders
updateDownloadState(message) updateDownloadState(message)
binding.seekbar.max = message.voiceMessageDuration binding.seekbar.max = message.voiceMessageDuration
viewThemeUtils.androidViewThemeUtils.themeHorizontalSeekBar(binding.seekbar) viewThemeUtils.platform.themeHorizontalSeekBar(binding.seekbar)
viewThemeUtils.androidViewThemeUtils.colorCircularProgressBarOnSurfaceVariant(binding.progressBar) viewThemeUtils.platform.colorCircularProgressBarOnSurfaceVariant(binding.progressBar)
handleIsPlayingVoiceMessageState(message) handleIsPlayingVoiceMessageState(message)

View File

@ -653,7 +653,7 @@ class ChatController(args: Bundle) :
} }
} }
viewThemeUtils.colorMaterialButtonPrimaryFilled(binding.popupBubbleView) viewThemeUtils.material.colorMaterialButtonPrimaryFilled(binding.popupBubbleView)
binding.messageInputView.setPadding(0, 0, 0, 0) binding.messageInputView.setPadding(0, 0, 0, 0)
@ -877,7 +877,7 @@ class ChatController(args: Bundle) :
.nc_description_send_message_button .nc_description_send_message_button
) )
viewThemeUtils.androidViewThemeUtils.colorImageView(binding.messageInputView.button) viewThemeUtils.platform.colorImageView(binding.messageInputView.button)
if (currentConversation != null && currentConversation?.roomId != null) { if (currentConversation != null && currentConversation?.roomId != null) {
loadAvatarForStatusBar() loadAvatarForStatusBar()
@ -1433,14 +1433,14 @@ class ChatController(args: Bundle) :
// unused atm // unused atm
} }
viewThemeUtils.colorMaterialAlertDialogBackground( viewThemeUtils.material.colorMaterialAlertDialogBackground(
binding.messageInputView.context, binding.messageInputView.context,
materialAlertDialogBuilder materialAlertDialogBuilder
) )
val dialog = materialAlertDialogBuilder.show() val dialog = materialAlertDialogBuilder.show()
viewThemeUtils.androidViewThemeUtils.colorTextButtons( viewThemeUtils.platform.colorTextButtons(
dialog.getButton(AlertDialog.BUTTON_POSITIVE), dialog.getButton(AlertDialog.BUTTON_POSITIVE),
dialog.getButton(AlertDialog.BUTTON_NEGATIVE) dialog.getButton(AlertDialog.BUTTON_NEGATIVE)
) )
@ -1772,7 +1772,7 @@ class ChatController(args: Bundle) :
cancelReply() cancelReply()
} }
viewThemeUtils.androidViewThemeUtils viewThemeUtils.platform
.themeImageButton(binding.messageInputView.findViewById<ImageButton>(R.id.cancelReplyButton)) .themeImageButton(binding.messageInputView.findViewById<ImageButton>(R.id.cancelReplyButton))
cancelNotificationsForCurrentConversation() cancelNotificationsForCurrentConversation()
@ -2524,12 +2524,12 @@ class ChatController(args: Bundle) :
super.onCreateOptionsMenu(menu, inflater) super.onCreateOptionsMenu(menu, inflater)
inflater.inflate(R.menu.menu_conversation, menu) inflater.inflate(R.menu.menu_conversation, menu)
viewThemeUtils.androidViewThemeUtils.colorToolbarMenuIcon( viewThemeUtils.platform.colorToolbarMenuIcon(
binding.messageInputView.context, binding.messageInputView.context,
menu.findItem(R.id.conversation_voice_call) menu.findItem(R.id.conversation_voice_call)
) )
viewThemeUtils.androidViewThemeUtils.colorToolbarMenuIcon( viewThemeUtils.platform.colorToolbarMenuIcon(
binding.messageInputView.context, binding.messageInputView.context,
menu.findItem(R.id.conversation_video_call) menu.findItem(R.id.conversation_video_call)
) )

View File

@ -380,7 +380,7 @@ class ContactsController(args: Bundle) :
super.onPrepareOptionsMenu(menu) super.onPrepareOptionsMenu(menu)
if (searchItem != null) { if (searchItem != null) {
viewThemeUtils.androidViewThemeUtils.colorToolbarMenuIcon( viewThemeUtils.platform.colorToolbarMenuIcon(
binding.titleTextView.context, binding.titleTextView.context,
searchItem!! searchItem!!
) )
@ -638,7 +638,7 @@ class ContactsController(args: Bundle) :
PorterDuff.Mode.SRC_IN PorterDuff.Mode.SRC_IN
) )
viewThemeUtils.androidViewThemeUtils.colorImageViewButton(binding.conversationPrivacyToggle.publicCallLink) viewThemeUtils.platform.colorImageViewButton(binding.conversationPrivacyToggle.publicCallLink)
disengageProgressBar() disengageProgressBar()
} }

View File

@ -227,7 +227,7 @@ class ConversationInfoController(args: Bundle) :
binding.addParticipantsAction.visibility = View.GONE binding.addParticipantsAction.visibility = View.GONE
viewThemeUtils.androidViewThemeUtils.colorCircularProgressBar(binding.progressBar) viewThemeUtils.platform.colorCircularProgressBar(binding.progressBar)
} }
private fun setupWebinaryView() { private fun setupWebinaryView() {
@ -374,9 +374,10 @@ class ConversationInfoController(args: Bundle) :
.setNegativeButton(R.string.nc_cancel) { _, _ -> .setNegativeButton(R.string.nc_cancel) { _, _ ->
// unused atm // unused atm
} }
viewThemeUtils.colorMaterialAlertDialogBackground(binding.conversationInfoName.context, dialogBuilder) viewThemeUtils.material
.colorMaterialAlertDialogBackground(binding.conversationInfoName.context, dialogBuilder)
val dialog = dialogBuilder.show() val dialog = dialogBuilder.show()
viewThemeUtils.androidViewThemeUtils.colorTextButtons( viewThemeUtils.platform.colorTextButtons(
dialog.getButton(AlertDialog.BUTTON_POSITIVE), dialog.getButton(AlertDialog.BUTTON_POSITIVE),
dialog.getButton(AlertDialog.BUTTON_NEGATIVE) dialog.getButton(AlertDialog.BUTTON_NEGATIVE)
) )
@ -545,9 +546,10 @@ class ConversationInfoController(args: Bundle) :
.setNegativeButton(R.string.nc_cancel) { _, _ -> .setNegativeButton(R.string.nc_cancel) { _, _ ->
// unused atm // unused atm
} }
viewThemeUtils.colorMaterialAlertDialogBackground(binding.conversationInfoName.context, dialogBuilder) viewThemeUtils.material
.colorMaterialAlertDialogBackground(binding.conversationInfoName.context, dialogBuilder)
val dialog = dialogBuilder.show() val dialog = dialogBuilder.show()
viewThemeUtils.androidViewThemeUtils.colorTextButtons( viewThemeUtils.platform.colorTextButtons(
dialog.getButton(AlertDialog.BUTTON_POSITIVE), dialog.getButton(AlertDialog.BUTTON_POSITIVE),
dialog.getButton(AlertDialog.BUTTON_NEGATIVE) dialog.getButton(AlertDialog.BUTTON_NEGATIVE)
) )
@ -765,7 +767,8 @@ class ConversationInfoController(args: Bundle) :
DisplayUtils.getImageRequestForUrl( DisplayUtils.getImageRequestForUrl(
ApiUtils.getUrlForAvatar( ApiUtils.getUrlForAvatar(
conversationUser!!.baseUrl, conversationUser!!.baseUrl,
conversation!!.name, true conversation!!.name,
true
), ),
conversationUser conversationUser
) )

View File

@ -274,7 +274,8 @@ class ConversationsListController(bundle: Bundle) :
credentials = ApiUtils.getCredentials(currentUser!!.username, currentUser!!.token) credentials = ApiUtils.getCredentials(currentUser!!.username, currentUser!!.token)
if (activity != null && activity is MainActivity) { if (activity != null && activity is MainActivity) {
loadUserAvatar((activity as MainActivity?)!!.binding.switchAccountButton) loadUserAvatar((activity as MainActivity?)!!.binding.switchAccountButton)
viewThemeUtils.colorMaterialTextButton((activity as MainActivity?)!!.binding.switchAccountButton) viewThemeUtils.material
.colorMaterialTextButton((activity as MainActivity?)!!.binding.switchAccountButton)
} }
fetchData() fetchData()
} }
@ -353,14 +354,14 @@ class ConversationsListController(bundle: Bundle) :
} }
activity.binding.searchText.setOnClickListener { activity.binding.searchText.setOnClickListener {
showSearchView(activity, searchView, searchItem) showSearchView(activity, searchView, searchItem)
viewThemeUtils.androidViewThemeUtils.themeStatusBar(activity, searchView!!) viewThemeUtils.platform.themeStatusBar(activity, searchView!!)
} }
} }
searchView!!.setOnCloseListener { searchView!!.setOnCloseListener {
if (TextUtils.isEmpty(searchView!!.query.toString())) { if (TextUtils.isEmpty(searchView!!.query.toString())) {
searchView!!.onActionViewCollapsed() searchView!!.onActionViewCollapsed()
if (activity != null) { if (activity != null) {
viewThemeUtils.androidViewThemeUtils.resetStatusBar(activity, searchView!!) viewThemeUtils.platform.resetStatusBar(activity, searchView!!)
} }
} else { } else {
searchView!!.post { searchView!!.setQuery(TAG, true) } searchView!!.post { searchView!!.setQuery(TAG, true) }
@ -400,7 +401,7 @@ class ConversationsListController(bundle: Bundle) :
mainActivity.binding.toolbar.visibility = View.GONE mainActivity.binding.toolbar.visibility = View.GONE
mainActivity.binding.searchToolbar.visibility = View.VISIBLE mainActivity.binding.searchToolbar.visibility = View.VISIBLE
if (resources != null) { if (resources != null) {
viewThemeUtils.androidViewThemeUtils viewThemeUtils.platform
.resetStatusBar(mainActivity, mainActivity.binding.searchToolbar) .resetStatusBar(mainActivity, mainActivity.binding.searchToolbar)
} }
} }
@ -671,7 +672,7 @@ class ConversationsListController(bundle: Bundle) :
run(context) run(context)
showNewConversationsScreen() showNewConversationsScreen()
} }
viewThemeUtils.themeFAB(binding.floatingActionButton) viewThemeUtils.material.themeFAB(binding.floatingActionButton)
if (activity != null && activity is MainActivity) { if (activity != null && activity is MainActivity) {
val activity = activity as MainActivity? val activity = activity as MainActivity?
activity!!.binding.switchAccountButton.setOnClickListener { activity!!.binding.switchAccountButton.setOnClickListener {
@ -696,7 +697,7 @@ class ConversationsListController(bundle: Bundle) :
nextUnreadConversationScrollPosition nextUnreadConversationScrollPosition
) )
} }
viewThemeUtils.colorMaterialButtonPrimaryFilled(binding.newMentionPopupBubble) viewThemeUtils.material.colorMaterialButtonPrimaryFilled(binding.newMentionPopupBubble)
} }
@Suppress("Detekt.TooGenericExceptionCaught") @Suppress("Detekt.TooGenericExceptionCaught")
@ -949,9 +950,10 @@ class ConversationsListController(bundle: Bundle) :
Log.d(TAG, "sharing files aborted, going back to share-to screen") Log.d(TAG, "sharing files aborted, going back to share-to screen")
showShareToScreen = true showShareToScreen = true
} }
viewThemeUtils.colorMaterialAlertDialogBackground(binding.floatingActionButton.context, dialogBuilder) viewThemeUtils.material
.colorMaterialAlertDialogBackground(binding.floatingActionButton.context, dialogBuilder)
val dialog = dialogBuilder.show() val dialog = dialogBuilder.show()
viewThemeUtils.androidViewThemeUtils.colorTextButtons( viewThemeUtils.platform.colorTextButtons(
dialog.getButton(AlertDialog.BUTTON_POSITIVE), dialog.getButton(AlertDialog.BUTTON_POSITIVE),
dialog.getButton(AlertDialog.BUTTON_NEGATIVE) dialog.getButton(AlertDialog.BUTTON_NEGATIVE)
) )
@ -1145,9 +1147,10 @@ class ConversationsListController(bundle: Bundle) :
.setNegativeButton(R.string.nc_cancel) { _, _ -> .setNegativeButton(R.string.nc_cancel) { _, _ ->
conversationMenuBundle = null conversationMenuBundle = null
} }
viewThemeUtils.colorMaterialAlertDialogBackground(binding.floatingActionButton.context, dialogBuilder) viewThemeUtils.material
.colorMaterialAlertDialogBackground(binding.floatingActionButton.context, dialogBuilder)
val dialog = dialogBuilder.show() val dialog = dialogBuilder.show()
viewThemeUtils.androidViewThemeUtils.colorTextButtons( viewThemeUtils.platform.colorTextButtons(
dialog.getButton(AlertDialog.BUTTON_POSITIVE), dialog.getButton(AlertDialog.BUTTON_POSITIVE),
dialog.getButton(AlertDialog.BUTTON_NEGATIVE) dialog.getButton(AlertDialog.BUTTON_NEGATIVE)
) )
@ -1188,9 +1191,10 @@ class ConversationsListController(bundle: Bundle) :
.popChangeHandler(VerticalChangeHandler()) .popChangeHandler(VerticalChangeHandler())
) )
} }
viewThemeUtils.colorMaterialAlertDialogBackground(binding.floatingActionButton.context, dialogBuilder) viewThemeUtils.material
.colorMaterialAlertDialogBackground(binding.floatingActionButton.context, dialogBuilder)
val dialog = dialogBuilder.show() val dialog = dialogBuilder.show()
viewThemeUtils.androidViewThemeUtils.colorTextButtons( viewThemeUtils.platform.colorTextButtons(
dialog.getButton(AlertDialog.BUTTON_POSITIVE), dialog.getButton(AlertDialog.BUTTON_POSITIVE),
dialog.getButton(AlertDialog.BUTTON_NEGATIVE) dialog.getButton(AlertDialog.BUTTON_NEGATIVE)
) )
@ -1230,9 +1234,9 @@ class ConversationsListController(bundle: Bundle) :
activity!!.finish() activity!!.finish()
} }
} }
viewThemeUtils.colorMaterialAlertDialogBackground(binding.floatingActionButton.context, dialogBuilder) viewThemeUtils.material.colorMaterialAlertDialogBackground(binding.floatingActionButton.context, dialogBuilder)
val dialog = dialogBuilder.show() val dialog = dialogBuilder.show()
viewThemeUtils.androidViewThemeUtils.colorTextButtons( viewThemeUtils.platform.colorTextButtons(
dialog.getButton(AlertDialog.BUTTON_POSITIVE), dialog.getButton(AlertDialog.BUTTON_POSITIVE),
dialog.getButton(AlertDialog.BUTTON_NEGATIVE) dialog.getButton(AlertDialog.BUTTON_NEGATIVE)
) )

View File

@ -261,10 +261,10 @@ class ProfileController : BaseController(R.layout.controller_profile) {
} }
private fun colorIcons() { private fun colorIcons() {
viewThemeUtils.themeFAB(binding.avatarChoose) viewThemeUtils.material.themeFAB(binding.avatarChoose)
viewThemeUtils.themeFAB(binding.avatarCamera) viewThemeUtils.material.themeFAB(binding.avatarCamera)
viewThemeUtils.themeFAB(binding.avatarUpload) viewThemeUtils.material.themeFAB(binding.avatarUpload)
viewThemeUtils.themeFAB(binding.avatarDelete) viewThemeUtils.material.themeFAB(binding.avatarDelete)
} }
private fun isAllEmpty(items: Array<String?>): Boolean { private fun isAllEmpty(items: Array<String?>): Boolean {
@ -755,10 +755,10 @@ class ProfileController : BaseController(R.layout.controller_profile) {
initUserInfoEditText(holder, item) initUserInfoEditText(holder, item)
holder.binding.icon.contentDescription = item.hint holder.binding.icon.contentDescription = item.hint
viewThemeUtils.androidViewThemeUtils.colorImageView(holder.binding.icon) viewThemeUtils.platform.colorImageView(holder.binding.icon)
if (!TextUtils.isEmpty(item.text) || controller.edit) { if (!TextUtils.isEmpty(item.text) || controller.edit) {
holder.binding.userInfoDetailContainer.visibility = View.VISIBLE holder.binding.userInfoDetailContainer.visibility = View.VISIBLE
controller.viewThemeUtils.colorTextInputLayout(holder.binding.userInfoInputLayout) controller.viewThemeUtils.material.colorTextInputLayout(holder.binding.userInfoInputLayout)
if (controller.edit && if (controller.edit &&
controller.editableFields.contains(item.field.toString().lowercase()) controller.editableFields.contains(item.field.toString().lowercase())
) { ) {

View File

@ -385,14 +385,14 @@ class SettingsController : BaseController(R.layout.controller_settings) {
// unused atm // unused atm
} }
viewThemeUtils.colorMaterialAlertDialogBackground( viewThemeUtils.material.colorMaterialAlertDialogBackground(
binding.messageText.context, binding.messageText.context,
materialAlertDialogBuilder materialAlertDialogBuilder
) )
val dialog = materialAlertDialogBuilder.show() val dialog = materialAlertDialogBuilder.show()
viewThemeUtils.androidViewThemeUtils.colorTextButtons( viewThemeUtils.platform.colorTextButtons(
dialog.getButton(AlertDialog.BUTTON_POSITIVE), dialog.getButton(AlertDialog.BUTTON_POSITIVE),
dialog.getButton(AlertDialog.BUTTON_NEGATIVE) dialog.getButton(AlertDialog.BUTTON_NEGATIVE)
) )
@ -952,7 +952,7 @@ class SettingsController : BaseController(R.layout.controller_settings) {
.setPositiveButton(context!!.resources.getString(R.string.nc_common_set), null) .setPositiveButton(context!!.resources.getString(R.string.nc_common_set), null)
.setNegativeButton(context!!.resources.getString(R.string.nc_common_skip), null) .setNegativeButton(context!!.resources.getString(R.string.nc_common_skip), null)
viewThemeUtils.colorMaterialAlertDialogBackground(phoneNumberInputLayout.context, dialogBuilder) viewThemeUtils.material.colorMaterialAlertDialogBackground(phoneNumberInputLayout.context, dialogBuilder)
val dialog = dialogBuilder.create() val dialog = dialogBuilder.create()
dialog.setOnShowListener(object : OnShowListener { dialog.setOnShowListener(object : OnShowListener {
@ -968,7 +968,7 @@ class SettingsController : BaseController(R.layout.controller_settings) {
dialog.show() dialog.show()
viewThemeUtils.androidViewThemeUtils.colorTextButtons( viewThemeUtils.platform.colorTextButtons(
dialog.getButton(AlertDialog.BUTTON_POSITIVE), dialog.getButton(AlertDialog.BUTTON_POSITIVE),
dialog.getButton(AlertDialog.BUTTON_NEGATIVE) dialog.getButton(AlertDialog.BUTTON_NEGATIVE)
) )

View File

@ -123,9 +123,9 @@ abstract class BaseController(@LayoutRes var layoutRes: Int, args: Bundle? = nul
if (getActivity() != null && getActivity() is MainActivity) { if (getActivity() != null && getActivity() is MainActivity) {
activity = getActivity() as MainActivity? activity = getActivity() as MainActivity?
viewThemeUtils.themeCardView(activity!!.binding.searchToolbar) viewThemeUtils.material.themeCardView(activity!!.binding.searchToolbar)
viewThemeUtils.themeToolbar(activity.binding.toolbar) viewThemeUtils.material.themeToolbar(activity.binding.toolbar)
viewThemeUtils.themeSearchBarText(activity.binding.searchText) viewThemeUtils.material.themeSearchBarText(activity.binding.searchText)
} }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && appPreferences.isKeyboardIncognito) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && appPreferences.isKeyboardIncognito) {
@ -188,7 +188,7 @@ abstract class BaseController(@LayoutRes var layoutRes: Int, args: Bundle? = nul
val layoutParams = binding.searchToolbar.layoutParams as AppBarLayout.LayoutParams val layoutParams = binding.searchToolbar.layoutParams as AppBarLayout.LayoutParams
binding.searchToolbar.visibility = View.GONE binding.searchToolbar.visibility = View.GONE
binding.toolbar.visibility = View.VISIBLE binding.toolbar.visibility = View.VISIBLE
viewThemeUtils.colorToolbarOverflowIcon(binding.toolbar) viewThemeUtils.material.colorToolbarOverflowIcon(binding.toolbar)
layoutParams.scrollFlags = 0 layoutParams.scrollFlags = 0
binding.appBar.stateListAnimator = AnimatorInflater.loadStateListAnimator( binding.appBar.stateListAnimator = AnimatorInflater.loadStateListAnimator(
binding.appBar.context, binding.appBar.context,
@ -217,9 +217,9 @@ abstract class BaseController(@LayoutRes var layoutRes: Int, args: Bundle? = nul
private fun colorizeStatusBar(showSearchBar: Boolean, activity: Activity?, resources: Resources?) { private fun colorizeStatusBar(showSearchBar: Boolean, activity: Activity?, resources: Resources?) {
if (activity != null && resources != null) { if (activity != null && resources != null) {
if (showSearchBar) { if (showSearchBar) {
view?.let { viewThemeUtils.androidViewThemeUtils.resetStatusBar(activity, it) } view?.let { viewThemeUtils.platform.resetStatusBar(activity, it) }
} else { } else {
view?.let { viewThemeUtils.androidViewThemeUtils.themeStatusBar(activity, it) } view?.let { viewThemeUtils.platform.themeStatusBar(activity, it) }
} }
} }
} }

View File

@ -126,7 +126,7 @@ class EntryMenuController(args: Bundle) :
rootView = view, rootView = view,
editText = binding.textEdit, editText = binding.textEdit,
onEmojiPopupShownListener = { onEmojiPopupShownListener = {
viewThemeUtils.androidViewThemeUtils.colorImageView(binding.smileyButton) viewThemeUtils.platform.colorImageView(binding.smileyButton)
}, },
onEmojiPopupDismissListener = { onEmojiPopupDismissListener = {
binding.smileyButton.imageTintList = ColorStateList.valueOf( binding.smileyButton.imageTintList = ColorStateList.valueOf(
@ -166,8 +166,8 @@ class EntryMenuController(args: Bundle) :
binding.textInputLayout.endIconMode = TextInputLayout.END_ICON_NONE binding.textInputLayout.endIconMode = TextInputLayout.END_ICON_NONE
} }
viewThemeUtils.colorTextInputLayout(binding.textInputLayout) viewThemeUtils.material.colorTextInputLayout(binding.textInputLayout)
viewThemeUtils.colorMaterialButtonText(binding.okButton) viewThemeUtils.material.colorMaterialButtonText(binding.okButton)
binding.textInputLayout.hint = labelText binding.textInputLayout.hint = labelText
binding.textInputLayout.requestFocus() binding.textInputLayout.requestFocus()

View File

@ -117,7 +117,7 @@ class OperationsMenuController(args: Bundle) : BaseController(
sharedApplication!!.componentApplication.inject(this) sharedApplication!!.componentApplication.inject(this)
currentUser = userManager.currentUser.blockingGet() currentUser = userManager.currentUser.blockingGet()
viewThemeUtils.androidViewThemeUtils.colorCircularProgressBar(binding.progressBar) viewThemeUtils.platform.colorCircularProgressBar(binding.progressBar)
if (!TextUtils.isEmpty(callUrl) && callUrl.contains("/call")) { if (!TextUtils.isEmpty(callUrl) && callUrl.contains("/call")) {
conversationToken = callUrl.substring(callUrl.lastIndexOf("/") + 1) conversationToken = callUrl.substring(callUrl.lastIndexOf("/") + 1)

View File

@ -50,7 +50,7 @@ class PollCreateOptionViewHolder(
} }
binding.pollOptionTextEdit.setText(pollCreateOptionItem.pollOption) binding.pollOptionTextEdit.setText(pollCreateOptionItem.pollOption)
viewThemeUtils.colorTextInputLayout(binding.pollOptionTextInputLayout) viewThemeUtils.material.colorTextInputLayout(binding.pollOptionTextInputLayout)
if (focus) { if (focus) {
itemsListener.requestFocus(binding.pollOptionTextEdit) itemsListener.requestFocus(binding.pollOptionTextEdit)

View File

@ -34,7 +34,7 @@ class PollResultHeaderViewHolder(
override fun bind(pollResultItem: PollResultItem, clickListener: PollResultItemClickListener) { override fun bind(pollResultItem: PollResultItem, clickListener: PollResultItemClickListener) {
val item = pollResultItem as PollResultHeaderItem val item = pollResultItem as PollResultHeaderItem
viewThemeUtils.colorProgressBar(binding.pollOptionBar) viewThemeUtils.material.colorProgressBar(binding.pollOptionBar)
binding.root.setOnClickListener { clickListener.onClick() } binding.root.setOnClickListener { clickListener.onClick() }

View File

@ -75,7 +75,7 @@ class PollCreateDialogFragment : DialogFragment(), PollCreateOptionsItemListener
val dialogBuilder = MaterialAlertDialogBuilder(binding.root.context) val dialogBuilder = MaterialAlertDialogBuilder(binding.root.context)
.setView(binding.root) .setView(binding.root)
viewThemeUtils.colorMaterialAlertDialogBackground(binding.root.context, dialogBuilder) viewThemeUtils.material.colorMaterialAlertDialogBackground(binding.root.context, dialogBuilder)
return dialogBuilder.create() return dialogBuilder.create()
} }
@ -101,18 +101,18 @@ class PollCreateDialogFragment : DialogFragment(), PollCreateOptionsItemListener
} }
private fun themeDialog() { private fun themeDialog() {
viewThemeUtils.androidViewThemeUtils.colorPrimaryTextViewElement(binding.pollQuestion) viewThemeUtils.platform.colorPrimaryTextViewElement(binding.pollQuestion)
viewThemeUtils.androidViewThemeUtils.colorPrimaryTextViewElement(binding.pollOptions) viewThemeUtils.platform.colorPrimaryTextViewElement(binding.pollOptions)
viewThemeUtils.androidViewThemeUtils.colorPrimaryTextViewElement(binding.pollSettings) viewThemeUtils.platform.colorPrimaryTextViewElement(binding.pollSettings)
viewThemeUtils.colorTextInputLayout(binding.pollCreateQuestionTextInputLayout) viewThemeUtils.material.colorTextInputLayout(binding.pollCreateQuestionTextInputLayout)
viewThemeUtils.colorMaterialButtonText(binding.pollAddOptionsItem) viewThemeUtils.material.colorMaterialButtonText(binding.pollAddOptionsItem)
viewThemeUtils.colorMaterialButtonText(binding.pollDismiss) viewThemeUtils.material.colorMaterialButtonText(binding.pollDismiss)
viewThemeUtils.colorMaterialButtonPrimaryFilled(binding.pollCreateButton) viewThemeUtils.material.colorMaterialButtonPrimaryFilled(binding.pollCreateButton)
viewThemeUtils.androidViewThemeUtils.themeCheckbox(binding.pollPrivatePollCheckbox) viewThemeUtils.platform.themeCheckbox(binding.pollPrivatePollCheckbox)
viewThemeUtils.androidViewThemeUtils.themeCheckbox(binding.pollMultipleAnswersCheckbox) viewThemeUtils.platform.themeCheckbox(binding.pollMultipleAnswersCheckbox)
} }
private fun setupListeners() { private fun setupListeners() {

View File

@ -55,7 +55,7 @@ class PollLoadingFragment : Fragment() {
): View { ): View {
binding = DialogPollLoadingBinding.inflate(inflater, container, false) binding = DialogPollLoadingBinding.inflate(inflater, container, false)
binding.root.layoutParams.height = fragmentHeight binding.root.layoutParams.height = fragmentHeight
viewThemeUtils.androidViewThemeUtils.colorCircularProgressBar(binding.pollLoadingProgressbar) viewThemeUtils.platform.colorCircularProgressBar(binding.pollLoadingProgressbar)
return binding.root return binding.root
} }

View File

@ -72,7 +72,7 @@ class PollMainDialogFragment : DialogFragment() {
val dialogBuilder = MaterialAlertDialogBuilder(binding.root.context).setView(binding.root) val dialogBuilder = MaterialAlertDialogBuilder(binding.root.context).setView(binding.root)
viewThemeUtils.colorMaterialAlertDialogBackground(binding.root.context, dialogBuilder) viewThemeUtils.material.colorMaterialAlertDialogBackground(binding.root.context, dialogBuilder)
val dialog = dialogBuilder.create() val dialog = dialogBuilder.create()

View File

@ -99,8 +99,8 @@ class PollResultsFragment : Fragment(), PollResultItemClickListener {
} }
private fun themeDialog() { private fun themeDialog() {
viewThemeUtils.colorMaterialButtonPrimaryFilled(binding.editVoteButton) viewThemeUtils.material.colorMaterialButtonPrimaryFilled(binding.editVoteButton)
viewThemeUtils.colorMaterialButtonPrimaryBorderless(binding.pollResultsEndPollButton) viewThemeUtils.material.colorMaterialButtonPrimaryBorderless(binding.pollResultsEndPollButton)
} }
private fun initAdapter() { private fun initAdapter() {
@ -132,14 +132,14 @@ class PollResultsFragment : Fragment(), PollResultItemClickListener {
} }
.setNegativeButton(R.string.nc_cancel, null) .setNegativeButton(R.string.nc_cancel, null)
viewThemeUtils.colorMaterialAlertDialogBackground( viewThemeUtils.material.colorMaterialAlertDialogBackground(
binding.pollResultsEndPollButton.context, binding.pollResultsEndPollButton.context,
dialogBuilder dialogBuilder
) )
val dialog = dialogBuilder.show() val dialog = dialogBuilder.show()
viewThemeUtils.androidViewThemeUtils.colorTextButtons( viewThemeUtils.platform.colorTextButtons(
dialog.getButton(AlertDialog.BUTTON_POSITIVE), dialog.getButton(AlertDialog.BUTTON_POSITIVE),
dialog.getButton(AlertDialog.BUTTON_NEGATIVE) dialog.getButton(AlertDialog.BUTTON_NEGATIVE)
) )

View File

@ -127,9 +127,9 @@ class PollVoteFragment : Fragment() {
} }
private fun themeDialog() { private fun themeDialog() {
viewThemeUtils.colorMaterialButtonPrimaryFilled(binding.pollVoteSubmitButton) viewThemeUtils.material.colorMaterialButtonPrimaryFilled(binding.pollVoteSubmitButton)
viewThemeUtils.colorMaterialButtonText(binding.pollVoteEndPollButton) viewThemeUtils.material.colorMaterialButtonText(binding.pollVoteEndPollButton)
viewThemeUtils.colorMaterialButtonPrimaryOutlined(binding.pollVoteEditDismiss) viewThemeUtils.material.colorMaterialButtonPrimaryOutlined(binding.pollVoteEditDismiss)
} }
private fun updateDismissEditButton(showDismissEditButton: Boolean) { private fun updateDismissEditButton(showDismissEditButton: Boolean) {
@ -149,7 +149,7 @@ class PollVoteFragment : Fragment() {
RadioButton(context).apply { text = option } RadioButton(context).apply { text = option }
}?.forEachIndexed { index, radioButton -> }?.forEachIndexed { index, radioButton ->
radioButton.id = index radioButton.id = index
viewThemeUtils.androidViewThemeUtils.themeRadioButton(radioButton) viewThemeUtils.platform.themeRadioButton(radioButton)
makeOptionBoldIfSelfVoted(radioButton, poll, index) makeOptionBoldIfSelfVoted(radioButton, poll, index)
binding.pollVoteRadioGroup.addView(radioButton) binding.pollVoteRadioGroup.addView(radioButton)
@ -170,7 +170,7 @@ class PollVoteFragment : Fragment() {
setLayoutParams(layoutParams) setLayoutParams(layoutParams)
} }
}?.forEachIndexed { index, checkBox -> }?.forEachIndexed { index, checkBox ->
viewThemeUtils.androidViewThemeUtils.themeCheckbox(checkBox) viewThemeUtils.platform.themeCheckbox(checkBox)
checkBox.id = index checkBox.id = index
makeOptionBoldIfSelfVoted(checkBox, poll, index) makeOptionBoldIfSelfVoted(checkBox, poll, index)
binding.voteOptionsCheckboxesWrapper.addView(checkBox) binding.voteOptionsCheckboxesWrapper.addView(checkBox)
@ -215,14 +215,14 @@ class PollVoteFragment : Fragment() {
} }
.setNegativeButton(R.string.nc_cancel, null) .setNegativeButton(R.string.nc_cancel, null)
viewThemeUtils.colorMaterialAlertDialogBackground( viewThemeUtils.material.colorMaterialAlertDialogBackground(
binding.pollVoteEndPollButton.context, binding.pollVoteEndPollButton.context,
dialogBuilder dialogBuilder
) )
val dialog = dialogBuilder.show() val dialog = dialogBuilder.show()
viewThemeUtils.androidViewThemeUtils.colorTextButtons( viewThemeUtils.platform.colorTextButtons(
dialog.getButton(AlertDialog.BUTTON_POSITIVE), dialog.getButton(AlertDialog.BUTTON_POSITIVE),
dialog.getButton(AlertDialog.BUTTON_NEGATIVE) dialog.getButton(AlertDialog.BUTTON_NEGATIVE)
) )

View File

@ -75,16 +75,16 @@ class RemoteFileBrowserActivity : AppCompatActivity(), SelectionInterface, Swipe
binding = ActivityRemoteFileBrowserBinding.inflate(layoutInflater) binding = ActivityRemoteFileBrowserBinding.inflate(layoutInflater)
setSupportActionBar(binding.remoteFileBrowserItemsToolbar) setSupportActionBar(binding.remoteFileBrowserItemsToolbar)
viewThemeUtils.themeToolbar(binding.remoteFileBrowserItemsToolbar) viewThemeUtils.material.themeToolbar(binding.remoteFileBrowserItemsToolbar)
val scheme = viewThemeUtils.getScheme(binding.sortListButtonGroup.context) val scheme = viewThemeUtils.getScheme(binding.sortListButtonGroup.context)
binding.sortListButtonGroup.setBackgroundColor(scheme.surface) binding.sortListButtonGroup.setBackgroundColor(scheme.surface)
binding.sortButton.iconTint = ColorStateList.valueOf(scheme.onSurface) binding.sortButton.iconTint = ColorStateList.valueOf(scheme.onSurface)
binding.sortButton.setTextColor(scheme.onSurface) binding.sortButton.setTextColor(scheme.onSurface)
viewThemeUtils.colorMaterialTextButton(binding.sortButton) viewThemeUtils.material.colorMaterialTextButton(binding.sortButton)
binding.pathNavigationBackButton.iconTint = ColorStateList.valueOf(scheme.onSurface) binding.pathNavigationBackButton.iconTint = ColorStateList.valueOf(scheme.onSurface)
binding.pathNavigationBackButton.setTextColor(scheme.onSurface) binding.pathNavigationBackButton.setTextColor(scheme.onSurface)
viewThemeUtils.colorMaterialTextButton(binding.pathNavigationBackButton) viewThemeUtils.material.colorMaterialTextButton(binding.pathNavigationBackButton)
viewThemeUtils.androidViewThemeUtils.themeStatusBar(this, binding.remoteFileBrowserItemsToolbar) viewThemeUtils.platform.themeStatusBar(this, binding.remoteFileBrowserItemsToolbar)
setContentView(binding.root) setContentView(binding.root)
DisplayUtils.applyColorToNavigationBar( DisplayUtils.applyColorToNavigationBar(

View File

@ -129,7 +129,7 @@ class RemoteFileBrowserItemsListViewHolder(
private fun setSelectability() { private fun setSelectability() {
if (selectable) { if (selectable) {
binding.selectFileCheckbox.visibility = View.VISIBLE binding.selectFileCheckbox.visibility = View.VISIBLE
viewThemeUtils.androidViewThemeUtils.themeCheckbox(binding.selectFileCheckbox) viewThemeUtils.platform.themeCheckbox(binding.selectFileCheckbox)
} else { } else {
binding.selectFileCheckbox.visibility = View.GONE binding.selectFileCheckbox.visibility = View.GONE
} }

View File

@ -73,9 +73,9 @@ class SharedItemsActivity : AppCompatActivity() {
setSupportActionBar(binding.sharedItemsToolbar) setSupportActionBar(binding.sharedItemsToolbar)
setContentView(binding.root) setContentView(binding.root)
viewThemeUtils.androidViewThemeUtils.themeStatusBar(this, binding.sharedItemsToolbar) viewThemeUtils.platform.themeStatusBar(this, binding.sharedItemsToolbar)
viewThemeUtils.themeToolbar(binding.sharedItemsToolbar) viewThemeUtils.material.themeToolbar(binding.sharedItemsToolbar)
viewThemeUtils.themeTabLayoutOnSurface(binding.sharedItemsTabs) viewThemeUtils.material.themeTabLayoutOnSurface(binding.sharedItemsTabs)
DisplayUtils.applyColorToNavigationBar( DisplayUtils.applyColorToNavigationBar(
this.window, this.window,
@ -146,7 +146,7 @@ class SharedItemsActivity : AppCompatActivity() {
else -> {} else -> {}
} }
viewThemeUtils.themeTabLayoutOnSurface(binding.sharedItemsTabs) viewThemeUtils.material.themeTabLayoutOnSurface(binding.sharedItemsTabs)
} }
private fun clearEmptyLoading() { private fun clearEmptyLoading() {

View File

@ -53,7 +53,7 @@ class AttachmentDialog(val activity: Activity, var chatController: ChatControlle
setContentView(dialogAttachmentBinding.root) setContentView(dialogAttachmentBinding.root)
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
viewThemeUtils.androidViewThemeUtils.themeDialog(dialogAttachmentBinding.root) viewThemeUtils.platform.themeDialog(dialogAttachmentBinding.root)
initItemsStrings() initItemsStrings()
initItemsVisibility() initItemsVisibility()
initItemsClickListeners() initItemsClickListeners()

View File

@ -51,7 +51,7 @@ class AudioOutputDialog(val callActivity: CallActivity) : BottomSheetDialog(call
setContentView(dialogAudioOutputBinding.root) setContentView(dialogAudioOutputBinding.root)
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
viewThemeUtils.androidViewThemeUtils.themeDialogDark(dialogAudioOutputBinding.root) viewThemeUtils.platform.themeDialogDark(dialogAudioOutputBinding.root)
updateOutputDeviceList() updateOutputDeviceList()
initClickListeners() initClickListeners()
} }
@ -92,27 +92,27 @@ class AudioOutputDialog(val callActivity: CallActivity) : BottomSheetDialog(call
private fun highlightActiveOutputChannel() { private fun highlightActiveOutputChannel() {
when (callActivity.audioManager?.currentAudioDevice) { when (callActivity.audioManager?.currentAudioDevice) {
WebRtcAudioManager.AudioDevice.BLUETOOTH -> { WebRtcAudioManager.AudioDevice.BLUETOOTH -> {
viewThemeUtils.androidViewThemeUtils.colorImageView(dialogAudioOutputBinding.audioOutputBluetoothIcon) viewThemeUtils.platform.colorImageView(dialogAudioOutputBinding.audioOutputBluetoothIcon)
viewThemeUtils.androidViewThemeUtils viewThemeUtils.platform
.colorPrimaryTextViewElementDarkMode(dialogAudioOutputBinding.audioOutputBluetoothText) .colorPrimaryTextViewElementDarkMode(dialogAudioOutputBinding.audioOutputBluetoothText)
} }
WebRtcAudioManager.AudioDevice.SPEAKER_PHONE -> { WebRtcAudioManager.AudioDevice.SPEAKER_PHONE -> {
viewThemeUtils.androidViewThemeUtils.colorImageView(dialogAudioOutputBinding.audioOutputSpeakerIcon) viewThemeUtils.platform.colorImageView(dialogAudioOutputBinding.audioOutputSpeakerIcon)
viewThemeUtils.androidViewThemeUtils viewThemeUtils.platform
.colorPrimaryTextViewElementDarkMode(dialogAudioOutputBinding.audioOutputSpeakerText) .colorPrimaryTextViewElementDarkMode(dialogAudioOutputBinding.audioOutputSpeakerText)
} }
WebRtcAudioManager.AudioDevice.EARPIECE -> { WebRtcAudioManager.AudioDevice.EARPIECE -> {
viewThemeUtils.androidViewThemeUtils.colorImageView(dialogAudioOutputBinding.audioOutputEarspeakerIcon) viewThemeUtils.platform.colorImageView(dialogAudioOutputBinding.audioOutputEarspeakerIcon)
viewThemeUtils.androidViewThemeUtils viewThemeUtils.platform
.colorPrimaryTextViewElementDarkMode(dialogAudioOutputBinding.audioOutputEarspeakerText) .colorPrimaryTextViewElementDarkMode(dialogAudioOutputBinding.audioOutputEarspeakerText)
} }
WebRtcAudioManager.AudioDevice.WIRED_HEADSET -> { WebRtcAudioManager.AudioDevice.WIRED_HEADSET -> {
viewThemeUtils.androidViewThemeUtils viewThemeUtils.platform
.colorImageView(dialogAudioOutputBinding.audioOutputWiredHeadsetIcon) .colorImageView(dialogAudioOutputBinding.audioOutputWiredHeadsetIcon)
viewThemeUtils.androidViewThemeUtils viewThemeUtils.platform
.colorPrimaryTextViewElementDarkMode(dialogAudioOutputBinding.audioOutputWiredHeadsetText) .colorPrimaryTextViewElementDarkMode(dialogAudioOutputBinding.audioOutputWiredHeadsetText)
} }

View File

@ -129,7 +129,7 @@ public class ChooseAccountDialogFragment extends DialogFragment {
binding.currentAccount.ticker.setVisibility(View.GONE); binding.currentAccount.ticker.setVisibility(View.GONE);
binding.currentAccount.account.setText((Uri.parse(user.getBaseUrl()).getHost())); binding.currentAccount.account.setText((Uri.parse(user.getBaseUrl()).getHost()));
viewThemeUtils.androidViewThemeUtils.colorImageView(binding.currentAccount.accountMenu); viewThemeUtils.platform.colorImageView(binding.currentAccount.accountMenu);
if (user.getBaseUrl() != null && if (user.getBaseUrl() != null &&
@ -213,14 +213,14 @@ public class ChooseAccountDialogFragment extends DialogFragment {
} }
private void themeViews() { private void themeViews() {
viewThemeUtils.androidViewThemeUtils.themeDialog(binding.getRoot()); viewThemeUtils.platform.themeDialog(binding.getRoot());
viewThemeUtils.androidViewThemeUtils.themeDialogDivider(binding.divider); viewThemeUtils.platform.themeDialogDivider(binding.divider);
viewThemeUtils.colorMaterialTextButton(binding.setStatus); viewThemeUtils.material.colorMaterialTextButton(binding.setStatus);
viewThemeUtils.colorDialogMenuText(binding.setStatus); viewThemeUtils.colorDialogMenuText(binding.setStatus);
viewThemeUtils.colorMaterialTextButton(binding.addAccount); viewThemeUtils.material.colorMaterialTextButton(binding.addAccount);
viewThemeUtils.colorDialogMenuText(binding.addAccount); viewThemeUtils.colorDialogMenuText(binding.addAccount);
viewThemeUtils.colorMaterialTextButton(binding.manageSettings); viewThemeUtils.material.colorMaterialTextButton(binding.manageSettings);
viewThemeUtils.colorDialogMenuText(binding.manageSettings); viewThemeUtils.colorDialogMenuText(binding.manageSettings);
} }

View File

@ -59,7 +59,7 @@ class ContactsBottomDialog(
setContentView(binding.root) setContentView(binding.root)
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
viewThemeUtils.androidViewThemeUtils.themeDialog(binding.root) viewThemeUtils.platform.themeDialog(binding.root)
executeEntryMenuController(bundle) executeEntryMenuController(bundle)
} }

View File

@ -97,7 +97,7 @@ class ConversationsListBottomDialog(
setContentView(binding.root) setContentView(binding.root)
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
viewThemeUtils.androidViewThemeUtils.themeDialog(binding.root) viewThemeUtils.platform.themeDialog(binding.root)
initHeaderDescription() initHeaderDescription()
initItemsVisibility() initItemsVisibility()
initClickListeners() initClickListeners()

View File

@ -83,7 +83,7 @@ class MessageActionsDialog(
setContentView(dialogMessageActionsBinding.root) setContentView(dialogMessageActionsBinding.root)
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
viewThemeUtils.androidViewThemeUtils.themeDialog(dialogMessageActionsBinding.root) viewThemeUtils.platform.themeDialog(dialogMessageActionsBinding.root)
initEmojiBar(hasChatPermission) initEmojiBar(hasChatPermission)
initMenuItemCopy(!message.isDeleted) initMenuItemCopy(!message.isDeleted)
initMenuReplyToMessage(message.replyable && hasChatPermission) initMenuReplyToMessage(message.replyable && hasChatPermission)

View File

@ -59,7 +59,7 @@ class ScopeDialog(
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
viewThemeUtils.androidViewThemeUtils.themeDialog(dialogScopeBinding.root) viewThemeUtils.platform.themeDialog(dialogScopeBinding.root)
if (field == ProfileController.Field.DISPLAYNAME || field == ProfileController.Field.EMAIL) { if (field == ProfileController.Field.DISPLAYNAME || field == ProfileController.Field.EMAIL) {
dialogScopeBinding.scopePrivate.visibility = View.GONE dialogScopeBinding.scopePrivate.visibility = View.GONE

View File

@ -167,7 +167,7 @@ class SetStatusDialogFragment :
binding = DialogSetStatusBinding.inflate(LayoutInflater.from(context)) binding = DialogSetStatusBinding.inflate(LayoutInflater.from(context))
val dialogBuilder = MaterialAlertDialogBuilder(binding.root.context).setView(binding.root) val dialogBuilder = MaterialAlertDialogBuilder(binding.root.context).setView(binding.root)
viewThemeUtils.colorMaterialAlertDialogBackground(binding.root.context, dialogBuilder) viewThemeUtils.material.colorMaterialAlertDialogBackground(binding.root.context, dialogBuilder)
return dialogBuilder.create() return dialogBuilder.create()
} }
@ -242,12 +242,12 @@ class SetStatusDialogFragment :
} }
} }
viewThemeUtils.androidViewThemeUtils.themeDialog(binding.root) viewThemeUtils.platform.themeDialog(binding.root)
viewThemeUtils.colorMaterialButtonText(binding.clearStatus) viewThemeUtils.material.colorMaterialButtonText(binding.clearStatus)
viewThemeUtils.colorMaterialButtonPrimaryFilled(binding.setStatus) viewThemeUtils.material.colorMaterialButtonPrimaryFilled(binding.setStatus)
viewThemeUtils.colorTextInputLayout(binding.customStatusInputContainer) viewThemeUtils.material.colorTextInputLayout(binding.customStatusInputContainer)
binding.customStatusInput.doAfterTextChanged { text -> binding.customStatusInput.doAfterTextChanged { text ->
binding.setStatus.isEnabled = !text.isNullOrEmpty() binding.setStatus.isEnabled = !text.isNullOrEmpty()
@ -418,8 +418,8 @@ class SetStatusDialogFragment :
return return
} }
} }
viewThemeUtils.colorCardViewBackground(views.first) viewThemeUtils.material.colorCardViewBackground(views.first)
viewThemeUtils.androidViewThemeUtils.colorPrimaryTextViewElement(views.second) viewThemeUtils.platform.colorPrimaryTextViewElement(views.second)
} }
private fun clearTopStatus() { private fun clearTopStatus() {

View File

@ -86,7 +86,7 @@ class ShowReactionsDialog(
binding = DialogMessageReactionsBinding.inflate(layoutInflater) binding = DialogMessageReactionsBinding.inflate(layoutInflater)
setContentView(binding.root) setContentView(binding.root)
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
viewThemeUtils.androidViewThemeUtils.themeDialog(binding.root) viewThemeUtils.platform.themeDialog(binding.root)
adapter = ReactionsAdapter(this, user) adapter = ReactionsAdapter(this, user)
binding.reactionsList.adapter = adapter binding.reactionsList.adapter = adapter
binding.reactionsList.layoutManager = LinearLayoutManager(context) binding.reactionsList.layoutManager = LinearLayoutManager(context)
@ -144,7 +144,7 @@ class ShowReactionsDialog(
} }
}) })
viewThemeUtils.themeTabLayoutOnSurface(binding.emojiReactionsTabs) viewThemeUtils.material.themeTabLayoutOnSurface(binding.emojiReactionsTabs)
updateParticipantsForEmoji(chatMessage, tagAll) updateParticipantsForEmoji(chatMessage, tagAll)
} }

View File

@ -120,8 +120,8 @@ public class SortingOrderDialogFragment extends DialogFragment implements View.O
* find all relevant UI elements and set their values. * find all relevant UI elements and set their values.
*/ */
private void setupDialogElements() { private void setupDialogElements() {
viewThemeUtils.androidViewThemeUtils.themeDialog(binding.root); viewThemeUtils.platform.themeDialog(binding.root);
viewThemeUtils.colorMaterialButtonPrimaryBorderless(binding.cancel); viewThemeUtils.material.colorMaterialButtonPrimaryBorderless(binding.cancel);
taggedViews = new View[12]; taggedViews = new View[12];
taggedViews[0] = binding.sortByNameAscending; taggedViews[0] = binding.sortByNameAscending;
@ -163,10 +163,10 @@ public class SortingOrderDialogFragment extends DialogFragment implements View.O
continue; continue;
} }
if (view instanceof MaterialButton) { if (view instanceof MaterialButton) {
viewThemeUtils.colorMaterialButtonText((MaterialButton) view); viewThemeUtils.material.colorMaterialButtonText((MaterialButton) view);
} }
if (view instanceof TextView) { if (view instanceof TextView) {
viewThemeUtils.androidViewThemeUtils.colorPrimaryTextViewElement((TextView) view); viewThemeUtils.platform.colorPrimaryTextViewElement((TextView) view);
((TextView) view).setTypeface(Typeface.DEFAULT_BOLD); ((TextView) view).setTypeface(Typeface.DEFAULT_BOLD);
} }
} }

View File

@ -25,7 +25,6 @@ import android.annotation.TargetApi
import android.content.Context import android.content.Context
import android.content.res.ColorStateList import android.content.res.ColorStateList
import android.graphics.Color import android.graphics.Color
import android.graphics.PorterDuff
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.graphics.drawable.LayerDrawable import android.graphics.drawable.LayerDrawable
import android.os.Build import android.os.Build
@ -48,47 +47,31 @@ import androidx.core.graphics.drawable.DrawableCompat
import androidx.core.view.ViewCompat import androidx.core.view.ViewCompat
import androidx.core.view.children import androidx.core.view.children
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.google.android.material.appbar.MaterialToolbar
import com.google.android.material.button.MaterialButton import com.google.android.material.button.MaterialButton
import com.google.android.material.card.MaterialCardView import com.google.android.material.card.MaterialCardView
import com.google.android.material.chip.Chip
import com.google.android.material.chip.ChipDrawable import com.google.android.material.chip.ChipDrawable
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.google.android.material.progressindicator.LinearProgressIndicator
import com.google.android.material.shape.MaterialShapeDrawable
import com.google.android.material.tabs.TabLayout
import com.google.android.material.textfield.TextInputLayout
import com.google.android.material.textview.MaterialTextView
import com.nextcloud.android.common.ui.color.ColorUtil
import com.nextcloud.android.common.ui.theme.MaterialSchemes import com.nextcloud.android.common.ui.theme.MaterialSchemes
import com.nextcloud.android.common.ui.theme.ViewThemeUtilsBase import com.nextcloud.android.common.ui.theme.ViewThemeUtilsBase
import com.nextcloud.talk.R import com.nextcloud.talk.R
import com.nextcloud.talk.ui.theme.viewthemeutils.AndroidViewThemeUtils import com.nextcloud.talk.ui.theme.viewthemeutils.AndroidViewThemeUtils
import com.nextcloud.talk.ui.theme.viewthemeutils.MaterialViewThemeUtils
import com.nextcloud.talk.utils.DisplayUtils import com.nextcloud.talk.utils.DisplayUtils
import com.nextcloud.talk.utils.DrawableUtils import com.nextcloud.talk.utils.DrawableUtils
import com.vanniktech.emoji.EmojiTextView import com.vanniktech.emoji.EmojiTextView
import com.yarolegovich.mp.MaterialPreferenceCategory import com.yarolegovich.mp.MaterialPreferenceCategory
import com.yarolegovich.mp.MaterialSwitchPreference import com.yarolegovich.mp.MaterialSwitchPreference
import eu.davidea.flexibleadapter.utils.FlexibleUtils import eu.davidea.flexibleadapter.utils.FlexibleUtils
import scheme.Scheme
import javax.inject.Inject import javax.inject.Inject
import kotlin.math.roundToInt import kotlin.math.roundToInt
@Suppress("TooManyFunctions") @Suppress("TooManyFunctions")
class ViewThemeUtils @Inject constructor( class ViewThemeUtils @Inject constructor(
schemes: MaterialSchemes, schemes: MaterialSchemes,
private val colorUtil: ColorUtil,
@JvmField @JvmField
val androidViewThemeUtils: AndroidViewThemeUtils val platform: AndroidViewThemeUtils,
) : @JvmField
ViewThemeUtilsBase(schemes) { val material: MaterialViewThemeUtils
) : ViewThemeUtilsBase(schemes) {
fun colorToolbarOverflowIcon(toolbar: MaterialToolbar) {
withScheme(toolbar) { scheme ->
toolbar.overflowIcon?.setColorFilter(scheme.onSurface, PorterDuff.Mode.SRC_ATOP)
}
}
fun themeSearchView(searchView: SearchView) { fun themeSearchView(searchView: SearchView) {
withScheme(searchView) { scheme -> withScheme(searchView) { scheme ->
@ -103,148 +86,6 @@ class ViewThemeUtils @Inject constructor(
} }
} }
fun themeSearchBarText(searchText: MaterialTextView) {
withScheme(searchText) { scheme ->
searchText.setHintTextColor(scheme.onSurfaceVariant)
}
}
fun themeFAB(fab: FloatingActionButton) {
withScheme(fab) { scheme ->
fab.backgroundTintList = ColorStateList.valueOf(scheme.primaryContainer)
fab.imageTintList = ColorStateList.valueOf(scheme.onPrimaryContainer)
}
}
fun themeCardView(cardView: MaterialCardView) {
withScheme(cardView) { scheme ->
cardView.backgroundTintList = ColorStateList.valueOf(scheme.surface)
}
}
fun colorMaterialTextButton(button: MaterialButton) {
withScheme(button) { scheme ->
button.rippleColor = ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_pressed)
),
intArrayOf(
colorUtil.adjustOpacity(scheme.primary, SURFACE_OPACITY_BUTTON_DISABLED)
)
)
}
}
fun colorMaterialButtonText(button: MaterialButton) {
withScheme(button) { scheme ->
val disabledColor = ContextCompat.getColor(button.context, R.color.disabled_text)
val colorStateList = ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_enabled),
intArrayOf(-android.R.attr.state_enabled)
),
intArrayOf(scheme.primary, disabledColor)
)
button.setTextColor(colorStateList)
button.iconTint = colorStateList
}
}
fun colorMaterialButtonPrimaryFilled(button: MaterialButton) {
withScheme(button) { scheme ->
button.backgroundTintList =
ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_enabled),
intArrayOf(-android.R.attr.state_enabled)
),
intArrayOf(
scheme.primary,
colorUtil.adjustOpacity(scheme.onSurface, SURFACE_OPACITY_BUTTON_DISABLED)
)
)
button.setTextColor(
ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_enabled),
intArrayOf(-android.R.attr.state_enabled)
),
intArrayOf(
scheme.onPrimary,
colorUtil.adjustOpacity(scheme.onSurface, ON_SURFACE_OPACITY_BUTTON_DISABLED)
)
)
)
button.iconTint = ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_enabled),
intArrayOf(-android.R.attr.state_enabled)
),
intArrayOf(
scheme.onPrimary,
colorUtil.adjustOpacity(scheme.onSurface, ON_SURFACE_OPACITY_BUTTON_DISABLED)
)
)
}
}
fun colorMaterialButtonPrimaryOutlined(button: MaterialButton) {
withScheme(button) { scheme ->
button.strokeColor = ColorStateList.valueOf(scheme.outline)
button.setTextColor(
ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_enabled),
intArrayOf(-android.R.attr.state_enabled)
),
intArrayOf(
scheme.primary,
colorUtil.adjustOpacity(scheme.onSurface, ON_SURFACE_OPACITY_BUTTON_DISABLED)
)
)
)
button.iconTint = ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_enabled),
intArrayOf(-android.R.attr.state_enabled)
),
intArrayOf(
scheme.primary,
colorUtil.adjustOpacity(scheme.onSurface, ON_SURFACE_OPACITY_BUTTON_DISABLED)
)
)
}
}
fun colorMaterialButtonPrimaryBorderless(button: MaterialButton) {
withScheme(button) { scheme ->
button.setTextColor(
ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_enabled),
intArrayOf(-android.R.attr.state_enabled)
),
intArrayOf(
scheme.primary,
colorUtil.adjustOpacity(scheme.onSurface, ON_SURFACE_OPACITY_BUTTON_DISABLED)
)
)
)
button.iconTint = ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_enabled),
intArrayOf(-android.R.attr.state_enabled)
),
intArrayOf(
scheme.primary,
colorUtil.adjustOpacity(scheme.onSurface, ON_SURFACE_OPACITY_BUTTON_DISABLED)
)
)
}
}
fun themeIncomingMessageBubble(bubble: ViewGroup, grouped: Boolean, deleted: Boolean) { fun themeIncomingMessageBubble(bubble: ViewGroup, grouped: Boolean, deleted: Boolean) {
val resources = bubble.resources val resources = bubble.resources
@ -268,14 +109,6 @@ class ViewThemeUtils @Inject constructor(
ViewCompat.setBackground(bubble, bubbleDrawable) ViewCompat.setBackground(bubble, bubbleDrawable)
} }
fun themeToolbar(toolbar: MaterialToolbar) {
withScheme(toolbar) { scheme ->
toolbar.setBackgroundColor(scheme.surface)
toolbar.setNavigationIconTint(scheme.onSurface)
toolbar.setTitleTextColor(scheme.onSurface)
}
}
fun themeOutgoingMessageBubble(bubble: ViewGroup, grouped: Boolean, deleted: Boolean) { fun themeOutgoingMessageBubble(bubble: ViewGroup, grouped: Boolean, deleted: Boolean) {
withScheme(bubble) { scheme -> withScheme(bubble) { scheme ->
val bgBubbleColor = if (deleted) { val bgBubbleColor = if (deleted) {
@ -317,12 +150,6 @@ class ViewThemeUtils @Inject constructor(
} }
} }
fun colorCardViewBackground(card: MaterialCardView) {
withScheme(card) { scheme ->
card.setCardBackgroundColor(scheme.surfaceVariant)
}
}
fun colorContactChatItemName(contactName: androidx.emoji.widget.EmojiTextView) { fun colorContactChatItemName(contactName: androidx.emoji.widget.EmojiTextView) {
withScheme(contactName) { scheme -> withScheme(contactName) { scheme ->
contactName.setTextColor(scheme.onPrimaryContainer) contactName.setTextColor(scheme.onPrimaryContainer)
@ -393,71 +220,6 @@ class ViewThemeUtils @Inject constructor(
} }
} }
fun colorProgressBar(progressIndicator: LinearProgressIndicator) {
withScheme(progressIndicator) { scheme ->
progressIndicator.setIndicatorColor(scheme.primary)
}
}
fun colorTextInputLayout(textInputLayout: TextInputLayout) {
withScheme(textInputLayout) { scheme ->
val errorColor = scheme.onSurfaceVariant
val errorColorStateList = ColorStateList(
arrayOf(
intArrayOf(-android.R.attr.state_focused),
intArrayOf(android.R.attr.state_focused)
),
intArrayOf(
errorColor,
errorColor
)
)
val coloredColorStateList = ColorStateList(
arrayOf(
intArrayOf(-android.R.attr.state_focused),
intArrayOf(android.R.attr.state_focused)
),
intArrayOf(
scheme.outline,
scheme.primary
)
)
textInputLayout.setBoxStrokeColorStateList(coloredColorStateList)
textInputLayout.setErrorIconTintList(errorColorStateList)
textInputLayout.setErrorTextColor(errorColorStateList)
textInputLayout.boxStrokeErrorColor = errorColorStateList
textInputLayout.defaultHintTextColor = coloredColorStateList
}
}
fun themeTabLayoutOnSurface(tabLayout: TabLayout) {
withScheme(tabLayout) { scheme ->
tabLayout.setBackgroundColor(scheme.surface)
colorTabLayout(tabLayout, scheme)
}
}
fun colorTabLayout(tabLayout: TabLayout, scheme: Scheme) {
tabLayout.setSelectedTabIndicatorColor(scheme.primary)
tabLayout.tabTextColors = ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_selected),
intArrayOf(-android.R.attr.state_selected)
),
intArrayOf(scheme.primary, ContextCompat.getColor(tabLayout.context, R.color.high_emphasis_text))
)
tabLayout.tabRippleColor = ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_pressed)
),
intArrayOf(
colorUtil.adjustOpacity(scheme.primary, SURFACE_OPACITY_BUTTON_DISABLED)
)
)
}
fun getPlaceholderImage(context: Context, mimetype: String?): Drawable? { fun getPlaceholderImage(context: Context, mimetype: String?): Drawable? {
val drawableResourceId = DrawableUtils.getDrawableResourceIdForMimeType(mimetype) val drawableResourceId = DrawableUtils.getDrawableResourceIdForMimeType(mimetype)
val drawable = AppCompatResources.getDrawable( val drawable = AppCompatResources.getDrawable(
@ -475,22 +237,6 @@ class ViewThemeUtils @Inject constructor(
drawable.setTint(scheme.primary) drawable.setTint(scheme.primary)
} }
fun colorChipBackground(chip: Chip) {
withScheme(chip) { scheme ->
chip.chipBackgroundColor = ColorStateList.valueOf(scheme.primary)
chip.setTextColor(scheme.onPrimary)
}
}
fun colorChipOutlined(chip: Chip, strokeWidth: Float) {
withScheme(chip) { scheme ->
chip.chipBackgroundColor = ColorStateList.valueOf(Color.TRANSPARENT)
chip.chipStrokeWidth = strokeWidth
chip.chipStrokeColor = ColorStateList.valueOf(scheme.primary)
chip.setTextColor(scheme.primary)
}
}
@TargetApi(Build.VERSION_CODES.O) @TargetApi(Build.VERSION_CODES.O)
fun themePlaceholderAvatar(avatar: View, @DrawableRes foreground: Int): Drawable? { fun themePlaceholderAvatar(avatar: View, @DrawableRes foreground: Int): Drawable? {
var drawable: LayerDrawable? = null var drawable: LayerDrawable? = null
@ -546,27 +292,6 @@ class ViewThemeUtils @Inject constructor(
} }
} }
fun colorMaterialAlertDialogBackground(context: Context, dialogBuilder: MaterialAlertDialogBuilder) {
withScheme(dialogBuilder.context) { scheme ->
val materialShapeDrawable = MaterialShapeDrawable(
context,
null,
com.google.android.material.R.attr.alertDialogStyle,
com.google.android.material.R.style.MaterialAlertDialog_MaterialComponents
)
materialShapeDrawable.initializeElevationOverlay(context)
materialShapeDrawable.fillColor = ColorStateList.valueOf(scheme.surface)
// dialogCornerRadius first appeared in Android Pie
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
val radius = context.resources.getDimension(R.dimen.dialogBorderRadius)
materialShapeDrawable.setCornerSize(radius)
}
dialogBuilder.background = materialShapeDrawable
}
}
fun colorDialogHeadline(textView: TextView) { fun colorDialogHeadline(textView: TextView) {
withScheme(textView) { scheme -> withScheme(textView) { scheme ->
textView.setTextColor(scheme.onSurface) textView.setTextColor(scheme.onSurface)
@ -617,8 +342,7 @@ class ViewThemeUtils @Inject constructor(
private const val SWITCH_COMPAT_TRACK_ALPHA: Int = 77 private const val SWITCH_COMPAT_TRACK_ALPHA: Int = 77
private const val HALF_ALPHA_INT: Int = 255 / 2 private const val HALF_ALPHA_INT: Int = 255 / 2
private const val SURFACE_OPACITY_BUTTON_DISABLED: Float = 0.12f
private const val ON_SURFACE_OPACITY_BUTTON_DISABLED: Float = 0.38f
private const val SEARCH_TEXT_SIZE: Float = 16f private const val SEARCH_TEXT_SIZE: Float = 16f
} }
} }

View File

@ -0,0 +1,324 @@
/*
* Nextcloud Talk application
*
* @author Álvaro Brey
* Copyright (C) 2022 Álvaro Brey
* Copyright (C) 2022 Nextcloud GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.nextcloud.talk.ui.theme.viewthemeutils
import android.content.Context
import android.content.res.ColorStateList
import android.graphics.Color
import android.graphics.PorterDuff
import android.os.Build
import androidx.core.content.ContextCompat
import com.google.android.material.appbar.MaterialToolbar
import com.google.android.material.button.MaterialButton
import com.google.android.material.card.MaterialCardView
import com.google.android.material.chip.Chip
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.google.android.material.progressindicator.LinearProgressIndicator
import com.google.android.material.shape.MaterialShapeDrawable
import com.google.android.material.tabs.TabLayout
import com.google.android.material.textfield.TextInputLayout
import com.google.android.material.textview.MaterialTextView
import com.nextcloud.android.common.ui.color.ColorUtil
import com.nextcloud.android.common.ui.theme.MaterialSchemes
import com.nextcloud.android.common.ui.theme.ViewThemeUtilsBase
import scheme.Scheme
import javax.inject.Inject
/**
* View theme utils for Material views (com.google.android.material.*)
*/
@Suppress("TooManyFunctions")
class MaterialViewThemeUtils @Inject constructor(schemes: MaterialSchemes, private val colorUtil: ColorUtil) :
ViewThemeUtilsBase(schemes) {
fun colorToolbarOverflowIcon(toolbar: MaterialToolbar) {
withScheme(toolbar) { scheme ->
toolbar.overflowIcon?.setColorFilter(scheme.onSurface, PorterDuff.Mode.SRC_ATOP)
}
}
fun themeSearchBarText(searchText: MaterialTextView) {
withScheme(searchText) { scheme ->
searchText.setHintTextColor(scheme.onSurfaceVariant)
}
}
fun themeFAB(fab: FloatingActionButton) {
withScheme(fab) { scheme ->
fab.backgroundTintList = ColorStateList.valueOf(scheme.primaryContainer)
fab.imageTintList = ColorStateList.valueOf(scheme.onPrimaryContainer)
}
}
fun themeCardView(cardView: MaterialCardView) {
withScheme(cardView) { scheme ->
cardView.backgroundTintList = ColorStateList.valueOf(scheme.surface)
}
}
fun colorMaterialTextButton(button: MaterialButton) {
withScheme(button) { scheme ->
button.rippleColor = ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_pressed)
),
intArrayOf(
colorUtil.adjustOpacity(scheme.primary, SURFACE_OPACITY_BUTTON_DISABLED)
)
)
}
}
fun colorMaterialButtonText(button: MaterialButton) {
withScheme(button) { scheme ->
val disabledColor = ContextCompat.getColor(button.context, com.nextcloud.talk.R.color.disabled_text)
val colorStateList = ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_enabled),
intArrayOf(-android.R.attr.state_enabled)
),
intArrayOf(scheme.primary, disabledColor)
)
button.setTextColor(colorStateList)
button.iconTint = colorStateList
}
}
fun colorMaterialButtonPrimaryFilled(button: MaterialButton) {
withScheme(button) { scheme ->
button.backgroundTintList =
ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_enabled),
intArrayOf(-android.R.attr.state_enabled)
),
intArrayOf(
scheme.primary,
colorUtil.adjustOpacity(scheme.onSurface, SURFACE_OPACITY_BUTTON_DISABLED)
)
)
button.setTextColor(
ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_enabled),
intArrayOf(-android.R.attr.state_enabled)
),
intArrayOf(
scheme.onPrimary,
colorUtil.adjustOpacity(scheme.onSurface, ON_SURFACE_OPACITY_BUTTON_DISABLED)
)
)
)
button.iconTint = ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_enabled),
intArrayOf(-android.R.attr.state_enabled)
),
intArrayOf(
scheme.onPrimary,
colorUtil.adjustOpacity(scheme.onSurface, ON_SURFACE_OPACITY_BUTTON_DISABLED)
)
)
}
}
fun colorMaterialButtonPrimaryOutlined(button: MaterialButton) {
withScheme(button) { scheme ->
button.strokeColor = ColorStateList.valueOf(scheme.outline)
button.setTextColor(
ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_enabled),
intArrayOf(-android.R.attr.state_enabled)
),
intArrayOf(
scheme.primary,
colorUtil.adjustOpacity(scheme.onSurface, ON_SURFACE_OPACITY_BUTTON_DISABLED)
)
)
)
button.iconTint = ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_enabled),
intArrayOf(-android.R.attr.state_enabled)
),
intArrayOf(
scheme.primary,
colorUtil.adjustOpacity(scheme.onSurface, ON_SURFACE_OPACITY_BUTTON_DISABLED)
)
)
}
}
fun colorMaterialButtonPrimaryBorderless(button: MaterialButton) {
withScheme(button) { scheme ->
button.setTextColor(
ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_enabled),
intArrayOf(-android.R.attr.state_enabled)
),
intArrayOf(
scheme.primary,
colorUtil.adjustOpacity(scheme.onSurface, ON_SURFACE_OPACITY_BUTTON_DISABLED)
)
)
)
button.iconTint = ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_enabled),
intArrayOf(-android.R.attr.state_enabled)
),
intArrayOf(
scheme.primary,
colorUtil.adjustOpacity(scheme.onSurface, ON_SURFACE_OPACITY_BUTTON_DISABLED)
)
)
}
}
fun themeToolbar(toolbar: MaterialToolbar) {
withScheme(toolbar) { scheme ->
toolbar.setBackgroundColor(scheme.surface)
toolbar.setNavigationIconTint(scheme.onSurface)
toolbar.setTitleTextColor(scheme.onSurface)
}
}
fun colorCardViewBackground(card: MaterialCardView) {
withScheme(card) { scheme ->
card.setCardBackgroundColor(scheme.surfaceVariant)
}
}
fun colorProgressBar(progressIndicator: LinearProgressIndicator) {
withScheme(progressIndicator) { scheme ->
progressIndicator.setIndicatorColor(scheme.primary)
}
}
fun colorTextInputLayout(textInputLayout: TextInputLayout) {
withScheme(textInputLayout) { scheme ->
val errorColor = scheme.onSurfaceVariant
val errorColorStateList = ColorStateList(
arrayOf(
intArrayOf(-android.R.attr.state_focused),
intArrayOf(android.R.attr.state_focused)
),
intArrayOf(
errorColor,
errorColor
)
)
val coloredColorStateList = ColorStateList(
arrayOf(
intArrayOf(-android.R.attr.state_focused),
intArrayOf(android.R.attr.state_focused)
),
intArrayOf(
scheme.outline,
scheme.primary
)
)
textInputLayout.setBoxStrokeColorStateList(coloredColorStateList)
textInputLayout.setErrorIconTintList(errorColorStateList)
textInputLayout.setErrorTextColor(errorColorStateList)
textInputLayout.boxStrokeErrorColor = errorColorStateList
textInputLayout.defaultHintTextColor = coloredColorStateList
}
}
fun themeTabLayoutOnSurface(tabLayout: TabLayout) {
withScheme(tabLayout) { scheme ->
tabLayout.setBackgroundColor(scheme.surface)
colorTabLayout(tabLayout, scheme)
}
}
fun colorTabLayout(tabLayout: TabLayout, scheme: Scheme) {
tabLayout.setSelectedTabIndicatorColor(scheme.primary)
tabLayout.tabTextColors = ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_selected),
intArrayOf(-android.R.attr.state_selected)
),
intArrayOf(
scheme.primary,
ContextCompat.getColor(tabLayout.context, com.nextcloud.talk.R.color.high_emphasis_text)
)
)
tabLayout.tabRippleColor = ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_pressed)
),
intArrayOf(
colorUtil.adjustOpacity(scheme.primary, SURFACE_OPACITY_BUTTON_DISABLED)
)
)
}
fun colorChipBackground(chip: Chip) {
withScheme(chip) { scheme ->
chip.chipBackgroundColor = ColorStateList.valueOf(scheme.primary)
chip.setTextColor(scheme.onPrimary)
}
}
fun colorChipOutlined(chip: Chip, strokeWidth: Float) {
withScheme(chip) { scheme ->
chip.chipBackgroundColor = ColorStateList.valueOf(Color.TRANSPARENT)
chip.chipStrokeWidth = strokeWidth
chip.chipStrokeColor = ColorStateList.valueOf(scheme.primary)
chip.setTextColor(scheme.primary)
}
}
fun colorMaterialAlertDialogBackground(context: Context, dialogBuilder: MaterialAlertDialogBuilder) {
withScheme(dialogBuilder.context) { scheme ->
val materialShapeDrawable = MaterialShapeDrawable(
context,
null,
com.google.android.material.R.attr.alertDialogStyle,
com.google.android.material.R.style.MaterialAlertDialog_MaterialComponents
)
materialShapeDrawable.initializeElevationOverlay(context)
materialShapeDrawable.fillColor = ColorStateList.valueOf(scheme.surface)
// dialogCornerRadius first appeared in Android Pie
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
val radius = context.resources.getDimension(com.nextcloud.talk.R.dimen.dialogBorderRadius)
materialShapeDrawable.setCornerSize(radius)
}
dialogBuilder.background = materialShapeDrawable
}
}
companion object {
private const val SURFACE_OPACITY_BUTTON_DISABLED: Float = 0.12f
private const val ON_SURFACE_OPACITY_BUTTON_DISABLED: Float = 0.38f
}
}

View File

@ -73,7 +73,7 @@ public class MagicUserInputModule extends StandardUserInputModule {
final Listener<String> listener) { final Listener<String> listener) {
final View view = LayoutInflater.from(context).inflate(R.layout.dialog_edittext, null); final View view = LayoutInflater.from(context).inflate(R.layout.dialog_edittext, null);
final EditText inputField = view.findViewById(R.id.mp_text_input); final EditText inputField = view.findViewById(R.id.mp_text_input);
viewThemeUtils.androidViewThemeUtils.colorEditText(inputField); viewThemeUtils.platform.colorEditText(inputField);
int paddingStartEnd = Math.round(view.getResources().getDimension(R.dimen.standard_padding)); int paddingStartEnd = Math.round(view.getResources().getDimension(R.dimen.standard_padding));
int paddingTopBottom = Math.round(view.getResources().getDimension(R.dimen.dialog_padding_top_bottom)); int paddingTopBottom = Math.round(view.getResources().getDimension(R.dimen.dialog_padding_top_bottom));
@ -96,12 +96,12 @@ public class MagicUserInputModule extends StandardUserInputModule {
.setTitle(title) .setTitle(title)
.setView(view); .setView(view);
viewThemeUtils.colorMaterialAlertDialogBackground(view.getContext(), dialogBuilder); viewThemeUtils.material.colorMaterialAlertDialogBackground(view.getContext(), dialogBuilder);
final Dialog dialog = dialogBuilder.show(); final Dialog dialog = dialogBuilder.show();
TextView button = view.findViewById(R.id.mp_btn_confirm); TextView button = view.findViewById(R.id.mp_btn_confirm);
viewThemeUtils.androidViewThemeUtils.colorPrimaryTextViewElement(button); viewThemeUtils.platform.colorPrimaryTextViewElement(button);
button.setOnClickListener(new View.OnClickListener() { button.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {