#1341 - Fix UI glitches with widget

This commit is contained in:
moezbhatti
2018-11-18 20:13:48 -05:00
parent e610a373ca
commit 7bc0b2181b
7 changed files with 40 additions and 17 deletions
@@ -22,6 +22,7 @@ import android.app.AlarmManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import com.moez.QKSMS.manager.WidgetManager
import com.moez.QKSMS.receiver.NightModeReceiver
import java.text.SimpleDateFormat
import java.util.*
@@ -32,7 +33,8 @@ import javax.inject.Singleton
@Singleton
class NightModeManager @Inject constructor(
private val context: Context,
private val prefs: Preferences) {
private val prefs: Preferences,
private val widgetManager: WidgetManager) {
fun updateCurrentTheme() {
// If night mode is not on auto, then there's nothing to do here
@@ -45,6 +47,7 @@ class NightModeManager @Inject constructor(
// If the last nightStart was more recent than the last nightEnd, then it's night time
prefs.night.set(nightStartTime > nightEndTime)
widgetManager.updateTheme()
}
fun updateNightMode(mode: Int) {
@@ -53,6 +56,7 @@ class NightModeManager @Inject constructor(
// If it's not on auto mode, set the appropriate night mode
if (mode != Preferences.NIGHT_MODE_AUTO) {
prefs.night.set(mode == Preferences.NIGHT_MODE_ON)
widgetManager.updateTheme()
}
updateAlarms()