Merge branch 'Sudoku-v3.0' of https://github.com/SecUSo/privacy-friendly-sudoku into Sudoku-v3.0
This commit is contained in:
commit
bd3f0031cb
9 changed files with 41 additions and 13 deletions
|
@ -60,7 +60,6 @@ import org.secuso.privacyfriendlysudoku.game.GameDifficulty;
|
||||||
import org.secuso.privacyfriendlysudoku.game.GameType;
|
import org.secuso.privacyfriendlysudoku.game.GameType;
|
||||||
import org.secuso.privacyfriendlysudoku.ui.listener.IImportDialogFragmentListener;
|
import org.secuso.privacyfriendlysudoku.ui.listener.IImportDialogFragmentListener;
|
||||||
import org.secuso.privacyfriendlysudoku.ui.view.R;
|
import org.secuso.privacyfriendlysudoku.ui.view.R;
|
||||||
import org.secuso.privacyfriendlysudoku.ui.SettingsActivity;
|
|
||||||
import org.secuso.privacyfriendlysudoku.ui.view.databinding.DialogFragmentImportBoardBinding;
|
import org.secuso.privacyfriendlysudoku.ui.view.databinding.DialogFragmentImportBoardBinding;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
|
@ -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;
|
package org.secuso.privacyfriendlysudoku.ui;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
@ -21,22 +40,23 @@ import org.secuso.privacyfriendlysudoku.ui.view.R;
|
||||||
public class SettingsActivity extends AppCompatActivity {
|
public class SettingsActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
|
||||||
private static PreferenceScreen prefScreen;
|
private static SettingsFragment settingsFragment;
|
||||||
|
|
||||||
private static void recheckNightModeProperties(SharedPreferences sharedPreferences) {
|
private static void recheckNightModeProperties(SharedPreferences sharedPreferences) {
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
|
|
||||||
if (sharedPreferences.getBoolean("pref_dark_mode_setting", false)) {
|
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 {
|
} else {
|
||||||
if (sharedPreferences.getBoolean("pref_dark_mode_automatically_by_battery", false) && sharedPreferences.getBoolean("pref_dark_mode_automatically_by_system", false) ) {
|
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();
|
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));
|
settingsFragment.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_battery").setEnabled(!sharedPreferences.getBoolean("pref_dark_mode_automatically_by_system", false));
|
||||||
}}
|
}}
|
||||||
|
|
||||||
if (sharedPreferences.getBoolean("pref_dark_mode_setting", 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
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||||
|
@ -65,19 +85,17 @@ public class SettingsActivity extends AppCompatActivity {
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.settings_activity);
|
setContentView(R.layout.settings_activity);
|
||||||
|
settingsFragment = new SettingsFragment();
|
||||||
getSupportFragmentManager()
|
getSupportFragmentManager()
|
||||||
.beginTransaction()
|
.beginTransaction()
|
||||||
.replace(R.id.settings, new SettingsFragment())
|
.replace(R.id.settings, settingsFragment)
|
||||||
.commit();
|
.commit();
|
||||||
ActionBar actionBar = getSupportActionBar();
|
ActionBar actionBar = getSupportActionBar();
|
||||||
if (actionBar != null) {
|
if (actionBar != null) {
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedPreferences preferenceManager = PreferenceManager
|
|
||||||
.getDefaultSharedPreferences(this);
|
|
||||||
|
|
||||||
preferenceManager.registerOnSharedPreferenceChangeListener(x);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
@ -92,14 +110,14 @@ public class SettingsActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
|
||||||
public static class SettingsFragment extends PreferenceFragmentCompat {
|
public static class SettingsFragment extends PreferenceFragmentCompat {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||||
setPreferencesFromResource(R.xml.pref_settings_general, rootKey);
|
setPreferencesFromResource(R.xml.pref_settings_general, rootKey);
|
||||||
prefScreen = getPreferenceScreen();
|
|
||||||
SharedPreferences preferenceManager = PreferenceManager
|
SharedPreferences preferenceManager = PreferenceManager
|
||||||
.getDefaultSharedPreferences(getActivity());
|
.getDefaultSharedPreferences(getActivity());
|
||||||
|
preferenceManager.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener);
|
||||||
recheckNightModeProperties(preferenceManager);
|
recheckNightModeProperties(preferenceManager);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -188,6 +188,8 @@
|
||||||
android:layout_gravity="start"
|
android:layout_gravity="start"
|
||||||
android:fitsSystemWindows="true"
|
android:fitsSystemWindows="true"
|
||||||
android:background="?attr/lightestBackGround"
|
android:background="?attr/lightestBackGround"
|
||||||
|
app:itemTextColor="?attr/menuTextColor"
|
||||||
|
app:itemIconTint="?attr/menuTextColor"
|
||||||
app:menu="@menu/menu_drawer_main"
|
app:menu="@menu/menu_drawer_main"
|
||||||
app:headerLayout="@layout/nav_header" />
|
app:headerLayout="@layout/nav_header" />
|
||||||
|
|
||||||
|
|
|
@ -264,6 +264,8 @@
|
||||||
android:layout_gravity="start"
|
android:layout_gravity="start"
|
||||||
android:fitsSystemWindows="true"
|
android:fitsSystemWindows="true"
|
||||||
android:background="?attr/lightestBackGround"
|
android:background="?attr/lightestBackGround"
|
||||||
|
app:itemTextColor="?attr/menuTextColor"
|
||||||
|
app:itemIconTint="?attr/menuTextColor"
|
||||||
app:menu="@menu/menu_drawer_main"
|
app:menu="@menu/menu_drawer_main"
|
||||||
app:headerLayout="@layout/nav_header" />
|
app:headerLayout="@layout/nav_header" />
|
||||||
|
|
||||||
|
|
|
@ -258,6 +258,8 @@
|
||||||
android:layout_gravity="start"
|
android:layout_gravity="start"
|
||||||
android:fitsSystemWindows="true"
|
android:fitsSystemWindows="true"
|
||||||
android:background="?attr/lightestBackGround"
|
android:background="?attr/lightestBackGround"
|
||||||
|
app:itemTextColor="?attr/menuTextColor"
|
||||||
|
app:itemIconTint="?attr/menuTextColor"
|
||||||
app:menu="@menu/menu_drawer_main"
|
app:menu="@menu/menu_drawer_main"
|
||||||
app:headerLayout="@layout/nav_header" />
|
app:headerLayout="@layout/nav_header" />
|
||||||
|
|
||||||
|
|
|
@ -259,6 +259,8 @@
|
||||||
android:layout_gravity="start"
|
android:layout_gravity="start"
|
||||||
android:fitsSystemWindows="true"
|
android:fitsSystemWindows="true"
|
||||||
android:background="?attr/lightestBackGround"
|
android:background="?attr/lightestBackGround"
|
||||||
|
app:itemTextColor="?attr/menuTextColor"
|
||||||
|
app:itemIconTint="?attr/menuTextColor"
|
||||||
app:menu="@menu/menu_drawer_main"
|
app:menu="@menu/menu_drawer_main"
|
||||||
app:headerLayout="@layout/nav_header" />
|
app:headerLayout="@layout/nav_header" />
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
<item name="android:itemBackground">@color/cardview_dark_background</item>
|
<item name="android:itemBackground">@color/cardview_dark_background</item>
|
||||||
<item name="backgroundTutorialSlide">@color/colorPrimaryDark</item>
|
<item name="backgroundTutorialSlide">@color/colorPrimaryDark</item>
|
||||||
<item name="backgroundTutorialStars">@color/colorPrimaryDark</item>
|
<item name="backgroundTutorialStars">@color/colorPrimaryDark</item>
|
||||||
|
<item name="menuTextColor">@color/white</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="ToolbarStyle" parent="Widget.AppCompat.ActionBar">
|
<style name="ToolbarStyle" parent="Widget.AppCompat.ActionBar">
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
<attr name="rankingStarNotSelected" format="color"/>
|
<attr name="rankingStarNotSelected" format="color"/>
|
||||||
<attr name="inactiveButtonColor" format="color"/>
|
<attr name="inactiveButtonColor" format="color"/>
|
||||||
<attr name="activeButtonColor" format="color"/>
|
<attr name="activeButtonColor" format="color"/>
|
||||||
|
<attr name="menuTextColor" format="color"/>
|
||||||
<attr name="highlightedButtonBorder" format="color"/>
|
<attr name="highlightedButtonBorder" format="color"/>
|
||||||
<attr name="backgroundTutorialSlide" format="color"/>
|
<attr name="backgroundTutorialSlide" format="color"/>
|
||||||
<attr name="backgroundTutorialStars" format="color"/>
|
<attr name="backgroundTutorialStars" format="color"/>
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
<item name="actionBarTheme">@style/ToolbarStyle</item>
|
<item name="actionBarTheme">@style/ToolbarStyle</item>
|
||||||
<item name="backgroundTutorialSlide">@color/colorAccent</item>
|
<item name="backgroundTutorialSlide">@color/colorAccent</item>
|
||||||
<item name="backgroundTutorialStars">@color/white</item>
|
<item name="backgroundTutorialStars">@color/white</item>
|
||||||
|
<item name="menuTextColor">@null</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="ToolbarStyle" parent="Widget.AppCompat.ActionBar">
|
<style name="ToolbarStyle" parent="Widget.AppCompat.ActionBar">
|
||||||
|
|
Loading…
Reference in a new issue