forked from upstream-mirrors/quik
Remove Observables from Views
commit 6bb74ca5201cba2fc5de2db349bb7627c028b617 Author: Moez Bhatti <moez.bhatti@gmail.com> Date: Sun May 27 15:15:27 2018 -0400 Fix crash when tapping on selected contact commit f5a45e2a600a8d373160dcb0273bab232e6cc0c5 Author: Moez Bhatti <moez.bhatti@gmail.com> Date: Sun May 27 15:10:44 2018 -0400 Add missing attributes for dialog themes commit 2188adbe5948b9b71f816dad5fb115829ba57e30 Author: Moez Bhatti <moez.bhatti@gmail.com> Date: Sun May 27 14:59:39 2018 -0400 Refresh settings activity when theme changed commit a9541019c566a3a6e41e64ea8136f7fd50a6d364 Author: Moez Bhatti <moez.bhatti@gmail.com> Date: Sun May 27 14:56:33 2018 -0400 Don't use themed attributes in widget commit 4823a3034848efac624eb82856f692c7f9e775a5 Author: Moez Bhatti <moez.bhatti@gmail.com> Date: Sun May 27 14:29:00 2018 -0400 Refresh adapter in conversation info when theme changed commit 7ea5837b99c2b6eac547dad383515ee7b79ff6e4 Author: Moez Bhatti <moez.bhatti@gmail.com> Date: Fri May 25 18:27:08 2018 -0400 Bundle theme colors into data class commit 6a832fdde98622c5a252aca0cac3150a6eb0f554 Author: Moez Bhatti <moez.bhatti@gmail.com> Date: Fri May 25 17:16:21 2018 -0400 Update conversation UI when theme changed commit ef6948e80ed8734a7fefbec1b00f1b32e8209072 Author: Moez Bhatti <moez.bhatti@gmail.com> Date: Fri May 25 16:15:39 2018 -0400 Fix avatar not respecting theme commit 4ea21b6a9963f91d3b9cdaf0ba4749a6f24e8a74 Author: Moez Bhatti <moez.bhatti@gmail.com> Date: Fri May 25 15:52:40 2018 -0400 Fix checkmark color in theme picker commit 270a9d3037439f165a110c7d7dcaf7dd84dad29f Author: Moez Bhatti <moez.bhatti@gmail.com> Date: Fri May 25 13:39:12 2018 -0400 Update views in MainActivity when theme changed commit cdc1187ccaee800e4305da5fab5d22220d04440f Author: Moez Bhatti <moez.bhatti@gmail.com> Date: Thu May 24 23:36:17 2018 -0400 Remove unnecessary programmatic creation of drawer item background commit bc6fbfa75c66bb81db9591617f8c1de4c0f2746f Author: Moez Bhatti <moez.bhatti@gmail.com> Date: Thu May 24 23:28:44 2018 -0400 Temporarily disable RxJava2Debug commit eae422be0bab8cedb3cb5ddf5f4ae61368ab5d1e Author: Moez Bhatti <moez.bhatti@gmail.com> Date: Thu May 24 21:16:46 2018 -0400 Remove observable usage inside of custom views commit 2e65d55b9b283e74fb395d4828eb310395b4902b Author: Moez Bhatti <moez.bhatti@gmail.com> Date: Thu May 24 02:27:26 2018 -0400 Migrate ripple and text size to no longer use observables
This commit is contained in:
@@ -35,12 +35,14 @@ import common.util.Colors
|
||||
import common.util.DateFormatter
|
||||
import common.util.GlideApp
|
||||
import common.util.extensions.dpToPx
|
||||
import common.util.extensions.getColorCompat
|
||||
import feature.main.MainActivity
|
||||
import injection.appComponent
|
||||
import model.Contact
|
||||
import model.Conversation
|
||||
import model.PhoneNumber
|
||||
import repository.MessageRepository
|
||||
import util.Preferences
|
||||
import javax.inject.Inject
|
||||
|
||||
class WidgetAdapter(intent: Intent) : RemoteViewsService.RemoteViewsFactory {
|
||||
@@ -53,6 +55,7 @@ class WidgetAdapter(intent: Intent) : RemoteViewsService.RemoteViewsFactory {
|
||||
@Inject lateinit var colors: Colors
|
||||
@Inject lateinit var dateFormatter: DateFormatter
|
||||
@Inject lateinit var messageRepo: MessageRepository
|
||||
@Inject lateinit var prefs: Preferences
|
||||
|
||||
private val appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID)
|
||||
private val smallWidget = intent.getBooleanExtra("small_widget", false)
|
||||
@@ -61,12 +64,19 @@ class WidgetAdapter(intent: Intent) : RemoteViewsService.RemoteViewsFactory {
|
||||
|
||||
// Cache colors, load lazily. This entire class is recreated when the widget is recreated,
|
||||
// so if the theme changes then these values will be correct in the new instance
|
||||
private val theme by lazy { colors.theme.blockingFirst() }
|
||||
private val background by lazy { colors.background.blockingFirst() }
|
||||
private val textPrimary by lazy { colors.textPrimary.blockingFirst() }
|
||||
private val textSecondary by lazy { colors.textSecondary.blockingFirst() }
|
||||
private val textTertiary by lazy { colors.textTertiary.blockingFirst() }
|
||||
private val textPrimaryOnTheme by lazy { colors.textPrimaryOnTheme.blockingFirst() }
|
||||
private val night by lazy { prefs.night.get() }
|
||||
private val black by lazy { prefs.black.get() }
|
||||
private val theme by lazy { colors.theme() }
|
||||
private val background by lazy {
|
||||
context.getColorCompat(when {
|
||||
night && black -> R.color.black
|
||||
night && !black -> R.color.backgroundDark
|
||||
else -> R.color.white
|
||||
})
|
||||
}
|
||||
private val textPrimary by lazy { context.getColorCompat(if (night) R.color.textPrimaryDark else R.color.textPrimary) }
|
||||
private val textSecondary by lazy { context.getColorCompat(if (night) R.color.textSecondaryDark else R.color.textSecondary) }
|
||||
private val textTertiary by lazy { context.getColorCompat(if (night) R.color.textTertiaryDark else R.color.textTertiary) }
|
||||
|
||||
override fun onCreate() {
|
||||
appComponent.inject(this)
|
||||
@@ -103,9 +113,9 @@ class WidgetAdapter(intent: Intent) : RemoteViewsService.RemoteViewsFactory {
|
||||
|
||||
// Avatar
|
||||
remoteViews.setViewVisibility(R.id.avatar, if (smallWidget) View.GONE else View.VISIBLE)
|
||||
remoteViews.setInt(R.id.avatar, "setBackgroundColor", theme)
|
||||
remoteViews.setTextColor(R.id.initial, textPrimaryOnTheme)
|
||||
remoteViews.setInt(R.id.icon, "setColorFilter", textPrimaryOnTheme)
|
||||
remoteViews.setInt(R.id.avatar, "setBackgroundColor", theme.theme)
|
||||
remoteViews.setTextColor(R.id.initial, theme.textPrimary)
|
||||
remoteViews.setInt(R.id.icon, "setColorFilter", theme.textPrimary)
|
||||
remoteViews.setInt(R.id.avatarMask, "setColorFilter", background)
|
||||
|
||||
val contact = conversation.recipients.map { recipient ->
|
||||
|
||||
Reference in New Issue
Block a user