aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2020-02-23 16:06:45 -0800
committerAllan Wang <me@allanwang.ca>2020-02-23 16:06:45 -0800
commitc8b54fd10a08ed53eb7d21578a4fe990fe14e3bc (patch)
tree0841d112c8c00504ce10ca72ef39e403b69c595c /app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt
parent4d5aaf541dbfa7d521ebbc5f011a642c83c4b9c5 (diff)
downloadfrost-c8b54fd10a08ed53eb7d21578a4fe990fe14e3bc.tar.gz
frost-c8b54fd10a08ed53eb7d21578a4fe990fe14e3bc.tar.bz2
frost-c8b54fd10a08ed53eb7d21578a4fe990fe14e3bc.zip
Move prefs to service locator
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt27
1 files changed, 15 insertions, 12 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt
index 64051929..df51e30f 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt
@@ -78,6 +78,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.launch
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
+import org.koin.android.ext.android.inject
/**
* Created by Allan Wang on 2017-06-01.
@@ -170,6 +171,8 @@ abstract class WebOverlayActivityBase(private val userAgent: String = USER_AGENT
get() = content.coreView
private val coordinator: CoordinatorLayout by bindView(R.id.overlay_main_content)
+ private val showcasePrefs: Showcase by inject()
+
private inline val urlTest: String?
get() = intent.getStringExtra(ARG_URL) ?: intent.dataString
@@ -184,7 +187,7 @@ abstract class WebOverlayActivityBase(private val userAgent: String = USER_AGENT
override val baseEnum: FbItem? = null
private inline val userId: Long
- get() = intent.getLongExtra(ARG_USER_ID, Prefs.userId)
+ get() = intent.getLongExtra(ARG_USER_ID, prefs.userId)
private val overlayContext: OverlayContext?
get() = OverlayContext[intent.extras]
@@ -205,14 +208,14 @@ abstract class WebOverlayActivityBase(private val userAgent: String = USER_AGENT
setSupportActionBar(toolbar)
supportActionBar?.setDisplayShowHomeEnabled(true)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
- toolbar.navigationIcon = GoogleMaterial.Icon.gmd_close.toDrawable(this, 16, Prefs.iconColor)
+ toolbar.navigationIcon = GoogleMaterial.Icon.gmd_close.toDrawable(this, 16, prefs.iconColor)
toolbar.setNavigationOnClickListener { finishSlideOut() }
setFrostColors {
toolbar(toolbar)
themeWindow = false
}
- coordinator.setBackgroundColor(Prefs.bgColor.withAlpha(255))
+ coordinator.setBackgroundColor(prefs.bgColor.withAlpha(255))
content.bind(this)
@@ -222,15 +225,15 @@ abstract class WebOverlayActivityBase(private val userAgent: String = USER_AGENT
with(web) {
userAgentString = userAgent
- Prefs.prevId = Prefs.userId
+ prefs.prevId = prefs.userId
launch {
val authDefer = BiometricUtils.authenticate(this@WebOverlayActivityBase)
- if (userId != Prefs.userId) {
+ if (userId != prefs.userId) {
FbCookie.switchUser(userId)
}
authDefer.await()
reloadBase(true)
- if (Showcase.firstWebOverlay) {
+ if (showcasePrefs.firstWebOverlay) {
coordinator.frostSnackbar(R.string.web_overlay_swipe_hint) {
duration = BaseTransientBottomBar.LENGTH_INDEFINITE
setAction(R.string.kau_got_it) { dismiss() }
@@ -240,7 +243,7 @@ abstract class WebOverlayActivityBase(private val userAgent: String = USER_AGENT
}
swipeBack = kauSwipeOnCreate {
- if (!Prefs.overlayFullScreenSwipe) edgeSize = 20.dpToPx
+ if (!prefs.overlayFullScreenSwipe) edgeSize = 20.dpToPx
transitionSystemBars = false
}
}
@@ -271,13 +274,13 @@ abstract class WebOverlayActivityBase(private val userAgent: String = USER_AGENT
* Our theme for the overlay should be fully opaque
*/
fun theme() {
- val opaqueAccent = Prefs.headerColor.withAlpha(255)
+ val opaqueAccent = prefs.headerColor.withAlpha(255)
statusBarColor = opaqueAccent.darken()
navigationBarColor = opaqueAccent
toolbar.setBackgroundColor(opaqueAccent)
- toolbar.setTitleTextColor(Prefs.iconColor)
- coordinator.setBackgroundColor(Prefs.bgColor.withAlpha(255))
- toolbar.overflowIcon?.setTint(Prefs.iconColor)
+ toolbar.setTitleTextColor(prefs.iconColor)
+ coordinator.setBackgroundColor(prefs.bgColor.withAlpha(255))
+ toolbar.overflowIcon?.setTint(prefs.iconColor)
}
override fun onResume() {
@@ -312,7 +315,7 @@ abstract class WebOverlayActivityBase(private val userAgent: String = USER_AGENT
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_web, menu)
overlayContext?.onMenuCreate(this, menu)
- toolbar.tint(Prefs.iconColor)
+ toolbar.tint(prefs.iconColor)
return true
}