1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-11-08 20:12:39 +01:00

Remove desktop overlay activity

This commit is contained in:
Allan Wang 2019-09-07 18:10:38 -07:00
parent 1a0ec6fc02
commit e736b53094
No known key found for this signature in database
GPG Key ID: C93E3F9C679D7A56
4 changed files with 4 additions and 43 deletions

View File

@ -59,13 +59,6 @@
android:label="@string/frost_name"
android:launchMode="singleTop"
android:theme="@style/FrostTheme.Overlay.Slide" />
<activity
android:name=".activities.WebOverlayDesktopActivity"
android:configChanges="orientation|screenSize|locale"
android:hardwareAccelerated="true"
android:label="@string/frost_web"
android:launchMode="singleTop"
android:theme="@style/FrostTheme.Overlay.Slide" />
<activity
android:name=".activities.FrostWebActivity"
android:autoRemoveFromRecents="true"

View File

@ -16,7 +16,6 @@
*/
package com.pitchedapps.frost.activities
import android.annotation.SuppressLint
import android.content.Intent
import android.graphics.PointF
import android.net.Uri
@ -60,7 +59,6 @@ import com.pitchedapps.frost.enums.OverlayContext
import com.pitchedapps.frost.facebook.FB_URL_BASE
import com.pitchedapps.frost.facebook.FbCookie
import com.pitchedapps.frost.facebook.FbItem
import com.pitchedapps.frost.facebook.USER_AGENT_DESKTOP
import com.pitchedapps.frost.facebook.formattedFbUrl
import com.pitchedapps.frost.kotlin.subscribeDuringJob
import com.pitchedapps.frost.services.FrostRunnable
@ -94,7 +92,7 @@ import okhttp3.HttpUrl
* Going back will bring you back to the previous app
*/
@UseExperimental(ExperimentalCoroutinesApi::class)
class FrostWebActivity : WebOverlayActivityBase(false) {
class FrostWebActivity : WebOverlayActivityBase() {
override fun onCreate(savedInstanceState: Bundle?) {
val requiresAction = !parseActionSend()
@ -142,20 +140,13 @@ class FrostWebActivity : WebOverlayActivityBase(false) {
}
}
/**
* Variant that forces a desktop user agent. This is largely internal,
* and is only necessary when we are launching from an existing [WebOverlayActivityBase]
*/
class WebOverlayDesktopActivity : WebOverlayActivityBase(true)
/**
* Internal overlay for the app; this is tied with the main task and is singleTop as opposed to singleInstance
*/
class WebOverlayActivity : WebOverlayActivityBase(false)
class WebOverlayActivity : WebOverlayActivityBase()
@SuppressLint("Registered")
@UseExperimental(ExperimentalCoroutinesApi::class)
open class WebOverlayActivityBase(private val forceDesktopAgent: Boolean) : BaseActivity(),
abstract class WebOverlayActivityBase : BaseActivity(),
ActivityContract, FrostContentContainer,
VideoViewHolder, FileChooserContract by FileChooserDelegate() {
@ -217,8 +208,6 @@ open class WebOverlayActivityBase(private val forceDesktopAgent: Boolean) : Base
}
with(web) {
if (forceDesktopAgent) //todo check; the webview already adds it dynamically
userAgentString = USER_AGENT_DESKTOP
Prefs.prevId = Prefs.userId
launch {
val authDefer = BiometricUtils.authenticate(this@WebOverlayActivityBase)

View File

@ -57,7 +57,6 @@ import com.pitchedapps.frost.activities.SettingsActivity
import com.pitchedapps.frost.activities.TabCustomizerActivity
import com.pitchedapps.frost.activities.WebOverlayActivity
import com.pitchedapps.frost.activities.WebOverlayActivityBase
import com.pitchedapps.frost.activities.WebOverlayDesktopActivity
import com.pitchedapps.frost.db.CookieEntity
import com.pitchedapps.frost.facebook.FACEBOOK_COM
import com.pitchedapps.frost.facebook.FBCDN_NET
@ -138,9 +137,6 @@ private inline fun <reified T : WebOverlayActivityBase> Context.launchWebOverlay
fun Context.launchWebOverlay(url: String) = launchWebOverlayImpl<WebOverlayActivity>(url)
fun Context.launchWebOverlayDesktop(url: String) =
launchWebOverlayImpl<WebOverlayDesktopActivity>(url)
private fun Context.fadeBundle() = ActivityOptions.makeCustomAnimation(
this,
android.R.anim.fade_in, android.R.anim.fade_out

View File

@ -22,7 +22,6 @@ import com.pitchedapps.frost.activities.WebOverlayActivityBase
import com.pitchedapps.frost.contracts.VideoViewHolder
import com.pitchedapps.frost.facebook.FbCookie
import com.pitchedapps.frost.facebook.FbItem
import com.pitchedapps.frost.facebook.USER_AGENT_DESKTOP
import com.pitchedapps.frost.facebook.formattedFbUrl
import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.Prefs
@ -32,7 +31,6 @@ import com.pitchedapps.frost.utils.isIndirectImageUrl
import com.pitchedapps.frost.utils.isVideoUrl
import com.pitchedapps.frost.utils.launchImageActivity
import com.pitchedapps.frost.utils.launchWebOverlay
import com.pitchedapps.frost.utils.launchWebOverlayDesktop
import com.pitchedapps.frost.views.FrostWebView
/**
@ -74,22 +72,7 @@ fun FrostWebView.requestWebOverlay(url: String): Boolean {
return false
}
if (!Prefs.overlayEnabled) return false
if (context is WebOverlayActivityBase) {
val shouldUseDesktop = url.formattedFbUrl.shouldUseDesktopAgent
//already overlay; manage user agent
if (userAgentString != USER_AGENT_DESKTOP && shouldUseDesktop) {
L._i { "Switch to desktop agent overlay" }
context.launchWebOverlayDesktop(url)
return true
}
if (userAgentString == USER_AGENT_DESKTOP && !shouldUseDesktop) {
L._i { "Switch from desktop agent" }
context.launchWebOverlay(url)
return true
}
L._i { "return false switch" }
return false
}
if (context is WebOverlayActivityBase) return false
L.v { "Request web overlay passed" }
context.launchWebOverlay(url)
return true