Skip to content

Commit

Permalink
Use switch for dark theme
Browse files Browse the repository at this point in the history
See #29

Use a switch instead of a checkbox for the theme selection as per point
2. I also removed the unneeded summary from the preference.
  • Loading branch information
raatmarien committed Apr 3, 2016
1 parent 89e3a08 commit c8bd6b5
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.SwitchPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceScreen;
Expand Down Expand Up @@ -86,7 +87,7 @@ public void onCreate(Bundle savedInstanceState) {
String automaticTurnOffPrefKey = getString(R.string.pref_key_custom_end_time);

PreferenceScreen prefScreen = getPreferenceScreen();
final CheckBoxPreference darkThemePref = (CheckBoxPreference)
final SwitchPreference darkThemePref = (SwitchPreference)
prefScreen.findPreference(darkThemePrefKey);
final CheckBoxPreference lowerBrightnessPref = (CheckBoxPreference)
prefScreen.findPreference(lowerBrightnessPrefKey);
Expand All @@ -97,11 +98,11 @@ public void onCreate(Bundle savedInstanceState) {
final TimePickerPreference automaticTurnOffPref = (TimePickerPreference)
prefScreen.findPreference(automaticTurnOffPrefKey);

darkThemePref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
darkThemePref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
public boolean onPreferenceChange(Preference preference, Object newValue) {
getActivity().recreate();
return false;
return true;
}
});

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
* Copyright (c) 2016 twckr <https://github.com/twckr>
* Copyright (c) 2016 twckr <https://github.com/twckr>
* Copyright (c) 2016 Marien Raat <marienraat@riseup.net>
*
* This file is free software: you may copy, redistribute and/or modify it
* under the terms of the GNU General Public License as published by the Free
Expand Down Expand Up @@ -40,7 +41,6 @@
<string name="custom_start_time_summary">Auswählen, wann der Filter eingeschaltet werden soll</string>
<string name="custom_start_time_title">Einschaltzeit</string>
<string name="dark_theme">Dunkles Thema</string>
<string name="dark_theme_summary">Dunkles Thema verwenden</string>
<string name="email_me_summary">Schreiben Sie mir eine Email für Vorschläge oder Fehlerberichte</string>
<string name="email_me_title">Schreiben Sie mit an marienraat@riseup.net</string>
<string name="ok_dialog">OK</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-fa/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
* Copyright (c) 2016 Danial Behzadi <dani.behzi@ubuntu.com>
* Copyright (c) 2016 Marien Raat <marienraat@riseup.net>
*
* This file is free software: you may copy, redistribute and/or modify it
* under the terms of the GNU General Public License as published by the Free
Expand Down Expand Up @@ -51,7 +52,6 @@
<string name="keep_running_after_reboot">ادامهٔ اجرا پس از راه‌اندازی دوباره</string>

<string name="dark_theme">زمینهٔ تیره</string>
<string name="dark_theme_summary">استفاده از یک زمینهٔ تیره برای این فعّالیت</string>

<string name="email_me_title">‫به من در marienraat@riseup.net رایانامه بزنید‬</string>
<string name="email_me_summary">مشکلات یا پیشنهادهایتان را به من رایانامه کنید</string>
Expand Down
53 changes: 36 additions & 17 deletions app/src/main/res/values-lt/strings.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2016 techwebpd <https://github.com/techwebpd>
**
** Permission to use, copy, modify, and/or distribute this software for
** any purpose with or without fee is hereby granted, provided that the
** above copyright notice and this permission notice appear in all copies.
**
** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
** WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
** ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
** SOFTWARE.
-->
<resources xmlns:tools="http://schemas.android.com/tools"
<!--
* Copyright (c) 2016 Marien Raat <marienraat@riseup.net>
*
* This file is free software: you may copy, redistribute 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 file 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, see <http://www.gnu.org/licenses/>.
*
* This file incorporates work covered by the following copyright and
* permission notice:
*
* Copyright (c) 2016 techwebpd <https://github.com/techwebpd>
*
* Permission to use, copy, modify, and/or distribute this software
* for any purpose with or without fee is hereby granted, provided
* that the above copyright notice and this permission notice appear
* in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-->
<resources xmlns:tools="http://schemas.android.com/tools"
tools:ignore="MissingTranslation">
<!-- App Name and Activity Labels -->
<string name="app_name">Red Moon</string>
Expand Down Expand Up @@ -50,7 +70,6 @@
<string name="keep_running_after_reboot">Veikti net ir po įrenginio perkrovimo</string>

<string name="dark_theme">Tamsi tema</string>
<string name="dark_theme_summary">Naudoti tamsią temą šiam aktyvumui</string>

<string name="email_me_title">Parašyti man el. paštu marienraat@riseup.net</string>
<string name="email_me_summary">Parašyti man el. paštu dėl programinių klaidų ar pasiūlymų</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
<string name="keep_running_after_reboot">Keep running after reboot</string>

<string name="dark_theme">Dark theme</string>
<string name="dark_theme_summary">Use a dark theme for this activity</string>

<string name="email_me_title">Email me at marienraat@riseup.net</string>
<string name="email_me_summary">Email me with bugs or suggestions</string>
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,9 @@
</PreferenceCategory>

<PreferenceCategory android:title="@string/pref_title_app_appearance">
<CheckBoxPreference
<SwitchPreference
android:key="@string/pref_key_dark_theme"
android:title="@string/dark_theme"
android:summary="@string/dark_theme_summary"
android:defaultValue="false" />
</PreferenceCategory>

Expand Down

0 comments on commit c8bd6b5

Please sign in to comment.