-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add same-toned monochrome icon and search bar color Add option to make monochrome icons darker Add option to make monochrome icons and search bar semi-transparent Refactor and clean codes for better readability
- Loading branch information
1 parent
e8e6d1f
commit 0d942fb
Showing
14 changed files
with
627 additions
and
442 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
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
62 changes: 62 additions & 0 deletions
62
app/src/main/java/com/drdisagree/colorblendr/utils/ColorMapUtil.kt
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,62 @@ | ||
package com.drdisagree.colorblendr.utils | ||
|
||
import androidx.core.util.Pair | ||
import com.drdisagree.colorblendr.utils.ColorUtil.modifyBrightness | ||
|
||
data class ColorMapping( | ||
val resourceName: String, | ||
val tonalPalette: TonalPalette? = null, | ||
val colorIndex: Int? = null, | ||
val lightModeColorIndex: Int? = null, | ||
val darkModeColorIndex: Int? = null, | ||
val lightModeColorCode: Int? = null, | ||
val colorCode: Int? = null, | ||
val darkModeColorCode: Int? = null, | ||
val lightnessAdjustment: Int? = null, | ||
val lightModeLightnessAdjustment: Int? = null, | ||
val darkModeLightnessAdjustment: Int? = null | ||
) | ||
|
||
fun ColorMapping.extractResourceFromColorMap( | ||
prefix: String = "", | ||
suffix: String = "", | ||
palette: ArrayList<ArrayList<Int>>, | ||
isDark: Boolean = false | ||
): Pair<String, Int> { | ||
val resourceName = prefix + resourceName + suffix | ||
|
||
val colorValue: Int = if (tonalPalette != null) { | ||
if (colorIndex != null) { | ||
palette[tonalPalette.index][colorIndex] | ||
} else { | ||
if (isDark) { | ||
palette[tonalPalette.index][darkModeColorIndex!!] | ||
} else { | ||
palette[tonalPalette.index][lightModeColorIndex!!] | ||
} | ||
} | ||
} else { | ||
colorCode ?: if (isDark) { | ||
darkModeColorCode | ||
} else { | ||
lightModeColorCode | ||
} | ||
}!! | ||
|
||
return Pair(resourceName, colorValue) | ||
} | ||
|
||
fun ColorMapping.adjustColorBrightnessIfRequired( | ||
colorValue: Int, | ||
isDark: Boolean | ||
): Int { | ||
return if (lightnessAdjustment != null) { | ||
modifyBrightness(colorValue, lightnessAdjustment) | ||
} else if (darkModeLightnessAdjustment != null && isDark) { | ||
modifyBrightness(colorValue, darkModeLightnessAdjustment) | ||
} else if (lightModeLightnessAdjustment != null && !isDark) { | ||
modifyBrightness(colorValue, lightModeLightnessAdjustment) | ||
} else { | ||
colorValue | ||
} | ||
} |
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
Oops, something went wrong.