Merge branch 'Sudoku-v3.0' of https://github.com/SecUSo/privacy-friendly-sudoku into Sudoku-v3.0

This commit is contained in:
uykek 2020-08-30 11:16:58 +02:00
commit bd3f0031cb
9 changed files with 41 additions and 13 deletions

View file

@ -60,7 +60,6 @@ import org.secuso.privacyfriendlysudoku.game.GameDifficulty;
import org.secuso.privacyfriendlysudoku.game.GameType;
import org.secuso.privacyfriendlysudoku.ui.listener.IImportDialogFragmentListener;
import org.secuso.privacyfriendlysudoku.ui.view.R;
import org.secuso.privacyfriendlysudoku.ui.SettingsActivity;
import org.secuso.privacyfriendlysudoku.ui.view.databinding.DialogFragmentImportBoardBinding;
import java.util.LinkedList;

View file

@ -1,3 +1,22 @@
/*
* qqwing - Sudoku solver and generator
* Copyright (C) 2014 Stephen Ostermiller
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package org.secuso.privacyfriendlysudoku.ui;
import android.content.SharedPreferences;
@ -21,22 +40,23 @@ import org.secuso.privacyfriendlysudoku.ui.view.R;
public class SettingsActivity extends AppCompatActivity {
private static PreferenceScreen prefScreen;
private static SettingsFragment settingsFragment;
private static void recheckNightModeProperties(SharedPreferences sharedPreferences) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
if (sharedPreferences.getBoolean("pref_dark_mode_setting", false)) {
prefScreen.findPreference("pref_dark_mode_automatically_by_system").setEnabled(false);
prefScreen.findPreference("pref_dark_mode_automatically_by_battery").setEnabled(false);
settingsFragment.findPreference("pref_dark_mode_automatically_by_system").setEnabled(false);
settingsFragment.findPreference("pref_dark_mode_automatically_by_battery").setEnabled(false);
} else {
if (sharedPreferences.getBoolean("pref_dark_mode_automatically_by_battery", false) && sharedPreferences.getBoolean("pref_dark_mode_automatically_by_system", false) ) {
sharedPreferences.edit().putBoolean("pref_dark_mode_automatically_by_battery", false).commit();
}
prefScreen.findPreference("pref_dark_mode_automatically_by_system").setEnabled(!sharedPreferences.getBoolean("pref_dark_mode_automatically_by_battery", false));
prefScreen.findPreference("pref_dark_mode_automatically_by_battery").setEnabled(!sharedPreferences.getBoolean("pref_dark_mode_automatically_by_system", false));
settingsFragment.findPreference("pref_dark_mode_automatically_by_system").setEnabled(!sharedPreferences.getBoolean("pref_dark_mode_automatically_by_battery", false));
settingsFragment.findPreference("pref_dark_mode_automatically_by_battery").setEnabled(!sharedPreferences.getBoolean("pref_dark_mode_automatically_by_system", false));
}}
if (sharedPreferences.getBoolean("pref_dark_mode_setting", false )) {
@ -51,7 +71,7 @@ public class SettingsActivity extends AppCompatActivity {
}
}
static SharedPreferences.OnSharedPreferenceChangeListener x = new SharedPreferences.OnSharedPreferenceChangeListener() {
static SharedPreferences.OnSharedPreferenceChangeListener sharedPreferenceChangeListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
@ -65,19 +85,17 @@ public class SettingsActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.settings_activity);
settingsFragment = new SettingsFragment();
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.settings, new SettingsFragment())
.replace(R.id.settings, settingsFragment)
.commit();
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
SharedPreferences preferenceManager = PreferenceManager
.getDefaultSharedPreferences(this);
preferenceManager.registerOnSharedPreferenceChangeListener(x);
}
@Override
@ -92,14 +110,14 @@ public class SettingsActivity extends AppCompatActivity {
public static class SettingsFragment extends PreferenceFragmentCompat {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.pref_settings_general, rootKey);
prefScreen = getPreferenceScreen();
SharedPreferences preferenceManager = PreferenceManager
.getDefaultSharedPreferences(getActivity());
preferenceManager.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener);
recheckNightModeProperties(preferenceManager);
}
}
}

View file

@ -188,6 +188,8 @@
android:layout_gravity="start"
android:fitsSystemWindows="true"
android:background="?attr/lightestBackGround"
app:itemTextColor="?attr/menuTextColor"
app:itemIconTint="?attr/menuTextColor"
app:menu="@menu/menu_drawer_main"
app:headerLayout="@layout/nav_header" />

View file

@ -264,6 +264,8 @@
android:layout_gravity="start"
android:fitsSystemWindows="true"
android:background="?attr/lightestBackGround"
app:itemTextColor="?attr/menuTextColor"
app:itemIconTint="?attr/menuTextColor"
app:menu="@menu/menu_drawer_main"
app:headerLayout="@layout/nav_header" />

View file

@ -258,6 +258,8 @@
android:layout_gravity="start"
android:fitsSystemWindows="true"
android:background="?attr/lightestBackGround"
app:itemTextColor="?attr/menuTextColor"
app:itemIconTint="?attr/menuTextColor"
app:menu="@menu/menu_drawer_main"
app:headerLayout="@layout/nav_header" />

View file

@ -259,6 +259,8 @@
android:layout_gravity="start"
android:fitsSystemWindows="true"
android:background="?attr/lightestBackGround"
app:itemTextColor="?attr/menuTextColor"
app:itemIconTint="?attr/menuTextColor"
app:menu="@menu/menu_drawer_main"
app:headerLayout="@layout/nav_header" />

View file

@ -24,6 +24,7 @@
<item name="android:itemBackground">@color/cardview_dark_background</item>
<item name="backgroundTutorialSlide">@color/colorPrimaryDark</item>
<item name="backgroundTutorialStars">@color/colorPrimaryDark</item>
<item name="menuTextColor">@color/white</item>
</style>
<style name="ToolbarStyle" parent="Widget.AppCompat.ActionBar">

View file

@ -13,6 +13,7 @@
<attr name="rankingStarNotSelected" format="color"/>
<attr name="inactiveButtonColor" format="color"/>
<attr name="activeButtonColor" format="color"/>
<attr name="menuTextColor" format="color"/>
<attr name="highlightedButtonBorder" format="color"/>
<attr name="backgroundTutorialSlide" format="color"/>
<attr name="backgroundTutorialStars" format="color"/>

View file

@ -22,6 +22,7 @@
<item name="actionBarTheme">@style/ToolbarStyle</item>
<item name="backgroundTutorialSlide">@color/colorAccent</item>
<item name="backgroundTutorialStars">@color/white</item>
<item name="menuTextColor">@null</item>
</style>
<style name="ToolbarStyle" parent="Widget.AppCompat.ActionBar">