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()
}
viewThemeUtils.colorMaterialAlertDialogBackground(context, dialogBuilder)
viewThemeUtils.material.colorMaterialAlertDialogBackground(context, dialogBuilder)
val dialog = dialogBuilder.show()
viewThemeUtils.androidViewThemeUtils.colorTextButtons(
viewThemeUtils.platform.colorTextButtons(
dialog.getButton(AlertDialog.BUTTON_POSITIVE),
dialog.getButton(AlertDialog.BUTTON_NEGATIVE)
)

View File

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

View File

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

View File

@ -113,7 +113,7 @@ public class ContactItem extends AbstractFlexibleItem<ContactItem.ContactItemVie
holder.binding.avatarDraweeView.setController(null);
if (participant.getSelected()) {
viewThemeUtils.androidViewThemeUtils.colorImageView(holder.binding.checkedImageView);
viewThemeUtils.platform.colorImageView(holder.binding.checkedImageView);
holder.binding.checkedImageView.setVisibility(View.VISIBLE);
} else {
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);
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()) {
if (CapabilitiesUtilNew.hasSpreedFeatureCapability(user, "direct-mention-flag")) {
if (conversation.getUnreadMentionDirect()) {
viewThemeUtils.colorChipBackground(holder.binding.dialogUnreadBubble);
viewThemeUtils.material.colorChipBackground(holder.binding.dialogUnreadBubble);
} else {
viewThemeUtils.colorChipOutlined(holder.binding.dialogUnreadBubble, 6.0f);
viewThemeUtils.material.colorChipOutlined(holder.binding.dialogUnreadBubble, 6.0f);
}
} else {
viewThemeUtils.colorChipBackground(holder.binding.dialogUnreadBubble);
viewThemeUtils.material.colorChipBackground(holder.binding.dialogUnreadBubble);
}
} else {
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!");
} else {
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))
if (parentChatMessage.actorId?.equals(message.activeUser!!.userId) == true) {
viewThemeUtils.androidViewThemeUtils.colorPrimaryView(binding.messageQuote.quoteColoredView)
viewThemeUtils.platform.colorPrimaryView(binding.messageQuote.quoteColoredView)
} else {
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))
if (parentChatMessage.actorId?.equals(message.activeUser!!.userId) == true) {
viewThemeUtils.androidViewThemeUtils.colorPrimaryView(binding.messageQuote.quoteColoredView)
viewThemeUtils.platform.colorPrimaryView(binding.messageQuote.quoteColoredView)
} else {
binding.messageQuote.quoteColoredView.setBackgroundResource(R.color.textColorMaxContrast)
}

View File

