mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-22 13:48:52 +01:00
Force widget to respect system dark and light mode
This commit is contained in:
@@ -25,6 +25,7 @@ import android.appwidget.AppWidgetProvider
|
|||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.res.Configuration
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.widget.RemoteViews
|
import android.widget.RemoteViews
|
||||||
@@ -109,8 +110,11 @@ class WidgetProvider : AppWidgetProvider() {
|
|||||||
Timber.v("updateWidget appWidgetId: $appWidgetId")
|
Timber.v("updateWidget appWidgetId: $appWidgetId")
|
||||||
val remoteViews = RemoteViews(context.packageName, R.layout.widget)
|
val remoteViews = RemoteViews(context.packageName, R.layout.widget)
|
||||||
|
|
||||||
|
val nightModeFlags = context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
|
||||||
|
val isNightMode = nightModeFlags == Configuration.UI_MODE_NIGHT_YES
|
||||||
|
|
||||||
// Apply colors from theme
|
// Apply colors from theme
|
||||||
val night = prefs.night.get()
|
val night = prefs.night.get() || isNightMode
|
||||||
val black = prefs.black.get()
|
val black = prefs.black.get()
|
||||||
|
|
||||||
remoteViews.setInt(R.id.background, "setColorFilter", context.getColorCompat(when {
|
remoteViews.setInt(R.id.background, "setColorFilter", context.getColorCompat(when {
|
||||||
|
|||||||
Reference in New Issue
Block a user