Use `AppCompatDelegate` instead of `DayNightDelegate` (#2453)
This commit is contained in:
parent
efceaa2432
commit
a185496e41
|
|
@ -38,6 +38,7 @@ import android.text.TextUtils;
|
|||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import org.lsposed.hiddenapibypass.HiddenApiBypass;
|
||||
|
|
@ -66,7 +67,6 @@ import okhttp3.Cache;
|
|||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import rikka.core.os.FileUtils;
|
||||
import rikka.material.app.DayNightDelegate;
|
||||
import rikka.material.app.LocaleDelegate;
|
||||
|
||||
public class App extends Application {
|
||||
|
|
@ -213,8 +213,7 @@ public class App extends Application {
|
|||
pref.edit().putBoolean("doh", true).apply();
|
||||
}
|
||||
}
|
||||
DayNightDelegate.setApplicationContext(this);
|
||||
DayNightDelegate.setDefaultNightMode(ThemeUtil.getDarkTheme());
|
||||
AppCompatDelegate.setDefaultNightMode(ThemeUtil.getDarkTheme());
|
||||
LocaleDelegate.setDefaultLocale(getLocale());
|
||||
var res = getResources();
|
||||
var config = res.getConfiguration();
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import androidx.activity.result.ActivityResultLauncher;
|
|||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
import androidx.core.text.HtmlCompat;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
|
|
@ -59,7 +60,6 @@ import java.util.ArrayList;
|
|||
import java.util.Locale;
|
||||
|
||||
import rikka.core.util.ResourceUtils;
|
||||
import rikka.material.app.DayNightDelegate;
|
||||
import rikka.material.app.LocaleDelegate;
|
||||
import rikka.material.preference.MaterialSwitchPreference;
|
||||
import rikka.preference.SimpleMenuPreference;
|
||||
|
|
@ -234,7 +234,7 @@ public class SettingsFragment extends BaseFragment {
|
|||
if (theme != null) {
|
||||
theme.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
if (!App.getPreferences().getString("dark_theme", ThemeUtil.MODE_NIGHT_FOLLOW_SYSTEM).equals(newValue)) {
|
||||
DayNightDelegate.setDefaultNightMode(ThemeUtil.getDarkTheme((String) newValue));
|
||||
AppCompatDelegate.setDefaultNightMode(ThemeUtil.getDarkTheme((String) newValue));
|
||||
MainActivity activity = (MainActivity) getActivity();
|
||||
if (activity != null) {
|
||||
activity.restart();
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import android.content.Context;
|
|||
import android.content.SharedPreferences;
|
||||
|
||||
import androidx.annotation.StyleRes;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
|
||||
import com.google.android.material.color.DynamicColors;
|
||||
|
||||
|
|
@ -33,7 +34,6 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import rikka.core.util.ResourceUtils;
|
||||
import rikka.material.app.DayNightDelegate;
|
||||
|
||||
public class ThemeUtil {
|
||||
private static final Map<String, Integer> colorThemeMap = new HashMap<>();
|
||||
|
|
@ -116,11 +116,11 @@ public class ThemeUtil {
|
|||
switch (mode) {
|
||||
case MODE_NIGHT_FOLLOW_SYSTEM:
|
||||
default:
|
||||
return DayNightDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
|
||||
return AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
|
||||
case MODE_NIGHT_YES:
|
||||
return DayNightDelegate.MODE_NIGHT_YES;
|
||||
return AppCompatDelegate.MODE_NIGHT_YES;
|
||||
case MODE_NIGHT_NO:
|
||||
return DayNightDelegate.MODE_NIGHT_NO;
|
||||
return AppCompatDelegate.MODE_NIGHT_NO;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,11 +23,11 @@ lsplugin-jgit = { id = "org.lsposed.lsplugin.jgit", version = "1.0" }
|
|||
appcenter-crashes = { group = "com.microsoft.appcenter", name = "appcenter-crashes", version.ref = "appcenter" }
|
||||
appcenter-analytics = { group = "com.microsoft.appcenter", name = "appcenter-analytics", version.ref = "appcenter" }
|
||||
|
||||
rikkax-appcompat = { module = "dev.rikka.rikkax.appcompat:appcompat", version = "1.5.0.1" }
|
||||
rikkax-appcompat = { module = "dev.rikka.rikkax.appcompat:appcompat", version = "1.6.1" }
|
||||
rikkax-core = { module = "dev.rikka.rikkax.core:core", version = "1.4.1" }
|
||||
rikkax-insets = { module = "dev.rikka.rikkax.insets:insets", version = "1.3.0" }
|
||||
rikkax-layoutinflater = { module = "dev.rikka.rikkax.layoutinflater:layoutinflater", version = "1.3.0" }
|
||||
rikkax-material = { module = "dev.rikka.rikkax.material:material", version = "2.5.1" }
|
||||
rikkax-material = { module = "dev.rikka.rikkax.material:material", version = "2.7.0" }
|
||||
rikkax-material-preference = { module = "dev.rikka.rikkax.material:material-preference", version = "2.0.0" }
|
||||
rikkax-parcelablelist = { module = "dev.rikka.rikkax.parcelablelist:parcelablelist", version = "2.0.1" }
|
||||
rikkax-preference = { module = "dev.rikka.rikkax.material:material-preference", version = "2.0.0" }
|
||||
|
|
|
|||
Loading…
Reference in New Issue