From 45cbab779564c1038ff0e65b73c5bf03907ca299 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 20 Jun 2023 01:25:17 -0700 Subject: [PATCH] Commit broken entrypoint --- .../compose/webview/FrostChromeClients.kt | 6 +-- .../compose/webview/FrostWebViewClients.kt | 8 +--- .../frost/main/MainScreenViewModel.kt | 1 + .../com/pitchedapps/frost/webview/FrostWeb.kt | 47 +++++++++++++++++-- 4 files changed, 48 insertions(+), 14 deletions(-) diff --git a/app-compose/src/main/kotlin/com/pitchedapps/frost/compose/webview/FrostChromeClients.kt b/app-compose/src/main/kotlin/com/pitchedapps/frost/compose/webview/FrostChromeClients.kt index 518de1a96..4f3832ea8 100644 --- a/app-compose/src/main/kotlin/com/pitchedapps/frost/compose/webview/FrostChromeClients.kt +++ b/app-compose/src/main/kotlin/com/pitchedapps/frost/compose/webview/FrostChromeClients.kt @@ -27,13 +27,9 @@ import com.pitchedapps.frost.web.state.TabAction import com.pitchedapps.frost.web.state.TabAction.ContentAction.UpdateProgressAction import com.pitchedapps.frost.web.state.TabAction.ContentAction.UpdateTitleAction import com.pitchedapps.frost.web.state.get -import com.pitchedapps.frost.webview.FrostWeb -import javax.inject.Inject /** The default chrome client */ -class FrostChromeClient -@Inject -internal constructor(@FrostWeb private val tabId: WebTargetId, private val store: FrostWebStore) : +class FrostChromeClient(private val tabId: WebTargetId, private val store: FrostWebStore) : WebChromeClient() { private fun FrostWebStore.dispatch(action: TabAction.Action) { diff --git a/app-compose/src/main/kotlin/com/pitchedapps/frost/compose/webview/FrostWebViewClients.kt b/app-compose/src/main/kotlin/com/pitchedapps/frost/compose/webview/FrostWebViewClients.kt index 6cf6c79cf..6f3bc7a21 100644 --- a/app-compose/src/main/kotlin/com/pitchedapps/frost/compose/webview/FrostWebViewClients.kt +++ b/app-compose/src/main/kotlin/com/pitchedapps/frost/compose/webview/FrostWebViewClients.kt @@ -32,9 +32,7 @@ import com.pitchedapps.frost.web.state.TabAction import com.pitchedapps.frost.web.state.TabAction.ContentAction.UpdateNavigationAction import com.pitchedapps.frost.web.state.TabAction.ContentAction.UpdateProgressAction import com.pitchedapps.frost.web.state.TabAction.ContentAction.UpdateTitleAction -import com.pitchedapps.frost.webview.FrostWeb import java.io.ByteArrayInputStream -import javax.inject.Inject /** * Created by Allan Wang on 2017-05-31. @@ -62,10 +60,8 @@ abstract class BaseWebViewClient : WebViewClient() { } /** The default webview client */ -class FrostWebViewClient -@Inject -internal constructor( - @FrostWeb private val tabId: WebTargetId, +class FrostWebViewClient( + private val tabId: WebTargetId, private val store: FrostWebStore, override val webHelper: FrostWebHelper ) : BaseWebViewClient() { diff --git a/app-compose/src/main/kotlin/com/pitchedapps/frost/main/MainScreenViewModel.kt b/app-compose/src/main/kotlin/com/pitchedapps/frost/main/MainScreenViewModel.kt index 6c42f8e0a..152e5a3a4 100644 --- a/app-compose/src/main/kotlin/com/pitchedapps/frost/main/MainScreenViewModel.kt +++ b/app-compose/src/main/kotlin/com/pitchedapps/frost/main/MainScreenViewModel.kt @@ -42,6 +42,7 @@ internal constructor( @ApplicationContext context: Context, val components: FrostComponents, val frostCoreExtension: FrostCoreExtension, + // sample: FrostWebEntrySample, frostWebComposer: FrostWebComposer, ) : ViewModel() { diff --git a/app-compose/src/main/kotlin/com/pitchedapps/frost/webview/FrostWeb.kt b/app-compose/src/main/kotlin/com/pitchedapps/frost/webview/FrostWeb.kt index a51a14e8a..06a4c47df 100644 --- a/app-compose/src/main/kotlin/com/pitchedapps/frost/webview/FrostWeb.kt +++ b/app-compose/src/main/kotlin/com/pitchedapps/frost/webview/FrostWeb.kt @@ -16,10 +16,20 @@ */ package com.pitchedapps.frost.webview +import android.webkit.WebViewClient +import com.pitchedapps.frost.compose.webview.FrostWebViewClient import com.pitchedapps.frost.ext.WebTargetId +import com.pitchedapps.frost.web.FrostWebHelper +import com.pitchedapps.frost.web.state.FrostWebStore import dagger.BindsInstance +import dagger.Module +import dagger.Provides import dagger.hilt.DefineComponent -import dagger.hilt.android.components.ViewModelComponent +import dagger.hilt.EntryPoint +import dagger.hilt.EntryPoints +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Inject import javax.inject.Qualifier import javax.inject.Scope @@ -35,9 +45,8 @@ annotation class FrostWebScoped @Qualifier annotation class FrostWeb -@FrostWebScoped @DefineComponent(parent = ViewModelComponent::class) interface FrostWebComponent +@FrostWebScoped @DefineComponent(parent = SingletonComponent::class) interface FrostWebComponent -/** Using this component seems to be buggy, leading to an invalid param tabId error. */ @DefineComponent.Builder interface FrostWebComponentBuilder { @@ -45,3 +54,35 @@ interface FrostWebComponentBuilder { fun build(): FrostWebComponent } + +@Module +@InstallIn(FrostWebComponent::class) +internal object FrostWebModule { + + @Provides + fun client( + @FrostWeb tabId: WebTargetId, + store: FrostWebStore, + webHelper: FrostWebHelper + ): WebViewClient = FrostWebViewClient(tabId, store, webHelper) +} + +/** + * Using this injection seems to be buggy, leading to an invalid param tabId error: + * + * Cause: not a valid name: tabId-4xHwVBUParam + */ +class FrostWebEntrySample +@Inject +internal constructor(private val frostWebComponentBuilder: FrostWebComponentBuilder) { + fun test(tabId: WebTargetId): WebViewClient { + val component = frostWebComponentBuilder.tabId(tabId).build() + return EntryPoints.get(component, FrostWebEntryPoint::class.java).client() + } + + @EntryPoint + @InstallIn(FrostWebComponent::class) + interface FrostWebEntryPoint { + fun client(): WebViewClient + } +}