Skip to content

Commit

Permalink
Fixes #17
Browse files Browse the repository at this point in the history
Signed-off-by: enricocid <enrico2588@gmail.com>
  • Loading branch information
enricocid committed Mar 1, 2020
1 parent 9e20147 commit 37cf221
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.annotation.SuppressLint
import android.content.Intent
import android.content.SharedPreferences
import android.content.res.ColorStateList
import android.content.res.Configuration
import android.graphics.Color
import android.os.Build
import android.os.Bundle
Expand Down Expand Up @@ -85,6 +86,7 @@ class MainActivity : AppCompatActivity(R.layout.vectorify_activity),

private val sSwapColor get() = mTempVectorColor != mTempBackgroundColor

private val sThemeNight get() = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES
private var sThemeChanged = false
private var sRestoreVectorFromBundle = false

Expand Down Expand Up @@ -183,7 +185,7 @@ class MainActivity : AppCompatActivity(R.layout.vectorify_activity),
statusBarColor = Color.TRANSPARENT
navigationBarColor = Color.TRANSPARENT
}
Utils.handleLightSystemBars(decorView)
Utils.handleLightSystemBars(sThemeNight, decorView)
edgeToEdge {
decorView.fit { Edge.Top }
mBottomBar.fit { Edge.Bottom + Edge.Right }
Expand Down Expand Up @@ -602,7 +604,7 @@ class MainActivity : AppCompatActivity(R.layout.vectorify_activity),
GridLayoutManager(context, 3, RecyclerView.VERTICAL, false)

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) window?.apply {
Utils.handleLightSystemBars(decorView)
Utils.handleLightSystemBars(sThemeNight, decorView)
edgeToEdge {
getRecyclerView().fit { Edge.Bottom }
decorView.fit { Edge.Top }
Expand Down
8 changes: 2 additions & 6 deletions project/app/src/main/java/com/iven/vectorify/utils/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,11 @@ object Utils {
else -> R.drawable.ic_theme_auto
}

@JvmStatic
private fun isThemeNight() =
AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_YES

@JvmStatic
@TargetApi(Build.VERSION_CODES.O_MR1)
fun handleLightSystemBars(view: View) {
fun handleLightSystemBars(isThemeNight: Boolean, view: View) {
view.systemUiVisibility =
if (isThemeNight()) 0 else View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR or View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
if (isThemeNight) 0 else View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR or View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
}

//method to open live wallpaper intent
Expand Down

0 comments on commit 37cf221

Please sign in to comment.