From 73e7fa395898a70af5e4a962f4d6b911d6e85882 Mon Sep 17 00:00:00 2001 From: ErikWaegerle Date: Wed, 24 Jun 2020 18:36:33 +0200 Subject: [PATCH] Adaptation of the MainActivity is loaded in Main Activity, that the dark theme remains activated when the app is opened again --- .../secuso/privacyfriendlysudoku/ui/MainActivity.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/MainActivity.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/MainActivity.java index a872a5b..e25b7b5 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/MainActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/MainActivity.java @@ -6,6 +6,8 @@ import android.os.Bundle; import android.preference.PreferenceActivity; import android.preference.PreferenceManager; import com.google.android.material.navigation.NavigationView; + +import androidx.appcompat.app.AppCompatDelegate; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentPagerAdapter; @@ -54,8 +56,16 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + + settings = PreferenceManager.getDefaultSharedPreferences(this); + if (settings.getBoolean("pref_dark_mode_setting", false )) { + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); + } else { + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); + } + NewLevelManager newLevelManager = NewLevelManager.getInstance(getApplicationContext(), settings); // check if we need to pre generate levels.