Skip to content

Commit

Permalink
Fix broken dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
doubleangels committed Jan 24, 2025
1 parent 1320b95 commit f88ebd3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
3 changes: 1 addition & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ android {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
debuggable true
debuggable false
}
debugSentryOn {
}
Expand Down Expand Up @@ -57,7 +57,6 @@ dependencies {
implementation 'androidx.preference:preference:1.2.1'
implementation 'androidx.webkit:webkit:1.12.1'
implementation 'com.google.android.material:material:1.12.0'
implementation 'com.jakewharton:process-phoenix:3.0.0'
implementation 'com.squareup.retrofit2:converter-gson:2.11.0'
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'io.sentry:sentry-android:8.0.0'
Expand Down
4 changes: 0 additions & 4 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
-dontwarn androidx.appcompat.**
-dontwarn androidx.preference.**

# Process Phoenix (Jake Wharton)
-keep class com.jakewharton.processphoenix.** { *; }
-dontwarn com.jakewharton.processphoenix.**

# Retrofit (Gson Converter)
-keep class com.squareup.retrofit2.** { *; }
-dontwarn com.squareup.retrofit2.**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.doubleangels.nextdnsmanagement.sentry.SentryInitializer;
import com.doubleangels.nextdnsmanagement.sentry.SentryManager;
import com.doubleangels.nextdnsmanagement.sharedpreferences.SharedPreferencesManager;
import com.jakewharton.processphoenix.ProcessPhoenix;

import java.util.Locale;

Expand All @@ -35,6 +34,8 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_settings);
sentryManager = new SentryManager(this);
SharedPreferencesManager.init(this);
sentryManager.captureMessage("SharedPreferences 'dark_mode' value: " + SharedPreferencesManager.getString("dark_mode", "match"));
sentryManager.captureMessage("SharedPreferences 'sentry_enable' value: " + SharedPreferencesManager.getBoolean("sentry_enable", false));
try {
if (sentryManager.isEnabled()) {
SentryInitializer.initialize(this);
Expand Down Expand Up @@ -159,7 +160,6 @@ private void setupDarkModeChangeListener(ListPreference setting) {
setting.setOnPreferenceChangeListener((preference, newValue) -> {
new SentryManager(requireContext()).captureMessage("Dark mode set to " + newValue.toString() + ".");
SharedPreferencesManager.putString("dark_mode", newValue.toString());
ProcessPhoenix.triggerRebirth(requireContext());
return true;
});
}
Expand All @@ -173,7 +173,6 @@ private void setupSentryChangeListener(SwitchPreference switchPreference) {
setPreferenceVisibility("whitelist_domains", isEnabled);
setPreferenceVisibility("whitelist_domain_1_button", isEnabled);
setPreferenceVisibility("whitelist_domain_2_button", isEnabled);
ProcessPhoenix.triggerRebirth(requireContext());
return true;
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.doubleangels.nextdnsmanagement.sharedpreferences;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;

Expand All @@ -17,19 +18,21 @@ public static synchronized void init(Context context) {
}
}

@SuppressLint("ApplySharedPref")
public static void putString(String key, String value) {
checkInitialization();
sharedPreferences.edit().putString(key, value).apply();
sharedPreferences.edit().putString(key, value).commit();
}

public static String getString(String key, String defaultValue) {
checkInitialization();
return sharedPreferences.getString(key, defaultValue);
}

@SuppressLint("ApplySharedPref")
public static void putBoolean(String key, boolean value) {
checkInitialization();
sharedPreferences.edit().putBoolean(key, value).apply();
sharedPreferences.edit().putBoolean(key, value).commit();
}

public static boolean getBoolean(String key, boolean defaultValue) {
Expand Down

0 comments on commit f88ebd3

Please sign in to comment.