forked from nextcloud/android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f59caa7
commit 573b60a
Showing
4 changed files
with
143 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.nmc.android.utils | ||
|
||
import android.content.Context | ||
import android.content.res.ColorStateList | ||
import android.graphics.Color | ||
import com.google.android.material.floatingactionbutton.FloatingActionButton | ||
import com.owncloud.android.R | ||
|
||
object FabThemeUtils { | ||
@JvmStatic | ||
fun colorFloatingActionButton( | ||
context: Context, | ||
button: FloatingActionButton | ||
) { | ||
val primaryColor = context.resources.getColor(R.color.primary, null) | ||
val disableColor = context.resources.getColor(R.color.grey_0, null) | ||
|
||
val bgStates = arrayOf( | ||
intArrayOf(android.R.attr.state_enabled), | ||
intArrayOf(-android.R.attr.state_enabled), | ||
) | ||
val bgColors = intArrayOf( | ||
primaryColor, | ||
disableColor | ||
) | ||
|
||
button.backgroundTintList = ColorStateList(bgStates, bgColors) | ||
|
||
val imageStates = arrayOf( | ||
intArrayOf(android.R.attr.state_enabled), | ||
intArrayOf(-android.R.attr.state_enabled), | ||
) | ||
val imageColors = intArrayOf( | ||
Color.WHITE, | ||
disableColor | ||
) | ||
|
||
button.imageTintList = ColorStateList(imageStates, imageColors) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters