diff --git a/app/build.gradle b/app/build.gradle
index 209c174c7..ac8ad687f 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -332,8 +332,8 @@ dependencies {
// implementation 'androidx.activity:activity-ktx:1.4.0'
- //
- implementation 'com.github.nextcloud.android-common:ui:4da3363e61ed646e091754147558ee3be346abc5'
+ // TODO substitute for tag after first common release
+ implementation 'com.github.nextcloud.android-common:ui:83c4a8aa885e8ef1bba2e44704be8625db396e1b'
}
task installGitHooks(type: Copy, group: "development") {
diff --git a/app/src/main/java/com/nextcloud/talk/ui/theme/viewthemeutils/TalkSpecificViewThemeUtils.kt b/app/src/main/java/com/nextcloud/talk/ui/theme/TalkSpecificViewThemeUtils.kt
similarity index 98%
rename from app/src/main/java/com/nextcloud/talk/ui/theme/viewthemeutils/TalkSpecificViewThemeUtils.kt
rename to app/src/main/java/com/nextcloud/talk/ui/theme/TalkSpecificViewThemeUtils.kt
index 50db3d2d3..a1f94460a 100644
--- a/app/src/main/java/com/nextcloud/talk/ui/theme/viewthemeutils/TalkSpecificViewThemeUtils.kt
+++ b/app/src/main/java/com/nextcloud/talk/ui/theme/TalkSpecificViewThemeUtils.kt
@@ -19,7 +19,7 @@
* along with this program. If not, see .
*/
-package com.nextcloud.talk.ui.theme.viewthemeutils
+package com.nextcloud.talk.ui.theme
import android.annotation.TargetApi
import android.content.Context
@@ -46,6 +46,7 @@ import com.google.android.material.card.MaterialCardView
import com.google.android.material.chip.ChipDrawable
import com.nextcloud.android.common.ui.theme.MaterialSchemes
import com.nextcloud.android.common.ui.theme.ViewThemeUtilsBase
+import com.nextcloud.android.common.ui.theme.utils.AndroidXViewThemeUtils
import com.nextcloud.talk.R
import com.nextcloud.talk.utils.DisplayUtils
import com.nextcloud.talk.utils.DrawableUtils
diff --git a/app/src/main/java/com/nextcloud/talk/ui/theme/ViewThemeUtils.kt b/app/src/main/java/com/nextcloud/talk/ui/theme/ViewThemeUtils.kt
index 41e17df76..5c058d16b 100644
--- a/app/src/main/java/com/nextcloud/talk/ui/theme/ViewThemeUtils.kt
+++ b/app/src/main/java/com/nextcloud/talk/ui/theme/ViewThemeUtils.kt
@@ -23,11 +23,10 @@ package com.nextcloud.talk.ui.theme
import com.nextcloud.android.common.ui.theme.MaterialSchemes
import com.nextcloud.android.common.ui.theme.ViewThemeUtilsBase
-import com.nextcloud.talk.ui.theme.viewthemeutils.AndroidViewThemeUtils
-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.TalkSpecificViewThemeUtils
+import com.nextcloud.android.common.ui.theme.utils.AndroidViewThemeUtils
+import com.nextcloud.android.common.ui.theme.utils.AndroidXViewThemeUtils
+import com.nextcloud.android.common.ui.theme.utils.DialogViewThemeUtils
+import com.nextcloud.android.common.ui.theme.utils.MaterialViewThemeUtils
import javax.inject.Inject
@Suppress("TooManyFunctions")
diff --git a/app/src/main/java/com/nextcloud/talk/ui/theme/viewthemeutils/AndroidViewThemeUtils.kt b/app/src/main/java/com/nextcloud/talk/ui/theme/viewthemeutils/AndroidViewThemeUtils.kt
deleted file mode 100644
index f8f71de19..000000000
--- a/app/src/main/java/com/nextcloud/talk/ui/theme/viewthemeutils/AndroidViewThemeUtils.kt
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * 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 .
- */
-
-package com.nextcloud.talk.ui.theme.viewthemeutils
-
-import android.app.Activity
-import android.content.Context
-import android.content.res.ColorStateList
-import android.graphics.Color
-import android.graphics.PorterDuff
-import android.os.Build
-import android.view.MenuItem
-import android.view.View
-import android.widget.Button
-import android.widget.CheckBox
-import android.widget.EditText
-import android.widget.ImageButton
-import android.widget.ImageView
-import android.widget.ProgressBar
-import android.widget.RadioButton
-import android.widget.SeekBar
-import android.widget.TextView
-import androidx.annotation.ColorInt
-import androidx.core.content.res.ResourcesCompat
-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.android.common.ui.util.PlatformThemeUtil
-import com.nextcloud.talk.R
-import eu.davidea.flexibleadapter.utils.FlexibleUtils
-import javax.inject.Inject
-
-/**
- * View theme utils for platform views (android.widget.*, android.view.*)
- */
-@Suppress("TooManyFunctions")
-class AndroidViewThemeUtils @Inject constructor(schemes: MaterialSchemes, private val colorUtil: ColorUtil) :
- ViewThemeUtilsBase(schemes) {
-
- fun colorViewBackground(view: View) {
- withScheme(view) { scheme ->
- view.setBackgroundColor(scheme.surface)
- }
- }
-
- fun colorToolbarMenuIcon(context: Context, item: MenuItem) {
- withScheme(context) { scheme ->
- item.icon.setColorFilter(scheme.onSurface, PorterDuff.Mode.SRC_ATOP)
- }
- }
-
- fun themeStatusBar(activity: Activity, view: View) {
- withScheme(view) { scheme ->
- applyColorToStatusBar(activity, scheme.surface)
- }
- }
-
- private fun applyColorToStatusBar(activity: Activity, @ColorInt color: Int) {
- val window = activity.window
- val isLightTheme = !PlatformThemeUtil.isDarkMode(activity)
- if (window != null) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- val decor = window.decorView
- if (isLightTheme) {
- val systemUiFlagLightStatusBar = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR or
- View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
- } else {
- View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
- }
- decor.systemUiVisibility = systemUiFlagLightStatusBar
- } else {
- decor.systemUiVisibility = 0
- }
- window.statusBarColor = color
- } else if (isLightTheme) {
- window.statusBarColor = Color.BLACK
- }
- }
- }
-
- fun resetStatusBar(activity: Activity) {
- applyColorToStatusBar(
- activity,
- ResourcesCompat.getColor(
- activity.resources,
- // TODO do not use talk.R
- R.color.bg_default,
- activity.theme
- )
- )
- }
-
- fun themeDialog(view: View) {
- withScheme(view) { scheme ->
- view.setBackgroundColor(scheme.surface)
- }
- }
-
- fun themeDialogDark(view: View) {
- withSchemeDark { scheme ->
- view.setBackgroundColor(scheme.surface)
- }
- }
-
- fun themeDialogDivider(view: View) {
- withScheme(view) { scheme ->
- view.setBackgroundColor(scheme.surfaceVariant)
- }
- }
-
- fun themeHorizontalSeekBar(seekBar: SeekBar) {
- withScheme(seekBar) { scheme ->
- themeHorizontalProgressBar(seekBar, scheme.primary)
- seekBar.thumb.setColorFilter(scheme.primary, PorterDuff.Mode.SRC_IN)
- }
- }
-
- fun themeHorizontalProgressBar(progressBar: ProgressBar?, @ColorInt color: Int) {
- if (progressBar != null) {
- progressBar.indeterminateDrawable.setColorFilter(color, PorterDuff.Mode.SRC_IN)
- progressBar.progressDrawable.setColorFilter(color, PorterDuff.Mode.SRC_IN)
- }
- }
-
- fun colorPrimaryTextViewElement(textView: TextView) {
- withScheme(textView) { scheme ->
- textView.setTextColor(scheme.primary)
- }
- }
-
- fun colorPrimaryTextViewElementDarkMode(textView: TextView) {
- withSchemeDark { scheme ->
- textView.setTextColor(scheme.primary)
- }
- }
-
- fun colorPrimaryView(view: View) {
- withScheme(view) { scheme ->
- view.setBackgroundColor(scheme.primary)
- }
- }
-
- /**
- * Colors the background as element color and the foreground as text color.
- */
- fun colorImageViewButton(imageView: ImageView) {
- withScheme(imageView) { scheme ->
- imageView.imageTintList = ColorStateList.valueOf(scheme.onPrimaryContainer)
- imageView.backgroundTintList = ColorStateList.valueOf(scheme.primaryContainer)
- }
- }
-
- fun themeImageButton(imageButton: ImageButton) {
- withScheme(imageButton) { scheme ->
- imageButton.imageTintList = ColorStateList(
- arrayOf(
- intArrayOf(android.R.attr.state_selected),
- intArrayOf(-android.R.attr.state_selected),
- intArrayOf(android.R.attr.state_enabled),
- intArrayOf(-android.R.attr.state_enabled)
- ),
- intArrayOf(
- scheme.primary,
- scheme.onSurfaceVariant,
- scheme.onSurfaceVariant,
- colorUtil.adjustOpacity(scheme.onSurface, ON_SURFACE_OPACITY_BUTTON_DISABLED)
- )
- )
- }
- }
-
- /**
- * Tints the image with element color
- */
- fun colorImageView(imageView: ImageView) {
- withScheme(imageView) { scheme ->
- imageView.imageTintList = ColorStateList.valueOf(scheme.primary)
- }
- }
-
- fun colorTextButtons(vararg buttons: Button) {
- withScheme(buttons[0]) { scheme ->
- for (button in buttons) {
- 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)
- )
- )
- )
- }
- }
- }
-
- fun colorCircularProgressBarOnPrimaryContainer(progressBar: ProgressBar) {
- withScheme(progressBar) { scheme ->
- progressBar.indeterminateDrawable.setColorFilter(scheme.onPrimaryContainer, PorterDuff.Mode.SRC_ATOP)
- }
- }
-
- fun colorCircularProgressBar(progressBar: ProgressBar) {
- withScheme(progressBar) { scheme ->
- progressBar.indeterminateDrawable.setColorFilter(scheme.primary, PorterDuff.Mode.SRC_ATOP)
- }
- }
-
- fun colorCircularProgressBarOnSurfaceVariant(progressBar: ProgressBar) {
- withScheme(progressBar) { scheme ->
- progressBar.indeterminateDrawable.setColorFilter(scheme.onSurfaceVariant, PorterDuff.Mode.SRC_ATOP)
- }
- }
-
- fun themeCheckbox(checkbox: CheckBox) {
- withScheme(checkbox) { scheme ->
- checkbox.buttonTintList = ColorStateList(
- arrayOf(
- intArrayOf(-android.R.attr.state_checked),
- intArrayOf(android.R.attr.state_checked)
- ),
- intArrayOf(Color.GRAY, scheme.primary)
- )
- }
- }
-
- fun themeRadioButton(radioButton: RadioButton) {
- withScheme(radioButton) { scheme ->
- radioButton.buttonTintList = ColorStateList(
- arrayOf(
- intArrayOf(-android.R.attr.state_checked),
- intArrayOf(android.R.attr.state_checked)
- ),
- intArrayOf(Color.GRAY, scheme.primary)
- )
- }
- }
-
- fun colorEditText(editText: EditText) {
- withScheme(editText) { scheme ->
- // TODO check API-level compatibility
- // editText.background.setColorFilter(color, PorterDuff.Mode.SRC_ATOP)
- editText.backgroundTintList = ColorStateList(
- arrayOf(
- intArrayOf(-android.R.attr.state_focused),
- intArrayOf(android.R.attr.state_focused)
- ),
- intArrayOf(
- scheme.outline,
- scheme.primary
- )
- )
- editText.setHintTextColor(scheme.onSurfaceVariant)
- editText.setTextColor(scheme.onSurface)
- }
- }
-
- 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 {
- private const val ON_SURFACE_OPACITY_BUTTON_DISABLED: Float = 0.38f
- }
-}
diff --git a/app/src/main/java/com/nextcloud/talk/ui/theme/viewthemeutils/AndroidXViewThemeUtils.kt b/app/src/main/java/com/nextcloud/talk/ui/theme/viewthemeutils/AndroidXViewThemeUtils.kt
deleted file mode 100644
index 9e066b465..000000000
--- a/app/src/main/java/com/nextcloud/talk/ui/theme/viewthemeutils/AndroidXViewThemeUtils.kt
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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 .
- */
-
-package com.nextcloud.talk.ui.theme.viewthemeutils
-
-import android.content.res.ColorStateList
-import android.graphics.Color
-import androidx.appcompat.widget.SwitchCompat
-import androidx.core.content.res.ResourcesCompat
-import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
-import com.nextcloud.android.common.ui.theme.MaterialSchemes
-import com.nextcloud.android.common.ui.theme.ViewThemeUtilsBase
-import com.nextcloud.talk.R
-import javax.inject.Inject
-
-/**
- * View theme utils for Android extension views (androidx.*)
- */
-class AndroidXViewThemeUtils @Inject constructor(schemes: MaterialSchemes) :
- ViewThemeUtilsBase(schemes) {
-
- fun colorSwitchCompat(switchCompat: SwitchCompat) {
- withScheme(switchCompat) { scheme ->
-
- val context = switchCompat.context
-
- val thumbUncheckedColor = ResourcesCompat.getColor(
- context.resources,
- // TODO extract to common
- R.color.switch_thumb_color_unchecked,
- context.theme
- )
- val trackUncheckedColor = ResourcesCompat.getColor(
- context.resources,
- // TODO extract to common
- R.color.switch_track_color_unchecked,
- context.theme
- )
-
- val trackColor = Color.argb(
- SWITCH_COMPAT_TRACK_ALPHA,
- Color.red(scheme.primary),
- Color.green(scheme.primary),
- Color.blue(scheme.primary)
- )
-
- switchCompat.thumbTintList = ColorStateList(
- arrayOf(intArrayOf(android.R.attr.state_checked), intArrayOf()),
- intArrayOf(scheme.primary, thumbUncheckedColor)
- )
-
- switchCompat.trackTintList = ColorStateList(
- arrayOf(intArrayOf(android.R.attr.state_checked), intArrayOf()),
- intArrayOf(trackColor, trackUncheckedColor)
- )
- }
- }
-
- fun themeSwipeRefreshLayout(swipeRefreshLayout: SwipeRefreshLayout) {
- withScheme(swipeRefreshLayout) { scheme ->
- swipeRefreshLayout.setColorSchemeColors(scheme.primary)
- swipeRefreshLayout.setProgressBackgroundColorSchemeResource(R.color.refresh_spinner_background)
- }
- }
-
- companion object {
- private const val SWITCH_COMPAT_TRACK_ALPHA: Int = 77
- }
-}
diff --git a/app/src/main/java/com/nextcloud/talk/ui/theme/viewthemeutils/DialogViewThemeUtils.kt b/app/src/main/java/com/nextcloud/talk/ui/theme/viewthemeutils/DialogViewThemeUtils.kt
deleted file mode 100644
index 9ab1edf9c..000000000
--- a/app/src/main/java/com/nextcloud/talk/ui/theme/viewthemeutils/DialogViewThemeUtils.kt
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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 .
- */
-
-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
- }
-}
diff --git a/app/src/main/java/com/nextcloud/talk/ui/theme/viewthemeutils/MaterialViewThemeUtils.kt b/app/src/main/java/com/nextcloud/talk/ui/theme/viewthemeutils/MaterialViewThemeUtils.kt
deleted file mode 100644
index aeece3171..000000000
--- a/app/src/main/java/com/nextcloud/talk/ui/theme/viewthemeutils/MaterialViewThemeUtils.kt
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- * 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 .
- */
-
-package com.nextcloud.talk.ui.theme.viewthemeutils
-
-import android.content.res.ColorStateList
-import android.graphics.Color
-import android.graphics.PorterDuff
-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.floatingactionbutton.FloatingActionButton
-import com.google.android.material.progressindicator.LinearProgressIndicator
-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)
- }
- }
-
- companion object {
- private const val SURFACE_OPACITY_BUTTON_DISABLED: Float = 0.12f
- private const val ON_SURFACE_OPACITY_BUTTON_DISABLED: Float = 0.38f
- }
-}
diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml
index 5dcc92fb6..4c74299fa 100644
--- a/app/src/main/res/values-night/colors.xml
+++ b/app/src/main/res/values-night/colors.xml
@@ -32,7 +32,6 @@
#1E1E1E
#FFFFFF
- #222222
#ffffff
@@ -78,7 +77,5 @@
#353535
#424242
- #cbcbcb
- #5a5a5a
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 1de3f5fb0..62b316e58 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -33,7 +33,6 @@
@android:color/white
#666666
#A5A5A5
- #ffffff
#000000
@@ -108,7 +107,6 @@
#FFFFFF
#FFFFFF
- #ececec
- #b2b2b2
+
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 06ad11ad2..fa9a62401 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -74,8 +74,6 @@
2dp
12dp
- 28dp
-
18dp
50dp
diff --git a/settings.gradle b/settings.gradle
index 19e78ae9b..ba13dd9ac 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -20,8 +20,3 @@
include ':app'
-includeBuild('../android-common') {
- dependencySubstitution {
- substitute module('com.github.nextcloud.android-common:ui') using project(':ui')
- }
-}