Skip to content

Commit

Permalink
Set the default night mode to AUTO
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrewartha committed Sep 15, 2018
1 parent 368041b commit 5247867
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/src/main/java/io/trewartha/positional/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import android.view.MenuItem
import android.view.View.*
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO
import androidx.core.app.ActivityCompat
import androidx.core.content.PermissionChecker
import com.google.android.material.bottomnavigation.BottomNavigationView
Expand All @@ -24,6 +26,8 @@ class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO)

val currentNightMode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
if (currentNightMode == UI_MODE_NIGHT_YES) window.decorView.systemUiVisibility =
SYSTEM_UI_FLAG_IMMERSIVE_STICKY or
Expand Down

0 comments on commit 5247867

Please sign in to comment.