mirror of
https://github.com/AllanWang/Frost-for-Facebook.git
synced 2024-11-08 12:02:33 +01:00
Remove koin dependency in production
This commit is contained in:
parent
795182bab7
commit
6abaf596e4
@ -26,5 +26,10 @@
|
||||
<option name="name" value="Google" />
|
||||
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="MavenRepo" />
|
||||
<option name="name" value="MavenRepo" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
@ -271,7 +271,6 @@ dependencies {
|
||||
|
||||
implementation "androidx.biometric:biometric:${Versions.andxBiometric}"
|
||||
|
||||
implementation kau.Dependencies.koin
|
||||
testImplementation kau.Dependencies.koinTest
|
||||
androidTestImplementation kau.Dependencies.koinTest
|
||||
|
||||
|
@ -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())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -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() }
|
||||
}
|
||||
|
@ -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() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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()) }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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()
|
||||
|
@ -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()) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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 = {
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 Activity.frostSnackbar(
|
||||
@StringRes text: Int,
|
||||
themeProvider: ThemeProvider,
|
||||
builder: Snackbar.() -> Unit = {}
|
||||
) = snackbar(text, Snackbar.LENGTH_LONG, frostSnackbar(themeProvider, builder))
|
||||
|
||||
fun View.frostSnackbar(@StringRes text: Int, builder: Snackbar.() -> Unit = {}) =
|
||||
snackbar(text, Snackbar.LENGTH_LONG, frostSnackbar(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) {
|
||||
inline fun Context.sendFrostEmail(
|
||||
subjectId: String,
|
||||
prefs: Prefs,
|
||||
crossinline builder: EmailBuilder.() -> Unit
|
||||
) = sendEmail("", subjectId) {
|
||||
builder()
|
||||
addFrostDetails()
|
||||
}
|
||||
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")
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
/**
|
||||
|
@ -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
|
||||
|
@ -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 ->
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,8 @@ class FrostJSI(val web: FrostWebView) {
|
||||
web.post {
|
||||
context.showWebContextMenu(
|
||||
WebContext(url.takeIf { it.isIndependent }, text),
|
||||
fbCookie
|
||||
fbCookie,
|
||||
prefs
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user