-
-
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.
Convert navigation bar color functions to extensions
- Loading branch information
1 parent
f056aa7
commit 2b8133e
Showing
2 changed files
with
22 additions
and
12 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
21 changes: 21 additions & 0 deletions
21
commons/src/main/kotlin/org/fossify/commons/extensions/Window.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,21 @@ | ||
package org.fossify.commons.extensions | ||
|
||
import android.view.View | ||
import android.view.Window | ||
import org.fossify.commons.helpers.DARK_GREY | ||
import org.fossify.commons.helpers.isOreoPlus | ||
|
||
fun Window.updateNavigationBarBackgroundColor(color: Int) { | ||
navigationBarColor = color | ||
updateNavigationBarForegroundColor(color) | ||
} | ||
|
||
fun Window.updateNavigationBarForegroundColor(color: Int) { | ||
if (isOreoPlus()) { | ||
if (color.getContrastColor() == DARK_GREY) { | ||
decorView.systemUiVisibility = decorView.systemUiVisibility.addBit(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR) | ||
} else { | ||
decorView.systemUiVisibility = decorView.systemUiVisibility.removeBit(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR) | ||
} | ||
} | ||
} |