Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)
}
}
32 changes: 28 additions & 4 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,39 @@

</com.google.android.material.chip.ChipGroup>

<com.google.android.material.progressindicator.CircularProgressIndicator
android:id="@+id/circular_progress_bar"
android:layout_width="200dp"
android:layout_height="200dp"
android:indeterminate="false"
android:indeterminateOnly="false"
android:progress="35"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/chipGroup"
app:trackCornerRadius="5dp"
app:trackThickness="5dp" />

<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/linear_progress_bar"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:indeterminate="false"
android:indeterminateOnly="false"
android:progress="35"
app:layout_constraintStart_toEndOf="@+id/circular_progress_bar"
app:layout_constraintTop_toBottomOf="@id/chipGroup"
app:trackCornerRadius="5dp"
app:trackStopIndicatorSize="0dp"
app:trackThickness="5dp" />

<com.google.android.material.button.MaterialButton
android:id="@+id/dialogBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/open_dialog"
android:layout_marginTop="@dimen/standard_half_margin"
android:layout_marginBottom="@dimen/standard_half_margin"
app:layout_constraintTop_toBottomOf="@id/chipGroup"
app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/circular_progress_bar" />

</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
Expand Down
6 changes: 6 additions & 0 deletions scripts/analysis/analysis-wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: 2022-2023 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: MIT

exit 0
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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) {
Expand Down
Loading