-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adjusted viewer look
- Loading branch information
Showing
9 changed files
with
170 additions
and
79 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
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
30 changes: 30 additions & 0 deletions
30
library-viewer/src/main/java/com/michaelflisar/lumberjack/LumberjackExtensions.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,30 @@ | ||
package com.michaelflisar.lumberjack | ||
|
||
import android.content.Context | ||
import android.graphics.Color | ||
import android.util.TypedValue | ||
import androidx.annotation.AttrRes | ||
import androidx.annotation.ColorInt | ||
|
||
@ColorInt | ||
internal fun Context.getColorFromAttr( | ||
@AttrRes attrColor: Int, | ||
typedValue: TypedValue = TypedValue(), | ||
resolveRefs: Boolean = true | ||
): Int { | ||
theme.resolveAttribute(attrColor, typedValue, resolveRefs) | ||
return typedValue.data | ||
} | ||
|
||
internal fun Context.isCurrentThemeDark(): Boolean { | ||
val color = resolve(android.R.attr.colorBackground) | ||
val darkness = | ||
1 - (0.299 * Color.red(color) + 0.587 * Color.green(color) + 0.114 * Color.blue(color)) / 255 | ||
return darkness > 0.5 | ||
} | ||
|
||
private fun Context.resolve(attrId: Int): Int { | ||
val typedValue = TypedValue() | ||
theme.resolveAttribute(attrId, typedValue, true) | ||
return typedValue.data | ||
} |
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.