@ -95,8 +95,8 @@ class IncomingVoiceMessageViewHolder(incomingView: View, payload: Any) : Message
updateDownloadState(message)
binding.seekbar.max = message.voiceMessageDuration
viewThemeUtils.androidViewThemeUtils.themeHorizontalSeekBar(binding.seekbar)
viewThemeUtils.androidViewThemeUtils.colorCircularProgressBarOnSurfaceVariant(binding.progressBar)
viewThemeUtils.platform.themeHorizontalSeekBar(binding.seekbar)
viewThemeUtils.platform.colorCircularProgressBarOnSurfaceVariant(binding.progressBar)
if (message.isPlayingVoiceMessage) {
showPlayButton()
@ -292,7 +292,7 @@ class IncomingVoiceMessageViewHolder(incomingView: View, payload: Any) : Message
.setTextColor(ContextCompat.getColor(context!!, R.color.textColorMaxContrast))
if (parentChatMessage.actorId?.equals(message.activeUser!!.userId) == true) {
viewThemeUtils.androidViewThemeUtils.colorPrimaryView(binding.messageQuote.quoteColoredView)
viewThemeUtils.platform.colorPrimaryView(binding.messageQuote.quoteColoredView)
} else {
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
if (parentChatMessage.actorId?.equals(message.activeUser!!.userId) == true) {
viewThemeUtils.androidViewThemeUtils.colorPrimaryView(binding.messageQuote.quoteColoredView)
viewThemeUtils.platform.colorPrimaryView(binding.messageQuote.quoteColoredView)
} else {
binding.messageQuote.quoteColoredView.setBackgroundColor(
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();
viewThemeUtils.androidViewThemeUtils.colorCircularProgressBar(getProgressBar());
viewThemeUtils.platform.colorCircularProgressBar(getProgressBar());
image = getImage();
clickView = getImage();
getMessageText().setVisibility(View.VISIBLE);
@ -169,7 +169,7 @@ public abstract class MagicPreviewMessageViewHolder extends MessageHolders.Incom
clickView = getPreviewContactContainer();
viewThemeUtils.colorContactChatItemBackground(getPreviewContactContainer());
viewThemeUtils.colorContactChatItemName(getPreviewContactName());
viewThemeUtils.androidViewThemeUtils.colorCircularProgressBarOnPrimaryContainer(getPreviewContactProgressBar());
viewThemeUtils.platform.colorCircularProgressBarOnPrimaryContainer(getPreviewContactProgressBar());
} else {
getPreviewContainer().setVisibility(View.VISIBLE);
getPreviewContactContainer().setVisibility(View.GONE);

View File

@ -90,8 +90,8 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) : MessageHolders
updateDownloadState(message)
binding.seekbar.max = message.voiceMessageDuration
viewThemeUtils.androidViewThemeUtils.themeHorizontalSeekBar(binding.seekbar)
viewThemeUtils.androidViewThemeUtils.colorCircularProgressBarOnSurfaceVariant(binding.progressBar)
viewThemeUtils.platform.themeHorizontalSeekBar(binding.seekbar)
viewThemeUtils.platform.colorCircularProgressBarOnSurfaceVariant(binding.progressBar)
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)
@ -877,7 +877,7 @@ class ChatController(args: Bundle) :
.nc_description_send_message_button
)
viewThemeUtils.androidViewThemeUtils.colorImageView(binding.messageInputView.button)
viewThemeUtils.platform.colorImageView(binding.messageInputView.button)
if (currentConversation != null && currentConversation?.roomId != null) {
loadAvatarForStatusBar()
@ -1433,14 +1433,14 @@ class ChatController(args: Bundle) :
// unused atm
}
viewThemeUtils.colorMaterialAlertDialogBackground(
viewThemeUtils.material.colorMaterialAlertDialogBackground(
binding.messageInputView.context,
materialAlertDialogBuilder
)
val dialog = materialAlertDialogBuilder.show()
viewThemeUtils.androidViewThemeUtils.colorTextButtons(
viewThemeUtils.platform.colorTextButtons(
dialog.getButton(AlertDialog.BUTTON_POSITIVE),
dialog.getButton(AlertDialog.BUTTON_NEGATIVE)
)
@ -1772,7 +1772,7 @@ class ChatController(args: Bundle) :
cancelReply()
}
viewThemeUtils.androidViewThemeUtils
viewThemeUtils.platform
.themeImageButton(binding.messageInputView.findViewById<ImageButton>(R.id.cancelReplyButton))
cancelNotificationsForCurrentConversation()
@ -2524,12 +2524,12 @@ class ChatController(args: Bundle) :
super.onCreateOptionsMenu(menu, inflater)
inflater.inflate(R.menu.menu_conversation, menu)
viewThemeUtils.androidViewThemeUtils.colorToolbarMenuIcon(
viewThemeUtils.platform.colorToolbarMenuIcon(
binding.messageInputView.context,
menu.findItem(R.id.conversation_voice_call)
)
viewThemeUtils.androidViewThemeUtils.colorToolbarMenuIcon(
viewThemeUtils.platform.colorToolbarMenuIcon(
binding.messageInputView.context,
menu.findItem(R.id.conversation_video_call)
)

View File

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

View File

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

View File

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

View File

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

View File

@ -385,14 +385,14 @@ class SettingsController : BaseController(R.layout.controller_settings) {
// unused atm
}
viewThemeUtils.colorMaterialAlertDialogBackground(
viewThemeUtils.material.colorMaterialAlertDialogBackground(
binding.messageText.context,
materialAlertDialogBuilder
)
val dialog = materialAlertDialogBuilder.show()
viewThemeUtils.androidViewThemeUtils.colorTextButtons(
viewThemeUtils.platform.colorTextButtons(
dialog.getButton(AlertDialog.BUTTON_POSITIVE),
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)
.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()
dialog.setOnShowListener(object : OnShowListener {
@ -968,7 +968,7 @@ class SettingsController : BaseController(R.layout.controller_settings) {
dialog.show()
viewThemeUtils.androidViewThemeUtils.colorTextButtons(
viewThemeUtils.platform.colorTextButtons(
dialog.getButton(AlertDialog.BUTTON_POSITIVE),
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) {
activity = getActivity() as MainActivity?
viewThemeUtils.themeCardView(activity!!.binding.searchToolbar)
viewThemeUtils.themeToolbar(activity.binding.toolbar)
viewThemeUtils.themeSearchBarText(activity.binding.searchText)
viewThemeUtils.material.themeCardView(activity!!.binding.searchToolbar)
viewThemeUtils.material.themeToolbar(activity.binding.toolbar)
viewThemeUtils.material.themeSearchBarText(activity.binding.searchText)
}
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
binding.searchToolbar.visibility = View.GONE
binding.toolbar.visibility = View.VISIBLE
viewThemeUtils.colorToolbarOverflowIcon(binding.toolbar)
viewThemeUtils.material.colorToolbarOverflowIcon(binding.toolbar)
layoutParams.scrollFlags = 0
binding.appBar.stateListAnimator = AnimatorInflater.loadStateListAnimator(
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?) {
if (activity != null && resources != null) {
if (showSearchBar) {
view?.let { viewThemeUtils.androidViewThemeUtils.resetStatusBar(activity, it) }
view?.let { viewThemeUtils.platform.resetStatusBar(activity, it) }
} 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,
editText = binding.textEdit,
onEmojiPopupShownListener = {
viewThemeUtils.androidViewThemeUtils.colorImageView(binding.smileyButton)
viewThemeUtils.platform.colorImageView(binding.smileyButton)
},
onEmojiPopupDismissListener = {
binding.smileyButton.imageTintList = ColorStateList.valueOf(
@ -166,8 +166,8 @@ class EntryMenuController(args: Bundle) :
binding.textInputLayout.endIconMode = TextInputLayout.END_ICON_NONE
}
viewThemeUtils.colorTextInputLayout(binding.textInputLayout)
viewThemeUtils.colorMaterialButtonText(binding.okButton)
viewThemeUtils.material.colorTextInputLayout(binding.textInputLayout)
viewThemeUtils.material.colorMaterialButtonText(binding.okButton)
binding.textInputLayout.hint = labelText
binding.textInputLayout.requestFocus()

View File

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

View File

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

View File

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

View File

@ -75,7 +75,7 @@ class PollCreateDialogFragment : DialogFragment(), PollCreateOptionsItemListener
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()
}
@ -101,18 +101,18 @@ class PollCreateDialogFragment : DialogFragment(), PollCreateOptionsItemListener
}
private fun themeDialog() {
viewThemeUtils.androidViewThemeUtils.colorPrimaryTextViewElement(binding.pollQuestion)
viewThemeUtils.androidViewThemeUtils.colorPrimaryTextViewElement(binding.pollOptions)
viewThemeUtils.androidViewThemeUtils.colorPrimaryTextViewElement(binding.pollSettings)
viewThemeUtils.platform.colorPrimaryTextViewElement(binding.pollQuestion)
viewThemeUtils.platform.colorPrimaryTextViewElement(binding.pollOptions)
viewThemeUtils.platform.colorPrimaryTextViewElement(binding.pollSettings)
viewThemeUtils.colorTextInputLayout(binding.pollCreateQuestionTextInputLayout)
viewThemeUtils.material.colorTextInputLayout(binding.pollCreateQuestionTextInputLayout)
viewThemeUtils.colorMaterialButtonText(binding.pollAddOptionsItem)
viewThemeUtils.colorMaterialButtonText(binding.pollDismiss)
viewThemeUtils.colorMaterialButtonPrimaryFilled(binding.pollCreateButton)
viewThemeUtils.material.colorMaterialButtonText(binding.pollAddOptionsItem)
viewThemeUtils.material.colorMaterialButtonText(binding.pollDismiss)
viewThemeUtils.material.colorMaterialButtonPrimaryFilled(binding.pollCreateButton)
viewThemeUtils.androidViewThemeUtils.themeCheckbox(binding.pollPrivatePollCheckbox)
viewThemeUtils.androidViewThemeUtils.themeCheckbox(binding.pollMultipleAnswersCheckbox)
viewThemeUtils.platform.themeCheckbox(binding.pollPrivatePollCheckbox)
viewThemeUtils.platform.themeCheckbox(binding.pollMultipleAnswersCheckbox)
}
private fun setupListeners() {

View File

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

View File

@ -72,7 +72,7 @@ class PollMainDialogFragment : DialogFragment() {
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()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -129,7 +129,7 @@ public class ChooseAccountDialogFragment extends DialogFragment {
binding.currentAccount.ticker.setVisibility(View.GONE);
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 &&
@ -213,14 +213,14 @@ public class ChooseAccountDialogFragment extends DialogFragment {
}
private void themeViews() {
viewThemeUtils.androidViewThemeUtils.themeDialog(binding.getRoot());
viewThemeUtils.androidViewThemeUtils.themeDialogDivider(binding.divider);
viewThemeUtils.platform.themeDialog(binding.getRoot());
viewThemeUtils.platform.themeDialogDivider(binding.divider);
viewThemeUtils.colorMaterialTextButton(binding.setStatus);
viewThemeUtils.material.colorMaterialTextButton(binding.setStatus);
viewThemeUtils.colorDialogMenuText(binding.setStatus);
viewThemeUtils.colorMaterialTextButton(binding.addAccount);
viewThemeUtils.material.colorMaterialTextButton(binding.addAccount);
viewThemeUtils.colorDialogMenuText(binding.addAccount);
viewThemeUtils.colorMaterialTextButton(binding.manageSettings);
viewThemeUtils.material.colorMaterialTextButton(binding.manageSettings);
viewThemeUtils.colorDialogMenuText(binding.manageSettings);
}

View File

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

View File

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

View File

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

View File

@ -59,7 +59,7 @@ class ScopeDialog(
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) {
dialogScopeBinding.scopePrivate.visibility = View.GONE

View File

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

View File

@ -86,7 +86,7 @@ class ShowReactionsDialog(
binding = DialogMessageReactionsBinding.inflate(layoutInflater)
setContentView(binding.root)
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
viewThemeUtils.androidViewThemeUtils.themeDialog(binding.root)
viewThemeUtils.platform.themeDialog(binding.root)
adapter = ReactionsAdapter(this, user)
binding.reactionsList.adapter = adapter
binding.reactionsList.layoutManager = LinearLayoutManager(context)
@ -144,7 +144,7 @@ class ShowReactionsDialog(
}
})
viewThemeUtils.themeTabLayoutOnSurface(binding.emojiReactionsTabs)
viewThemeUtils.material.themeTabLayoutOnSurface(binding.emojiReactionsTabs)
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.
*/
private void setupDialogElements() {
viewThemeUtils.androidViewThemeUtils.themeDialog(binding.root);
viewThemeUtils.colorMaterialButtonPrimaryBorderless(binding.cancel);
viewThemeUtils.platform.themeDialog(binding.root);
viewThemeUtils.material.colorMaterialButtonPrimaryBorderless(binding.cancel);
taggedViews = new View[12];
taggedViews[0] = binding.sortByNameAscending;
@ -163,10 +163,10 @@ public class SortingOrderDialogFragment extends DialogFragment implements View.O
continue;
}
if (view instanceof MaterialButton) {
viewThemeUtils.colorMaterialButtonText((MaterialButton) view);
viewThemeUtils.material.colorMaterialButtonText((MaterialButton) view);
}
if (view instanceof TextView) {
viewThemeUtils.androidViewThemeUtils.colorPrimaryTextViewElement((TextView) view);
viewThemeUtils.platform.colorPrimaryTextViewElement((TextView) view);
((TextView) view).setTypeface(Typeface.DEFAULT_BOLD);
}
}

View File

@ -25,7 +25,6 @@ import android.annotation.TargetApi
import android.content.Context
import android.content.res.ColorStateList
import android.graphics.Color
import android.graphics.PorterDuff
import android.graphics.drawable.Drawable
import android.graphics.drawable.LayerDrawable
import android.os.Build
@ -48,47 +47,31 @@ import androidx.core.graphics.drawable.DrawableCompat
import androidx.core.view.ViewCompat
import androidx.core.view.children
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
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.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.ViewThemeUtilsBase
import com.nextcloud.talk.R
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.DrawableUtils
import com.vanniktech.emoji.EmojiTextView
import com.yarolegovich.mp.MaterialPreferenceCategory
import com.yarolegovich.mp.MaterialSwitchPreference
import eu.davidea.flexibleadapter.utils.FlexibleUtils
import scheme.Scheme
import javax.inject.Inject
import kotlin.math.roundToInt
@Suppress("TooManyFunctions")
class ViewThemeUtils @Inject constructor(
schemes: MaterialSchemes,
private val colorUtil: ColorUtil,
@JvmField
val androidViewThemeUtils: AndroidViewThemeUtils
) :
ViewThemeUtilsBase(schemes) {
fun colorToolbarOverflowIcon(toolbar: MaterialToolbar) {
withScheme(toolbar) { scheme ->
toolbar.overflowIcon?.setColorFilter(scheme.onSurface, PorterDuff.Mode.SRC_ATOP)
}
}
val platform: AndroidViewThemeUtils,
@JvmField
val material: MaterialViewThemeUtils
) : ViewThemeUtilsBase(schemes) {
fun themeSearchView(searchView: SearchView) {
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) {
val resources = bubble.resources
@ -268,14 +109,6 @@ class ViewThemeUtils @Inject constructor(
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) {
withScheme(bubble) { scheme ->
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) {
withScheme(contactName) { scheme ->
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? {
val drawableResourceId = DrawableUtils.getDrawableResourceIdForMimeType(mimetype)
val drawable = AppCompatResources.getDrawable(
@ -475,22 +237,6 @@ class ViewThemeUtils @Inject constructor(
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)
fun themePlaceholderAvatar(avatar: View, @DrawableRes foreground: Int): Drawable? {
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) {
withScheme(textView) { scheme ->
textView.setTextColor(scheme.onSurface)
@ -617,8 +342,7 @@ class ViewThemeUtils @Inject constructor(
private const val SWITCH_COMPAT_TRACK_ALPHA: Int = 77
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
}
}

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