Loading app/src/main/java/io/heckel/ntfy/ui/MainSettingsActivity.kt +38 −3 Original line number Diff line number Diff line package io.heckel.ntfy.ui import android.content.res.Configuration import android.os.Build import android.os.Bundle import android.view.WindowInsetsController import androidx.annotation.RequiresApi import androidx.appcompat.app.AppCompatActivity import io.heckel.ntfy.R import io.heckel.ntfy.databinding.MainSettingsActivityBinding class MainSettingsActivity : AppCompatActivity() { private lateinit var mBinding: MainSettingsActivityBinding @RequiresApi(Build.VERSION_CODES.R) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) mBinding = MainSettingsActivityBinding.inflate(layoutInflater) setContentView(mBinding.root) setupToolbar() setSystemBarsAppearance() showPreferencesFragment() } private fun setupToolbar() { mBinding.toolbar.setNavigationOnClickListener { onBackPressed() onBackPressedDispatcher.onBackPressed() } } @RequiresApi(Build.VERSION_CODES.R) private fun setSystemBarsAppearance() { val insetsController = window.insetsController ?: return val isLightMode = isSystemInLightMode() if (isLightMode) { insetsController.setSystemBarsAppearance( WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS, WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS ) } else { insetsController.setSystemBarsAppearance( 0, WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS ) } } private fun isSystemInLightMode(): Boolean { val nightModeFlags = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK return nightModeFlags != Configuration.UI_MODE_NIGHT_YES } private fun showPreferencesFragment() { supportFragmentManager .beginTransaction() .replace(R.id.fragment_container, PreferencesFragment()) Loading Loading
app/src/main/java/io/heckel/ntfy/ui/MainSettingsActivity.kt +38 −3 Original line number Diff line number Diff line package io.heckel.ntfy.ui import android.content.res.Configuration import android.os.Build import android.os.Bundle import android.view.WindowInsetsController import androidx.annotation.RequiresApi import androidx.appcompat.app.AppCompatActivity import io.heckel.ntfy.R import io.heckel.ntfy.databinding.MainSettingsActivityBinding class MainSettingsActivity : AppCompatActivity() { private lateinit var mBinding: MainSettingsActivityBinding @RequiresApi(Build.VERSION_CODES.R) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) mBinding = MainSettingsActivityBinding.inflate(layoutInflater) setContentView(mBinding.root) setupToolbar() setSystemBarsAppearance() showPreferencesFragment() } private fun setupToolbar() { mBinding.toolbar.setNavigationOnClickListener { onBackPressed() onBackPressedDispatcher.onBackPressed() } } @RequiresApi(Build.VERSION_CODES.R) private fun setSystemBarsAppearance() { val insetsController = window.insetsController ?: return val isLightMode = isSystemInLightMode() if (isLightMode) { insetsController.setSystemBarsAppearance( WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS, WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS ) } else { insetsController.setSystemBarsAppearance( 0, WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS ) } } private fun isSystemInLightMode(): Boolean { val nightModeFlags = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK return nightModeFlags != Configuration.UI_MODE_NIGHT_YES } private fun showPreferencesFragment() { supportFragmentManager .beginTransaction() .replace(R.id.fragment_container, PreferencesFragment()) Loading