From c7cfb2c8682b223e5949735a015cb920934b36cd Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 23 May 2020 18:36:41 -0700 Subject: Create full size image css --- .../com/pitchedapps/frost/injectors/CssHider.kt | 4 ++-- .../pitchedapps/frost/injectors/CssSmallAssets.kt | 20 ++++++++++++++++++++ .../main/kotlin/com/pitchedapps/frost/utils/Prefs.kt | 2 ++ .../kotlin/com/pitchedapps/frost/web/DebugWebView.kt | 2 ++ .../com/pitchedapps/frost/web/FrostWebViewClients.kt | 4 +++- 5 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 app/src/main/kotlin/com/pitchedapps/frost/injectors/CssSmallAssets.kt diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssHider.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssHider.kt index 94367853..9630117d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssHider.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssHider.kt @@ -24,7 +24,7 @@ import com.pitchedapps.frost.utils.Prefs * * List of elements to hide */ -enum class CssHider(vararg val items: String) : InjectorContract { +enum class CssHider(private vararg val items: String) : InjectorContract { CORE("[data-sigil=m_login_upsell]", "[role=progressbar]"), HEADER( "#header:not(.mFuturePageHeader):not(.titled)", @@ -51,7 +51,7 @@ enum class CssHider(vararg val items: String) : InjectorContract { val injector: JsInjector by lazy { JsBuilder().css("${items.joinToString(separator = ",")}{display:none !important}") - .single(name).build() + .single("css-hider-$name").build() } override fun inject(webView: WebView, prefs: Prefs) = diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssSmallAssets.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssSmallAssets.kt new file mode 100644 index 00000000..e2485c71 --- /dev/null +++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssSmallAssets.kt @@ -0,0 +1,20 @@ +package com.pitchedapps.frost.injectors + +import android.webkit.WebView +import com.pitchedapps.frost.utils.Prefs + +/** + * Small misc inline css assets + */ +enum class CssSmallAssets(private val content: String) : InjectorContract { + FullSizeImage("div._4prr[style*=\"max-width\"][style*=\"max-height\"]{max-width:none !important;max-height:none !important}") + ; + + val injector: JsInjector by lazy { + JsBuilder().css(content).single("css-small-assets-$name").build() + } + + override fun inject(webView: WebView, prefs: Prefs) { + injector.inject(webView, prefs) + } +} \ No newline at end of file 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 8b2b5067..1dfd6871 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt @@ -198,6 +198,8 @@ class Prefs(factory: KPrefFactory) : KPref("${BuildConfig.APPLICATION_ID}.prefs" var showCreateFab: Boolean by kpref("show_create_fab", true) + var fullSizeImage: Boolean by kpref("full_size_image", false) + inline val mainActivityLayout: MainActivityLayout get() = MainActivityLayout(mainActivityLayoutType) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt index 8d4deef8..199e9cfb 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt @@ -26,6 +26,7 @@ import android.webkit.WebView import ca.allanwang.kau.utils.withAlpha import com.pitchedapps.frost.facebook.USER_AGENT import com.pitchedapps.frost.injectors.CssHider +import com.pitchedapps.frost.injectors.CssSmallAssets import com.pitchedapps.frost.injectors.jsInject import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.Prefs @@ -116,6 +117,7 @@ class DebugWebView @JvmOverloads constructor( (url?.contains("?sk=h_chr") ?: false) && prefs.aggressiveRecents ), + CssSmallAssets.FullSizeImage.maybe(prefs.fullSizeImage), prefs = prefs ) } 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 4d635547..3e47fd2a 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt @@ -29,6 +29,7 @@ import com.pitchedapps.frost.facebook.FbItem import com.pitchedapps.frost.facebook.WWW_FACEBOOK_COM import com.pitchedapps.frost.facebook.formattedFbUrl import com.pitchedapps.frost.injectors.CssHider +import com.pitchedapps.frost.injectors.CssSmallAssets import com.pitchedapps.frost.injectors.JsActions import com.pitchedapps.frost.injectors.JsAssets import com.pitchedapps.frost.injectors.jsInject @@ -126,10 +127,11 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() { (web.url?.contains("?sk=h_chr") ?: false) && prefs.aggressiveRecents ), + CssHider.ADS.maybe(!prefs.showFacebookAds), + CssSmallAssets.FullSizeImage.maybe(prefs.fullSizeImage), JsAssets.DOCUMENT_WATCHER, JsAssets.HORIZONTAL_SCROLLING, JsAssets.CLICK_A, - CssHider.ADS.maybe(!prefs.showFacebookAds), JsAssets.CONTEXT_A, JsAssets.MEDIA, prefs = prefs -- cgit v1.2.3 From 3d4d9e636f06bb72c0468927a91e9a81e203424f Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 23 May 2020 18:45:03 -0700 Subject: Add pref entry --- app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt | 7 +++++++ app/src/main/res/values-gr-rGR/strings_pref_feed.xml | 2 +- app/src/main/res/values/strings_pref_feed.xml | 6 ++++-- 3 files changed, 12 insertions(+), 3 deletions(-) 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 15a0633b..22917106 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt @@ -97,4 +97,11 @@ fun SettingsActivity.getFeedPrefs(): KPrefAdapterBuilder.() -> Unit = { }) { descRes = R.string.facebook_ads_desc } + + checkbox(R.string.full_size_image, prefs::fullSizeImage, { + prefs.fullSizeImage = it + shouldRefreshMain() + }) { + descRes = R.string.full_size_image_desc + } } diff --git a/app/src/main/res/values-gr-rGR/strings_pref_feed.xml b/app/src/main/res/values-gr-rGR/strings_pref_feed.xml index 218ccd7e..ea707524 100644 --- a/app/src/main/res/values-gr-rGR/strings_pref_feed.xml +++ b/app/src/main/res/values-gr-rGR/strings_pref_feed.xml @@ -9,7 +9,7 @@ Εμφάνιση Δημιουργίας Δημοσίευσης στο feed δημοσιεύσεων Προτεινόμενοι Φίλοι - Εμφάνισε "Ανθρώπους που ίσως γνωρίζετε" στο feed δημοσιεύσεων + Εμφάνισε \"Ανθρώπους που ίσως γνωρίζετε\" στο feed δημοσιεύσεων Προτεινόμενες ομάδες Εμφάνισε "Προτεινόμενες ομάδες" στο feed Εμφάνιση Ιστοριών diff --git a/app/src/main/res/values/strings_pref_feed.xml b/app/src/main/res/values/strings_pref_feed.xml index 96112059..330c900c 100644 --- a/app/src/main/res/values/strings_pref_feed.xml +++ b/app/src/main/res/values/strings_pref_feed.xml @@ -11,12 +11,14 @@ Show FAB in feed to create new post Suggested Friends - Show "People You May Know" in the feed + Show \"People You May Know\" in the feed Suggested Groups - Show "Suggested Groups" in the feed + Show \"Suggested Groups\" in the feed Show Stories Show stories in the feed Facebook Ads Show native Facebook ads + Full Size Images + Force news feed images to be full width \ No newline at end of file -- cgit v1.2.3 From a6a1b8dffd08219c76614e0eeba6e4d92f02aa6b Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 23 May 2020 18:49:25 -0700 Subject: Update changelog and format --- .../com/pitchedapps/frost/injectors/CssSmallAssets.kt | 18 +++++++++++++++++- app/src/main/play/en-US/whatsnew | 7 +++---- app/src/main/res/xml/frost_changelog.xml | 9 +++++++++ docs/Changelog.md | 4 ++++ 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssSmallAssets.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssSmallAssets.kt index e2485c71..27b6e278 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssSmallAssets.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssSmallAssets.kt @@ -1,3 +1,19 @@ +/* + * Copyright 2020 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 . + */ package com.pitchedapps.frost.injectors import android.webkit.WebView @@ -17,4 +33,4 @@ enum class CssSmallAssets(private val content: String) : InjectorContract { override fun inject(webView: WebView, prefs: Prefs) { injector.inject(webView, prefs) } -} \ No newline at end of file +} diff --git a/app/src/main/play/en-US/whatsnew b/app/src/main/play/en-US/whatsnew index cd456c04..b63931c3 100644 --- a/app/src/main/play/en-US/whatsnew +++ b/app/src/main/play/en-US/whatsnew @@ -1,5 +1,4 @@ -v2.4.4 +v2.4.5 -* Lots of under the hood fixes -* Fixed sharing -* Fix photo downloads for Android Q+ \ No newline at end of file +* Fix url query encoding +* Add option to make images full screen (settings > news feed) \ No newline at end of file diff --git a/app/src/main/res/xml/frost_changelog.xml b/app/src/main/res/xml/frost_changelog.xml index 2193ace9..2fae701b 100644 --- a/app/src/main/res/xml/frost_changelog.xml +++ b/app/src/main/res/xml/frost_changelog.xml @@ -6,6 +6,15 @@ --> + + + + + + + + + diff --git a/docs/Changelog.md b/docs/Changelog.md index 51ef89f8..a0429697 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -1,5 +1,9 @@ # Changelog +## v2.4.5 +* Fix url query encoding +* Add option to make images full screen (settings > news feed) + ## v2.4.4 * Lots of under the hood fixes * Fixed sharing -- cgit v1.2.3