File tree Expand file tree Collapse file tree
java/com/example/mynotes/ui/fragments Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -71,18 +71,18 @@ class NotesFragment : Fragment() {
7171 override fun onOptionsItemSelected (item : MenuItem ): Boolean {
7272
7373 return when (item.itemId) {
74- // R.id.mode -> {
75- // val mode =
76- // if ((resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_NO) {
77- // AppCompatDelegate.MODE_NIGHT_YES
78- // } else {
79- // AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY
80- // }
81- //
82- // // Change UI Mode
83- // AppCompatDelegate.setDefaultNightMode(mode)
84- // true
85- // }
74+ R .id.mode -> {
75+ val mode =
76+ if ((resources.configuration.uiMode and Configuration .UI_MODE_NIGHT_MASK ) == Configuration .UI_MODE_NIGHT_NO ) {
77+ AppCompatDelegate .MODE_NIGHT_YES
78+ } else {
79+ AppCompatDelegate .MODE_NIGHT_AUTO_BATTERY
80+ }
81+
82+ // Change UI Mode
83+ AppCompatDelegate .setDefaultNightMode(mode)
84+ true
85+ }
8686
8787 R .id.delete -> {
8888 deleteAllNotes()
Original file line number Diff line number Diff line change 44 xmlns : tools =" http://schemas.android.com/tools" >
55
66 <androidx .constraintlayout.widget.ConstraintLayout
7+ android : configChanges =" uiMode"
78 android : layout_width =" match_parent"
89 android : layout_height =" match_parent"
910 tools : context =" .ui.fragments.NotesFragment" >
You can’t perform that action at this time.
0 commit comments