Skip to content

Commit

Permalink
Remove unnecessary Context parameter from setNightMode (#3971)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
CodeWithTamim authored Nov 18, 2024
1 parent 41893d7 commit 2626462
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion V2rayNG/app/src/main/java/com/v2ray/ang/AngApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion V2rayNG/app/src/main/java/com/v2ray/ang/util/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class SettingsViewModel(application: Application) : AndroidViewModel(application
// }
}
if (key == AppConfig.PREF_UI_MODE_NIGHT) {
Utils.setNightMode(getApplication())
Utils.setNightMode()
}
}
}

0 comments on commit 2626462

Please sign in to comment.