Adaptation of the MainActivity

is loaded in Main Activity, that the dark theme remains activated when the app is opened again
This commit is contained in:
ErikWaegerle 2020-06-24 18:36:33 +02:00
parent 1106ee84bb
commit 73e7fa3958

View file

@ -6,6 +6,8 @@ import android.os.Bundle;
import android.preference.PreferenceActivity; import android.preference.PreferenceActivity;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import com.google.android.material.navigation.NavigationView; import com.google.android.material.navigation.NavigationView;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter; import androidx.fragment.app.FragmentPagerAdapter;
@ -54,8 +56,16 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
settings = PreferenceManager.getDefaultSharedPreferences(this); 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); NewLevelManager newLevelManager = NewLevelManager.getInstance(getApplicationContext(), settings);
// check if we need to pre generate levels. // check if we need to pre generate levels.