File tree Expand file tree Collapse file tree 2 files changed +14
-18
lines changed
sample/src/main/java/com/nextcloud/android/common/sample
ui/src/main/java/com/nextcloud/android/common/ui/color Expand file tree Collapse file tree 2 files changed +14
-18
lines changed Original file line number Diff line number Diff line change @@ -36,11 +36,12 @@ class MainActivity : AppCompatActivity() {
3636 try {
3737 mainViewModel.color.value = Color .parseColor(" #${binding.color.text} " )
3838 } catch (_: java.lang.IllegalArgumentException ) {
39- Toast .makeText(
40- this ,
41- " #${binding.color.text} is not a valid color." ,
42- Toast .LENGTH_SHORT
43- ).show()
39+ Toast
40+ .makeText(
41+ this ,
42+ " #${binding.color.text} is not a valid color." ,
43+ Toast .LENGTH_SHORT
44+ ).show()
4445 }
4546 }
4647
Original file line number Diff line number Diff line change @@ -21,41 +21,36 @@ import kotlin.math.roundToInt
2121
2222class ColorUtil
2323 @Inject
24- constructor (private val context: Context ) {
24+ constructor (
25+ private val context: Context
26+ ) {
2527 @ColorInt
2628 fun getNullSafeColor (
2729 color : String? ,
2830 @ColorInt fallbackColor : Int
29- ): Int {
30- return color.parseColorOrFallback { fallbackColor }
31- }
31+ ): Int = color.parseColorOrFallback { fallbackColor }
3232
3333 @ColorInt
3434 fun getNullSafeColorWithFallbackRes (
3535 color : String? ,
3636 @ColorRes fallbackColorRes : Int
37- ): Int {
38- return color.parseColorOrFallback { ContextCompat .getColor(context, fallbackColorRes) }
39- }
37+ ): Int = color.parseColorOrFallback { ContextCompat .getColor(context, fallbackColorRes) }
4038
4139 @ColorInt
4240 fun getTextColor (
4341 colorText : String? ,
4442 @ColorInt backgroundColor : Int
45- ): Int {
46- return colorText.parseColorOrFallback { getForegroundColorForBackgroundColor(backgroundColor) }
47- }
43+ ): Int = colorText.parseColorOrFallback { getForegroundColorForBackgroundColor(backgroundColor) }
4844
4945 @ColorInt
5046 fun getForegroundColorForBackgroundColor (
5147 @ColorInt color : Int
52- ): Int {
53- return if (isDarkBackground(color)) {
48+ ): Int =
49+ if (isDarkBackground(color)) {
5450 Color .WHITE
5551 } else {
5652 ContextCompat .getColor(context, R .color.grey_900)
5753 }
58- }
5954
6055 fun isDarkBackground (
6156 @ColorInt color : Int
You can’t perform that action at this time.
0 commit comments