mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 19:49:33 +01:00
Finish splitting ViewThemeUtils
Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
parent
892cc82ade
commit
05c60ff4b7
@ -117,7 +117,7 @@ open class BaseActivity : AppCompatActivity() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
val dialogBuilder = MaterialAlertDialogBuilder(this)
|
val dialogBuilder = MaterialAlertDialogBuilder(this)
|
||||||
.setIcon(viewThemeUtils.colorMaterialAlertDialogIcon(context, R.drawable.ic_security_white_24dp))
|
.setIcon(viewThemeUtils.dialog.colorMaterialAlertDialogIcon(context, R.drawable.ic_security_white_24dp))
|
||||||
.setTitle(R.string.nc_certificate_dialog_title)
|
.setTitle(R.string.nc_certificate_dialog_title)
|
||||||
.setMessage(dialogText)
|
.setMessage(dialogText)
|
||||||
.setPositiveButton(R.string.nc_yes) { _, _ ->
|
.setPositiveButton(R.string.nc_yes) { _, _ ->
|
||||||
@ -128,7 +128,7 @@ open class BaseActivity : AppCompatActivity() {
|
|||||||
sslErrorHandler?.cancel()
|
sslErrorHandler?.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
viewThemeUtils.material.colorMaterialAlertDialogBackground(context, dialogBuilder)
|
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(context, dialogBuilder)
|
||||||
|
|
||||||
val dialog = dialogBuilder.show()
|
val dialog = dialogBuilder.show()
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ public class ConversationItem extends AbstractFlexibleItem<ConversationItem.Conv
|
|||||||
null));
|
null));
|
||||||
|
|
||||||
if (adapter.hasFilter()) {
|
if (adapter.hasFilter()) {
|
||||||
viewThemeUtils.highlightText(holder.binding.dialogName,
|
viewThemeUtils.platform.highlightText(holder.binding.dialogName,
|
||||||
conversation.getDisplayName(),
|
conversation.getDisplayName(),
|
||||||
String.valueOf(adapter.getFilter(String.class)));
|
String.valueOf(adapter.getFilter(String.class)));
|
||||||
} else {
|
} else {
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
package com.nextcloud.talk.adapters.items
|
package com.nextcloud.talk.adapters.items
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.text.SpannableString
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.nextcloud.talk.R
|
import com.nextcloud.talk.R
|
||||||
@ -77,12 +76,11 @@ data class MessageResultItem constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun bindMessageExcerpt(holder: ViewHolder) {
|
private fun bindMessageExcerpt(holder: ViewHolder) {
|
||||||
val highlightedSpan = viewThemeUtils.createHighlightedSpan(
|
viewThemeUtils.platform.highlightText(
|
||||||
holder.binding.messageExcerpt.context,
|
holder.binding.messageExcerpt,
|
||||||
SpannableString(messageEntry.messageExcerpt),
|
messageEntry.messageExcerpt,
|
||||||
messageEntry.searchTerm
|
messageEntry.searchTerm
|
||||||
)
|
)
|
||||||
holder.binding.messageExcerpt.text = highlightedSpan
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadImage(holder: ViewHolder) {
|
private fun loadImage(holder: ViewHolder) {
|
||||||
|
@ -1433,7 +1433,7 @@ class ChatController(args: Bundle) :
|
|||||||
// unused atm
|
// unused atm
|
||||||
}
|
}
|
||||||
|
|
||||||
viewThemeUtils.material.colorMaterialAlertDialogBackground(
|
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(
|
||||||
binding.messageInputView.context,
|
binding.messageInputView.context,
|
||||||
materialAlertDialogBuilder
|
materialAlertDialogBuilder
|
||||||
)
|
)
|
||||||
|
@ -334,7 +334,7 @@ class ContactsController(args: Bundle) :
|
|||||||
val searchManager: SearchManager? = activity?.getSystemService(Context.SEARCH_SERVICE) as SearchManager?
|
val searchManager: SearchManager? = activity?.getSystemService(Context.SEARCH_SERVICE) as SearchManager?
|
||||||
if (searchItem != null) {
|
if (searchItem != null) {
|
||||||
searchView = MenuItemCompat.getActionView(searchItem) as SearchView
|
searchView = MenuItemCompat.getActionView(searchItem) as SearchView
|
||||||
viewThemeUtils.appcompat.themeSearchView(searchView!!)
|
viewThemeUtils.androidx.themeSearchView(searchView!!)
|
||||||
searchView!!.maxWidth = Int.MAX_VALUE
|
searchView!!.maxWidth = Int.MAX_VALUE
|
||||||
searchView!!.inputType = InputType.TYPE_TEXT_VARIATION_FILTER
|
searchView!!.inputType = InputType.TYPE_TEXT_VARIATION_FILTER
|
||||||
var imeOptions: Int = EditorInfo.IME_ACTION_DONE or EditorInfo.IME_FLAG_NO_FULLSCREEN
|
var imeOptions: Int = EditorInfo.IME_ACTION_DONE or EditorInfo.IME_FLAG_NO_FULLSCREEN
|
||||||
@ -629,7 +629,7 @@ class ContactsController(args: Bundle) :
|
|||||||
binding.controllerGenericRv.recyclerView.adapter = adapter
|
binding.controllerGenericRv.recyclerView.adapter = adapter
|
||||||
binding.controllerGenericRv.swipeRefreshLayout.setOnRefreshListener { fetchData() }
|
binding.controllerGenericRv.swipeRefreshLayout.setOnRefreshListener { fetchData() }
|
||||||
|
|
||||||
viewThemeUtils.themeSwipeRefreshLayout(binding.controllerGenericRv.swipeRefreshLayout)
|
viewThemeUtils.androidx.themeSwipeRefreshLayout(binding.controllerGenericRv.swipeRefreshLayout)
|
||||||
|
|
||||||
binding.joinConversationViaLink.joinConversationViaLinkImageView
|
binding.joinConversationViaLink.joinConversationViaLinkImageView
|
||||||
.background
|
.background
|
||||||
|
@ -191,7 +191,7 @@ class ConversationInfoController(args: Bundle) :
|
|||||||
binding.webinarInfoView.conversationInfoLobby,
|
binding.webinarInfoView.conversationInfoLobby,
|
||||||
binding.notificationSettingsView.callNotifications,
|
binding.notificationSettingsView.callNotifications,
|
||||||
binding.notificationSettingsView.conversationInfoPriorityConversation
|
binding.notificationSettingsView.conversationInfoPriorityConversation
|
||||||
).forEach(viewThemeUtils::colorSwitchPreference)
|
).forEach(viewThemeUtils.talk::colorSwitchPreference)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,7 +207,7 @@ class ConversationInfoController(args: Bundle) :
|
|||||||
categoryConversationSettings,
|
categoryConversationSettings,
|
||||||
binding.webinarInfoView.conversationInfoWebinar,
|
binding.webinarInfoView.conversationInfoWebinar,
|
||||||
binding.notificationSettingsView.notificationSettingsCategory
|
binding.notificationSettingsView.notificationSettingsCategory
|
||||||
).forEach(viewThemeUtils::colorPreferenceCategory)
|
).forEach(viewThemeUtils.talk::colorPreferenceCategory)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ class ConversationInfoController(args: Bundle) :
|
|||||||
private fun showDeleteConversationDialog() {
|
private fun showDeleteConversationDialog() {
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
val dialogBuilder = MaterialAlertDialogBuilder(binding.conversationInfoName.context)
|
val dialogBuilder = MaterialAlertDialogBuilder(binding.conversationInfoName.context)
|
||||||
.setIcon(viewThemeUtils.colorMaterialAlertDialogIcon(context, R.drawable.ic_delete_black_24dp))
|
.setIcon(viewThemeUtils.dialog.colorMaterialAlertDialogIcon(context, R.drawable.ic_delete_black_24dp))
|
||||||
.setTitle(R.string.nc_delete_call)
|
.setTitle(R.string.nc_delete_call)
|
||||||
.setMessage(R.string.nc_delete_conversation_more)
|
.setMessage(R.string.nc_delete_conversation_more)
|
||||||
.setPositiveButton(R.string.nc_delete) { _, _ ->
|
.setPositiveButton(R.string.nc_delete) { _, _ ->
|
||||||
@ -374,7 +374,7 @@ class ConversationInfoController(args: Bundle) :
|
|||||||
.setNegativeButton(R.string.nc_cancel) { _, _ ->
|
.setNegativeButton(R.string.nc_cancel) { _, _ ->
|
||||||
// unused atm
|
// unused atm
|
||||||
}
|
}
|
||||||
viewThemeUtils.material
|
viewThemeUtils.dialog
|
||||||
.colorMaterialAlertDialogBackground(binding.conversationInfoName.context, dialogBuilder)
|
.colorMaterialAlertDialogBackground(binding.conversationInfoName.context, dialogBuilder)
|
||||||
val dialog = dialogBuilder.show()
|
val dialog = dialogBuilder.show()
|
||||||
viewThemeUtils.platform.colorTextButtons(
|
viewThemeUtils.platform.colorTextButtons(
|
||||||
@ -537,7 +537,7 @@ class ConversationInfoController(args: Bundle) :
|
|||||||
private fun showClearHistoryDialog() {
|
private fun showClearHistoryDialog() {
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
val dialogBuilder = MaterialAlertDialogBuilder(binding.conversationInfoName.context)
|
val dialogBuilder = MaterialAlertDialogBuilder(binding.conversationInfoName.context)
|
||||||
.setIcon(viewThemeUtils.colorMaterialAlertDialogIcon(context, R.drawable.ic_delete_black_24dp))
|
.setIcon(viewThemeUtils.dialog.colorMaterialAlertDialogIcon(context, R.drawable.ic_delete_black_24dp))
|
||||||
.setTitle(R.string.nc_clear_history)
|
.setTitle(R.string.nc_clear_history)
|
||||||
.setMessage(R.string.nc_clear_history_warning)
|
.setMessage(R.string.nc_clear_history_warning)
|
||||||
.setPositiveButton(R.string.nc_delete_all) { _, _ ->
|
.setPositiveButton(R.string.nc_delete_all) { _, _ ->
|
||||||
@ -546,7 +546,7 @@ class ConversationInfoController(args: Bundle) :
|
|||||||
.setNegativeButton(R.string.nc_cancel) { _, _ ->
|
.setNegativeButton(R.string.nc_cancel) { _, _ ->
|
||||||
// unused atm
|
// unused atm
|
||||||
}
|
}
|
||||||
viewThemeUtils.material
|
viewThemeUtils.dialog
|
||||||
.colorMaterialAlertDialogBackground(binding.conversationInfoName.context, dialogBuilder)
|
.colorMaterialAlertDialogBackground(binding.conversationInfoName.context, dialogBuilder)
|
||||||
val dialog = dialogBuilder.show()
|
val dialog = dialogBuilder.show()
|
||||||
viewThemeUtils.platform.colorTextButtons(
|
viewThemeUtils.platform.colorTextButtons(
|
||||||
|
@ -296,7 +296,7 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
val searchManager = activity!!.getSystemService(Context.SEARCH_SERVICE) as SearchManager?
|
val searchManager = activity!!.getSystemService(Context.SEARCH_SERVICE) as SearchManager?
|
||||||
if (searchItem != null) {
|
if (searchItem != null) {
|
||||||
searchView = MenuItemCompat.getActionView(searchItem) as SearchView
|
searchView = MenuItemCompat.getActionView(searchItem) as SearchView
|
||||||
viewThemeUtils.appcompat.themeSearchView(searchView!!)
|
viewThemeUtils.androidx.themeSearchView(searchView!!)
|
||||||
searchView!!.maxWidth = Int.MAX_VALUE
|
searchView!!.maxWidth = Int.MAX_VALUE
|
||||||
searchView!!.inputType = InputType.TYPE_TEXT_VARIATION_FILTER
|
searchView!!.inputType = InputType.TYPE_TEXT_VARIATION_FILTER
|
||||||
var imeOptions = EditorInfo.IME_ACTION_DONE or EditorInfo.IME_FLAG_NO_FULLSCREEN
|
var imeOptions = EditorInfo.IME_ACTION_DONE or EditorInfo.IME_FLAG_NO_FULLSCREEN
|
||||||
@ -666,7 +666,7 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
binding.swipeRefreshLayoutView.setOnRefreshListener { fetchData() }
|
binding.swipeRefreshLayoutView.setOnRefreshListener { fetchData() }
|
||||||
viewThemeUtils.themeSwipeRefreshLayout(binding.swipeRefreshLayoutView)
|
viewThemeUtils.androidx.themeSwipeRefreshLayout(binding.swipeRefreshLayoutView)
|
||||||
binding.emptyLayout.setOnClickListener { showNewConversationsScreen() }
|
binding.emptyLayout.setOnClickListener { showNewConversationsScreen() }
|
||||||
binding.floatingActionButton.setOnClickListener {
|
binding.floatingActionButton.setOnClickListener {
|
||||||
run(context)
|
run(context)
|
||||||
@ -939,7 +939,7 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
val dialogBuilder = MaterialAlertDialogBuilder(binding.floatingActionButton.context)
|
val dialogBuilder = MaterialAlertDialogBuilder(binding.floatingActionButton.context)
|
||||||
.setIcon(viewThemeUtils.colorMaterialAlertDialogIcon(context, R.drawable.upload))
|
.setIcon(viewThemeUtils.dialog.colorMaterialAlertDialogIcon(context, R.drawable.upload))
|
||||||
.setTitle(confirmationQuestion)
|
.setTitle(confirmationQuestion)
|
||||||
.setMessage(fileNamesWithLineBreaks.toString())
|
.setMessage(fileNamesWithLineBreaks.toString())
|
||||||
.setPositiveButton(R.string.nc_yes) { _, _ ->
|
.setPositiveButton(R.string.nc_yes) { _, _ ->
|
||||||
@ -950,7 +950,7 @@ 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.material
|
viewThemeUtils.dialog
|
||||||
.colorMaterialAlertDialogBackground(binding.floatingActionButton.context, dialogBuilder)
|
.colorMaterialAlertDialogBackground(binding.floatingActionButton.context, dialogBuilder)
|
||||||
val dialog = dialogBuilder.show()
|
val dialog = dialogBuilder.show()
|
||||||
viewThemeUtils.platform.colorTextButtons(
|
viewThemeUtils.platform.colorTextButtons(
|
||||||
@ -1131,7 +1131,10 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
val conversation = Parcels.unwrap<Conversation>(conversationMenuBundle!!.getParcelable(KEY_ROOM))
|
val conversation = Parcels.unwrap<Conversation>(conversationMenuBundle!!.getParcelable(KEY_ROOM))
|
||||||
if (conversation != null) {
|
if (conversation != null) {
|
||||||
val dialogBuilder = MaterialAlertDialogBuilder(binding.floatingActionButton.context)
|
val dialogBuilder = MaterialAlertDialogBuilder(binding.floatingActionButton.context)
|
||||||
.setIcon(viewThemeUtils.colorMaterialAlertDialogIcon(context, R.drawable.ic_delete_black_24dp))
|
.setIcon(
|
||||||
|
viewThemeUtils.dialog
|
||||||
|
.colorMaterialAlertDialogIcon(context, R.drawable.ic_delete_black_24dp)
|
||||||
|
)
|
||||||
.setTitle(R.string.nc_delete_call)
|
.setTitle(R.string.nc_delete_call)
|
||||||
.setMessage(R.string.nc_delete_conversation_more)
|
.setMessage(R.string.nc_delete_conversation_more)
|
||||||
.setPositiveButton(R.string.nc_delete) { _, _ ->
|
.setPositiveButton(R.string.nc_delete) { _, _ ->
|
||||||
@ -1147,7 +1150,7 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
.setNegativeButton(R.string.nc_cancel) { _, _ ->
|
.setNegativeButton(R.string.nc_cancel) { _, _ ->
|
||||||
conversationMenuBundle = null
|
conversationMenuBundle = null
|
||||||
}
|
}
|
||||||
viewThemeUtils.material
|
viewThemeUtils.dialog
|
||||||
.colorMaterialAlertDialogBackground(binding.floatingActionButton.context, dialogBuilder)
|
.colorMaterialAlertDialogBackground(binding.floatingActionButton.context, dialogBuilder)
|
||||||
val dialog = dialogBuilder.show()
|
val dialog = dialogBuilder.show()
|
||||||
viewThemeUtils.platform.colorTextButtons(
|
viewThemeUtils.platform.colorTextButtons(
|
||||||
@ -1161,7 +1164,7 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
private fun showUnauthorizedDialog() {
|
private fun showUnauthorizedDialog() {
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
val dialogBuilder = MaterialAlertDialogBuilder(binding.floatingActionButton.context)
|
val dialogBuilder = MaterialAlertDialogBuilder(binding.floatingActionButton.context)
|
||||||
.setIcon(viewThemeUtils.colorMaterialAlertDialogIcon(context, R.drawable.ic_delete_black_24dp))
|
.setIcon(viewThemeUtils.dialog.colorMaterialAlertDialogIcon(context, R.drawable.ic_delete_black_24dp))
|
||||||
.setTitle(R.string.nc_dialog_invalid_password)
|
.setTitle(R.string.nc_dialog_invalid_password)
|
||||||
.setMessage(R.string.nc_dialog_reauth_or_delete)
|
.setMessage(R.string.nc_dialog_reauth_or_delete)
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
@ -1191,7 +1194,7 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
.popChangeHandler(VerticalChangeHandler())
|
.popChangeHandler(VerticalChangeHandler())
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
viewThemeUtils.material
|
viewThemeUtils.dialog
|
||||||
.colorMaterialAlertDialogBackground(binding.floatingActionButton.context, dialogBuilder)
|
.colorMaterialAlertDialogBackground(binding.floatingActionButton.context, dialogBuilder)
|
||||||
val dialog = dialogBuilder.show()
|
val dialog = dialogBuilder.show()
|
||||||
viewThemeUtils.platform.colorTextButtons(
|
viewThemeUtils.platform.colorTextButtons(
|
||||||
@ -1203,7 +1206,7 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
|
|
||||||
private fun showServerEOLDialog() {
|
private fun showServerEOLDialog() {
|
||||||
val dialogBuilder = MaterialAlertDialogBuilder(binding.floatingActionButton.context)
|
val dialogBuilder = MaterialAlertDialogBuilder(binding.floatingActionButton.context)
|
||||||
.setIcon(viewThemeUtils.colorMaterialAlertDialogIcon(context, R.drawable.ic_warning_white))
|
.setIcon(viewThemeUtils.dialog.colorMaterialAlertDialogIcon(context, R.drawable.ic_warning_white))
|
||||||
.setTitle(R.string.nc_settings_server_eol_title)
|
.setTitle(R.string.nc_settings_server_eol_title)
|
||||||
.setMessage(R.string.nc_settings_server_eol)
|
.setMessage(R.string.nc_settings_server_eol)
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
@ -1234,7 +1237,7 @@ class ConversationsListController(bundle: Bundle) :
|
|||||||
activity!!.finish()
|
activity!!.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
viewThemeUtils.material.colorMaterialAlertDialogBackground(binding.floatingActionButton.context, dialogBuilder)
|
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(binding.floatingActionButton.context, dialogBuilder)
|
||||||
val dialog = dialogBuilder.show()
|
val dialog = dialogBuilder.show()
|
||||||
viewThemeUtils.platform.colorTextButtons(
|
viewThemeUtils.platform.colorTextButtons(
|
||||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE),
|
dialog.getButton(AlertDialog.BUTTON_POSITIVE),
|
||||||
|
@ -385,7 +385,7 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|||||||
// unused atm
|
// unused atm
|
||||||
}
|
}
|
||||||
|
|
||||||
viewThemeUtils.material.colorMaterialAlertDialogBackground(
|
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(
|
||||||
binding.messageText.context,
|
binding.messageText.context,
|
||||||
materialAlertDialogBuilder
|
materialAlertDialogBuilder
|
||||||
)
|
)
|
||||||
@ -508,7 +508,7 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|||||||
settingsPhoneBookIntegration,
|
settingsPhoneBookIntegration,
|
||||||
settingsReadPrivacy,
|
settingsReadPrivacy,
|
||||||
settingsProxyUseCredentials
|
settingsProxyUseCredentials
|
||||||
).forEach(viewThemeUtils::colorSwitchPreference)
|
).forEach(viewThemeUtils.talk::colorSwitchPreference)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -520,7 +520,7 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|||||||
settingsAdvancedCategory,
|
settingsAdvancedCategory,
|
||||||
settingsAppearanceCategory,
|
settingsAppearanceCategory,
|
||||||
settingsPrivacyCategory
|
settingsPrivacyCategory
|
||||||
).forEach(viewThemeUtils::colorPreferenceCategory)
|
).forEach(viewThemeUtils.talk::colorPreferenceCategory)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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.material.colorMaterialAlertDialogBackground(phoneNumberInputLayout.context, dialogBuilder)
|
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(phoneNumberInputLayout.context, dialogBuilder)
|
||||||
|
|
||||||
val dialog = dialogBuilder.create()
|
val dialog = dialogBuilder.create()
|
||||||
dialog.setOnShowListener(object : OnShowListener {
|
dialog.setOnShowListener(object : OnShowListener {
|
||||||
|
@ -41,8 +41,8 @@ class PollResultHeaderViewHolder(
|
|||||||
binding.pollOptionText.text = item.name
|
binding.pollOptionText.text = item.name
|
||||||
binding.pollOptionPercentText.text = "${item.percent}%"
|
binding.pollOptionPercentText.text = "${item.percent}%"
|
||||||
|
|
||||||
viewThemeUtils.colorDialogSupportingText(binding.pollOptionText)
|
viewThemeUtils.dialog.colorDialogSupportingText(binding.pollOptionText)
|
||||||
viewThemeUtils.colorDialogSupportingText(binding.pollOptionPercentText)
|
viewThemeUtils.dialog.colorDialogSupportingText(binding.pollOptionPercentText)
|
||||||
|
|
||||||
if (item.selfVoted) {
|
if (item.selfVoted) {
|
||||||
binding.pollOptionText.setTypeface(null, Typeface.BOLD)
|
binding.pollOptionText.setTypeface(null, Typeface.BOLD)
|
||||||
|
@ -47,7 +47,7 @@ class PollResultVoterViewHolder(
|
|||||||
|
|
||||||
binding.pollVoterName.text = item.details.actorDisplayName
|
binding.pollVoterName.text = item.details.actorDisplayName
|
||||||
binding.pollVoterAvatar.controller = getAvatarDraweeController(item.details)
|
binding.pollVoterAvatar.controller = getAvatarDraweeController(item.details)
|
||||||
viewThemeUtils.colorDialogSupportingText(binding.pollVoterName)
|
viewThemeUtils.dialog.colorDialogSupportingText(binding.pollVoterName)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getAvatarDraweeController(pollDetail: PollDetails): DraweeController? {
|
private fun getAvatarDraweeController(pollDetail: PollDetails): DraweeController? {
|
||||||
|
@ -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.material.colorMaterialAlertDialogBackground(binding.root.context, dialogBuilder)
|
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(binding.root.context, dialogBuilder)
|
||||||
|
|
||||||
return dialogBuilder.create()
|
return dialogBuilder.create()
|
||||||
}
|
}
|
||||||
|
@ -72,13 +72,13 @@ class PollMainDialogFragment : DialogFragment() {
|
|||||||
|
|
||||||
val dialogBuilder = MaterialAlertDialogBuilder(binding.root.context).setView(binding.root)
|
val dialogBuilder = MaterialAlertDialogBuilder(binding.root.context).setView(binding.root)
|
||||||
|
|
||||||
viewThemeUtils.material.colorMaterialAlertDialogBackground(binding.root.context, dialogBuilder)
|
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(binding.root.context, dialogBuilder)
|
||||||
|
|
||||||
val dialog = dialogBuilder.create()
|
val dialog = dialogBuilder.create()
|
||||||
|
|
||||||
binding.messagePollTitle.text = viewModel.pollTitle
|
binding.messagePollTitle.text = viewModel.pollTitle
|
||||||
viewThemeUtils.colorDialogHeadline(binding.messagePollTitle)
|
viewThemeUtils.dialog.colorDialogHeadline(binding.messagePollTitle)
|
||||||
viewThemeUtils.colorDialogIcon(binding.messagePollIcon)
|
viewThemeUtils.dialog.colorDialogIcon(binding.messagePollIcon)
|
||||||
|
|
||||||
return dialog
|
return dialog
|
||||||
}
|
}
|
||||||
@ -143,7 +143,7 @@ class PollMainDialogFragment : DialogFragment() {
|
|||||||
|
|
||||||
private fun initVotersAmount(showVotersAmount: Boolean, numVoters: Int, showResultSubtitle: Boolean) {
|
private fun initVotersAmount(showVotersAmount: Boolean, numVoters: Int, showResultSubtitle: Boolean) {
|
||||||
if (showVotersAmount) {
|
if (showVotersAmount) {
|
||||||
viewThemeUtils.colorDialogSupportingText(binding.pollVotesAmount)
|
viewThemeUtils.dialog.colorDialogSupportingText(binding.pollVotesAmount)
|
||||||
binding.pollVotesAmount.visibility = View.VISIBLE
|
binding.pollVotesAmount.visibility = View.VISIBLE
|
||||||
binding.pollVotesAmount.text = resources.getQuantityString(
|
binding.pollVotesAmount.text = resources.getQuantityString(
|
||||||
R.plurals.polls_amount_voters,
|
R.plurals.polls_amount_voters,
|
||||||
@ -155,7 +155,7 @@ class PollMainDialogFragment : DialogFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (showResultSubtitle) {
|
if (showResultSubtitle) {
|
||||||
viewThemeUtils.colorDialogSupportingText(binding.pollResultsSubtitle)
|
viewThemeUtils.dialog.colorDialogSupportingText(binding.pollResultsSubtitle)
|
||||||
binding.pollResultsSubtitle.visibility = View.VISIBLE
|
binding.pollResultsSubtitle.visibility = View.VISIBLE
|
||||||
binding.pollResultsSubtitleSeperator.visibility = View.VISIBLE
|
binding.pollResultsSubtitleSeperator.visibility = View.VISIBLE
|
||||||
} else {
|
} else {
|
||||||
|
@ -132,7 +132,7 @@ class PollResultsFragment : Fragment(), PollResultItemClickListener {
|
|||||||
}
|
}
|
||||||
.setNegativeButton(R.string.nc_cancel, null)
|
.setNegativeButton(R.string.nc_cancel, null)
|
||||||
|
|
||||||
viewThemeUtils.material.colorMaterialAlertDialogBackground(
|
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(
|
||||||
binding.pollResultsEndPollButton.context,
|
binding.pollResultsEndPollButton.context,
|
||||||
dialogBuilder
|
dialogBuilder
|
||||||
)
|
)
|
||||||
|
@ -215,7 +215,7 @@ class PollVoteFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
.setNegativeButton(R.string.nc_cancel, null)
|
.setNegativeButton(R.string.nc_cancel, null)
|
||||||
|
|
||||||
viewThemeUtils.material.colorMaterialAlertDialogBackground(
|
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(
|
||||||
binding.pollVoteEndPollButton.context,
|
binding.pollVoteEndPollButton.context,
|
||||||
dialogBuilder
|
dialogBuilder
|
||||||
)
|
)
|
||||||
|
@ -100,7 +100,7 @@ class RemoteFileBrowserActivity : AppCompatActivity(), SelectionInterface, Swipe
|
|||||||
initViewModel(mimeTypeSelectionFilter)
|
initViewModel(mimeTypeSelectionFilter)
|
||||||
|
|
||||||
binding.swipeRefreshList.setOnRefreshListener(this)
|
binding.swipeRefreshList.setOnRefreshListener(this)
|
||||||
viewThemeUtils.themeSwipeRefreshLayout(binding.swipeRefreshList)
|
viewThemeUtils.androidx.themeSwipeRefreshLayout(binding.swipeRefreshList)
|
||||||
|
|
||||||
binding.pathNavigationBackButton.setOnClickListener { viewModel.navigateUp() }
|
binding.pathNavigationBackButton.setOnClickListener { viewModel.navigateUp() }
|
||||||
binding.sortButton.setOnClickListener { changeSorting() }
|
binding.sortButton.setOnClickListener { changeSorting() }
|
||||||
|
@ -217,11 +217,11 @@ public class ChooseAccountDialogFragment extends DialogFragment {
|
|||||||
viewThemeUtils.platform.themeDialogDivider(binding.divider);
|
viewThemeUtils.platform.themeDialogDivider(binding.divider);
|
||||||
|
|
||||||
viewThemeUtils.material.colorMaterialTextButton(binding.setStatus);
|
viewThemeUtils.material.colorMaterialTextButton(binding.setStatus);
|
||||||
viewThemeUtils.colorDialogMenuText(binding.setStatus);
|
viewThemeUtils.dialog.colorDialogMenuText(binding.setStatus);
|
||||||
viewThemeUtils.material.colorMaterialTextButton(binding.addAccount);
|
viewThemeUtils.material.colorMaterialTextButton(binding.addAccount);
|
||||||
viewThemeUtils.colorDialogMenuText(binding.addAccount);
|
viewThemeUtils.dialog.colorDialogMenuText(binding.addAccount);
|
||||||
viewThemeUtils.material.colorMaterialTextButton(binding.manageSettings);
|
viewThemeUtils.material.colorMaterialTextButton(binding.manageSettings);
|
||||||
viewThemeUtils.colorDialogMenuText(binding.manageSettings);
|
viewThemeUtils.dialog.colorDialogMenuText(binding.manageSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadCurrentStatus(User user) {
|
private void loadCurrentStatus(User user) {
|
||||||
|
@ -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.material.colorMaterialAlertDialogBackground(binding.root.context, dialogBuilder)
|
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(binding.root.context, dialogBuilder)
|
||||||
|
|
||||||
return dialogBuilder.create()
|
return dialogBuilder.create()
|
||||||
}
|
}
|
||||||
|
@ -21,26 +21,13 @@
|
|||||||
|
|
||||||
package com.nextcloud.talk.ui.theme
|
package com.nextcloud.talk.ui.theme
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.res.ColorStateList
|
|
||||||
import android.graphics.drawable.Drawable
|
|
||||||
import android.text.Spannable
|
|
||||||
import android.text.SpannableString
|
|
||||||
import android.widget.ImageView
|
|
||||||
import android.widget.TextView
|
|
||||||
import androidx.appcompat.content.res.AppCompatResources
|
|
||||||
import androidx.core.graphics.drawable.DrawableCompat
|
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
|
||||||
import com.google.android.material.button.MaterialButton
|
|
||||||
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.ui.theme.viewthemeutils.AndroidViewThemeUtils
|
import com.nextcloud.talk.ui.theme.viewthemeutils.AndroidViewThemeUtils
|
||||||
import com.nextcloud.talk.ui.theme.viewthemeutils.AppCompatViewThemeUtils
|
import com.nextcloud.talk.ui.theme.viewthemeutils.AndroidXViewThemeUtils
|
||||||
|
import com.nextcloud.talk.ui.theme.viewthemeutils.DialogViewThemeUtils
|
||||||
import com.nextcloud.talk.ui.theme.viewthemeutils.MaterialViewThemeUtils
|
import com.nextcloud.talk.ui.theme.viewthemeutils.MaterialViewThemeUtils
|
||||||
import com.nextcloud.talk.ui.theme.viewthemeutils.TalkSpecificViewThemeUtils
|
import com.nextcloud.talk.ui.theme.viewthemeutils.TalkSpecificViewThemeUtils
|
||||||
import com.nextcloud.talk.utils.DisplayUtils
|
|
||||||
import eu.davidea.flexibleadapter.utils.FlexibleUtils
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@Suppress("TooManyFunctions")
|
@Suppress("TooManyFunctions")
|
||||||
@ -51,62 +38,9 @@ class ViewThemeUtils @Inject constructor(
|
|||||||
@JvmField
|
@JvmField
|
||||||
val material: MaterialViewThemeUtils,
|
val material: MaterialViewThemeUtils,
|
||||||
@JvmField
|
@JvmField
|
||||||
val appcompat: AppCompatViewThemeUtils,
|
val androidx: AndroidXViewThemeUtils,
|
||||||
@JvmField
|
@JvmField
|
||||||
val talk: TalkSpecificViewThemeUtils
|
val talk: TalkSpecificViewThemeUtils,
|
||||||
) : ViewThemeUtilsBase(schemes) {
|
@JvmField
|
||||||
|
val dialog: DialogViewThemeUtils
|
||||||
fun themeSwipeRefreshLayout(swipeRefreshLayout: SwipeRefreshLayout) {
|
) : ViewThemeUtilsBase(schemes)
|
||||||
withScheme(swipeRefreshLayout) { scheme ->
|
|
||||||
swipeRefreshLayout.setColorSchemeColors(scheme.primary)
|
|
||||||
swipeRefreshLayout.setProgressBackgroundColorSchemeResource(R.color.refresh_spinner_background)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun colorDialogMenuText(button: MaterialButton) {
|
|
||||||
withScheme(button) { scheme ->
|
|
||||||
button.setTextColor(scheme.onSurface)
|
|
||||||
button.iconTint = ColorStateList.valueOf(scheme.onSurface)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun colorDialogHeadline(textView: TextView) {
|
|
||||||
withScheme(textView) { scheme ->
|
|
||||||
textView.setTextColor(scheme.onSurface)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun colorDialogSupportingText(textView: TextView) {
|
|
||||||
withScheme(textView) { scheme ->
|
|
||||||
textView.setTextColor(scheme.onSurfaceVariant)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun colorDialogIcon(icon: ImageView) {
|
|
||||||
withScheme(icon) { scheme ->
|
|
||||||
icon.setColorFilter(scheme.secondary)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun highlightText(textView: TextView, originalText: String, constraint: String) {
|
|
||||||
withScheme(textView) { scheme ->
|
|
||||||
FlexibleUtils.highlightText(textView, originalText, constraint, scheme.primary)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun createHighlightedSpan(context: Context, messageSpannable: SpannableString, searchTerm: String): Spannable {
|
|
||||||
var spannable: Spannable = messageSpannable
|
|
||||||
withScheme(context) { scheme ->
|
|
||||||
spannable = DisplayUtils.searchAndColor(messageSpannable, searchTerm, scheme.primary)
|
|
||||||
}
|
|
||||||
return spannable
|
|
||||||
}
|
|
||||||
|
|
||||||
fun colorMaterialAlertDialogIcon(context: Context, drawableId: Int): Drawable {
|
|
||||||
val drawable = AppCompatResources.getDrawable(context, drawableId)!!
|
|
||||||
withScheme(context) { scheme ->
|
|
||||||
DrawableCompat.setTint(drawable, scheme.secondary)
|
|
||||||
}
|
|
||||||
return drawable
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -44,6 +44,7 @@ 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.utils.DisplayUtils
|
import com.nextcloud.talk.utils.DisplayUtils
|
||||||
|
import eu.davidea.flexibleadapter.utils.FlexibleUtils
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,15 +68,18 @@ class AndroidViewThemeUtils @Inject constructor(schemes: MaterialSchemes, privat
|
|||||||
|
|
||||||
fun themeStatusBar(activity: Activity, view: View) {
|
fun themeStatusBar(activity: Activity, view: View) {
|
||||||
withScheme(view) { scheme ->
|
withScheme(view) { scheme ->
|
||||||
|
// TODO extract from displayutils to common
|
||||||
DisplayUtils.applyColorToStatusBar(activity, scheme.surface)
|
DisplayUtils.applyColorToStatusBar(activity, scheme.surface)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun resetStatusBar(activity: Activity, view: View) {
|
fun resetStatusBar(activity: Activity, view: View) {
|
||||||
|
// TODO extract from displayutils to common
|
||||||
DisplayUtils.applyColorToStatusBar(
|
DisplayUtils.applyColorToStatusBar(
|
||||||
activity,
|
activity,
|
||||||
ResourcesCompat.getColor(
|
ResourcesCompat.getColor(
|
||||||
activity.resources,
|
activity.resources,
|
||||||
|
// TODO do not use talk.R
|
||||||
R.color.bg_default,
|
R.color.bg_default,
|
||||||
activity.theme
|
activity.theme
|
||||||
)
|
)
|
||||||
@ -250,6 +254,13 @@ class AndroidViewThemeUtils @Inject constructor(schemes: MaterialSchemes, privat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun highlightText(textView: TextView, originalText: String, constraint: String) {
|
||||||
|
withScheme(textView) { scheme ->
|
||||||
|
// TODO do not use FlexibleUtils for this
|
||||||
|
FlexibleUtils.highlightText(textView, originalText, constraint, scheme.primary)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val ON_SURFACE_OPACITY_BUTTON_DISABLED: Float = 0.38f
|
private const val ON_SURFACE_OPACITY_BUTTON_DISABLED: Float = 0.38f
|
||||||
}
|
}
|
||||||
|
@ -27,16 +27,16 @@ import android.widget.LinearLayout
|
|||||||
import androidx.appcompat.widget.SearchView
|
import androidx.appcompat.widget.SearchView
|
||||||
import androidx.appcompat.widget.SwitchCompat
|
import androidx.appcompat.widget.SwitchCompat
|
||||||
import androidx.core.content.res.ResourcesCompat
|
import androidx.core.content.res.ResourcesCompat
|
||||||
import com.nextcloud.android.common.ui.color.ColorUtil
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
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 javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View theme utils for AppCompat views (androidx.appcompat.*)
|
* View theme utils for Android extension views (androidx.*)
|
||||||
*/
|
*/
|
||||||
class AppCompatViewThemeUtils @Inject constructor(schemes: MaterialSchemes, private val colorUtil: ColorUtil) :
|
class AndroidXViewThemeUtils @Inject constructor(schemes: MaterialSchemes) :
|
||||||
ViewThemeUtilsBase(schemes) {
|
ViewThemeUtilsBase(schemes) {
|
||||||
fun themeSearchView(searchView: SearchView) {
|
fun themeSearchView(searchView: SearchView) {
|
||||||
withScheme(searchView) { scheme ->
|
withScheme(searchView) { scheme ->
|
||||||
@ -58,11 +58,13 @@ class AppCompatViewThemeUtils @Inject constructor(schemes: MaterialSchemes, priv
|
|||||||
|
|
||||||
val thumbUncheckedColor = ResourcesCompat.getColor(
|
val thumbUncheckedColor = ResourcesCompat.getColor(
|
||||||
context.resources,
|
context.resources,
|
||||||
|
// TODO extract to common
|
||||||
R.color.switch_thumb_color_unchecked,
|
R.color.switch_thumb_color_unchecked,
|
||||||
context.theme
|
context.theme
|
||||||
)
|
)
|
||||||
val trackUncheckedColor = ResourcesCompat.getColor(
|
val trackUncheckedColor = ResourcesCompat.getColor(
|
||||||
context.resources,
|
context.resources,
|
||||||
|
// TODO extract to common
|
||||||
R.color.switch_track_color_unchecked,
|
R.color.switch_track_color_unchecked,
|
||||||
context.theme
|
context.theme
|
||||||
)
|
)
|
||||||
@ -86,6 +88,13 @@ class AppCompatViewThemeUtils @Inject constructor(schemes: MaterialSchemes, priv
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun themeSwipeRefreshLayout(swipeRefreshLayout: SwipeRefreshLayout) {
|
||||||
|
withScheme(swipeRefreshLayout) { scheme ->
|
||||||
|
swipeRefreshLayout.setColorSchemeColors(scheme.primary)
|
||||||
|
swipeRefreshLayout.setProgressBackgroundColorSchemeResource(R.color.refresh_spinner_background)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val SWITCH_COMPAT_TRACK_ALPHA: Int = 77
|
private const val SWITCH_COMPAT_TRACK_ALPHA: Int = 77
|
||||||
private const val SEARCH_TEXT_SIZE: Float = 16f
|
private const val SEARCH_TEXT_SIZE: Float = 16f
|
@ -0,0 +1,99 @@
|
|||||||
|
/*
|
||||||
|
* 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.drawable.Drawable
|
||||||
|
import android.os.Build
|
||||||
|
import android.widget.ImageView
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.appcompat.content.res.AppCompatResources
|
||||||
|
import androidx.core.graphics.drawable.DrawableCompat
|
||||||
|
import com.google.android.material.R
|
||||||
|
import com.google.android.material.button.MaterialButton
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
import com.google.android.material.shape.MaterialShapeDrawable
|
||||||
|
import com.nextcloud.android.common.ui.theme.MaterialSchemes
|
||||||
|
import com.nextcloud.android.common.ui.theme.ViewThemeUtilsBase
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
/**
|
||||||
|
* View theme utils for dialogs
|
||||||
|
*/
|
||||||
|
class DialogViewThemeUtils @Inject constructor(schemes: MaterialSchemes) :
|
||||||
|
ViewThemeUtilsBase(schemes) {
|
||||||
|
|
||||||
|
fun colorMaterialAlertDialogBackground(context: Context, dialogBuilder: MaterialAlertDialogBuilder) {
|
||||||
|
withScheme(dialogBuilder.context) { scheme ->
|
||||||
|
val materialShapeDrawable = MaterialShapeDrawable(
|
||||||
|
context,
|
||||||
|
null,
|
||||||
|
R.attr.alertDialogStyle,
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun colorDialogMenuText(button: MaterialButton) {
|
||||||
|
withScheme(button) { scheme ->
|
||||||
|
button.setTextColor(scheme.onSurface)
|
||||||
|
button.iconTint = ColorStateList.valueOf(scheme.onSurface)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun colorDialogHeadline(textView: TextView) {
|
||||||
|
withScheme(textView) { scheme ->
|
||||||
|
textView.setTextColor(scheme.onSurface)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun colorDialogSupportingText(textView: TextView) {
|
||||||
|
withScheme(textView) { scheme ->
|
||||||
|
textView.setTextColor(scheme.onSurfaceVariant)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun colorDialogIcon(icon: ImageView) {
|
||||||
|
withScheme(icon) { scheme ->
|
||||||
|
icon.setColorFilter(scheme.secondary)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun colorMaterialAlertDialogIcon(context: Context, drawableId: Int): Drawable {
|
||||||
|
val drawable = AppCompatResources.getDrawable(context, drawableId)!!
|
||||||
|
withScheme(context) { scheme ->
|
||||||
|
DrawableCompat.setTint(drawable, scheme.secondary)
|
||||||
|
}
|
||||||
|
return drawable
|
||||||
|
}
|
||||||
|
}
|
@ -21,20 +21,16 @@
|
|||||||
|
|
||||||
package com.nextcloud.talk.ui.theme.viewthemeutils
|
package com.nextcloud.talk.ui.theme.viewthemeutils
|
||||||
|
|
||||||
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.PorterDuff
|
||||||
import android.os.Build
|
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import com.google.android.material.appbar.MaterialToolbar
|
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.Chip
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
import com.google.android.material.progressindicator.LinearProgressIndicator
|
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.tabs.TabLayout
|
||||||
import com.google.android.material.textfield.TextInputLayout
|
import com.google.android.material.textfield.TextInputLayout
|
||||||
import com.google.android.material.textview.MaterialTextView
|
import com.google.android.material.textview.MaterialTextView
|
||||||
@ -296,27 +292,6 @@ class MaterialViewThemeUtils @Inject constructor(schemes: MaterialSchemes, priva
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
companion object {
|
||||||
private const val SURFACE_OPACITY_BUTTON_DISABLED: Float = 0.12f
|
private const val SURFACE_OPACITY_BUTTON_DISABLED: Float = 0.12f
|
||||||
private const val ON_SURFACE_OPACITY_BUTTON_DISABLED: Float = 0.38f
|
private const val ON_SURFACE_OPACITY_BUTTON_DISABLED: Float = 0.38f
|
||||||
|
@ -62,7 +62,7 @@ import kotlin.math.roundToInt
|
|||||||
@Suppress("TooManyFunctions")
|
@Suppress("TooManyFunctions")
|
||||||
class TalkSpecificViewThemeUtils @Inject constructor(
|
class TalkSpecificViewThemeUtils @Inject constructor(
|
||||||
schemes: MaterialSchemes,
|
schemes: MaterialSchemes,
|
||||||
private val appcompat: AppCompatViewThemeUtils
|
private val appcompat: AndroidXViewThemeUtils
|
||||||
) :
|
) :
|
||||||
ViewThemeUtilsBase(schemes) {
|
ViewThemeUtilsBase(schemes) {
|
||||||
fun themeIncomingMessageBubble(bubble: ViewGroup, grouped: Boolean, deleted: Boolean) {
|
fun themeIncomingMessageBubble(bubble: ViewGroup, grouped: Boolean, deleted: Boolean) {
|
||||||
|
@ -96,7 +96,7 @@ public class MagicUserInputModule extends StandardUserInputModule {
|
|||||||
.setTitle(title)
|
.setTitle(title)
|
||||||
.setView(view);
|
.setView(view);
|
||||||
|
|
||||||
viewThemeUtils.material.colorMaterialAlertDialogBackground(view.getContext(), dialogBuilder);
|
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(view.getContext(), dialogBuilder);
|
||||||
|
|
||||||
final Dialog dialog = dialogBuilder.show();
|
final Dialog dialog = dialogBuilder.show();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user