aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/views
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2021-01-12 21:15:08 -0800
committerAllan Wang <me@allanwang.ca>2021-01-12 21:15:08 -0800
commite01e51574613459a036c1d60383bfb229799a407 (patch)
tree4214c9803638fcc1b9d9e19159651f7115c846c4 /app/src/main/kotlin/com/pitchedapps/frost/views
parent0e5c1ab2dd2b574970883576e18f9a119b058788 (diff)
downloadfrost-e01e51574613459a036c1d60383bfb229799a407.tar.gz
frost-e01e51574613459a036c1d60383bfb229799a407.tar.bz2
frost-e01e51574613459a036c1d60383bfb229799a407.zip
Convert all theme access to themeprovider
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/views')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt8
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt10
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt8
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt8
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/Keywords.kt16
5 files changed, 29 insertions, 21 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt
index 6ba9ff4d..6eebd36f 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt
@@ -37,7 +37,7 @@ import com.pitchedapps.frost.db.CookieEntity
import com.pitchedapps.frost.facebook.profilePictureUrl
import com.pitchedapps.frost.glide.FrostGlide
import com.pitchedapps.frost.glide.GlideApp
-import com.pitchedapps.frost.prefs.Prefs
+import com.pitchedapps.frost.injectors.ThemeProvider
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
@@ -48,13 +48,13 @@ class AccountItem(val cookie: CookieEntity?) :
KauIItem<AccountItem.ViewHolder>(R.layout.view_account, { ViewHolder(it) }, R.id.item_account),
KoinComponent {
- private val prefs: Prefs by inject()
+ private val themeProvider: ThemeProvider by inject()
override fun bindView(holder: ViewHolder, payloads: List<Any>) {
super.bindView(holder, payloads)
with(holder) {
text.invisible()
- text.setTextColor(prefs.textColor)
+ text.setTextColor(themeProvider.textColor)
if (cookie != null) {
text.text = cookie.name
GlideApp.with(itemView).load(profilePictureUrl(cookie.id))
@@ -86,7 +86,7 @@ class AccountItem(val cookie: CookieEntity?) :
GoogleMaterial.Icon.gmd_add_circle_outline.toDrawable(
itemView.context,
100,
- prefs.textColor
+ themeProvider.textColor
)
)
text.text = itemView.context.getString(R.string.kau_add_account)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt
index ed94b59f..78af4edf 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt
@@ -29,6 +29,7 @@ import ca.allanwang.kau.utils.visible
import ca.allanwang.kau.utils.withAlpha
import com.mikepenz.iconics.typeface.IIcon
import com.pitchedapps.frost.databinding.ViewBadgedIconBinding
+import com.pitchedapps.frost.injectors.ThemeProvider
import com.pitchedapps.frost.prefs.Prefs
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
@@ -43,6 +44,7 @@ class BadgedIcon @JvmOverloads constructor(
) : ConstraintLayout(context, attrs, defStyleAttr), KoinComponent {
private val prefs: Prefs by inject()
+ private val themeProvider: ThemeProvider by inject()
private val binding: ViewBadgedIconBinding =
ViewBadgedIconBinding.inflate(LayoutInflater.from(context), this, true)
@@ -52,7 +54,7 @@ class BadgedIcon @JvmOverloads constructor(
private fun ViewBadgedIconBinding.init() {
val badgeColor =
- prefs.mainActivityLayout.backgroundColor(prefs).withAlpha(255).colorToForeground(0.2f)
+ prefs.mainActivityLayout.backgroundColor(themeProvider).withAlpha(255).colorToForeground(0.2f)
val badgeBackground =
GradientDrawable(
GradientDrawable.Orientation.BOTTOM_TOP,
@@ -60,7 +62,7 @@ class BadgedIcon @JvmOverloads constructor(
)
badgeBackground.cornerRadius = 13.dpToPx.toFloat()
badgeText.background = badgeBackground
- badgeText.setTextColor(prefs.mainActivityLayout.iconColor(prefs))
+ badgeText.setTextColor(prefs.mainActivityLayout.iconColor(themeProvider))
}
var iicon: IIcon? = null
@@ -70,13 +72,13 @@ class BadgedIcon @JvmOverloads constructor(
value?.toDrawable(
context,
sizeDp = 20,
- color = prefs.mainActivityLayout.iconColor(prefs)
+ color = prefs.mainActivityLayout.iconColor(themeProvider)
)
)
}
fun setAllAlpha(alpha: Float) {
- // badgeTextView.setTextColor(prefs.textColor.withAlpha(alpha.toInt()))
+ // badgeTextView.setTextColor(themeProvider.textColor.withAlpha(alpha.toInt()))
binding.badgeImage.drawable.alpha = alpha.toInt()
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt
index 55f41807..e25b603e 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt
@@ -39,6 +39,7 @@ import com.pitchedapps.frost.contracts.FrostContentCore
import com.pitchedapps.frost.contracts.FrostContentParent
import com.pitchedapps.frost.facebook.FbItem
import com.pitchedapps.frost.facebook.WEB_LOAD_DELAY
+import com.pitchedapps.frost.injectors.ThemeProvider
import com.pitchedapps.frost.kotlin.subscribeDuringJob
import com.pitchedapps.frost.prefs.Prefs
import com.pitchedapps.frost.utils.L
@@ -80,6 +81,7 @@ abstract class FrostContentView<out T> @JvmOverloads constructor(
FrostContentParent, KoinComponent where T : View, T : FrostContentCore {
private val prefs: Prefs by inject()
+ private val themeProvider: ThemeProvider by inject()
private val refresh: SwipeRefreshLayout by bindView(R.id.content_refresh)
private val progress: ProgressBar by bindView(R.id.content_progress)
val coreView: T by bindView(R.id.content_core)
@@ -156,9 +158,9 @@ abstract class FrostContentView<out T> @JvmOverloads constructor(
}
override fun reloadThemeSelf() {
- progress.tint(prefs.textColor.withAlpha(180))
- refresh.setColorSchemeColors(prefs.iconColor)
- refresh.setProgressBackgroundColorSchemeColor(prefs.headerColor.withAlpha(255))
+ progress.tint(themeProvider.textColor.withAlpha(180))
+ refresh.setColorSchemeColors(themeProvider.iconColor)
+ refresh.setProgressBackgroundColorSchemeColor(themeProvider.headerColor.withAlpha(255))
}
override fun reloadTextSizeSelf() {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt
index 09be1184..169e7f73 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt
@@ -43,6 +43,7 @@ import com.pitchedapps.frost.R
import com.pitchedapps.frost.databinding.ViewVideoBinding
import com.pitchedapps.frost.db.CookieDao
import com.pitchedapps.frost.db.currentCookie
+import com.pitchedapps.frost.injectors.ThemeProvider
import com.pitchedapps.frost.prefs.Prefs
import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.ctxCoroutine
@@ -88,6 +89,7 @@ class FrostVideoViewer @JvmOverloads constructor(
}
private val prefs: Prefs by inject()
+ private val themeProvider: ThemeProvider by inject()
private val cookieDao: CookieDao by inject()
private val binding: ViewVideoBinding =
@@ -100,8 +102,8 @@ class FrostVideoViewer @JvmOverloads constructor(
fun ViewVideoBinding.init() {
alpha = 0f
videoBackground.setBackgroundColor(
- if (!prefs.blackMediaBg && prefs.bgColor.isColorDark)
- prefs.bgColor.withMinAlpha(200)
+ if (!prefs.blackMediaBg && themeProvider.bgColor.isColorDark)
+ themeProvider.bgColor.withMinAlpha(200)
else
Color.BLACK
)
@@ -109,7 +111,7 @@ class FrostVideoViewer @JvmOverloads constructor(
video.pause()
videoToolbar.inflateMenu(R.menu.menu_video)
context.setMenuIcons(
- videoToolbar.menu, prefs.iconColor,
+ videoToolbar.menu, themeProvider.iconColor,
R.id.action_pip to GoogleMaterial.Icon.gmd_picture_in_picture_alt,
R.id.action_download to GoogleMaterial.Icon.gmd_file_download
)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/Keywords.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/Keywords.kt
index 0d53608b..c3d5a90e 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/Keywords.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/Keywords.kt
@@ -37,6 +37,7 @@ import com.mikepenz.fastadapter.listeners.ClickEventHook
import com.mikepenz.iconics.typeface.IIcon
import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial
import com.pitchedapps.frost.R
+import com.pitchedapps.frost.injectors.ThemeProvider
import com.pitchedapps.frost.prefs.Prefs
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
@@ -51,6 +52,7 @@ class Keywords @JvmOverloads constructor(
) : ConstraintLayout(context, attrs, defStyleAttr), KoinComponent {
private val prefs: Prefs by inject()
+ private val themeProvider: ThemeProvider by inject()
val editText: AppCompatEditText by bindView(R.id.edit_text)
val addIcon: ImageView by bindView(R.id.add_icon)
val recycler: RecyclerView by bindView(R.id.recycler)
@@ -58,8 +60,8 @@ class Keywords @JvmOverloads constructor(
init {
inflate(context, R.layout.view_keywords, this)
- editText.tint(prefs.textColor)
- addIcon.setImageDrawable(GoogleMaterial.Icon.gmd_add.keywordDrawable(context, prefs))
+ editText.tint(themeProvider.textColor)
+ addIcon.setImageDrawable(GoogleMaterial.Icon.gmd_add.keywordDrawable(context, themeProvider))
addIcon.setOnClickListener {
if (editText.text.isNullOrEmpty()) editText.error =
context.string(R.string.empty_keyword)
@@ -91,8 +93,8 @@ class Keywords @JvmOverloads constructor(
}
}
-private fun IIcon.keywordDrawable(context: Context, prefs: Prefs): Drawable =
- toDrawable(context, 20, prefs.textColor)
+private fun IIcon.keywordDrawable(context: Context, themeProvider: ThemeProvider): Drawable =
+ toDrawable(context, 20, themeProvider.textColor)
class KeywordItem(val keyword: String) : AbstractItem<KeywordItem.ViewHolder>() {
@@ -116,16 +118,16 @@ class KeywordItem(val keyword: String) : AbstractItem<KeywordItem.ViewHolder>()
class ViewHolder(v: View) : RecyclerView.ViewHolder(v), KoinComponent {
- private val prefs: Prefs by inject()
+ private val themeProvider: ThemeProvider by inject()
val text: AppCompatTextView by bindView(R.id.keyword_text)
val delete: ImageView by bindView(R.id.keyword_delete)
init {
- text.setTextColor(prefs.textColor)
+ text.setTextColor(themeProvider.textColor)
delete.setImageDrawable(
GoogleMaterial.Icon.gmd_delete.keywordDrawable(
itemView.context,
- prefs
+ themeProvider
)
)
}