Skip to content

Commit

Permalink
I lied. THIS is 2018.2-beta1. I'll sneak in a theme setting too.
Browse files Browse the repository at this point in the history
  • Loading branch information
19lmyers committed Apr 15, 2018
1 parent 54644d4 commit 46f6b7d
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 10 deletions.
6 changes: 6 additions & 0 deletions app/src/main/java/com/team980/thunderscout/ThunderScout.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import android.preference.PreferenceManager;
import android.service.quicksettings.TileService;
import android.support.multidex.MultiDexApplication;
import android.support.v7.app.AppCompatDelegate;

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

if (sharedPref.getBoolean(getResources().getString(R.string.pref_app_theme), false)) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
} else {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import android.provider.Settings;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.app.AppCompatDelegate;
import android.support.v7.preference.EditTextPreference;
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference;
Expand Down Expand Up @@ -245,6 +246,27 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
}
}

public static class AppearancePreferenceFragment extends PreferenceFragmentCompat {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.pref_appearance);

SettingsActivity activity = (SettingsActivity) getActivity();
activity.getSupportActionBar().setTitle("Theme settings [BETA]");

findPreference(getResources().getString(R.string.pref_app_theme))
.setOnPreferenceChangeListener((preference, newValue) -> {
if ((boolean) newValue) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
} else {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
}
activity.recreate();
return true;
});
}
}

public static class MatchScoutPreferenceFragment extends PreferenceFragmentCompat {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
Expand Down
28 changes: 28 additions & 0 deletions app/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ MIT License
~
~ Copyright (c) 2016 - 2018 Luke Myers (FRC Team 980 ThunderBots)
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in all
~ copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ SOFTWARE.
-->

<resources>
<color name="primary">#222</color>
<color name="primary_dark">#111</color>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
\n
\n(Oh, and the team info screen now incorporates individual match tabs.)
\n
\nTechnical note: ThunderCloud is being in a separate branch from the rest of the app, and may change significantly or disappear in subsequent releases.
\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.
</string>

<!--- TODO remove before flight (stable) -->
Expand Down
9 changes: 7 additions & 2 deletions app/src/main/res/xml/pref_appearance.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
~ SOFTWARE.
-->

<PreferenceScreen>
<android.support.v7.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">

<android.support.v7.preference.SwitchPreferenceCompat
android:key="@string/pref_app_theme"
android:summary="Internal testing only - this will change or disappear in the future!"
android:title="Use beta theme" />

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

</PreferenceScreen>
</android.support.v7.preference.PreferenceScreen>
15 changes: 8 additions & 7 deletions app/src/main/res/xml/pref_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@
android:title="General settings"
app:allowDividerBelow="false" />

<!--<android.support.v7.preference.Preference
app:allowDividerBelow="false"
android:fragment="com.team980.thunderscout.preferences.SettingsActivity$AppearancePreferenceFragment"
android:icon="@drawable/ic_brush_white_24dp"
android:layout="@layout/preference_backport_material"
android:title="Appearance" />-->

<com.team980.thunderscout.preferences.backport.MasterSwitchPreference
android:defaultValue="true"
android:fragment="com.team980.thunderscout.preferences.SettingsActivity$MatchScoutPreferenceFragment"
Expand All @@ -66,6 +59,14 @@
android:title="ThunderCloud"
app:allowDividerBelow="false" />

<android.support.v7.preference.Preference
android:fragment="com.team980.thunderscout.preferences.SettingsActivity$AppearancePreferenceFragment"
android:icon="@drawable/ic_brush_white_24dp"
android:layout="@layout/preference_backport_material"
android:summary="Expect these to change or break in future releases!"
android:title="Theme settings [BETA]"
app:allowDividerBelow="false" />

<android.support.v7.preference.Preference
android:icon="@drawable/ic_notification_white_24dp"
android:key="@string/pref_notification_settings"
Expand Down

0 comments on commit 46f6b7d

Please sign in to comment.