Skip to content

Commit 46f6b7d

Browse files
committed
I lied. THIS is 2018.2-beta1. I'll sneak in a theme setting too.
1 parent 54644d4 commit 46f6b7d

File tree

6 files changed

+72
-10
lines changed

6 files changed

+72
-10
lines changed

app/src/main/java/com/team980/thunderscout/ThunderScout.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import android.preference.PreferenceManager;
3232
import android.service.quicksettings.TileService;
3333
import android.support.multidex.MultiDexApplication;
34+
import android.support.v7.app.AppCompatDelegate;
3435

3536
import com.crashlytics.android.Crashlytics;
3637
import com.crashlytics.android.core.CrashlyticsCore;
@@ -106,6 +107,11 @@ public void onCreate() { //This isn't why loading is slow
106107
Fabric.with(this, crashlyticsKit);
107108
}
108109

110+
if (sharedPref.getBoolean(getResources().getString(R.string.pref_app_theme), false)) {
111+
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
112+
} else {
113+
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
114+
}
109115
}
110116

111117
@Override

app/src/main/java/com/team980/thunderscout/preferences/SettingsActivity.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import android.provider.Settings;
3333
import android.support.annotation.Nullable;
3434
import android.support.v7.app.AppCompatActivity;
35+
import android.support.v7.app.AppCompatDelegate;
3536
import android.support.v7.preference.EditTextPreference;
3637
import android.support.v7.preference.ListPreference;
3738
import android.support.v7.preference.Preference;
@@ -245,6 +246,27 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
245246
}
246247
}
247248

249+
public static class AppearancePreferenceFragment extends PreferenceFragmentCompat {
250+
@Override
251+
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
252+
addPreferencesFromResource(R.xml.pref_appearance);
253+
254+
SettingsActivity activity = (SettingsActivity) getActivity();
255+
activity.getSupportActionBar().setTitle("Theme settings [BETA]");
256+
257+
findPreference(getResources().getString(R.string.pref_app_theme))
258+
.setOnPreferenceChangeListener((preference, newValue) -> {
259+
if ((boolean) newValue) {
260+
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
261+
} else {
262+
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
263+
}
264+
activity.recreate();
265+
return true;
266+
});
267+
}
268+
}
269+
248270
public static class MatchScoutPreferenceFragment extends PreferenceFragmentCompat {
249271
@Override
250272
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="utf-8"?><!--
2+
~ MIT License
3+
~
4+
~ Copyright (c) 2016 - 2018 Luke Myers (FRC Team 980 ThunderBots)
5+
~
6+
~ Permission is hereby granted, free of charge, to any person obtaining a copy
7+
~ of this software and associated documentation files (the "Software"), to deal
8+
~ in the Software without restriction, including without limitation the rights
9+
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
~ copies of the Software, and to permit persons to whom the Software is
11+
~ furnished to do so, subject to the following conditions:
12+
~
13+
~ The above copyright notice and this permission notice shall be included in all
14+
~ copies or substantial portions of the Software.
15+
~
16+
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
~ SOFTWARE.
23+
-->
24+
25+
<resources>
26+
<color name="primary">#222</color>
27+
<color name="primary_dark">#111</color>
28+
</resources>

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
\n
5050
\n(Oh, and the team info screen now incorporates individual match tabs.)
5151
\n
52-
\nTechnical note: ThunderCloud is being in a separate branch from the rest of the app, and may change significantly or disappear in subsequent releases.
52+
\nTechnical note: ThunderCloud is being developed in a separate branch from the rest of the app, and may change significantly or disappear in subsequent releases.
5353
</string>
5454

5555
<!--- TODO remove before flight (stable) -->

app/src/main/res/xml/pref_appearance.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@
2222
~ SOFTWARE.
2323
-->
2424

25-
<PreferenceScreen>
25+
<android.support.v7.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
26+
27+
<android.support.v7.preference.SwitchPreferenceCompat
28+
android:key="@string/pref_app_theme"
29+
android:summary="Internal testing only - this will change or disappear in the future!"
30+
android:title="Use beta theme" />
2631

2732
<!--<android.support.v7.preference.ListPreference
2833
android:title="Theme"
@@ -33,4 +38,4 @@
3338
android:summary="May help prevent burn in on OLED devices"
3439
android:key="@string/pref_tint_navigation_bar"/>-->
3540

36-
</PreferenceScreen>
41+
</android.support.v7.preference.PreferenceScreen>

app/src/main/res/xml/pref_main.xml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@
3333
android:title="General settings"
3434
app:allowDividerBelow="false" />
3535

36-
<!--<android.support.v7.preference.Preference
37-
app:allowDividerBelow="false"
38-
android:fragment="com.team980.thunderscout.preferences.SettingsActivity$AppearancePreferenceFragment"
39-
android:icon="@drawable/ic_brush_white_24dp"
40-
android:layout="@layout/preference_backport_material"
41-
android:title="Appearance" />-->
42-
4336
<com.team980.thunderscout.preferences.backport.MasterSwitchPreference
4437
android:defaultValue="true"
4538
android:fragment="com.team980.thunderscout.preferences.SettingsActivity$MatchScoutPreferenceFragment"
@@ -66,6 +59,14 @@
6659
android:title="ThunderCloud"
6760
app:allowDividerBelow="false" />
6861

62+
<android.support.v7.preference.Preference
63+
android:fragment="com.team980.thunderscout.preferences.SettingsActivity$AppearancePreferenceFragment"
64+
android:icon="@drawable/ic_brush_white_24dp"
65+
android:layout="@layout/preference_backport_material"
66+
android:summary="Expect these to change or break in future releases!"
67+
android:title="Theme settings [BETA]"
68+
app:allowDividerBelow="false" />
69+
6970
<android.support.v7.preference.Preference
7071
android:icon="@drawable/ic_notification_white_24dp"
7172
android:key="@string/pref_notification_settings"

0 commit comments

Comments
 (0)