From 2626462e49cad9e0233b4085ee565808eef40218 Mon Sep 17 00:00:00 2001 From: Tamim Hossain <132823494+CodeWithTamim@users.noreply.github.com> Date: Mon, 18 Nov 2024 17:26:00 +0600 Subject: [PATCH] Remove unnecessary Context parameter from setNightMode (#3971) Refactored the `setNightMode` function to remove the unused `Context` parameter. Changes: - Eliminated the `context` parameter from the `setNightMode` function. - Adjusted function signature to align with the current implementation, which does not utilize the `Context`. This simplifies the function interface and ensures cleaner, more maintainable code. --- V2rayNG/app/src/main/java/com/v2ray/ang/AngApplication.kt | 2 +- V2rayNG/app/src/main/java/com/v2ray/ang/util/Utils.kt | 2 +- .../src/main/java/com/v2ray/ang/viewmodel/SettingsViewModel.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/AngApplication.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/AngApplication.kt index e1981822..5c01d496 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/AngApplication.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/AngApplication.kt @@ -37,7 +37,7 @@ class AngApplication : MultiDexApplication() { MMKV.initialize(this) - Utils.setNightMode(application) + Utils.setNightMode() // Initialize WorkManager with the custom configuration WorkManager.initialize(this, workManagerConfiguration) diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/util/Utils.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/util/Utils.kt index a9195121..58b6e05d 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/util/Utils.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/util/Utils.kt @@ -396,7 +396,7 @@ object Utils { } - fun setNightMode(context: Context) { + fun setNightMode() { when (MmkvManager.decodeSettingsString(AppConfig.PREF_UI_MODE_NIGHT, "0")) { "0" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM) "1" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO) diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/viewmodel/SettingsViewModel.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/viewmodel/SettingsViewModel.kt index 311c1a4a..cc1cca4c 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/viewmodel/SettingsViewModel.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/viewmodel/SettingsViewModel.kt @@ -81,7 +81,7 @@ class SettingsViewModel(application: Application) : AndroidViewModel(application // } } if (key == AppConfig.PREF_UI_MODE_NIGHT) { - Utils.setNightMode(getApplication()) + Utils.setNightMode() } } }