diff --git a/sample/src/main/java/com/nextcloud/android/common/sample/MainActivity.kt b/sample/src/main/java/com/nextcloud/android/common/sample/MainActivity.kt index d9e9c503..ed29a272 100644 --- a/sample/src/main/java/com/nextcloud/android/common/sample/MainActivity.kt +++ b/sample/src/main/java/com/nextcloud/android/common/sample/MainActivity.kt @@ -8,8 +8,11 @@ */ package com.nextcloud.android.common.sample +import android.graphics.Color import android.os.Bundle import android.widget.Toast +import androidx.activity.SystemBarStyle +import androidx.activity.enableEdgeToEdge import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity import androidx.core.graphics.toColorInt @@ -23,11 +26,15 @@ import com.nextcloud.android.common.ui.theme.utils.AndroidViewThemeUtils import com.nextcloud.android.common.ui.theme.utils.ColorRole import com.nextcloud.android.common.ui.theme.utils.DialogViewThemeUtils import com.nextcloud.android.common.ui.theme.utils.MaterialViewThemeUtils +import com.nextcloud.android.common.ui.util.extensions.addSystemBarPaddings class MainActivity : AppCompatActivity() { private lateinit var binding: ActivityMainBinding override fun onCreate(savedInstanceState: Bundle?) { + val style = SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT) + enableEdgeToEdge(style, style) + window.addSystemBarPaddings() super.onCreate(savedInstanceState) binding = ActivityMainBinding.inflate(layoutInflater) @@ -109,6 +116,8 @@ class MainActivity : AppCompatActivity() { material.themeChipInput(binding.inputChip) material.themeChipSuggestion(binding.suggestionChip) material.themeChipFilter(binding.filterChip) + material.colorProgressBar(binding.circularProgressBar) + material.colorProgressBar(binding.linearProgressBar) material.colorMaterialButtonPrimaryFilled(binding.dialogBtn) } } diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml index a438df46..23447605 100644 --- a/sample/src/main/res/layout/activity_main.xml +++ b/sample/src/main/res/layout/activity_main.xml @@ -159,15 +159,39 @@ + + + + + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/circular_progress_bar" /> diff --git a/scripts/analysis/analysis-wrapper.sh b/scripts/analysis/analysis-wrapper.sh new file mode 100755 index 00000000..2d55cbf9 --- /dev/null +++ b/scripts/analysis/analysis-wrapper.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +# SPDX-FileCopyrightText: 2022-2023 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: MIT + +exit 0 diff --git a/ui/src/main/java/com/nextcloud/android/common/ui/theme/utils/MaterialViewThemeUtils.kt b/ui/src/main/java/com/nextcloud/android/common/ui/theme/utils/MaterialViewThemeUtils.kt index 356f6b8c..74dfc8df 100644 --- a/ui/src/main/java/com/nextcloud/android/common/ui/theme/utils/MaterialViewThemeUtils.kt +++ b/ui/src/main/java/com/nextcloud/android/common/ui/theme/utils/MaterialViewThemeUtils.kt @@ -47,7 +47,7 @@ import javax.inject.Inject /** * View theme utils for Material views (com.google.android.material.*) */ -@Suppress("TooManyFunctions") +@Suppress("TooManyFunctions", "LargeClass") class MaterialViewThemeUtils @Inject constructor( @@ -375,30 +375,66 @@ class MaterialViewThemeUtils ) fun colorCardViewBackground(card: MaterialCardView) = themeCardView(card) - fun colorProgressBar(progressIndicator: LinearProgressIndicator) { - withScheme(progressIndicator) { scheme -> - colorProgressBar(progressIndicator, dynamicColor.primary().getArgb(scheme)) + /** + * Themes a [LinearProgressIndicator] using the provided [ColorRole]. + * + * @param linearProgressIndicator The progress indicator to theme. + * @param colorRole The color role to be used for the active indicator part. Defaults to [ColorRole.PRIMARY]. + */ + fun colorProgressBar( + linearProgressIndicator: LinearProgressIndicator, + colorRole: ColorRole = ColorRole.PRIMARY + ) { + withScheme(linearProgressIndicator) { scheme -> + colorProgressBar(linearProgressIndicator, colorRole.select(scheme)) } } + /** + * Themes a [LinearProgressIndicator] using the provided color [Int]. + * + * @param linearProgressIndicator The progress indicator to theme. + * @param color The color to be used for the active indicator part. + */ fun colorProgressBar( - progressIndicator: LinearProgressIndicator, + linearProgressIndicator: LinearProgressIndicator, @ColorInt color: Int ) { - progressIndicator.setIndicatorColor(color) + withScheme(linearProgressIndicator) { scheme -> + linearProgressIndicator.setIndicatorColor(color) + linearProgressIndicator.trackColor = dynamicColor.secondaryContainer().getArgb(scheme) + } } - fun colorProgressBar(progressIndicator: CircularProgressIndicator) { - withScheme(progressIndicator) { scheme -> - colorProgressBar(progressIndicator, dynamicColor.primary().getArgb(scheme)) + /** + * Themes a [CircularProgressIndicator] using the provided [ColorRole]. + * + * @param circularProgressIndicator The progress indicator to theme. + * @param colorRole The color role to be used for the active indicator part. Defaults to [ColorRole.PRIMARY]. + */ + fun colorProgressBar( + circularProgressIndicator: CircularProgressIndicator, + colorRole: ColorRole = ColorRole.PRIMARY + ) { + withScheme(circularProgressIndicator) { scheme -> + colorProgressBar(circularProgressIndicator, colorRole.select(scheme)) } } + /** + * Themes a [CircularProgressIndicator] using the provided color [Int]. + * + * @param circularProgressIndicator The progress indicator to theme. + * @param color The color to be used for the active indicator part. + */ fun colorProgressBar( - progressIndicator: CircularProgressIndicator, + circularProgressIndicator: CircularProgressIndicator, @ColorInt color: Int ) { - progressIndicator.setIndicatorColor(color) + withScheme(circularProgressIndicator) { scheme -> + circularProgressIndicator.setIndicatorColor(color) + circularProgressIndicator.trackColor = dynamicColor.secondaryContainer().getArgb(scheme) + } } fun colorTextInputLayout(textInputLayout: TextInputLayout) {