aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2021-04-17 20:06:36 -0700
committerAllan Wang <me@allanwang.ca>2021-04-17 20:06:36 -0700
commit6abaf596e4db5a36057f6a8acf31b72f57a12e18 (patch)
tree1b2d52fe2f6a4d1d73fe23c0061a697c9d664eab /app/src/main/kotlin
parent795182bab71e70c28e7d07550bca0d2e35b70c60 (diff)
downloadfrost-6abaf596e4db5a36057f6a8acf31b72f57a12e18.tar.gz
frost-6abaf596e4db5a36057f6a8acf31b72f57a12e18.tar.bz2
frost-6abaf596e4db5a36057f6a8acf31b72f57a12e18.zip
Remove koin dependency in production
Diffstat (limited to 'app/src/main/kotlin')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt38
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt9
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt5
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/glide/GlideUtils.kt3
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt10
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/prefs/Prefs.kt29
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/UpdateReceiver.kt3
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt14
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt42
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt14
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt3
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/FrostViewPager.kt7
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt3
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt8
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt3
20 files changed, 65 insertions, 136 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
index 35d3313b..1e2b438e 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
@@ -20,14 +20,10 @@ import android.app.Activity
import android.app.Application
import android.os.Bundle
import android.util.Log
-import ca.allanwang.kau.kpref.KPrefFactory
-import ca.allanwang.kau.kpref.KPrefFactoryAndroid
import ca.allanwang.kau.logging.KL
import ca.allanwang.kau.utils.buildIsLollipopAndUp
import com.pitchedapps.frost.db.CookieDao
-import com.pitchedapps.frost.db.FrostDatabase
import com.pitchedapps.frost.db.NotificationDao
-import com.pitchedapps.frost.facebook.FbCookie
import com.pitchedapps.frost.injectors.ThemeProvider
import com.pitchedapps.frost.prefs.Prefs
import com.pitchedapps.frost.services.scheduleNotificationsFromPrefs
@@ -35,12 +31,6 @@ import com.pitchedapps.frost.services.setupNotificationChannels
import com.pitchedapps.frost.utils.FrostPglAdBlock
import com.pitchedapps.frost.utils.L
import dagger.hilt.android.HiltAndroidApp
-import org.koin.android.ext.koin.androidContext
-import org.koin.android.ext.koin.androidLogger
-import org.koin.core.component.KoinComponent
-import org.koin.core.context.startKoin
-import org.koin.core.module.Module
-import org.koin.dsl.module
import java.util.Random
import javax.inject.Inject
@@ -48,7 +38,7 @@ import javax.inject.Inject
* Created by Allan Wang on 2017-05-28.
*/
@HiltAndroidApp
-class FrostApp : Application(), KoinComponent {
+class FrostApp : Application() {
@Inject
lateinit var prefs: Prefs
@@ -63,28 +53,10 @@ class FrostApp : Application(), KoinComponent {
lateinit var notifDao: NotificationDao
override fun onCreate() {
- startKoin {
- if (BuildConfig.DEBUG) {
- androidLogger()
- }
- androidContext(this@FrostApp)
- modules(
- listOf(
- FrostDatabase.module(),
- prefFactoryModule(),
- Prefs.module(),
- FbCookie.module(),
- ThemeProvider.module()
- )
- )
- }
-
super.onCreate()
if (!buildIsLollipopAndUp) return // not supported
-// prefs = get()
-// themeProvider = get()
initPrefs()
L.i { "Begin Frost for Facebook" }
@@ -134,12 +106,4 @@ class FrostApp : Application(), KoinComponent {
}
prefs.lastLaunch = System.currentTimeMillis()
}
-
- companion object {
- fun prefFactoryModule(): Module = module {
- single<KPrefFactory> {
- KPrefFactoryAndroid(get())
- }
- }
- }
}
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 5d41be29..c5b8bdaa 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt
@@ -401,7 +401,7 @@ internal enum class FabStates(
} catch (e: Exception) {
activity.errorRef = e
e.logFrostEvent("Image share failed")
- activity.frostSnackbar(R.string.image_share_failed)
+ activity.frostSnackbar(R.string.image_share_failed, activity.themeProvider)
}
}
};
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 3ae3aef0..689d9a65 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt
@@ -231,7 +231,7 @@ abstract class WebOverlayActivityBase(private val userAgent: String = USER_AGENT
authDefer.await()
reloadBase(true)
if (prefs.firstWebOverlay) {
- coordinator.frostSnackbar(R.string.web_overlay_swipe_hint) {
+ coordinator.frostSnackbar(R.string.web_overlay_swipe_hint, themeProvider) {
duration = BaseTransientBottomBar.LENGTH_INDEFINITE
setAction(R.string.kau_got_it) { dismiss() }
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt b/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt
index 5972b972..ef763617 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt
@@ -26,7 +26,6 @@ import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
-import org.koin.dsl.module
import javax.inject.Singleton
interface FrostPrivateDao {
@@ -97,14 +96,6 @@ class FrostDatabase(
).frostBuild()
return FrostDatabase(privateDb, publicDb)
}
-
- fun module() = module {
- single { create(get()) }
- single { get<FrostDatabase>().cookieDao() }
- single { get<FrostDatabase>().cacheDao() }
- single { get<FrostDatabase>().notifDao() }
- single { get<FrostDatabase>().genericDao() }
- }
}
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt
index 7cec041e..ea1b0946 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt
@@ -33,7 +33,6 @@ import kotlinx.coroutines.NonCancellable
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.withContext
-import org.koin.dsl.module
import javax.inject.Inject
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine
@@ -51,10 +50,6 @@ class FbCookie @Inject internal constructor(
companion object {
private const val FB_COOKIE_DOMAIN = HTTPS_FACEBOOK_COM
private const val MESSENGER_COOKIE_DOMAIN = HTTPS_MESSENGER_COM
-
- fun module() = module {
- single { FbCookie(get(), get()) }
- }
}
/**
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/glide/GlideUtils.kt b/app/src/main/kotlin/com/pitchedapps/frost/glide/GlideUtils.kt
index 6962cf52..5600d49d 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/glide/GlideUtils.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/glide/GlideUtils.kt
@@ -29,7 +29,6 @@ import com.bumptech.glide.request.RequestOptions
import com.pitchedapps.frost.facebook.FbCookie
import okhttp3.Interceptor
import okhttp3.Response
-import org.koin.core.component.KoinComponent
import javax.inject.Inject
/**
@@ -66,7 +65,7 @@ class FrostGlideModule : AppGlideModule() {
class FrostCookieInterceptor @Inject internal constructor(
private val fbCookie: FbCookie
-) : Interceptor, KoinComponent {
+) : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
val origRequest = chain.request()
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt
index 5c721389..069c5d90 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt
@@ -37,7 +37,6 @@ import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
-import org.koin.core.context.GlobalContext
import java.io.BufferedReader
import java.io.FileNotFoundException
import javax.inject.Inject
@@ -72,15 +71,6 @@ interface ThemeProvider {
fun reset()
suspend fun preload()
-
- companion object {
-
- fun get(): ThemeProvider = GlobalContext.get().get()
-
- fun module() = org.koin.dsl.module {
- single<ThemeProvider> { ThemeProviderImpl(get(), get()) }
- }
- }
}
/**
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/prefs/Prefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/prefs/Prefs.kt
index b76b8ead..0cf97c56 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/prefs/Prefs.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/prefs/Prefs.kt
@@ -37,8 +37,6 @@ import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
-import org.koin.core.context.GlobalContext
-import org.koin.dsl.module
import javax.inject.Inject
import javax.inject.Singleton
@@ -57,32 +55,7 @@ interface Prefs :
NotifPrefs,
ThemePrefs,
ShowcasePrefs,
- PrefsBase {
- companion object {
- fun get(): Prefs = GlobalContext.get().get()
-
- fun module() = module {
- single<BehaviourPrefs> { BehaviourPrefsImpl(get(), get()) }
- single<CorePrefs> { CorePrefsImpl(get(), get()) }
- single<FeedPrefs> { FeedPrefsImpl(get(), get()) }
- single<NotifPrefs> { NotifPrefsImpl(get(), get()) }
- single<ThemePrefs> { ThemePrefsImpl(get(), get()) }
- single<ShowcasePrefs> { ShowcasePrefsImpl(get()) }
- single<Prefs> {
- PrefsImpl(
- behaviourPrefs = get(),
- corePrefs = get(),
- feedPrefs = get(),
- notifPrefs = get(),
- themePrefs = get(),
- showcasePrefs = get()
- )
- }
- // Needed for migration
- single<OldPrefs> { OldPrefs(factory = get()) }
- }
- }
-}
+ PrefsBase
class PrefsImpl @Inject internal constructor(
private val behaviourPrefs: BehaviourPrefs,
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/UpdateReceiver.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/UpdateReceiver.kt
index 81e08e71..91a60d90 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/UpdateReceiver.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/UpdateReceiver.kt
@@ -22,7 +22,6 @@ import android.content.Intent
import com.pitchedapps.frost.prefs.Prefs
import com.pitchedapps.frost.utils.L
import dagger.hilt.android.AndroidEntryPoint
-import org.koin.core.component.KoinComponent
import javax.inject.Inject
/**
@@ -31,7 +30,7 @@ import javax.inject.Inject
* Receiver that is triggered whenever the app updates so it can bind the notifications again
*/
@AndroidEntryPoint
-class UpdateReceiver : BroadcastReceiver(), KoinComponent {
+class UpdateReceiver : BroadcastReceiver() {
@Inject
lateinit var prefs: Prefs
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt
index e99d7a2c..34f1ba1c 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt
@@ -69,7 +69,7 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = {
fun KPrefColorPicker.KPrefColorContract.dependsOnCustom() {
enabler = themeProvider::isCustomTheme
- onDisabledClick = { frostSnackbar(R.string.requires_custom_theme) }
+ onDisabledClick = { frostSnackbar(R.string.requires_custom_theme, themeProvider) }
allowCustom = true
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt
index 65348e71..b2bb1d11 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt
@@ -36,6 +36,7 @@ import com.pitchedapps.frost.facebook.parsers.FrostParser
import com.pitchedapps.frost.facebook.parsers.MessageParser
import com.pitchedapps.frost.facebook.parsers.NotifParser
import com.pitchedapps.frost.facebook.parsers.SearchParser
+import com.pitchedapps.frost.prefs.Prefs
import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.frostUriFromFile
import com.pitchedapps.frost.utils.sendFrostEmail
@@ -89,10 +90,10 @@ fun SettingsActivity.getDebugPrefs(): KPrefAdapterBuilder.() -> Unit = {
val data = parser.parse(fbCookie.webCookie)
withMainContext {
loading.dismiss()
- createEmail(parser, data?.data)
+ createEmail(parser, data?.data, prefs)
}
} catch (e: Exception) {
- createEmail(parser, "Error: ${e.message}")
+ createEmail(parser, "Error: ${e.message}", prefs)
}
}
}
@@ -101,8 +102,11 @@ fun SettingsActivity.getDebugPrefs(): KPrefAdapterBuilder.() -> Unit = {
}
}
-private fun Context.createEmail(parser: FrostParser<*>, content: Any?) =
- sendFrostEmail("${string(R.string.debug_report)}: ${parser::class.java.simpleName}") {
+private fun Context.createEmail(parser: FrostParser<*>, content: Any?, prefs: Prefs) =
+ sendFrostEmail(
+ "${string(R.string.debug_report)}: ${parser::class.java.simpleName}",
+ prefs = prefs
+ ) {
addItem("Url", parser.url)
addItem("Contents", "$content")
}
@@ -148,7 +152,7 @@ fun SettingsActivity.sendDebug(url: String, html: String?) {
File(downloader.baseDir, "$ZIP_NAME.zip")
)
L.i { "Sending debug zip with uri $zipUri" }
- sendFrostEmail(R.string.debug_report_email_title) {
+ sendFrostEmail(R.string.debug_report_email_title, prefs = prefs) {
addItem("Url", url)
addAttachment(zipUri)
extras = {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt
index 96429f1c..a0fd2e3d 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt
@@ -215,7 +215,7 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = {
val text =
if (fetchNotifications()) R.string.notification_fetch_success
else R.string.notification_fetch_fail
- frostSnackbar(text)
+ frostSnackbar(text, themeProvider)
}
}
}
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 73572a44..ec8aec6c 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
@@ -266,15 +266,23 @@ fun Throwable?.logFrostEvent(text: String) {
frostEvent("Errors", "text" to text, "message" to (this?.message ?: "NA"))
}
-fun Activity.frostSnackbar(@StringRes text: Int, builder: Snackbar.() -> Unit = {}) =
- snackbar(text, Snackbar.LENGTH_LONG, frostSnackbar(builder))
-
-fun View.frostSnackbar(@StringRes text: Int, builder: Snackbar.() -> Unit = {}) =
- snackbar(text, Snackbar.LENGTH_LONG, frostSnackbar(builder))
+fun Activity.frostSnackbar(
+ @StringRes text: Int,
+ themeProvider: ThemeProvider,
+ builder: Snackbar.() -> Unit = {}
+) = snackbar(text, Snackbar.LENGTH_LONG, frostSnackbar(themeProvider, builder))
+
+fun View.frostSnackbar(
+ @StringRes text: Int,
+ themeProvider: ThemeProvider,
+ builder: Snackbar.() -> Unit = {}
+) = snackbar(text, Snackbar.LENGTH_LONG, frostSnackbar(themeProvider, builder))
@SuppressLint("RestrictedApi")
-private inline fun frostSnackbar(crossinline builder: Snackbar.() -> Unit): Snackbar.() -> Unit = {
- val themeProvider = ThemeProvider.get()
+private inline fun frostSnackbar(
+ themeProvider: ThemeProvider,
+ crossinline builder: Snackbar.() -> Unit
+): Snackbar.() -> Unit = {
builder()
// hacky workaround, but it has proper checks and shouldn't crash
((view as? FrameLayout)?.getChildAt(0) as? SnackbarContentLayout)?.apply {
@@ -421,18 +429,20 @@ fun Context.frostUri(entry: String): Uri {
inline fun Context.sendFrostEmail(
@StringRes subjectId: Int,
+ prefs: Prefs,
crossinline builder: EmailBuilder.() -> Unit
-) =
- sendFrostEmail(string(subjectId), builder)
+) = sendFrostEmail(string(subjectId), prefs, builder)
-inline fun Context.sendFrostEmail(subjectId: String, crossinline builder: EmailBuilder.() -> Unit) =
- sendEmail("", subjectId) {
- builder()
- addFrostDetails()
- }
+inline fun Context.sendFrostEmail(
+ subjectId: String,
+ prefs: Prefs,
+ crossinline builder: EmailBuilder.() -> Unit
+) = sendEmail("", subjectId) {
+ builder()
+ addFrostDetails(prefs)
+}
-fun EmailBuilder.addFrostDetails() {
- val prefs = Prefs.get()
+fun EmailBuilder.addFrostDetails(prefs: Prefs) {
addItem("Prev version", prefs.prevVersionCode.toString())
val proTag = "FO"
addItem("Random Frost ID", "${prefs.frostId}-$proTag")
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt
index 2e88141d..f3c81578 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt
@@ -32,7 +32,7 @@ import com.pitchedapps.frost.prefs.Prefs
/**
* Created by Allan Wang on 2017-07-07.
*/
-fun Context.showWebContextMenu(wc: WebContext, fbCookie: FbCookie) {
+fun Context.showWebContextMenu(wc: WebContext, fbCookie: FbCookie, prefs: Prefs) {
if (wc.isEmpty) return
var title = wc.url ?: string(R.string.menu)
title =
@@ -45,7 +45,7 @@ fun Context.showWebContextMenu(wc: WebContext, fbCookie: FbCookie) {
materialDialog {
title(text = title)
listItems(items = menuItems.map { string(it.textId) }) { _, position, _ ->
- menuItems[position].onClick(this@showWebContextMenu, wc, fbCookie)
+ menuItems[position].onClick(this@showWebContextMenu, wc, fbCookie, prefs)
}
onDismiss {
// showing the dialog interrupts the touch down event, so we must ensure that the viewpager's swipe is enabled
@@ -67,16 +67,16 @@ class WebContext(val unformattedUrl: String?, val text: String?) {
enum class WebContextType(
val textId: Int,
val constraint: (wc: WebContext) -> Boolean,
- val onClick: (c: Context, wc: WebContext, fc: FbCookie) -> Unit
+ val onClick: (c: Context, wc: WebContext, fc: FbCookie, prefs: Prefs) -> Unit
) {
OPEN_LINK(
R.string.open_link,
{ it.hasUrl },
- { c, wc, fc -> c.launchWebOverlay(wc.url!!, fc, Prefs.get()) }
+ { c, wc, fc, prefs -> c.launchWebOverlay(wc.url!!, fc, prefs) }
),
- COPY_LINK(R.string.copy_link, { it.hasUrl }, { c, wc, _ -> c.copyToClipboard(wc.url) }),
- COPY_TEXT(R.string.copy_text, { it.hasText }, { c, wc, _ -> c.copyToClipboard(wc.text) }),
- SHARE_LINK(R.string.share_link, { it.hasUrl }, { c, wc, _ -> c.shareText(wc.url) })
+ COPY_LINK(R.string.copy_link, { it.hasUrl }, { c, wc, _, _ -> c.copyToClipboard(wc.url) }),
+ COPY_TEXT(R.string.copy_text, { it.hasText }, { c, wc, _, _ -> c.copyToClipboard(wc.text) }),
+ SHARE_LINK(R.string.share_link, { it.hasUrl }, { c, wc, _, _ -> c.shareText(wc.url) })
;
companion object {
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 85b58698..836d8666 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt
@@ -49,7 +49,6 @@ import com.pitchedapps.frost.prefs.Prefs
import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.frostDownload
import dagger.hilt.android.AndroidEntryPoint
-import org.koin.core.component.KoinComponent
import javax.inject.Inject
/**
@@ -60,7 +59,7 @@ class FrostVideoViewer @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
-) : FrameLayout(context, attrs, defStyleAttr), FrostVideoViewerContract, KoinComponent {
+) : FrameLayout(context, attrs, defStyleAttr), FrostVideoViewerContract {
companion object {
/**
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostViewPager.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostViewPager.kt
index 0ef3223d..f04a2f57 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostViewPager.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostViewPager.kt
@@ -23,7 +23,6 @@ import android.view.MotionEvent
import androidx.viewpager.widget.ViewPager
import com.pitchedapps.frost.prefs.Prefs
import dagger.hilt.android.AndroidEntryPoint
-import org.koin.core.component.KoinComponent
import javax.inject.Inject
/**
@@ -32,8 +31,10 @@ import javax.inject.Inject
* Basic override to allow us to control swiping
*/
@AndroidEntryPoint
-class FrostViewPager @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
- ViewPager(context, attrs), KoinComponent {
+class FrostViewPager @JvmOverloads constructor(
+ context: Context,
+ attrs: AttributeSet? = null
+) : ViewPager(context, attrs) {
@Inject
lateinit var prefs: Prefs
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt
index 3e3223d6..ec012ed5 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt
@@ -98,7 +98,7 @@ class FrostWebView @JvmOverloads constructor(
// attempt to get custom client; otherwise fallback to original
frostWebClient = (container as? WebFragment)?.client(this) ?: FrostWebViewClient(this)
webViewClient = frostWebClient
- webChromeClient = FrostChromeClient(this)
+ webChromeClient = FrostChromeClient(this, themeProvider)
addJavascriptInterface(FrostJSI(this), "Frost")
setBackgroundColor(Color.TRANSPARENT)
setDownloadListener { url, userAgent, contentDisposition, mimetype, contentLength ->
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt
index dc375a8d..187e7d4e 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt
@@ -37,7 +37,6 @@ import com.pitchedapps.frost.utils.isFacebookUrl
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
-import org.koin.core.component.KoinComponent
import java.io.File
import javax.inject.Inject
@@ -51,7 +50,7 @@ class DebugWebView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
-) : WebView(context, attrs, defStyleAttr), KoinComponent {
+) : WebView(context, attrs, defStyleAttr) {
@Inject
lateinit var prefs: Prefs
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt
index 43b7071e..e687dd2d 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt
@@ -32,6 +32,7 @@ import com.afollestad.materialdialogs.callbacks.onDismiss
import com.afollestad.materialdialogs.input.input
import com.pitchedapps.frost.R
import com.pitchedapps.frost.contracts.ActivityContract
+import com.pitchedapps.frost.injectors.ThemeProvider
import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.frostSnackbar
import com.pitchedapps.frost.views.FrostWebView
@@ -46,7 +47,10 @@ import kotlinx.coroutines.channels.SendChannel
/**
* The default chrome client
*/
-class FrostChromeClient(web: FrostWebView) : WebChromeClient() {
+class FrostChromeClient(
+ web: FrostWebView,
+ private val themeProvider: ThemeProvider
+) : WebChromeClient() {
private val refresh: SendChannel<Boolean> = web.parent.refreshChannel
private val progress: SendChannel<Int> = web.parent.progressChannel
@@ -80,7 +84,7 @@ class FrostChromeClient(web: FrostWebView) : WebChromeClient() {
fileChooserParams: FileChooserParams
): Boolean {
activity?.openFileChooser(filePathCallback, fileChooserParams)
- ?: webView.frostSnackbar(R.string.file_chooser_not_found)
+ ?: webView.frostSnackbar(R.string.file_chooser_not_found, themeProvider)
return activity != null
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt
index 12e10e10..0d7bbb79 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt
@@ -84,7 +84,8 @@ class FrostJSI(val web: FrostWebView) {
web.post {
context.showWebContextMenu(
WebContext(url.takeIf { it.isIndependent }, text),
- fbCookie
+ fbCookie,
+ prefs
)
}
}