mirror of
https://github.com/SoPat712/TrackCovid19.git
synced 2025-08-21 10:18:46 -04:00
SwitchPreference
Working, but not updating
This commit is contained in:
Binary file not shown.
@@ -4,7 +4,10 @@ import android.os.Bundle;
|
||||
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
public class SettingsActivity extends AppCompatActivity {
|
||||
|
||||
@@ -26,6 +29,19 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
setPreferencesFromResource(R.xml.root_preferences, rootKey);
|
||||
SwitchPreference darkModeSwitch = findPreference("darkMode");
|
||||
assert darkModeSwitch != null;
|
||||
darkModeSwitch.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
if (AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_YES) {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
|
||||
} else {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -27,12 +27,12 @@
|
||||
<group
|
||||
android:id="@+id/menu_bottom"
|
||||
android:checkableBehavior="none">
|
||||
<!--
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_yoursettings"
|
||||
android:icon="@drawable/ic_action_name"
|
||||
android:title="@string/item" />
|
||||
-->
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_sendFeedback"
|
||||
android:icon="@drawable/ic_action_name2"
|
||||
|
@@ -38,7 +38,7 @@
|
||||
<string name="title_activity_settings">Settings</string>
|
||||
|
||||
<!-- Preference Titles -->
|
||||
<string name="messages_header">Messages</string>
|
||||
<string name="messages_header">Preferences</string>
|
||||
<string name="sync_header">Sync</string>
|
||||
|
||||
<!-- Messages Preferences -->
|
||||
|
@@ -1,19 +1,14 @@
|
||||
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<PreferenceCategory app:title="@string/messages_header">
|
||||
|
||||
<EditTextPreference
|
||||
app:key="signature"
|
||||
app:title="@string/signature_title"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<ListPreference
|
||||
app:defaultValue="reply"
|
||||
app:entries="@array/reply_entries"
|
||||
app:entryValues="@array/reply_values"
|
||||
app:key="reply"
|
||||
app:title="@string/reply_title"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
<SwitchPreference
|
||||
android:key="darkMode"
|
||||
android:title="Dark Mode" />
|
||||
|
||||
|
||||
|
||||
</PreferenceCategory>
|
||||
<!--
|
||||
|
Reference in New Issue
Block a user