aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-01-25 00:23:44 -0500
committerGitHub <noreply@github.com>2018-01-25 00:23:44 -0500
commit8bfbbac2b8f364bb03866712b113cd2f5de8b9d9 (patch)
tree8001dd1e467ddd22e4dcec84a9c9e3aa36d2bbb8 /app/src/main/kotlin/com
parent6fe7bd43581d5dfbb85e4e0deb524e65d07b5ce6 (diff)
downloadfrost-8bfbbac2b8f364bb03866712b113cd2f5de8b9d9.tar.gz
frost-8bfbbac2b8f364bb03866712b113cd2f5de8b9d9.tar.bz2
frost-8bfbbac2b8f364bb03866712b113cd2f5de8b9d9.zip
Enhancement/video (#669)v1.8.0
* Test stricter video extractor * Mess around with mutations * Revert back to strict click listener * Update theme * Update dependencies * Update theme * Create pip toggle * Add pip disabler * Update theme * Update theme
Diffstat (limited to 'app/src/main/kotlin/com')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt6
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt1
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt22
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt20
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt12
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt25
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt5
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/KPrefTextSeekbar.kt11
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt18
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt16
15 files changed, 78 insertions, 74 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
index a2c48bd5..bb9c45c0 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
@@ -30,6 +30,7 @@ import com.raizlabs.android.dbflow.config.FlowManager
import com.raizlabs.android.dbflow.runtime.ContentResolverNotifier
import io.fabric.sdk.android.Fabric
import io.reactivex.plugins.RxJavaPlugins
+import java.net.SocketTimeoutException
import java.util.*
import kotlin.reflect.KClass
@@ -114,7 +115,10 @@ class FrostApp : Application() {
})
RxJavaPlugins.setErrorHandler {
- L.e(it) { "RxJava error" }
+ when (it) {
+ is SocketTimeoutException -> Unit
+ else -> L.e(it) { "RxJava error" }
+ }
}
}
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 9fe4ae22..ec8f11ff 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt
@@ -160,7 +160,7 @@ open class WebOverlayActivityBase(private val forceBasicAgent: Boolean) : BaseAc
.subscribe { toolbar.title = it }
with(web) {
- if (forceBasicAgent)
+ if (forceBasicAgent) //todo check; the webview already adds it dynamically
userAgentString = USER_AGENT_BASIC
Prefs.prevId = Prefs.userId
if (userId != Prefs.userId) FbCookie.switchUser(userId) { reloadBase(true) }
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt
index f1bf55b1..6456b0d6 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt
@@ -5,6 +5,7 @@ package com.pitchedapps.frost.facebook
*/
const val FACEBOOK_COM = "facebook.com"
+const val FBCDN_NET = "fbcdn.net"
const val HTTPS_FACEBOOK_COM = "https://$FACEBOOK_COM"
const val FB_URL_BASE = "https://m.$FACEBOOK_COM/"
fun PROFILE_PICTURE_URL(id: Long) = "https://graph.facebook.com/$id/picture?type=large"
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 7305f9ef..07aff0aa 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt
@@ -21,7 +21,7 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = {
header(R.string.theme_customization)
- text(R.string.theme, { Prefs.theme }, { Prefs.theme = it }) {
+ text(R.string.theme, Prefs::theme, { Prefs.theme = it }) {
onClick = {
materialDialogThemed {
title(R.string.theme)
@@ -52,7 +52,7 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = {
}
fun KPrefColorPicker.KPrefColorContract.dependsOnCustom() {
- enabler = { Prefs.isCustomTheme }
+ enabler = Prefs::isCustomTheme
onDisabledClick = { frostSnackbar(R.string.requires_custom_theme) }
allowCustom = true
}
@@ -61,7 +61,7 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = {
CssAssets.CUSTOM.injector.invalidate()
}
- colorPicker(R.string.text_color, { Prefs.customTextColor }, {
+ colorPicker(R.string.text_color, Prefs::customTextColor, {
Prefs.customTextColor = it
reload()
invalidateCustomTheme()
@@ -71,7 +71,7 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = {
allowCustomAlpha = false
}
- colorPicker(R.string.accent_color, { Prefs.customAccentColor }, {
+ colorPicker(R.string.accent_color, Prefs::customAccentColor, {
Prefs.customAccentColor = it
reload()
invalidateCustomTheme()
@@ -82,7 +82,7 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = {
}
- colorPicker(R.string.background_color, { Prefs.customBackgroundColor }, {
+ colorPicker(R.string.background_color, Prefs::customBackgroundColor, {
Prefs.customBackgroundColor = it
bgCanvas.ripple(it, duration = 500L)
invalidateCustomTheme()
@@ -93,7 +93,7 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = {
allowCustomAlpha = true
}
- colorPicker(R.string.header_color, { Prefs.customHeaderColor }, {
+ colorPicker(R.string.header_color, Prefs::customHeaderColor, {
Prefs.customHeaderColor = it
frostNavigationBar()
toolbarCanvas.ripple(it, RippleCanvas.MIDDLE, RippleCanvas.END, duration = 500L)
@@ -104,7 +104,7 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = {
allowCustomAlpha = true
}
- colorPicker(R.string.icon_color, { Prefs.customIconColor }, {
+ colorPicker(R.string.icon_color, Prefs::customIconColor, {
Prefs.customIconColor = it
invalidateOptionsMenu()
shouldRestartMain()
@@ -115,7 +115,7 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = {
header(R.string.global_customization)
- text(R.string.main_activity_layout, { Prefs.mainActivityLayoutType }, { Prefs.mainActivityLayoutType = it }) {
+ text(R.string.main_activity_layout, Prefs::mainActivityLayoutType, { Prefs.mainActivityLayoutType = it }) {
textGetter = { string(Prefs.mainActivityLayout.titleRes) }
onClick = {
materialDialogThemed {
@@ -138,14 +138,14 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = {
onClick = { launchTabCustomizerActivity() }
}
- checkbox(R.string.rounded_icons, { Prefs.showRoundedIcons }, {
+ checkbox(R.string.rounded_icons, Prefs::showRoundedIcons, {
Prefs.showRoundedIcons = it
setFrostResult(REQUEST_REFRESH)
}) {
descRes = R.string.rounded_icons_desc
}
- checkbox(R.string.tint_nav, { Prefs.tintNavBar }, {
+ checkbox(R.string.tint_nav, Prefs::tintNavBar, {
Prefs.tintNavBar = it
frostNavigationBar()
setFrostResult(REQUEST_NAV)
@@ -156,5 +156,5 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = {
list.add(KPrefTextSeekbar(
KPrefSeekbar.KPrefSeekbarBuilder(
globalOptions,
- R.string.web_text_scaling, { Prefs.webTextScaling }, { Prefs.webTextScaling = it; setFrostResult(REQUEST_TEXT_ZOOM) })))
+ R.string.web_text_scaling, Prefs::webTextScaling, { Prefs.webTextScaling = it; setFrostResult(REQUEST_TEXT_ZOOM) })))
} \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt
index 4d0cd9d8..02a86e58 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt
@@ -11,35 +11,39 @@ import com.pitchedapps.frost.utils.REQUEST_REFRESH
*/
fun SettingsActivity.getBehaviourPrefs(): KPrefAdapterBuilder.() -> Unit = {
- checkbox(R.string.fancy_animations, { Prefs.animate }, { Prefs.animate = it; animate = it }) {
+ checkbox(R.string.fancy_animations, Prefs::animate, { Prefs.animate = it; animate = it }) {
descRes = R.string.fancy_animations_desc
}
- checkbox(R.string.overlay_swipe, { Prefs.overlayEnabled }, { Prefs.overlayEnabled = it; setFrostResult(REQUEST_REFRESH) }) {
+ checkbox(R.string.overlay_swipe, Prefs::overlayEnabled, { Prefs.overlayEnabled = it; setFrostResult(REQUEST_REFRESH) }) {
descRes = R.string.overlay_swipe_desc
}
- checkbox(R.string.overlay_full_screen_swipe, { Prefs.overlayFullScreenSwipe }, { Prefs.overlayFullScreenSwipe = it }) {
+ checkbox(R.string.overlay_full_screen_swipe, Prefs::overlayFullScreenSwipe, { Prefs.overlayFullScreenSwipe = it }) {
descRes = R.string.overlay_full_screen_swipe_desc
}
- checkbox(R.string.open_links_in_default, { Prefs.linksInDefaultApp }, { Prefs.linksInDefaultApp = it }) {
+ checkbox(R.string.open_links_in_default, Prefs::linksInDefaultApp, { Prefs.linksInDefaultApp = it }) {
descRes = R.string.open_links_in_default_desc
}
- checkbox(R.string.viewpager_swipe, { Prefs.viewpagerSwipe }, { Prefs.viewpagerSwipe = it }) {
+ checkbox(R.string.viewpager_swipe, Prefs::viewpagerSwipe, { Prefs.viewpagerSwipe = it }) {
descRes = R.string.viewpager_swipe_desc
}
- checkbox(R.string.force_message_bottom, { Prefs.messageScrollToBottom }, { Prefs.messageScrollToBottom = it }) {
+ checkbox(R.string.force_message_bottom, Prefs::messageScrollToBottom, { Prefs.messageScrollToBottom = it }) {
descRes = R.string.force_message_bottom_desc
}
- checkbox(R.string.exit_confirmation, { Prefs.exitConfirmation }, { Prefs.exitConfirmation = it }) {
+ checkbox(R.string.enable_pip, Prefs::enablePip, { Prefs.enablePip = it }) {
+ descRes = R.string.enable_pip_desc
+ }
+
+ checkbox(R.string.exit_confirmation, Prefs::exitConfirmation, { Prefs.exitConfirmation = it }) {
descRes = R.string.exit_confirmation_desc
}
- checkbox(R.string.analytics, { Prefs.analytics }, { Prefs.analytics = it }) {
+ checkbox(R.string.analytics, Prefs::analytics, { Prefs.analytics = it }) {
descRes = R.string.analytics_desc
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt
index d6124140..fe95e7f1 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt
@@ -18,7 +18,7 @@ fun SettingsActivity.getExperimentalPrefs(): KPrefAdapterBuilder.() -> Unit = {
descRes = R.string.experimental_disclaimer_info
}
- checkbox(R.string.experimental_by_default, { Showcase.experimentalDefault }, { Showcase.experimentalDefault = it }) {
+ checkbox(R.string.experimental_by_default, Showcase::experimentalDefault, { Showcase.experimentalDefault = it }) {
descRes = R.string.experimental_by_default_desc
}
@@ -27,7 +27,7 @@ fun SettingsActivity.getExperimentalPrefs(): KPrefAdapterBuilder.() -> Unit = {
// Experimental content ends here --------------------
- checkbox(R.string.verbose_logging, { Prefs.verboseLogging }, {
+ checkbox(R.string.verbose_logging, Prefs::verboseLogging, {
Prefs.verboseLogging = it
KL.shouldLog = { it != Log.VERBOSE }
}) {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt
index 00ce5116..78898eeb 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt
@@ -14,7 +14,7 @@ import com.pitchedapps.frost.utils.materialDialogThemed
*/
fun SettingsActivity.getFeedPrefs(): KPrefAdapterBuilder.() -> Unit = {
- text(R.string.newsfeed_sort, { Prefs.feedSort }, { Prefs.feedSort = it }) {
+ text(R.string.newsfeed_sort, Prefs::feedSort, { Prefs.feedSort = it }) {
descRes = R.string.newsfeed_sort_desc
onClick = {
materialDialogThemed {
@@ -32,14 +32,14 @@ fun SettingsActivity.getFeedPrefs(): KPrefAdapterBuilder.() -> Unit = {
textGetter = { string(FeedSort(it).textRes) }
}
- checkbox(R.string.aggressive_recents, { Prefs.aggressiveRecents }, {
+ checkbox(R.string.aggressive_recents, Prefs::aggressiveRecents, {
Prefs.aggressiveRecents = it
setFrostResult(REQUEST_REFRESH)
}) {
descRes = R.string.aggressive_recents_desc
}
- checkbox(R.string.composer, { Prefs.showComposer }, {
+ checkbox(R.string.composer, Prefs::showComposer, {
Prefs.showComposer = it
setFrostResult(REQUEST_REFRESH)
}) {
@@ -48,7 +48,7 @@ fun SettingsActivity.getFeedPrefs(): KPrefAdapterBuilder.() -> Unit = {
header(R.string.pro_features)
- checkbox(R.string.suggested_friends, { Prefs.showSuggestedFriends }, {
+ checkbox(R.string.suggested_friends, Prefs::showSuggestedFriends, {
Prefs.showSuggestedFriends = it
setFrostResult(REQUEST_REFRESH)
}) {
@@ -56,7 +56,7 @@ fun SettingsActivity.getFeedPrefs(): KPrefAdapterBuilder.() -> Unit = {
dependsOnPro()
}
- checkbox(R.string.suggested_groups, { Prefs.showSuggestedGroups }, {
+ checkbox(R.string.suggested_groups, Prefs::showSuggestedGroups, {
Prefs.showSuggestedGroups = it
setFrostResult(REQUEST_REFRESH)
}) {
@@ -64,7 +64,7 @@ fun SettingsActivity.getFeedPrefs(): KPrefAdapterBuilder.() -> Unit = {
dependsOnPro()
}
- checkbox(R.string.facebook_ads, { Prefs.showFacebookAds }, {
+ checkbox(R.string.facebook_ads, Prefs::showFacebookAds, {
Prefs.showFacebookAds = it
setFrostResult(REQUEST_REFRESH)
}) {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
index 7422fb36..f9f471df 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
@@ -133,6 +133,8 @@ object Prefs : KPref() {
var messageScrollToBottom: Boolean by kpref("message_scroll_to_bottom", false)
+ var enablePip: Boolean by kpref("enable_pip", true)
+
/**
* Cache like value to determine if user has or had pro
* In most cases, [com.pitchedapps.frost.utils.iab.IS_FROST_PRO] should be looked at instead
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 6a3b80ca..144e65ef 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
@@ -199,11 +199,9 @@ fun Throwable?.logFrostAnswers(text: String) {
frostAnswersCustom("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, 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 View.frostSnackbar(@StringRes text: Int, builder: Snackbar.() -> Unit = {}) = snackbar(text, Snackbar.LENGTH_LONG, frostSnackbar(builder))
@SuppressLint("RestrictedApi")
private inline fun frostSnackbar(crossinline builder: Snackbar.() -> Unit): Snackbar.() -> Unit = {
@@ -245,19 +243,20 @@ fun Context.resolveActivityForUri(uri: Uri): Boolean {
* [true] if url contains [FACEBOOK_COM]
*/
inline val String?.isFacebookUrl
- get() = this != null && (contains(FACEBOOK_COM) || contains("fbcdn.net"))
+ get() = this != null && (contains(FACEBOOK_COM) || contains(FBCDN_NET))
/**
* [true] if url is a video and can be accepted by VideoViewer
*/
inline val String.isVideoUrl
- get() = startsWith(VIDEO_REDIRECT) || startsWith("https://video-")
+ get() = startsWith(VIDEO_REDIRECT) ||
+ (startsWith("https://video-") && contains(FBCDN_NET))
/**
* [true] if url is or redirects to an explicit facebook image
*/
inline val String.isImageUrl
- get() = contains("fbcdn.net") && (contains(".png") || contains(".jpg"))
+ get() = contains(FBCDN_NET) && (contains(".png") || contains(".jpg"))
/**
* [true] if url can be displayed in a different webview
@@ -302,11 +301,9 @@ fun Context.frostUriFromFile(file: File): Uri =
BuildConfig.APPLICATION_ID + ".provider",
file)
-inline fun Context.sendFrostEmail(@StringRes subjectId: Int, crossinline builder: EmailBuilder.() -> Unit)
- = sendFrostEmail(string(subjectId), builder)
+inline fun Context.sendFrostEmail(@StringRes subjectId: Int, crossinline builder: EmailBuilder.() -> Unit) = sendFrostEmail(string(subjectId), builder)
-inline fun Context.sendFrostEmail(subjectId: String, crossinline builder: EmailBuilder.() -> Unit)
- = sendEmail(string(R.string.dev_email), subjectId) {
+inline fun Context.sendFrostEmail(subjectId: String, crossinline builder: EmailBuilder.() -> Unit) = sendEmail(string(R.string.dev_email), subjectId) {
builder()
addFrostDetails()
}
@@ -318,11 +315,9 @@ fun EmailBuilder.addFrostDetails() {
addItem("Locale", Locale.getDefault().displayName)
}
-fun frostJsoup(url: String)
- = frostJsoup(FbCookie.webCookie, url)
+fun frostJsoup(url: String) = frostJsoup(FbCookie.webCookie, url)
-fun frostJsoup(cookie: String?, url: String)
- = Jsoup.connect(url).cookie(FACEBOOK_COM, cookie).userAgent(USER_AGENT_BASIC).get()!!
+fun frostJsoup(cookie: String?, url: String) = Jsoup.connect(url).cookie(FACEBOOK_COM, cookie).userAgent(USER_AGENT_BASIC).get()!!
fun Element.first(vararg select: String): Element? {
select.forEach {
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 ce2b8d46..aef9099a 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt
@@ -83,11 +83,10 @@ class FrostVideoViewer @JvmOverloads constructor(
}
fun setVideo(url: String, repeat: Boolean = false) {
- val formattedUrl = url.formattedFbUrl
L.d { "Load video; repeat: $repeat" }
- L._d { "Video Url\t\t\t$url\nformatted\t$formattedUrl" }
+ L._d { "Video Url: $url" }
animate().alpha(1f).setDuration(FrostVideoView.ANIMATION_DURATION).start()
- video.setVideoURI(Uri.parse(formattedUrl))
+ video.setVideoURI(Uri.parse(url))
video.repeat = repeat
}
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 7972e813..14596935 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt
@@ -40,10 +40,10 @@ class FrostWebView @JvmOverloads constructor(
@SuppressLint("SetJavaScriptEnabled")
override fun bind(container: FrostContentContainer): View {
+ if (parent.baseEnum != null || parent.baseUrl.shouldUseBasicAgent)
+ userAgentString = USER_AGENT_BASIC // go through our own agent ref
with(settings) {
javaScriptEnabled = true
- if (parent.baseUrl.shouldUseBasicAgent)
- userAgentString = USER_AGENT_BASIC
allowFileAccess = true
textZoom = Prefs.webTextScaling
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/KPrefTextSeekbar.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/KPrefTextSeekbar.kt
index 4249cd09..14f77e72 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/KPrefTextSeekbar.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/KPrefTextSeekbar.kt
@@ -29,15 +29,14 @@ class KPrefTextSeekbar(builder: KPrefSeekbarContract) : KPrefSeekbar(builder) {
}
@SuppressLint("MissingSuperCall")
- override fun onPostBindView(viewHolder: ViewHolder, textColor: Int?, accentColor: Int?) {
- descOriginalSize = viewHolder.desc?.textSize ?: 1f
- viewHolder.desc?.layoutParams
+ override fun bindView(holder: ViewHolder, payloads: List<Any>) {
+ super.bindView(holder, payloads)
+ descOriginalSize = holder.desc?.textSize ?: 1f
+ holder.desc?.layoutParams
builder.toText = {
- viewHolder.desc?.setTextSize(TypedValue.COMPLEX_UNIT_PX, descOriginalSize * it.toFloat() / 100)
+ holder.desc?.setTextSize(TypedValue.COMPLEX_UNIT_PX, descOriginalSize * it.toFloat() / 100)
"$it%"
}
-
- super.onPostBindView(viewHolder, textColor, accentColor)
}
override fun unbindView(holder: ViewHolder) {
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 d735fd50..4a3fa2a2 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt
@@ -26,17 +26,19 @@ class FrostJSI(val web: FrostWebView) {
* or {@code false} otherwise, meaning the event should be propagated
*/
@JavascriptInterface
- fun loadUrl(url: String?): Boolean
- = if (url == null) false else web.requestWebOverlay(url)
+ fun loadUrl(url: String?): Boolean = if (url == null) false else web.requestWebOverlay(url)
@JavascriptInterface
- fun loadVideo(url: String?, isGif: Boolean) {
- if (url != null)
- web.post {
- (context as? VideoViewHolder)?.showVideo(url, isGif)
- ?: L.d { "Could not load video; contract not implemented" }
+ fun loadVideo(url: String?, isGif: Boolean): Boolean =
+ if (url != null && Prefs.enablePip) {
+ web.post {
+ (context as? VideoViewHolder)?.showVideo(url, isGif)
+ ?: L.e { "Could not load video; contract not implemented" }
+ }
+ true
+ } else {
+ false
}
- }
@JavascriptInterface
fun reloadBaseUrl(animate: Boolean) {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt
index 6c09de7c..8df5b065 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt
@@ -31,8 +31,8 @@ fun FrostWebView.requestWebOverlay(url: String): Boolean {
L.v { "Request web overlay: $url" }
val context = context // finalize reference
if (url.isVideoUrl && context is VideoViewHolder) {
- L.d { "Found video" }
- context.runOnUiThread { context.showVideo(url) }
+ L.d { "Found video through overlay" }
+ context.runOnUiThread { context.showVideo(url.formattedFbUrl) }
return true
}
if (url.isImageUrl) {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
index f1b30795..4f36fdba 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
@@ -27,8 +27,7 @@ import org.jetbrains.anko.withAlpha
*/
open class BaseWebViewClient : WebViewClient() {
- override fun shouldInterceptRequest(view: WebView, request: WebResourceRequest): WebResourceResponse?
- = view.shouldFrostInterceptRequest(request)
+ override fun shouldInterceptRequest(view: WebView, request: WebResourceRequest): WebResourceResponse? = view.shouldFrostInterceptRequest(request)
}
@@ -74,7 +73,11 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() {
Prefs.themeInjector,
CssHider.NON_RECENT.maybe((web.url?.contains("?sk=h_chr") ?: false)
&& Prefs.aggressiveRecents),
- JsAssets.DOCUMENT_WATCHER)
+ JsAssets.DOCUMENT_WATCHER,
+ JsAssets.CLICK_A,
+ CssHider.ADS.maybe(!Prefs.showFacebookAds && IS_FROST_PRO),
+ JsAssets.CONTEXT_A,
+ JsAssets.MEDIA)
else
refresh.onNext(false)
}
@@ -101,13 +104,8 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() {
injectBackgroundColor()
web.jsInject(
JsActions.LOGIN_CHECK,
- JsAssets.CLICK_A,
JsAssets.TEXTAREA_LISTENER,
- CssHider.ADS.maybe(!Prefs.showFacebookAds && IS_FROST_PRO),
- JsAssets.CONTEXT_A,
- JsAssets.MEDIA,
- JsAssets.HEADER_BADGES.maybe(web.parent.baseEnum != null)
- )
+ JsAssets.HEADER_BADGES.maybe(isMain))
}
open fun handleHtml(html: String?) {