mirror of
https://github.com/AllanWang/Frost-for-Facebook.git
synced 2024-09-18 21:12:24 +02:00
Delete dependencies
This commit is contained in:
parent
e7b55dd677
commit
20910278ad
@ -175,53 +175,14 @@ dependencies {
|
||||
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1"
|
||||
|
||||
// https://maven.mozilla.org/?prefix=maven2/org/mozilla/geckoview/geckoview-beta/
|
||||
def geckoviewChannel = "beta"
|
||||
def geckoviewVersion = "105.0.20220908185813"
|
||||
// implementation "org.mozilla.geckoview:geckoview-${geckoviewChannel}:${geckoviewVersion}"
|
||||
|
||||
// https://maven.mozilla.org/maven2/org/mozilla/components/browser-engine-gecko/maven-metadata.xml
|
||||
// https://github.com/mozilla-mobile/reference-browser/blob/master/buildSrc/src/main/java/AndroidComponents.kt
|
||||
// https://nightly.maven.mozilla.org/maven2/org/mozilla/components/browser-engine-gecko/maven-metadata.xml
|
||||
def mozillaAndroidComponents = "116.0.20230617040331"
|
||||
|
||||
implementation "org.mozilla.components:browser-engine-gecko:${mozillaAndroidComponents}"
|
||||
implementation "org.mozilla.components:browser-domains:${mozillaAndroidComponents}"
|
||||
implementation "org.mozilla.components:browser-icons:${mozillaAndroidComponents}"
|
||||
implementation "org.mozilla.components:browser-menu:${mozillaAndroidComponents}"
|
||||
implementation "org.mozilla.components:browser-session-storage:${mozillaAndroidComponents}"
|
||||
implementation "org.mozilla.components:browser-state:${mozillaAndroidComponents}"
|
||||
implementation "org.mozilla.components:browser-toolbar:${mozillaAndroidComponents}"
|
||||
|
||||
implementation "org.mozilla.components:concept-engine:${mozillaAndroidComponents}"
|
||||
implementation "org.mozilla.components:concept-menu:${mozillaAndroidComponents}"
|
||||
implementation "org.mozilla.components:concept-storage:${mozillaAndroidComponents}"
|
||||
implementation "org.mozilla.components:concept-toolbar:${mozillaAndroidComponents}"
|
||||
|
||||
implementation "org.mozilla.components:feature-app-links:${mozillaAndroidComponents}"
|
||||
implementation "org.mozilla.components:feature-addons:${mozillaAndroidComponents}"
|
||||
implementation "org.mozilla.components:feature-autofill:${mozillaAndroidComponents}"
|
||||
implementation "org.mozilla.components:feature-awesomebar:${mozillaAndroidComponents}"
|
||||
implementation "org.mozilla.components:feature-contextmenu:${mozillaAndroidComponents}"
|
||||
implementation "org.mozilla.components:feature-downloads:${mozillaAndroidComponents}"
|
||||
implementation "org.mozilla.components:feature-findinpage:${mozillaAndroidComponents}"
|
||||
implementation "org.mozilla.components:feature-logins:${mozillaAndroidComponents}"
|
||||
implementation "org.mozilla.components:feature-media:${mozillaAndroidComponents}"
|
||||
implementation "org.mozilla.components:feature-prompts:${mozillaAndroidComponents}"
|
||||
implementation "org.mozilla.components:feature-push:${mozillaAndroidComponents}"
|
||||
implementation "org.mozilla.components:feature-session:${mozillaAndroidComponents}"
|
||||
implementation "org.mozilla.components:feature-sitepermissions:${mozillaAndroidComponents}"
|
||||
implementation "org.mozilla.components:feature-tabs:${mozillaAndroidComponents}"
|
||||
implementation "org.mozilla.components:feature-toolbar:${mozillaAndroidComponents}"
|
||||
implementation "org.mozilla.components:feature-webnotifications:${mozillaAndroidComponents}"
|
||||
|
||||
implementation "org.mozilla.components:support-ktx:${mozillaAndroidComponents}"
|
||||
implementation "org.mozilla.components:support-webextensions:${mozillaAndroidComponents}"
|
||||
|
||||
implementation "org.mozilla.components:ui-autocomplete:${mozillaAndroidComponents}"
|
||||
|
||||
implementation "org.mozilla.components:compose-engine:${mozillaAndroidComponents}"
|
||||
implementation "org.mozilla.components:lib-state:${mozillaAndroidComponents}"
|
||||
// Kept for reference; not needed
|
||||
implementation "org.mozilla.components:browser-state:${mozillaAndroidComponents}"
|
||||
|
||||
// Compose
|
||||
def composeVersion = "1.4.3"
|
||||
|
@ -1,134 +0,0 @@
|
||||
/*
|
||||
* Copyright 2023 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.compose
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.material.LinearProgressIndicator
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.viewinterop.AndroidView
|
||||
import androidx.compose.ui.zIndex
|
||||
import mozilla.components.browser.state.action.EngineAction
|
||||
import mozilla.components.browser.state.helper.Target
|
||||
import mozilla.components.browser.state.state.SessionState
|
||||
import mozilla.components.browser.state.store.BrowserStore
|
||||
import mozilla.components.concept.engine.Engine
|
||||
import mozilla.components.concept.engine.EngineSession
|
||||
import mozilla.components.concept.engine.EngineView
|
||||
|
||||
/**
|
||||
* Simple Frost web view, with progress bar.
|
||||
*
|
||||
* TODO add swipe?
|
||||
*/
|
||||
@Composable
|
||||
fun FrostWeb(engine: Engine, store: BrowserStore, target: Target, modifier: Modifier = Modifier) {
|
||||
val selectedTab by
|
||||
target.observeAsComposableStateFrom(
|
||||
store = store,
|
||||
observe = { tab ->
|
||||
// Render if the tab itself changed or when the state of the linked engine session changes
|
||||
arrayOf(
|
||||
tab?.id,
|
||||
tab?.engineState?.engineSession,
|
||||
tab?.engineState?.crashed,
|
||||
tab?.content?.firstContentfulPaint,
|
||||
// Added on top of Mozilla's WebContent observe values
|
||||
tab?.content?.progress,
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
Box(modifier = modifier) {
|
||||
ProgressBar(progress = selectedTab?.content?.progress, modifier = Modifier.zIndex(1f))
|
||||
WebContent(engine = engine, store = store, state = WebContentState(selectedTab))
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ProgressBar(progress: Int?, modifier: Modifier = Modifier) {
|
||||
val shouldDisplay = progress != null && progress in 0 until 100
|
||||
LinearProgressIndicator(
|
||||
modifier = modifier.alpha(if (shouldDisplay) 1f else 0f).height(2.dp),
|
||||
progress = if (progress == null) 0f else progress.toFloat() * 0.01f,
|
||||
)
|
||||
}
|
||||
|
||||
/** Minimum amount of [SessionState] needed to update [WebContent] */
|
||||
private data class WebContentState(
|
||||
val id: String,
|
||||
val engineSession: EngineSession?,
|
||||
val canGoBack: Boolean,
|
||||
) {
|
||||
companion object {
|
||||
operator fun invoke(tab: SessionState?): WebContentState? {
|
||||
tab ?: return null
|
||||
return WebContentState(
|
||||
id = tab.id,
|
||||
engineSession = tab.engineState.engineSession,
|
||||
canGoBack = tab.content.canGoBack,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Based on Mozilla WebContent:
|
||||
* https://github.com/mozilla-mobile/android-components/blob/main/components/compose/engine/src/main/java/mozilla/components/compose/engine/WebContent.kt
|
||||
*
|
||||
* WebView from Accompanist:
|
||||
* https://github.com/google/accompanist/blob/main/web/src/main/java/com/google/accompanist/web/WebView.kt
|
||||
*
|
||||
* Blinking Bug: Switching tabs causes an empty state where nothing is rendered. Not as noticeable
|
||||
* on light themes, but it's a full black screen on dark mode. May be related to
|
||||
* https://github.com/mozilla-mobile/fenix/issues/1901
|
||||
*/
|
||||
@Composable
|
||||
private fun WebContent(engine: Engine, store: BrowserStore, state: WebContentState?) {
|
||||
|
||||
BackHandler(state?.canGoBack == true) {
|
||||
val id = state?.id ?: return@BackHandler
|
||||
store.dispatch(EngineAction.GoBackAction(id, userInteraction = true))
|
||||
}
|
||||
|
||||
AndroidView(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
factory = { context -> engine.createView(context).asView() },
|
||||
update = { view ->
|
||||
val engineView = view as EngineView
|
||||
if (state == null) {
|
||||
engineView.release()
|
||||
} else {
|
||||
val session = state.engineSession
|
||||
if (session == null) {
|
||||
// This tab does not have an EngineSession that we can render yet. Let's dispatch an
|
||||
// action to request creating one. Once one was created and linked to this session, this
|
||||
// method will get invoked again.
|
||||
store.dispatch(EngineAction.CreateEngineSessionAction(state.id))
|
||||
} else {
|
||||
engineView.render(session)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
Loading…
Reference in New Issue
Block a user