aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2020-02-23 17:06:05 -0800
committerAllan Wang <me@allanwang.ca>2020-02-23 17:06:05 -0800
commit04fb50b33c4be7f5b9c70ea209c16e40bac521b9 (patch)
treefbe6c7eae50c36df081d630a6201ab08ee0acac4 /app
parentcb18600f2685dd79e893d69fcb8b9a28d629d3a2 (diff)
downloadfrost-04fb50b33c4be7f5b9c70ea209c16e40bac521b9.tar.gz
frost-04fb50b33c4be7f5b9c70ea209c16e40bac521b9.tar.bz2
frost-04fb50b33c4be7f5b9c70ea209c16e40bac521b9.zip
Remove koincomponent for ActivityThemeUtils
Diffstat (limited to 'app')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/SelectorActivity.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/TabCustomizerActivity.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt20
8 files changed, 18 insertions, 16 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
index 3641c2f3..b22ef999 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
@@ -201,7 +201,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
}
drawerWrapperBinding.mainContainer.addView(contentBinding.root)
with(contentBinding) {
- setFrostColors {
+ setFrostColors(prefs) {
toolbar(toolbar)
themeWindow = false
header(appbar)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt
index 3d9c3d70..51b1134a 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt
@@ -72,7 +72,7 @@ class DebugActivity : KauBaseActivity() {
}
setTitle(R.string.debug_frost)
- setFrostColors {
+ setFrostColors(prefs) {
toolbar(toolbar)
}
debugWebview.loadUrl(FbItem.FEED.url)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt
index 5fd054f6..6ae7622d 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt
@@ -229,7 +229,7 @@ class ImageActivity : KauBaseActivity() {
loadError(e)
}
})
- setFrostColors {
+ setFrostColors(prefs) {
themeWindow = false
}
dragHelper = ViewDragHelper.create(imageDrag, ViewDragCallback()).apply {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt
index ffb1f1ef..25a97ae2 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt
@@ -82,7 +82,7 @@ class LoginActivity : BaseActivity() {
setContentView(R.layout.activity_login)
setSupportActionBar(toolbar)
setTitle(R.string.kau_login)
- setFrostColors {
+ setFrostColors(prefs) {
toolbar(toolbar)
}
profileLoader = GlideApp.with(profile)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/SelectorActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/SelectorActivity.kt
index 33215c7e..a0e3ae42 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/SelectorActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/SelectorActivity.kt
@@ -67,7 +67,7 @@ class SelectorActivity : BaseActivity() {
}
}
})
- setFrostColors {
+ setFrostColors(prefs) {
text(text)
background(container)
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/TabCustomizerActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/TabCustomizerActivity.kt
index 589289ab..11126803 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/TabCustomizerActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/TabCustomizerActivity.kt
@@ -107,7 +107,7 @@ class TabCustomizerActivity : BaseActivity() {
fabCancel.setIcon(GoogleMaterial.Icon.gmd_close, prefs.iconColor)
fabCancel.backgroundTintList = ColorStateList.valueOf(prefs.accentColor)
fabCancel.setOnClickListener { finish() }
- setFrostColors {
+ setFrostColors(prefs) {
themeWindow = true
}
}
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 ac02a052..01fad8fa 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt
@@ -209,7 +209,7 @@ abstract class WebOverlayActivityBase(private val userAgent: String = USER_AGENT
toolbar.navigationIcon = GoogleMaterial.Icon.gmd_close.toDrawable(this, 16, prefs.iconColor)
toolbar.setNavigationOnClickListener { finishSlideOut() }
- setFrostColors {
+ setFrostColors(prefs) {
toolbar(toolbar)
themeWindow = false
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
index 854f315c..1f266eb9 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
@@ -81,8 +81,6 @@ import org.apache.commons.text.StringEscapeUtils
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
-import org.koin.core.KoinComponent
-import org.koin.core.inject
/**
* Created by Allan Wang on 2017-06-03.
@@ -125,7 +123,10 @@ fun Activity.cookies(): ArrayList<CookieEntity> {
* Note that most requests may need to first check if the url can be launched as an overlay
* See [requestWebOverlay] to verify the launch
*/
-private inline fun <reified T : WebOverlayActivityBase> Context.launchWebOverlayImpl(url: String, fbCookie: FbCookie) {
+private inline fun <reified T : WebOverlayActivityBase> Context.launchWebOverlayImpl(
+ url: String,
+ fbCookie: FbCookie
+) {
val prefs = Prefs.get()
val argUrl = url.formattedFbUrl
L.v { "Launch received: $url\nLaunch web overlay: $argUrl" }
@@ -141,10 +142,12 @@ private inline fun <reified T : WebOverlayActivityBase> Context.launchWebOverlay
}
}
-fun Context.launchWebOverlay(url: String, fbCookie: FbCookie) = launchWebOverlayImpl<WebOverlayActivity>(url, fbCookie)
+fun Context.launchWebOverlay(url: String, fbCookie: FbCookie) =
+ launchWebOverlayImpl<WebOverlayActivity>(url, fbCookie)
// TODO Currently, default is overlay. Switch this if default changes
-fun Context.launchWebOverlayDesktop(url: String, fbCookie: FbCookie) = launchWebOverlay(url, fbCookie)
+fun Context.launchWebOverlayDesktop(url: String, fbCookie: FbCookie) =
+ launchWebOverlay(url, fbCookie)
fun Context.launchWebOverlayMobile(url: String, fbCookie: FbCookie) =
launchWebOverlayImpl<WebOverlayMobileActivity>(url, fbCookie)
@@ -186,14 +189,13 @@ fun Activity.setFrostTheme(forceTransparent: Boolean = false) {
}
}
-class ActivityThemeUtils : KoinComponent {
+class ActivityThemeUtils(val prefs: Prefs) {
private var toolbar: Toolbar? = null
var themeWindow = true
private var texts = mutableListOf<TextView>()
private var headers = mutableListOf<View>()
private var backgrounds = mutableListOf<View>()
- private val prefs: Prefs by inject()
fun toolbar(toolbar: Toolbar) {
this.toolbar = toolbar
@@ -226,8 +228,8 @@ class ActivityThemeUtils : KoinComponent {
}
}
-inline fun Activity.setFrostColors(builder: ActivityThemeUtils.() -> Unit) {
- val themer = ActivityThemeUtils()
+inline fun Activity.setFrostColors(prefs: Prefs, builder: ActivityThemeUtils.() -> Unit) {
+ val themer = ActivityThemeUtils(prefs)
themer.builder()
themer.theme(this)
}