Checks theme in preferences on startup

This commit is contained in:
Corewala 2022-05-10 10:34:04 -04:00
parent fbf6c80282
commit 1542ec5539
1 changed files with 7 additions and 0 deletions

View File

@ -19,6 +19,7 @@ import android.widget.EditText
import androidx.activity.viewModels
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.browser.customtabs.CustomTabsIntent
import androidx.databinding.DataBindingUtil
import androidx.preference.PreferenceManager
@ -147,6 +148,12 @@ class GemActivity : AppCompatActivity() {
prefs = PreferenceManager.getDefaultSharedPreferences(this)
when (prefs.getString("theme", "theme_FollowSystem")) {
"theme_FollowSystem" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
"theme_Light" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
"theme_Dark" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
}
adapter = AbstractGemtextAdapter.getAdapter(onLink, inlineImage)
binding.gemtextRecycler.adapter = adapter