From e5e1a0d4a521eb3c668e04c2123e0ecdd71230e5 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 10 Jan 2021 19:57:18 -0800 Subject: Add messenger entry --- app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt | 1 + app/src/main/kotlin/com/pitchedapps/frost/facebook/FbItem.kt | 1 + app/src/main/res/values/strings.xml | 1 + 3 files changed, 3 insertions(+) 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 61745b95..55321ed2 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt @@ -27,6 +27,7 @@ const val FACEBOOK_BASE_COM = "m.$FACEBOOK_COM" const val FB_URL_BASE = "https://$FACEBOOK_BASE_COM/" const val FACEBOOK_MBASIC_COM = "mbasic.$FACEBOOK_COM" const val FB_URL_MBASIC_BASE = "https://$FACEBOOK_MBASIC_COM/" +const val MESSENGER_URL_BASE = "https://www.messenger.com/" fun profilePictureUrl(id: Long) = "https://graph.facebook.com/$id/picture?type=large" const val FB_LOGIN_URL = "${FB_URL_BASE}login" const val FB_HOME_URL = "${FB_URL_BASE}home.php" diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbItem.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbItem.kt index 4c33fe8d..3ad79f4a 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbItem.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbItem.kt @@ -48,6 +48,7 @@ enum class FbItem( MARKETPLACE(R.string.marketplace, GoogleMaterial.Icon.gmd_store, "marketplace"), MENU(R.string.menu, GoogleMaterial.Icon.gmd_menu, "settings"), MESSAGES(R.string.messages, MaterialDesignIconic.Icon.gmi_comments, "messages"), + MESSENGER(R.string.messenger, CommunityMaterial.Icon2.cmd_facebook_messenger, "", prefix = MESSENGER_URL_BASE), NOTES(R.string.notes, CommunityMaterial.Icon3.cmd_note, "notes"), NOTIFICATIONS(R.string.notifications, MaterialDesignIconic.Icon.gmi_globe, "notifications"), ON_THIS_DAY(R.string.on_this_day, GoogleMaterial.Icon.gmd_today, "onthisday"), diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 96957c4c..e66a5637 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -7,6 +7,7 @@ Events Friends Messages + Messenger Notifications Activity Log Pages -- cgit v1.2.3 From 7ad9fdfc6ff5faebb9588335013d1f414d3d0bad Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 10 Jan 2021 20:28:07 -0800 Subject: Prepare for messenger cookies --- .../com/pitchedapps/frost/facebook/FbConst.kt | 3 +- .../com/pitchedapps/frost/facebook/FbCookie.kt | 40 +++++++++++++--------- .../com/pitchedapps/frost/facebook/FbItem.kt | 2 +- 3 files changed, 27 insertions(+), 18 deletions(-) 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 55321ed2..9edcc496 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt @@ -23,11 +23,12 @@ package com.pitchedapps.frost.facebook const val FACEBOOK_COM = "facebook.com" const val FBCDN_NET = "fbcdn.net" const val WWW_FACEBOOK_COM = "www.$FACEBOOK_COM" +const val HTTPS_FACEBOOK_COM = "https://$WWW_FACEBOOK_COM" +const val HTTPS_MESSENGER_COM = "https://www.messenger.com/" const val FACEBOOK_BASE_COM = "m.$FACEBOOK_COM" const val FB_URL_BASE = "https://$FACEBOOK_BASE_COM/" const val FACEBOOK_MBASIC_COM = "mbasic.$FACEBOOK_COM" const val FB_URL_MBASIC_BASE = "https://$FACEBOOK_MBASIC_COM/" -const val MESSENGER_URL_BASE = "https://www.messenger.com/" fun profilePictureUrl(id: Long) = "https://graph.facebook.com/$id/picture?type=large" const val FB_LOGIN_URL = "${FB_URL_BASE}login" const val FB_HOME_URL = "${FB_URL_BASE}home.php" diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt index e66eaf27..78d51aef 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt @@ -28,6 +28,7 @@ import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.cookies import com.pitchedapps.frost.utils.launchLogin +import kotlinx.coroutines.Dispatchers import kotlin.coroutines.resume import kotlin.coroutines.suspendCoroutine import kotlinx.coroutines.NonCancellable @@ -44,7 +45,8 @@ import org.koin.dsl.module class FbCookie(private val prefs: Prefs, private val cookieDao: CookieDao) { companion object { - private const val COOKIE_DOMAIN = FB_URL_BASE + private const val FB_COOKIE_DOMAIN = HTTPS_FACEBOOK_COM + private const val MESSENGER_COOKIE_DOMAIN = HTTPS_MESSENGER_COM fun module() = module { single { FbCookie(get(), get()) } @@ -56,36 +58,37 @@ class FbCookie(private val prefs: Prefs, private val cookieDao: CookieDao) { * Note that this is a synchronized call */ val webCookie: String? - get() = CookieManager.getInstance().getCookie(COOKIE_DOMAIN) + get() = CookieManager.getInstance().getCookie(FB_COOKIE_DOMAIN) - private suspend fun CookieManager.suspendSetWebCookie(cookie: String?): Boolean { + val messengerCookie: String? + get() = CookieManager.getInstance().getCookie(HTTPS_MESSENGER_COM) + + private suspend fun CookieManager.suspendSetWebCookie(domain: String, cookie: String?): Boolean { cookie ?: return true return withContext(NonCancellable) { - removeAllCookies() // Save all cookies regardless of result, then check if all succeeded val result = cookie.split(";") - .map { async { setSingleWebCookie(it) } } + .map { async { setSingleWebCookie(domain, it) } } .awaitAll().all { it } - flush() L.d { "Cookies set" } L._d { "Set $cookie\n\tResult $webCookie" } result } } + private suspend fun CookieManager.setSingleWebCookie(domain: String, cookie: String): Boolean = + suspendCoroutine { cont -> + setCookie(domain, cookie.trim()) { + cont.resume(it) + } + } + private suspend fun CookieManager.removeAllCookies(): Boolean = suspendCoroutine { cont -> removeAllCookies { cont.resume(it) } } - private suspend fun CookieManager.setSingleWebCookie(cookie: String): Boolean = - suspendCoroutine { cont -> - setCookie(COOKIE_DOMAIN, cookie.trim()) { - cont.resume(it) - } - } - suspend fun save(id: Long) { L.d { "New cookie found" } prefs.userId = id @@ -108,14 +111,19 @@ class FbCookie(private val prefs: Prefs, private val cookieDao: CookieDao) { } suspend fun switchUser(cookie: CookieEntity?) { - if (cookie == null) { + if (cookie?.cookie == null) { L.d { "Switching User; null cookie" } return } - withContext(NonCancellable) { + withContext(Dispatchers.IO + NonCancellable) { L.d { "Switching User" } prefs.userId = cookie.id - CookieManager.getInstance().suspendSetWebCookie(cookie.cookie) + CookieManager.getInstance().apply { + removeAllCookies() + suspendSetWebCookie(FB_COOKIE_DOMAIN, cookie.cookie) + // TODO set messenger cookie + flush() + } } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbItem.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbItem.kt index 3ad79f4a..9b08c775 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbItem.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbItem.kt @@ -48,7 +48,7 @@ enum class FbItem( MARKETPLACE(R.string.marketplace, GoogleMaterial.Icon.gmd_store, "marketplace"), MENU(R.string.menu, GoogleMaterial.Icon.gmd_menu, "settings"), MESSAGES(R.string.messages, MaterialDesignIconic.Icon.gmi_comments, "messages"), - MESSENGER(R.string.messenger, CommunityMaterial.Icon2.cmd_facebook_messenger, "", prefix = MESSENGER_URL_BASE), + MESSENGER(R.string.messenger, CommunityMaterial.Icon2.cmd_facebook_messenger, "", prefix = HTTPS_MESSENGER_COM), NOTES(R.string.notes, CommunityMaterial.Icon3.cmd_note, "notes"), NOTIFICATIONS(R.string.notifications, MaterialDesignIconic.Icon.gmi_globe, "notifications"), ON_THIS_DAY(R.string.on_this_day, GoogleMaterial.Icon.gmd_today, "onthisday"), -- cgit v1.2.3 From fb122b7af6e230e9458ab7d892d5d20f551b98ed Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 10 Jan 2021 20:50:20 -0800 Subject: Rename old messenger scss to messages --- .../kotlin/com/pitchedapps/frost/facebook/FbConst.kt | 2 +- .../com/pitchedapps/frost/facebook/FbCookie.kt | 1 + app/src/web/scss/core/_core_messages.scss | 20 ++++++++++++++++++++ app/src/web/scss/core/_core_messenger.scss | 20 -------------------- app/src/web/scss/core/core.scss | 2 +- 5 files changed, 23 insertions(+), 22 deletions(-) create mode 100644 app/src/web/scss/core/_core_messages.scss delete mode 100644 app/src/web/scss/core/_core_messenger.scss 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 9edcc496..7a65a818 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt @@ -24,7 +24,7 @@ const val FACEBOOK_COM = "facebook.com" const val FBCDN_NET = "fbcdn.net" const val WWW_FACEBOOK_COM = "www.$FACEBOOK_COM" const val HTTPS_FACEBOOK_COM = "https://$WWW_FACEBOOK_COM" -const val HTTPS_MESSENGER_COM = "https://www.messenger.com/" +const val HTTPS_MESSENGER_COM = "https://www.messenger.com" const val FACEBOOK_BASE_COM = "m.$FACEBOOK_COM" const val FB_URL_BASE = "https://$FACEBOOK_BASE_COM/" const val FACEBOOK_MBASIC_COM = "mbasic.$FACEBOOK_COM" diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt index 78d51aef..36d51ec9 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt @@ -117,6 +117,7 @@ class FbCookie(private val prefs: Prefs, private val cookieDao: CookieDao) { } withContext(Dispatchers.IO + NonCancellable) { L.d { "Switching User" } + // TODO save old messenger cookie prefs.userId = cookie.id CookieManager.getInstance().apply { removeAllCookies() diff --git a/app/src/web/scss/core/_core_messages.scss b/app/src/web/scss/core/_core_messages.scss new file mode 100644 index 00000000..aa3c04eb --- /dev/null +++ b/app/src/web/scss/core/_core_messages.scss @@ -0,0 +1,20 @@ +// Not all message related components are here; only the main ones. +// Borders for instance are merged into core_border + +// Other person's message bubble +._34ee { + background: $background2 !important; + color: $text !important; + +} + +// Your message bubble; order matters +._34em ._34ee { + background: $accent !important; + color: $accent_text !important; +} + +// Sticker page +._5as0, ._5cni, ._5as2 { + background: $bg_opaque !important; +} \ No newline at end of file diff --git a/app/src/web/scss/core/_core_messenger.scss b/app/src/web/scss/core/_core_messenger.scss deleted file mode 100644 index 608fc23d..00000000 --- a/app/src/web/scss/core/_core_messenger.scss +++ /dev/null @@ -1,20 +0,0 @@ -// Not all messenger related components are here; only the main ones. -// Borders for instance are merged into core_border - -// Other person's message bubble -._34ee { - background: $background2 !important; - color: $text !important; - -} - -// Your message bubble; order matters -._34em ._34ee { - background: $accent !important; - color: $accent_text !important; -} - -// Sticker page -._5as0, ._5cni, ._5as2 { - background: $bg_opaque !important; -} \ No newline at end of file diff --git a/app/src/web/scss/core/core.scss b/app/src/web/scss/core/core.scss index 38086529..112c0003 100644 --- a/app/src/web/scss/core/core.scss +++ b/app/src/web/scss/core/core.scss @@ -3,7 +3,7 @@ @import "core_text"; @import "core_bg"; @import "core_border"; -@import "core_messenger"; +@import "core_messages"; //GLOBAL overrides; use with caution *, *::after, *::before { -- cgit v1.2.3 From b01d23bdaa03b7feb23c17d2af63926b1f5bb592 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 10 Jan 2021 21:18:54 -0800 Subject: Remap theme structure --- .../com/pitchedapps/frost/injectors/CssAssets.kt | 6 +- app/src/web/scss/core/_core_bg.scss | 91 ------------------ app/src/web/scss/core/_core_border.scss | 106 --------------------- app/src/web/scss/core/_core_messages.scss | 20 ---- app/src/web/scss/core/_core_text.scss | 44 --------- app/src/web/scss/core/_main.scss | 6 -- app/src/web/scss/core/_svg.scss | 74 -------------- app/src/web/scss/core/core.scss | 54 ----------- app/src/web/scss/facebook/core/_core_bg.scss | 91 ++++++++++++++++++ app/src/web/scss/facebook/core/_core_border.scss | 106 +++++++++++++++++++++ app/src/web/scss/facebook/core/_core_messages.scss | 20 ++++ app/src/web/scss/facebook/core/_core_text.scss | 44 +++++++++ app/src/web/scss/facebook/core/_main.scss | 6 ++ app/src/web/scss/facebook/core/_svg.scss | 74 ++++++++++++++ app/src/web/scss/facebook/core/core.scss | 54 +++++++++++ app/src/web/scss/facebook/themes/.gitignore | 1 + app/src/web/scss/facebook/themes/custom.scss | 2 + .../web/scss/facebook/themes/material_amoled.scss | 2 + .../web/scss/facebook/themes/material_dark.scss | 2 + .../web/scss/facebook/themes/material_glass.scss | 2 + .../web/scss/facebook/themes/material_light.scss | 2 + app/src/web/scss/messenger/core/_core_bg.scss | 0 app/src/web/scss/messenger/core/_core_border.scss | 0 app/src/web/scss/messenger/core/_core_text.scss | 0 app/src/web/scss/messenger/core/_main.scss | 3 + app/src/web/scss/messenger/core/core.scss | 5 + app/src/web/scss/messenger/themes/.gitignore | 1 + app/src/web/scss/messenger/themes/custom.scss | 2 + .../web/scss/messenger/themes/material_amoled.scss | 2 + .../web/scss/messenger/themes/material_dark.scss | 2 + .../web/scss/messenger/themes/material_glass.scss | 2 + .../web/scss/messenger/themes/material_light.scss | 2 + app/src/web/scss/palette/_custom.scss | 12 +++ app/src/web/scss/palette/_material_amoled.scss | 9 ++ app/src/web/scss/palette/_material_dark.scss | 8 ++ app/src/web/scss/palette/_material_glass.scss | 8 ++ app/src/web/scss/palette/_material_light.scss | 13 +++ app/src/web/scss/themes/.gitignore | 1 - app/src/web/scss/themes/custom.scss | 14 --- app/src/web/scss/themes/material_amoled.scss | 11 --- app/src/web/scss/themes/material_dark.scss | 10 -- app/src/web/scss/themes/material_glass.scss | 10 -- app/src/web/scss/themes/material_light.scss | 15 --- 43 files changed, 478 insertions(+), 459 deletions(-) delete mode 100644 app/src/web/scss/core/_core_bg.scss delete mode 100644 app/src/web/scss/core/_core_border.scss delete mode 100644 app/src/web/scss/core/_core_messages.scss delete mode 100644 app/src/web/scss/core/_core_text.scss delete mode 100644 app/src/web/scss/core/_main.scss delete mode 100644 app/src/web/scss/core/_svg.scss delete mode 100644 app/src/web/scss/core/core.scss create mode 100644 app/src/web/scss/facebook/core/_core_bg.scss create mode 100644 app/src/web/scss/facebook/core/_core_border.scss create mode 100644 app/src/web/scss/facebook/core/_core_messages.scss create mode 100644 app/src/web/scss/facebook/core/_core_text.scss create mode 100644 app/src/web/scss/facebook/core/_main.scss create mode 100644 app/src/web/scss/facebook/core/_svg.scss create mode 100644 app/src/web/scss/facebook/core/core.scss create mode 100644 app/src/web/scss/facebook/themes/.gitignore create mode 100644 app/src/web/scss/facebook/themes/custom.scss create mode 100644 app/src/web/scss/facebook/themes/material_amoled.scss create mode 100644 app/src/web/scss/facebook/themes/material_dark.scss create mode 100644 app/src/web/scss/facebook/themes/material_glass.scss create mode 100644 app/src/web/scss/facebook/themes/material_light.scss create mode 100644 app/src/web/scss/messenger/core/_core_bg.scss create mode 100644 app/src/web/scss/messenger/core/_core_border.scss create mode 100644 app/src/web/scss/messenger/core/_core_text.scss create mode 100644 app/src/web/scss/messenger/core/_main.scss create mode 100644 app/src/web/scss/messenger/core/core.scss create mode 100644 app/src/web/scss/messenger/themes/.gitignore create mode 100644 app/src/web/scss/messenger/themes/custom.scss create mode 100644 app/src/web/scss/messenger/themes/material_amoled.scss create mode 100644 app/src/web/scss/messenger/themes/material_dark.scss create mode 100644 app/src/web/scss/messenger/themes/material_glass.scss create mode 100644 app/src/web/scss/messenger/themes/material_light.scss create mode 100644 app/src/web/scss/palette/_custom.scss create mode 100644 app/src/web/scss/palette/_material_amoled.scss create mode 100644 app/src/web/scss/palette/_material_dark.scss create mode 100644 app/src/web/scss/palette/_material_glass.scss create mode 100644 app/src/web/scss/palette/_material_light.scss delete mode 100644 app/src/web/scss/themes/.gitignore delete mode 100644 app/src/web/scss/themes/custom.scss delete mode 100644 app/src/web/scss/themes/material_amoled.scss delete mode 100644 app/src/web/scss/themes/material_dark.scss delete mode 100644 app/src/web/scss/themes/material_glass.scss delete mode 100644 app/src/web/scss/themes/material_light.scss diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt index 5329046f..e012de3f 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt @@ -34,6 +34,8 @@ import java.util.Locale import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext +private const val THEME_FOLDER = "themes" + /** * Created by Allan Wang on 2017-05-31. * Mapping of the available assets @@ -110,6 +112,4 @@ enum class CssAssets(val folder: String = THEME_FOLDER) : InjectorContract { } } } -} - -private const val THEME_FOLDER = "themes" +} \ No newline at end of file diff --git a/app/src/web/scss/core/_core_bg.scss b/app/src/web/scss/core/_core_bg.scss deleted file mode 100644 index c5269ccf..00000000 --- a/app/src/web/scss/core/_core_bg.scss +++ /dev/null @@ -1,91 +0,0 @@ -#viewport { - background: $background !important; -} - -html, body, :root, #root, #header, #MComposer, ._1upc, input, ._2f9r, ._59e9, ._5pz4, ._5lp4, -[style*="background-color: #FFFFFF"], [style*="background-color: #E4E6EB"], -._5lp5, .container, .subpage, ._5n_f, #static_templates, ._22_8, ._1t4h, ._uoq, ._3qdh, ._8ca, ._3h8i, -._6-l ._2us7, ._6-l ._6-p:not([style*="background-image:"]), ._333v, div.sharerSelector, ._529j, ._305j, ._1pph, ._3t_l, ._4pvz, -._1g05, .acy, ._51-g, ._533c, ._ib-, .sharerAttachmentEmpty, .sharerBottomWrapper, ._24e1, ._7g4m, ._bub, -._3bg5 ._56do, ._5hfh, ._52e-, .mQuestionsPollResultsBar, ._5hoc, ._5oxw, ._32_4, ._1hiz, ._53_-, ._4ut9, -._38do, .bo, .cq, ._234-, ._a-5, ._2zh4, ._15ks, ._3oyc, ._36dc, ._3iyw ._3iyx, ._6bes, ._55wo, ._4-dy, -.tlBody, #timelineBody, .timelineX, .timeline, .feed, .tlPrelude, .tlFeedPlaceholder, ._4_d0, ._2wn5, -.al, ._1gkq, ._5c5b, ._1qxg, ._5luf, ._2new, ._cld, ._3zvb, ._2nk0, .btnD, .btnI, ._2bdb, ._3ci9, ._2_gy, -._11ub, ._5p7j, ._55wm, ._5rgs, ._5xuj, ._1sv1, ._45fu, ._18qg, ._1_ac, ._5w3g, ._3e18, ._6be7, ._-kp, ._-kq, -._5q_r, ._5yt8, ._idb, ._2ip_, ._f6s, ._2l5v, ._8i2, ._kr5, ._2q7u, ._2q7v, ._5xp2, div.fullwidthMore, -._577z, ._2u4w, ._3u9p, ._3u9t, ._cw4, ._5_y-, ._5_y_, ._5_z3, ._cwy, ._5_z0, ._voz, ._vos, ._7i8m, -._5_z1, ._5_z2, ._2mtc, ._206a, ._1_-1, ._1ybg, .appCenterCategorySelectorButton, ._5_ee, ._3clk, -._5c9u, div._5y57::before, ._59f6._55so::before, .structuredPublisher, ._94v, ._vqv, ._8r-n, -._5lp5, ._1ho1, ._39y9._39ya, ._59_m, ._6rny, -._55wm, ._2om3, ._2ol-, ._1f9d, ._vee, ._31a-, ._3r8b, ._3r9d, ._5vq5, ._3tl8, ._65wz, ._4edl, -.acw, ._4_xl, ._1p70, ._1p70, ._1ih_, ._51v6, ._u2c, ._484w, ._3ils, ._rm7, ._32qk, ._d01, ._1glm, -._ue6, ._hdn._hdn, ._6vzw, ._77xj, ._38nq, ._9_7, ._51li, ._7hkf, ._6vzz, ._3iyw ._37fb, -._2y60, ._5fu3, ._2foa, ._2y5_, ._38o9, ._1kb, .mAppCenterFatLabel, ._3bmj, ._5zmb, ._2x2s, ._3kac, ._3kad, -._3f50, .mentions-placeholder, .mentions, .mentions-measurer, .acg, ._59tu, ._7lcm, ._7kxh, -._4l9b, ._4gj3, .groupChromeView, ._i3g, ._3jcf, .error, ._1dbp, ._5zma, ._6beq, ._vi6, -._uww, textarea, ._15n_, ._skt, ._5f28, ._14_j, ._3bg5, ._53_-, ._52x1, ._35au, ._cwy, -._1rfn ._1rfk ._4vc-, ._1rfk, ._1rfk ._2v9s, ._301x { - background: $bg_transparent !important; -} - -// card related -._31nf, ._2v9s, ._d4i, article._55wo, ._10c_, ._2jl2, ._6150, ._50mi, ._4-dw, ._4_2z, ._5m_s, ._13fn, ._7kxe, [style*="background-color: #F5F8FF"], -._84lx, ._517h, ._59pe:focus, ._59pe:hover, ._m_1, ._3eqz, ._6m2, ._6q-c { - background: $card !important; -} - -// unread related - -.aclb { - background: $tint !important; -} - -// contains images so must have background-color -._cv_, ._2sq8 { - background-color: $bg_transparent !important; -} - -#page, ._8l7, ._-j8, ._-j9, ._6o5v, ._uwx, .touch ._uwx.mentions-input { - background: transparent !important; -} - -.jewel, .flyout, ._52z5, ._13e_, ._5-lw, ._5c0e, .jx-result, ._336p, .mentions-suggest-item, ._2suk, ._-j7, ._4d0v, ._4d0m, -.mentions-suggest, ._1xoz, ._1xow, ._14v5 ._14v8, ._8s4y, ._55ws, -// desktop sharing page -.uiBoxLightblue, .uiBoxWhite, .uiBoxGray, .uiTokenizer, .uiTypeahead, ._558b ._54ng, ._2_bh, ._509o, ._509o:hover { - background: $bg_opaque !important; -} - -._403n, ._1-kc { - background: $bg_opaque2 !important; -} - -button:not([style*=image]):not(.privacyButtons), button::before, .touch ._56bt, ._56be::before, .btnS, .touch::before, -._590n, ._4g8h, ._2cpp, ._58a0.touched:after, ._7hfd, -.timeline .timelinePublisher, .touched, .sharerAttachment, -.item a.primary.touched .primarywrap, ._537a, ._7cui, ._785, -._5xo2, ._5u5a::before, ._4u3j, ._15ks, ._5hua, ._59tt, ._41ft, .jx-tokenizer, ._55fj, -.excessItem, .acr, ._5-lx, ._3g9-, ._6dsj ._3gin, ._69aj, -._4e8n, ._5pxa._3uj9, ._5n_5, ._u2d, ._56bu::before, ._5h8f, ._d00, ._2066, ._2k51, -._10sb li.selected, ._2z4j, ._ib-, ._1bhl, ._5a5j, ._6--d, ._77p7, -._2b06, ._2tsf, ._3gka, .mCount, ._27vc, ._4pv-, ._6pk5, ._86nt, -._4qax, ._4756, ._w34, ._56bv::before, ._5769, ._34iv, ._z-w, ._t21, .mToken, -#addMembersTypeahead .mToken.mTokenWeakReference, ._4_d0 ._8-89, -.acbk { - background: $background2 !important; -} - -.mQuestionsPollResultsBar .shaded, ._1r00 { - background: $accent !important; -} - -._220g, ._1_y8:after, ._6pk6, -._2zh4::before, ._2ip_ ._2zh4::before, ._2ip_ ._15kk::before, ._2ip_ ._15kk + ._4u3j::before, -._58a0:before, ._43mh::before, ._43mh::after, ._1_-1::before, ._1kmv:after, ._1_ac:before { - background: $divider !important; -} - -//fab -button ._v89 ._54k8._1fl1 { - background: $accent !important; -} diff --git a/app/src/web/scss/core/_core_border.scss b/app/src/web/scss/core/_core_border.scss deleted file mode 100644 index 1929e546..00000000 --- a/app/src/web/scss/core/_core_border.scss +++ /dev/null @@ -1,106 +0,0 @@ -//border between like and comment -._15kl::before, ._37fd .inlineComposerButton, ._1hb:before, -._pfn ._pfo::before, -._5j35::after, ._2k4b, ._3to7, ._4nw8 { - border-left: 1px solid $divider !important; -} - -._4_d1, ._5cni, ._3jcq, ._1ho1 { - border-right: 1px solid $divider !important; -} - -//above see more -._1mx0, ._1rbr, ._5yt8, ._idb, ._cld, ._1e8h, ._z-w, ._1ha, ._1n8h ._1oby, ._5f99, ._2t39, -._2pbp, ._5rou:first-child, ._egf:first-child, ._io2, ._3qdi ._48_m::after, ._46dd::before, -._15n_, ._3-2-, ._27ve, ._2s20, ._gui, ._2s21 > *::after, ._32qk, ._d00, ._d01, ._38o9, -._3u9t, ._55fj, .mEventProfileSection.useBorder td, ._3ils, ._5as0, ._5as2, ._5-lw, -._2s1_:before, ._143z::before, ._143z::after, ._4d0x, ._5_gz, ._5_ev, ._63ur, ._6pi8, -._52x1, ._3wjp, ._usq, ._2cul:before, ._13e_, .jewel .flyout, ._3bg5 ._52x6, ._56d8, .al { - border-top: 1px solid $divider !important; -} - -._15ny::after, ._z-w, ._8i2, ._2nk0, ._22_8, ._1t4h, ._37fd, ._1ha, ._3bg5 ._56do, ._8he, -._400s, ._5hoc, ._1bhn, ._5ag6, ._4pvz, ._31y5, ._7gxb, ._-kp, ._6_q3::after, ._3al1, ._4d0w, ._4d0k, -._301x, ._x08 ._x0a:after, ._36dc, ._6-l ._57jn, ._527k, ._g_k, ._7i8v, ._7k1c, ._2_gy, -._577z:not(:last-child) ._ygd, ._3u9u, ._3mgz, ._52x6, ._2066, ._5luf, ._2bdc, ._3ci9, -.mAppCenterFatLabel, .appCenterCategorySelectorButton, ._1q6v, ._5q_r, ._5yt8, ._38do, ._38dt, -._ap1, ._52x1, ._59tu, ._usq, ._13e_, ._59f6._55so::before, ._4gj3, .error, ._35--, ._1wev, -.jx-result, ._1f9d, ._vef, ._55x2 > *, .al, ._44qk, ._5rgs, ._5xuj, ._1sv1, ._idb, ._5_g-, -._5lp5, ._3-2-, ._3to6, ._ir5, ._4nw6, ._4nwh, ._27ve, div._51v6::before, ._5hu6, ._2wn5, ._1ho1, ._1xk6, -._3c9h::before, ._2s20, ._gui, ._5jku, ._2foa, ._2y60, ._5fu3, ._4en9, ._1kb:not(:last-child) ._1kc, -._5pz4, ._5lp4, ._5lp5, ._5h6z, ._5h6x, ._2om4, ._5fjw > div, ._5fjv > :first-child, -._5fjw > :first-child { - border-bottom: 1px solid $divider !important; -} - -.item a.primary.touched .primarywrap, ._4dwt ._5y33, ._1ih_, ._5_50, ._6beq, ._69aj, ._3iyw ._37fb, -._5fjv, ._3on6, ._2u4w, ._2om3, ._2ol-, ._5fjw, ._4z83, ._1gkq, ._4-dy, ._bub { - border-top: 1px solid $divider !important; - border-bottom: 1px solid $divider !important; -} - -//friend card border -._d4i, ._f6s, .mentions-suggest-item, .mentions-suggest, .sharerAttachment, -.mToken, #addMembersTypeahead .mToken.mTokenWeakReference, .mQuestionsPollResultsBar, -._15q7, ._2q7v, ._4dwt ._16ii, ._3qdi::after, ._6q-c, -._2q7w, .acy, ._58ak, ._3t_l, ._4msa, ._3h8i, ._3clk, ._1kt6, ._1ksq, -._1_y5, ._lr0, ._5hgt, ._2cpp, ._50uu, ._50uw, ._31yd, ._1e3d, ._3xz7, ._1xoz, -._4kcb, ._2lut, .jewel .touchable-notification.touched, .touchable-notification .touchable.touched, -.home-notification .touchable.touched, ._6beo ._6ber, ._7kxg, -._73ku ._73jw, ._6--d, ._26vk._56bt, ._3iyw ._2whz ._13-g, ._-jx, -._4e8n, ._uww, .mentions-placeholder, .mentions-shadow, .mentions-measurer, ._517h, ._59pe:focus, ._59pe:hover, -.uiBoxLightblue, .uiBoxWhite, ._558b ._54nc, -._5whq, ._59tt, ._41ft::after, .jx-tokenizer, ._3uqf, ._4756, ._1rrd, ._5n_f { - border: 1px solid $divider !important; -} - -.mQuestionsPollResultsBar .shaded, ._1027._13sm { - border: 1px solid $text !important; -} - -._3gka { - border: 1px dashed $divider !important; -} - -//link card bottom border -._4o58::after, .acr, ._t21, ._2bdb, ._4ks>li, -.acw, .aclb, ._4qax, ._5h8f { - border-color: $divider !important; -} - -// like, comment, share divider -._15ks ._15kl::before { - border-left: 1px solid transparent !important; -} - -._56bf, .touch .btn { - border-radius: 0 !important; - border: 0 !important; -} - -//page side tab layout -._2cis { - border-left: 10px solid $bg_transparent !important; - border-right: 10px solid $bg_transparent !important; -} - -._2cir.selected, ._42rv, ._5zma, ._2x2s { - border-bottom: 3px solid $text !important; -} - -._1ss6 { - border-left: 2px solid $text !important; -} - -._484w.selected > ._6zf, ._5kqs::after, ._3lvo ._5xum._5xuk, ._x0b { - border-bottom: 1px solid $text !important; -} - -._484w.selected ._6zf, ._7gxa, ._2wn2 { - border-bottom: 2px solid $accent !important; -} - -// Small face previews -.facepile .facepileItem.facepileItemOverLapped .facepileItemRound, .facepile .facepileItem.facepileItemOverLapped.facepileItemRound, .facepile .facepileItem.facepileItemOverLapped .facepileMoreDotsRound { - border: 2px solid $bg_opaque2 !important; -} \ No newline at end of file diff --git a/app/src/web/scss/core/_core_messages.scss b/app/src/web/scss/core/_core_messages.scss deleted file mode 100644 index aa3c04eb..00000000 --- a/app/src/web/scss/core/_core_messages.scss +++ /dev/null @@ -1,20 +0,0 @@ -// Not all message related components are here; only the main ones. -// Borders for instance are merged into core_border - -// Other person's message bubble -._34ee { - background: $background2 !important; - color: $text !important; - -} - -// Your message bubble; order matters -._34em ._34ee { - background: $accent !important; - color: $accent_text !important; -} - -// Sticker page -._5as0, ._5cni, ._5as2 { - background: $bg_opaque !important; -} \ No newline at end of file diff --git a/app/src/web/scss/core/_core_text.scss b/app/src/web/scss/core/_core_text.scss deleted file mode 100644 index 8ac66758..00000000 --- a/app/src/web/scss/core/_core_text.scss +++ /dev/null @@ -1,44 +0,0 @@ -html, body, input, ._42rv, ._4qau, ._dwm .descArea, ._eu5, -._1tcc, ._3g9-, ._29z_, ._3xz7, ._ib-, ._3bg5 ._56dq, ._477i, ._2vxk, ._29e6, ._8wr8, -.touched *, ._1_yj, ._1_yl, ._4pj9, ._2bdc, ._3qdh ._3qdn ._3qdk, ._3qdk ._48_q, ._7iah, -._z-z, ._z-v, ._1e8d, ._36nl, ._36nm, ._2_11, ._2_rf, ._2ip_, ._403p, .cq, ._usr, #mErrorView .message, -._5xu2, ._3ml8, ._3mla, ._50vk, ._1m2u, ._31y7, ._4kcb, ._1lf6, ._1lf5, ._7-1j, ._4ajz, ._m_1 ._2aha, -._1lf4, ._1hiz, ._xod, ._5ag5, ._zmk, ._3t_h, ._5lm6, ._3clv, ._3zlc, ._36rd, ._6oby, ._6_qk, -._31zk, ._31zl, ._3xsa, ._3xs9, ._2-4s, ._2fzz ul, ._3z10, ._4mo, ._2om6, ._33r5, ._82y3, ._82y1, -._43mh, .touch .btn, .fcg, button, ._52j9, ._52jb, ._52ja, ._5j35, ._ctg, ._5300, ._5302, ._5_o0, -._rnk, ._24u0, ._1g06, ._14ye, .fcb, ._56cz._56c_, ._1gk_, ._55fj, ._45fu, ._7kx4, ._20zd, ._egh, ._egi, -._18qg, ._1_ac, ._529p, ._4dwt ._1vh3, ._4a5f, ._23_t, ._2rzc, ._23_s, ._2rzd, ._6obp, ._2iiu, ._1s06, -._5aga, ._5ag9, ._537a, .acy, ._5ro_, ._6-l ._2us7, ._4mp, ._2b08, ._36e0, ._4-dy, ._55i1, ._2wn6, -._14v5 ._14v8, ._1440, ._1442, ._1448, ._4ks_, .mCount, ._27vc, ._24e1, ._2rbw, ._3iyw ._3mzw, -textarea:not([style*="color: rgb"]), ._24pi, ._4en9, ._1kb, ._5p7j, ._2klz, ._5780, ._5781, ._5782, -._3u9u, ._3u9_, ._3u9s, ._1hcx, ._2066, ._1_-1, ._cv_, ._1nbx, ._2cuh, ._6--d, ._77p7, ._7h_g, -._4ms9, ._4ms5, ._4ms6, ._31b4, ._31b5, ._5q_r, ._idb, ._38d-, ._3n8y, ._38dt, ._3oyg, ._21dc, -.uiStickyPlaceholderInput .placeholder, .mTypeahead span, ._4_d0 ._8-8a, ._6r12, ._5hoa, ._8r-l, -._27vp, ._4nwe, ._4nw9, ._27vi, .appCenterAppInfo, .appCenterPermissions, ._6xqt, ._7cui, ._84lx [style*="color: rgb"], -._3c9l, ._3c9m, ._4jn_, ._32qt, ._3mom, ._3moo, ._-7o, ._d00, ._d01, ._559g, ._7cdj, ._1_yd, ._1_yc, -._2new, .appCenterCategorySelectorButton, ._1ksq, ._1kt6, ._6ber, ._mxb, ._3oyd, ._3gir, ._3gis, -div.sharerSelector, .footer, ._4pv_, ._1dbp, ._3kad, ._20zc, ._2i5v, ._2i5w, ._6zf, ._mhg, -a, ._5fpq, ._4gux, ._3bg5 ._52x1, ._3bg5 ._52x2, ._6dsj ._3gin, ._hdn._hdn, ._3iyw ._2whz ._13-g, -.mentions-input:not([style*="color: rgb"]), .mentions-placeholder:not([style*="color: rgb"]), -.largeStatusBox .placeHolder, .fcw, ._2rgt, ._67i4 ._5hu6 ._59tt, ._2bu3, ._2bu4, ._1ii2, ._1ii3, -._5-7t, .fcl, ._4qas, .thread-title, .title, ._46pa, ._336p, ._1rrd, ._2om4, ._4yxo, ._6m3, ._6m7, ._6m3 ._1t62, -._3m1m, ._2om2, ._5n_e, .appListExplanation, ._5yt8, ._8he, ._2luw, ._5rgs, ._t86 ._t87, ._t86 ._t88, -h1, h2, h3, h4, h5, h6 { - color: $text !important; -} - -// Related to like buttons -a[data-sigil~="unlike"], a[style*="color: rgb(32, 120, 244)"], a[style*="color:#2078f4"], -strong > a, a > ._2vyr, ._15ks ._2q8z._2q8z, ._1e3e, .blueName, ._5kqs ._55sr, ._484w.selected ._6zf, ._6_qj, ._2wn3, -._by_, ._1r05 { - color: $accent !important; -} - -._42nf ._42ng { - color: transparent !important; -} - -// most links do not have a special color. We will highlight those in posts and messages -p > a, .msg span > a { - color: $link !important; -} diff --git a/app/src/web/scss/core/_main.scss b/app/src/web/scss/core/_main.scss deleted file mode 100644 index 3e972f93..00000000 --- a/app/src/web/scss/core/_main.scss +++ /dev/null @@ -1,6 +0,0 @@ -@import "core"; -@import "svg"; - -//this file is used as the base for all themes -//given that svgs take a lot of characters, we won't compile them when testing -//therefore we use the core scss diff --git a/app/src/web/scss/core/_svg.scss b/app/src/web/scss/core/_svg.scss deleted file mode 100644 index 9ed25433..00000000 --- a/app/src/web/scss/core/_svg.scss +++ /dev/null @@ -1,74 +0,0 @@ -// icons courtesy of https://material.io/icons/ - -$camera: ''; - -// status upload image -._50uu { - @include background-svg($camera); -} - -$video: ''; - -// status upload video -._50uw { - @include background-svg($video); -} - -$like: ''; -$like_selected: ''; - -// 2018/12/29 -// Previously ._15km ._15ko::before and ._15km ._15ko._77la::before; however, reaction changes no longer affect this element -// The robust measure seems to be the parent of a[data-sigil~="like-reaction-flyout"] along with [data-sigil~="like"] for an unliked post -// and [data-sigil~="unlike"] for a liked post -a._15ko::before { - @include background-svg($like); - background-position: center !important; -} - -a._15ko._77la::before { - @include background-svg($like_selected); - background-position: center !important; -} - -$comment: ''; - -._15km ._15kq::before { - @include background-svg($comment); - background-position: center !important; -} - -$share: ''; - -._15km ._15kr::before { - @include background-svg($share); - background-position: center !important; -} - -$more_horiz: ''; - -//$menus: ".sp_89zNula0Qh5", -//".sp_MP2OtCXORz9", -//".sp_NIWBacTn8LF", -//// 2018/12/31 -//".sp_9ZFVhnFyWsw", -//// 2019/01/03 -//".sp_SJIJjSlGEIO"; -// -//$menu_collector: (); -// -//@each $menu in $menus { -// $menu_collector: append($menu_collector, unquote('#{$menu}'), 'comma'); -// $menu_collector: append($menu_collector, unquote('#{$menu}_2x'), 'comma'); -// $menu_collector: append($menu_collector, unquote('#{$menu}_3x'), 'comma'); -//} -// -//#{$menu_collector} { -// @include background-svg($more_horiz); -// background-position: center !important; -//} - -.story_body_container i.img[data-sigil*="story-popup-context"] { - @include background-svg($more_horiz); - background-position: center !important; -} \ No newline at end of file diff --git a/app/src/web/scss/core/core.scss b/app/src/web/scss/core/core.scss deleted file mode 100644 index 112c0003..00000000 --- a/app/src/web/scss/core/core.scss +++ /dev/null @@ -1,54 +0,0 @@ -@import "colors"; -@import "base"; -@import "core_text"; -@import "core_bg"; -@import "core_border"; -@import "core_messages"; - -//GLOBAL overrides; use with caution -*, *::after, *::before { - text-shadow: none !important; - box-shadow: none !important; -} - -// .touch .btnS, button, ._94v, ._590n { -// box-shadow: none !important; -// } - -[data-sigil=m_login_upsell], -[data-sigil="m-loading-indicator-animate m-loading-indicator-root"] { - display: none !important; -} - -@include placeholder { - color: $text !important; -} - -.excessItem { - outline: $divider !important; -} - -._3m1m { - background: linear-gradient(transparent, $bg_opaque) !important; -} - -//new comment -@include keyframes(highlightFade) { - 0%, 50% { - background: $background2; - } - - 100% { - background: $bg_transparent; - } -} - -@include keyframes(chatHighlightAnimation) { - 0%, 100% { - background: $bg_transparent; - } - - 50% { - background: $background2; - } -} diff --git a/app/src/web/scss/facebook/core/_core_bg.scss b/app/src/web/scss/facebook/core/_core_bg.scss new file mode 100644 index 00000000..c5269ccf --- /dev/null +++ b/app/src/web/scss/facebook/core/_core_bg.scss @@ -0,0 +1,91 @@ +#viewport { + background: $background !important; +} + +html, body, :root, #root, #header, #MComposer, ._1upc, input, ._2f9r, ._59e9, ._5pz4, ._5lp4, +[style*="background-color: #FFFFFF"], [style*="background-color: #E4E6EB"], +._5lp5, .container, .subpage, ._5n_f, #static_templates, ._22_8, ._1t4h, ._uoq, ._3qdh, ._8ca, ._3h8i, +._6-l ._2us7, ._6-l ._6-p:not([style*="background-image:"]), ._333v, div.sharerSelector, ._529j, ._305j, ._1pph, ._3t_l, ._4pvz, +._1g05, .acy, ._51-g, ._533c, ._ib-, .sharerAttachmentEmpty, .sharerBottomWrapper, ._24e1, ._7g4m, ._bub, +._3bg5 ._56do, ._5hfh, ._52e-, .mQuestionsPollResultsBar, ._5hoc, ._5oxw, ._32_4, ._1hiz, ._53_-, ._4ut9, +._38do, .bo, .cq, ._234-, ._a-5, ._2zh4, ._15ks, ._3oyc, ._36dc, ._3iyw ._3iyx, ._6bes, ._55wo, ._4-dy, +.tlBody, #timelineBody, .timelineX, .timeline, .feed, .tlPrelude, .tlFeedPlaceholder, ._4_d0, ._2wn5, +.al, ._1gkq, ._5c5b, ._1qxg, ._5luf, ._2new, ._cld, ._3zvb, ._2nk0, .btnD, .btnI, ._2bdb, ._3ci9, ._2_gy, +._11ub, ._5p7j, ._55wm, ._5rgs, ._5xuj, ._1sv1, ._45fu, ._18qg, ._1_ac, ._5w3g, ._3e18, ._6be7, ._-kp, ._-kq, +._5q_r, ._5yt8, ._idb, ._2ip_, ._f6s, ._2l5v, ._8i2, ._kr5, ._2q7u, ._2q7v, ._5xp2, div.fullwidthMore, +._577z, ._2u4w, ._3u9p, ._3u9t, ._cw4, ._5_y-, ._5_y_, ._5_z3, ._cwy, ._5_z0, ._voz, ._vos, ._7i8m, +._5_z1, ._5_z2, ._2mtc, ._206a, ._1_-1, ._1ybg, .appCenterCategorySelectorButton, ._5_ee, ._3clk, +._5c9u, div._5y57::before, ._59f6._55so::before, .structuredPublisher, ._94v, ._vqv, ._8r-n, +._5lp5, ._1ho1, ._39y9._39ya, ._59_m, ._6rny, +._55wm, ._2om3, ._2ol-, ._1f9d, ._vee, ._31a-, ._3r8b, ._3r9d, ._5vq5, ._3tl8, ._65wz, ._4edl, +.acw, ._4_xl, ._1p70, ._1p70, ._1ih_, ._51v6, ._u2c, ._484w, ._3ils, ._rm7, ._32qk, ._d01, ._1glm, +._ue6, ._hdn._hdn, ._6vzw, ._77xj, ._38nq, ._9_7, ._51li, ._7hkf, ._6vzz, ._3iyw ._37fb, +._2y60, ._5fu3, ._2foa, ._2y5_, ._38o9, ._1kb, .mAppCenterFatLabel, ._3bmj, ._5zmb, ._2x2s, ._3kac, ._3kad, +._3f50, .mentions-placeholder, .mentions, .mentions-measurer, .acg, ._59tu, ._7lcm, ._7kxh, +._4l9b, ._4gj3, .groupChromeView, ._i3g, ._3jcf, .error, ._1dbp, ._5zma, ._6beq, ._vi6, +._uww, textarea, ._15n_, ._skt, ._5f28, ._14_j, ._3bg5, ._53_-, ._52x1, ._35au, ._cwy, +._1rfn ._1rfk ._4vc-, ._1rfk, ._1rfk ._2v9s, ._301x { + background: $bg_transparent !important; +} + +// card related +._31nf, ._2v9s, ._d4i, article._55wo, ._10c_, ._2jl2, ._6150, ._50mi, ._4-dw, ._4_2z, ._5m_s, ._13fn, ._7kxe, [style*="background-color: #F5F8FF"], +._84lx, ._517h, ._59pe:focus, ._59pe:hover, ._m_1, ._3eqz, ._6m2, ._6q-c { + background: $card !important; +} + +// unread related + +.aclb { + background: $tint !important; +} + +// contains images so must have background-color +._cv_, ._2sq8 { + background-color: $bg_transparent !important; +} + +#page, ._8l7, ._-j8, ._-j9, ._6o5v, ._uwx, .touch ._uwx.mentions-input { + background: transparent !important; +} + +.jewel, .flyout, ._52z5, ._13e_, ._5-lw, ._5c0e, .jx-result, ._336p, .mentions-suggest-item, ._2suk, ._-j7, ._4d0v, ._4d0m, +.mentions-suggest, ._1xoz, ._1xow, ._14v5 ._14v8, ._8s4y, ._55ws, +// desktop sharing page +.uiBoxLightblue, .uiBoxWhite, .uiBoxGray, .uiTokenizer, .uiTypeahead, ._558b ._54ng, ._2_bh, ._509o, ._509o:hover { + background: $bg_opaque !important; +} + +._403n, ._1-kc { + background: $bg_opaque2 !important; +} + +button:not([style*=image]):not(.privacyButtons), button::before, .touch ._56bt, ._56be::before, .btnS, .touch::before, +._590n, ._4g8h, ._2cpp, ._58a0.touched:after, ._7hfd, +.timeline .timelinePublisher, .touched, .sharerAttachment, +.item a.primary.touched .primarywrap, ._537a, ._7cui, ._785, +._5xo2, ._5u5a::before, ._4u3j, ._15ks, ._5hua, ._59tt, ._41ft, .jx-tokenizer, ._55fj, +.excessItem, .acr, ._5-lx, ._3g9-, ._6dsj ._3gin, ._69aj, +._4e8n, ._5pxa._3uj9, ._5n_5, ._u2d, ._56bu::before, ._5h8f, ._d00, ._2066, ._2k51, +._10sb li.selected, ._2z4j, ._ib-, ._1bhl, ._5a5j, ._6--d, ._77p7, +._2b06, ._2tsf, ._3gka, .mCount, ._27vc, ._4pv-, ._6pk5, ._86nt, +._4qax, ._4756, ._w34, ._56bv::before, ._5769, ._34iv, ._z-w, ._t21, .mToken, +#addMembersTypeahead .mToken.mTokenWeakReference, ._4_d0 ._8-89, +.acbk { + background: $background2 !important; +} + +.mQuestionsPollResultsBar .shaded, ._1r00 { + background: $accent !important; +} + +._220g, ._1_y8:after, ._6pk6, +._2zh4::before, ._2ip_ ._2zh4::before, ._2ip_ ._15kk::before, ._2ip_ ._15kk + ._4u3j::before, +._58a0:before, ._43mh::before, ._43mh::after, ._1_-1::before, ._1kmv:after, ._1_ac:before { + background: $divider !important; +} + +//fab +button ._v89 ._54k8._1fl1 { + background: $accent !important; +} diff --git a/app/src/web/scss/facebook/core/_core_border.scss b/app/src/web/scss/facebook/core/_core_border.scss new file mode 100644 index 00000000..1929e546 --- /dev/null +++ b/app/src/web/scss/facebook/core/_core_border.scss @@ -0,0 +1,106 @@ +//border between like and comment +._15kl::before, ._37fd .inlineComposerButton, ._1hb:before, +._pfn ._pfo::before, +._5j35::after, ._2k4b, ._3to7, ._4nw8 { + border-left: 1px solid $divider !important; +} + +._4_d1, ._5cni, ._3jcq, ._1ho1 { + border-right: 1px solid $divider !important; +} + +//above see more +._1mx0, ._1rbr, ._5yt8, ._idb, ._cld, ._1e8h, ._z-w, ._1ha, ._1n8h ._1oby, ._5f99, ._2t39, +._2pbp, ._5rou:first-child, ._egf:first-child, ._io2, ._3qdi ._48_m::after, ._46dd::before, +._15n_, ._3-2-, ._27ve, ._2s20, ._gui, ._2s21 > *::after, ._32qk, ._d00, ._d01, ._38o9, +._3u9t, ._55fj, .mEventProfileSection.useBorder td, ._3ils, ._5as0, ._5as2, ._5-lw, +._2s1_:before, ._143z::before, ._143z::after, ._4d0x, ._5_gz, ._5_ev, ._63ur, ._6pi8, +._52x1, ._3wjp, ._usq, ._2cul:before, ._13e_, .jewel .flyout, ._3bg5 ._52x6, ._56d8, .al { + border-top: 1px solid $divider !important; +} + +._15ny::after, ._z-w, ._8i2, ._2nk0, ._22_8, ._1t4h, ._37fd, ._1ha, ._3bg5 ._56do, ._8he, +._400s, ._5hoc, ._1bhn, ._5ag6, ._4pvz, ._31y5, ._7gxb, ._-kp, ._6_q3::after, ._3al1, ._4d0w, ._4d0k, +._301x, ._x08 ._x0a:after, ._36dc, ._6-l ._57jn, ._527k, ._g_k, ._7i8v, ._7k1c, ._2_gy, +._577z:not(:last-child) ._ygd, ._3u9u, ._3mgz, ._52x6, ._2066, ._5luf, ._2bdc, ._3ci9, +.mAppCenterFatLabel, .appCenterCategorySelectorButton, ._1q6v, ._5q_r, ._5yt8, ._38do, ._38dt, +._ap1, ._52x1, ._59tu, ._usq, ._13e_, ._59f6._55so::before, ._4gj3, .error, ._35--, ._1wev, +.jx-result, ._1f9d, ._vef, ._55x2 > *, .al, ._44qk, ._5rgs, ._5xuj, ._1sv1, ._idb, ._5_g-, +._5lp5, ._3-2-, ._3to6, ._ir5, ._4nw6, ._4nwh, ._27ve, div._51v6::before, ._5hu6, ._2wn5, ._1ho1, ._1xk6, +._3c9h::before, ._2s20, ._gui, ._5jku, ._2foa, ._2y60, ._5fu3, ._4en9, ._1kb:not(:last-child) ._1kc, +._5pz4, ._5lp4, ._5lp5, ._5h6z, ._5h6x, ._2om4, ._5fjw > div, ._5fjv > :first-child, +._5fjw > :first-child { + border-bottom: 1px solid $divider !important; +} + +.item a.primary.touched .primarywrap, ._4dwt ._5y33, ._1ih_, ._5_50, ._6beq, ._69aj, ._3iyw ._37fb, +._5fjv, ._3on6, ._2u4w, ._2om3, ._2ol-, ._5fjw, ._4z83, ._1gkq, ._4-dy, ._bub { + border-top: 1px solid $divider !important; + border-bottom: 1px solid $divider !important; +} + +//friend card border +._d4i, ._f6s, .mentions-suggest-item, .mentions-suggest, .sharerAttachment, +.mToken, #addMembersTypeahead .mToken.mTokenWeakReference, .mQuestionsPollResultsBar, +._15q7, ._2q7v, ._4dwt ._16ii, ._3qdi::after, ._6q-c, +._2q7w, .acy, ._58ak, ._3t_l, ._4msa, ._3h8i, ._3clk, ._1kt6, ._1ksq, +._1_y5, ._lr0, ._5hgt, ._2cpp, ._50uu, ._50uw, ._31yd, ._1e3d, ._3xz7, ._1xoz, +._4kcb, ._2lut, .jewel .touchable-notification.touched, .touchable-notification .touchable.touched, +.home-notification .touchable.touched, ._6beo ._6ber, ._7kxg, +._73ku ._73jw, ._6--d, ._26vk._56bt, ._3iyw ._2whz ._13-g, ._-jx, +._4e8n, ._uww, .mentions-placeholder, .mentions-shadow, .mentions-measurer, ._517h, ._59pe:focus, ._59pe:hover, +.uiBoxLightblue, .uiBoxWhite, ._558b ._54nc, +._5whq, ._59tt, ._41ft::after, .jx-tokenizer, ._3uqf, ._4756, ._1rrd, ._5n_f { + border: 1px solid $divider !important; +} + +.mQuestionsPollResultsBar .shaded, ._1027._13sm { + border: 1px solid $text !important; +} + +._3gka { + border: 1px dashed $divider !important; +} + +//link card bottom border +._4o58::after, .acr, ._t21, ._2bdb, ._4ks>li, +.acw, .aclb, ._4qax, ._5h8f { + border-color: $divider !important; +} + +// like, comment, share divider +._15ks ._15kl::before { + border-left: 1px solid transparent !important; +} + +._56bf, .touch .btn { + border-radius: 0 !important; + border: 0 !important; +} + +//page side tab layout +._2cis { + border-left: 10px solid $bg_transparent !important; + border-right: 10px solid $bg_transparent !important; +} + +._2cir.selected, ._42rv, ._5zma, ._2x2s { + border-bottom: 3px solid $text !important; +} + +._1ss6 { + border-left: 2px solid $text !important; +} + +._484w.selected > ._6zf, ._5kqs::after, ._3lvo ._5xum._5xuk, ._x0b { + border-bottom: 1px solid $text !important; +} + +._484w.selected ._6zf, ._7gxa, ._2wn2 { + border-bottom: 2px solid $accent !important; +} + +// Small face previews +.facepile .facepileItem.facepileItemOverLapped .facepileItemRound, .facepile .facepileItem.facepileItemOverLapped.facepileItemRound, .facepile .facepileItem.facepileItemOverLapped .facepileMoreDotsRound { + border: 2px solid $bg_opaque2 !important; +} \ No newline at end of file diff --git a/app/src/web/scss/facebook/core/_core_messages.scss b/app/src/web/scss/facebook/core/_core_messages.scss new file mode 100644 index 00000000..aa3c04eb --- /dev/null +++ b/app/src/web/scss/facebook/core/_core_messages.scss @@ -0,0 +1,20 @@ +// Not all message related components are here; only the main ones. +// Borders for instance are merged into core_border + +// Other person's message bubble +._34ee { + background: $background2 !important; + color: $text !important; + +} + +// Your message bubble; order matters +._34em ._34ee { + background: $accent !important; + color: $accent_text !important; +} + +// Sticker page +._5as0, ._5cni, ._5as2 { + background: $bg_opaque !important; +} \ No newline at end of file diff --git a/app/src/web/scss/facebook/core/_core_text.scss b/app/src/web/scss/facebook/core/_core_text.scss new file mode 100644 index 00000000..8ac66758 --- /dev/null +++ b/app/src/web/scss/facebook/core/_core_text.scss @@ -0,0 +1,44 @@ +html, body, input, ._42rv, ._4qau, ._dwm .descArea, ._eu5, +._1tcc, ._3g9-, ._29z_, ._3xz7, ._ib-, ._3bg5 ._56dq, ._477i, ._2vxk, ._29e6, ._8wr8, +.touched *, ._1_yj, ._1_yl, ._4pj9, ._2bdc, ._3qdh ._3qdn ._3qdk, ._3qdk ._48_q, ._7iah, +._z-z, ._z-v, ._1e8d, ._36nl, ._36nm, ._2_11, ._2_rf, ._2ip_, ._403p, .cq, ._usr, #mErrorView .message, +._5xu2, ._3ml8, ._3mla, ._50vk, ._1m2u, ._31y7, ._4kcb, ._1lf6, ._1lf5, ._7-1j, ._4ajz, ._m_1 ._2aha, +._1lf4, ._1hiz, ._xod, ._5ag5, ._zmk, ._3t_h, ._5lm6, ._3clv, ._3zlc, ._36rd, ._6oby, ._6_qk, +._31zk, ._31zl, ._3xsa, ._3xs9, ._2-4s, ._2fzz ul, ._3z10, ._4mo, ._2om6, ._33r5, ._82y3, ._82y1, +._43mh, .touch .btn, .fcg, button, ._52j9, ._52jb, ._52ja, ._5j35, ._ctg, ._5300, ._5302, ._5_o0, +._rnk, ._24u0, ._1g06, ._14ye, .fcb, ._56cz._56c_, ._1gk_, ._55fj, ._45fu, ._7kx4, ._20zd, ._egh, ._egi, +._18qg, ._1_ac, ._529p, ._4dwt ._1vh3, ._4a5f, ._23_t, ._2rzc, ._23_s, ._2rzd, ._6obp, ._2iiu, ._1s06, +._5aga, ._5ag9, ._537a, .acy, ._5ro_, ._6-l ._2us7, ._4mp, ._2b08, ._36e0, ._4-dy, ._55i1, ._2wn6, +._14v5 ._14v8, ._1440, ._1442, ._1448, ._4ks_, .mCount, ._27vc, ._24e1, ._2rbw, ._3iyw ._3mzw, +textarea:not([style*="color: rgb"]), ._24pi, ._4en9, ._1kb, ._5p7j, ._2klz, ._5780, ._5781, ._5782, +._3u9u, ._3u9_, ._3u9s, ._1hcx, ._2066, ._1_-1, ._cv_, ._1nbx, ._2cuh, ._6--d, ._77p7, ._7h_g, +._4ms9, ._4ms5, ._4ms6, ._31b4, ._31b5, ._5q_r, ._idb, ._38d-, ._3n8y, ._38dt, ._3oyg, ._21dc, +.uiStickyPlaceholderInput .placeholder, .mTypeahead span, ._4_d0 ._8-8a, ._6r12, ._5hoa, ._8r-l, +._27vp, ._4nwe, ._4nw9, ._27vi, .appCenterAppInfo, .appCenterPermissions, ._6xqt, ._7cui, ._84lx [style*="color: rgb"], +._3c9l, ._3c9m, ._4jn_, ._32qt, ._3mom, ._3moo, ._-7o, ._d00, ._d01, ._559g, ._7cdj, ._1_yd, ._1_yc, +._2new, .appCenterCategorySelectorButton, ._1ksq, ._1kt6, ._6ber, ._mxb, ._3oyd, ._3gir, ._3gis, +div.sharerSelector, .footer, ._4pv_, ._1dbp, ._3kad, ._20zc, ._2i5v, ._2i5w, ._6zf, ._mhg, +a, ._5fpq, ._4gux, ._3bg5 ._52x1, ._3bg5 ._52x2, ._6dsj ._3gin, ._hdn._hdn, ._3iyw ._2whz ._13-g, +.mentions-input:not([style*="color: rgb"]), .mentions-placeholder:not([style*="color: rgb"]), +.largeStatusBox .placeHolder, .fcw, ._2rgt, ._67i4 ._5hu6 ._59tt, ._2bu3, ._2bu4, ._1ii2, ._1ii3, +._5-7t, .fcl, ._4qas, .thread-title, .title, ._46pa, ._336p, ._1rrd, ._2om4, ._4yxo, ._6m3, ._6m7, ._6m3 ._1t62, +._3m1m, ._2om2, ._5n_e, .appListExplanation, ._5yt8, ._8he, ._2luw, ._5rgs, ._t86 ._t87, ._t86 ._t88, +h1, h2, h3, h4, h5, h6 { + color: $text !important; +} + +// Related to like buttons +a[data-sigil~="unlike"], a[style*="color: rgb(32, 120, 244)"], a[style*="color:#2078f4"], +strong > a, a > ._2vyr, ._15ks ._2q8z._2q8z, ._1e3e, .blueName, ._5kqs ._55sr, ._484w.selected ._6zf, ._6_qj, ._2wn3, +._by_, ._1r05 { + color: $accent !important; +} + +._42nf ._42ng { + color: transparent !important; +} + +// most links do not have a special color. We will highlight those in posts and messages +p > a, .msg span > a { + color: $link !important; +} diff --git a/app/src/web/scss/facebook/core/_main.scss b/app/src/web/scss/facebook/core/_main.scss new file mode 100644 index 00000000..3e972f93 --- /dev/null +++ b/app/src/web/scss/facebook/core/_main.scss @@ -0,0 +1,6 @@ +@import "core"; +@import "svg"; + +//this file is used as the base for all themes +//given that svgs take a lot of characters, we won't compile them when testing +//therefore we use the core scss diff --git a/app/src/web/scss/facebook/core/_svg.scss b/app/src/web/scss/facebook/core/_svg.scss new file mode 100644 index 00000000..9ed25433 --- /dev/null +++ b/app/src/web/scss/facebook/core/_svg.scss @@ -0,0 +1,74 @@ +// icons courtesy of https://material.io/icons/ + +$camera: ''; + +// status upload image +._50uu { + @include background-svg($camera); +} + +$video: ''; + +// status upload video +._50uw { + @include background-svg($video); +} + +$like: ''; +$like_selected: ''; + +// 2018/12/29 +// Previously ._15km ._15ko::before and ._15km ._15ko._77la::before; however, reaction changes no longer affect this element +// The robust measure seems to be the parent of a[data-sigil~="like-reaction-flyout"] along with [data-sigil~="like"] for an unliked post +// and [data-sigil~="unlike"] for a liked post +a._15ko::before { + @include background-svg($like); + background-position: center !important; +} + +a._15ko._77la::before { + @include background-svg($like_selected); + background-position: center !important; +} + +$comment: ''; + +._15km ._15kq::before { + @include background-svg($comment); + background-position: center !important; +} + +$share: ''; + +._15km ._15kr::before { + @include background-svg($share); + background-position: center !important; +} + +$more_horiz: ''; + +//$menus: ".sp_89zNula0Qh5", +//".sp_MP2OtCXORz9", +//".sp_NIWBacTn8LF", +//// 2018/12/31 +//".sp_9ZFVhnFyWsw", +//// 2019/01/03 +//".sp_SJIJjSlGEIO"; +// +//$menu_collector: (); +// +//@each $menu in $menus { +// $menu_collector: append($menu_collector, unquote('#{$menu}'), 'comma'); +// $menu_collector: append($menu_collector, unquote('#{$menu}_2x'), 'comma'); +// $menu_collector: append($menu_collector, unquote('#{$menu}_3x'), 'comma'); +//} +// +//#{$menu_collector} { +// @include background-svg($more_horiz); +// background-position: center !important; +//} + +.story_body_container i.img[data-sigil*="story-popup-context"] { + @include background-svg($more_horiz); + background-position: center !important; +} \ No newline at end of file diff --git a/app/src/web/scss/facebook/core/core.scss b/app/src/web/scss/facebook/core/core.scss new file mode 100644 index 00000000..dd8fd398 --- /dev/null +++ b/app/src/web/scss/facebook/core/core.scss @@ -0,0 +1,54 @@ +@import "../../core/colors"; +@import "../../core/base"; +@import "core_text"; +@import "core_bg"; +@import "core_border"; +@import "core_messages"; + +//GLOBAL overrides; use with caution +*, *::after, *::before { + text-shadow: none !important; + box-shadow: none !important; +} + +// .touch .btnS, button, ._94v, ._590n { +// box-shadow: none !important; +// } + +[data-sigil=m_login_upsell], +[data-sigil="m-loading-indicator-animate m-loading-indicator-root"] { + display: none !important; +} + +@include placeholder { + color: $text !important; +} + +.excessItem { + outline: $divider !important; +} + +._3m1m { + background: linear-gradient(transparent, $bg_opaque) !important; +} + +//new comment +@include keyframes(highlightFade) { + 0%, 50% { + background: $background2; + } + + 100% { + background: $bg_transparent; + } +} + +@include keyframes(chatHighlightAnimation) { + 0%, 100% { + background: $bg_transparent; + } + + 50% { + background: $background2; + } +} diff --git a/app/src/web/scss/facebook/themes/.gitignore b/app/src/web/scss/facebook/themes/.gitignore new file mode 100644 index 00000000..4c46adff --- /dev/null +++ b/app/src/web/scss/facebook/themes/.gitignore @@ -0,0 +1 @@ +test.scss diff --git a/app/src/web/scss/facebook/themes/custom.scss b/app/src/web/scss/facebook/themes/custom.scss new file mode 100644 index 00000000..ab3d0f34 --- /dev/null +++ b/app/src/web/scss/facebook/themes/custom.scss @@ -0,0 +1,2 @@ +@import "../../palette/custom"; +@import "../core/main"; diff --git a/app/src/web/scss/facebook/themes/material_amoled.scss b/app/src/web/scss/facebook/themes/material_amoled.scss new file mode 100644 index 00000000..4b1b5d17 --- /dev/null +++ b/app/src/web/scss/facebook/themes/material_amoled.scss @@ -0,0 +1,2 @@ +@import "../../palette/material_amoled"; +@import "../core/main"; diff --git a/app/src/web/scss/facebook/themes/material_dark.scss b/app/src/web/scss/facebook/themes/material_dark.scss new file mode 100644 index 00000000..badec66d --- /dev/null +++ b/app/src/web/scss/facebook/themes/material_dark.scss @@ -0,0 +1,2 @@ +@import "../../palette/material_dark"; +@import "../core/main"; diff --git a/app/src/web/scss/facebook/themes/material_glass.scss b/app/src/web/scss/facebook/themes/material_glass.scss new file mode 100644 index 00000000..480def7f --- /dev/null +++ b/app/src/web/scss/facebook/themes/material_glass.scss @@ -0,0 +1,2 @@ +@import "../../palette/material_glass"; +@import "../core/main"; diff --git a/app/src/web/scss/facebook/themes/material_light.scss b/app/src/web/scss/facebook/themes/material_light.scss new file mode 100644 index 00000000..2a84f449 --- /dev/null +++ b/app/src/web/scss/facebook/themes/material_light.scss @@ -0,0 +1,2 @@ +@import "../../palette/material_light"; +@import "../core/main"; \ No newline at end of file diff --git a/app/src/web/scss/messenger/core/_core_bg.scss b/app/src/web/scss/messenger/core/_core_bg.scss new file mode 100644 index 00000000..e69de29b diff --git a/app/src/web/scss/messenger/core/_core_border.scss b/app/src/web/scss/messenger/core/_core_border.scss new file mode 100644 index 00000000..e69de29b diff --git a/app/src/web/scss/messenger/core/_core_text.scss b/app/src/web/scss/messenger/core/_core_text.scss new file mode 100644 index 00000000..e69de29b diff --git a/app/src/web/scss/messenger/core/_main.scss b/app/src/web/scss/messenger/core/_main.scss new file mode 100644 index 00000000..e5da5377 --- /dev/null +++ b/app/src/web/scss/messenger/core/_main.scss @@ -0,0 +1,3 @@ +@import "core"; + +//this file is used as the base for all messenger themes diff --git a/app/src/web/scss/messenger/core/core.scss b/app/src/web/scss/messenger/core/core.scss new file mode 100644 index 00000000..f6a92475 --- /dev/null +++ b/app/src/web/scss/messenger/core/core.scss @@ -0,0 +1,5 @@ +@import "../../core/colors"; +@import "../../core/base"; +@import "core_text"; +@import "core_bg"; +@import "core_border"; \ No newline at end of file diff --git a/app/src/web/scss/messenger/themes/.gitignore b/app/src/web/scss/messenger/themes/.gitignore new file mode 100644 index 00000000..4c46adff --- /dev/null +++ b/app/src/web/scss/messenger/themes/.gitignore @@ -0,0 +1 @@ +test.scss diff --git a/app/src/web/scss/messenger/themes/custom.scss b/app/src/web/scss/messenger/themes/custom.scss new file mode 100644 index 00000000..ab3d0f34 --- /dev/null +++ b/app/src/web/scss/messenger/themes/custom.scss @@ -0,0 +1,2 @@ +@import "../../palette/custom"; +@import "../core/main"; diff --git a/app/src/web/scss/messenger/themes/material_amoled.scss b/app/src/web/scss/messenger/themes/material_amoled.scss new file mode 100644 index 00000000..4b1b5d17 --- /dev/null +++ b/app/src/web/scss/messenger/themes/material_amoled.scss @@ -0,0 +1,2 @@ +@import "../../palette/material_amoled"; +@import "../core/main"; diff --git a/app/src/web/scss/messenger/themes/material_dark.scss b/app/src/web/scss/messenger/themes/material_dark.scss new file mode 100644 index 00000000..badec66d --- /dev/null +++ b/app/src/web/scss/messenger/themes/material_dark.scss @@ -0,0 +1,2 @@ +@import "../../palette/material_dark"; +@import "../core/main"; diff --git a/app/src/web/scss/messenger/themes/material_glass.scss b/app/src/web/scss/messenger/themes/material_glass.scss new file mode 100644 index 00000000..480def7f --- /dev/null +++ b/app/src/web/scss/messenger/themes/material_glass.scss @@ -0,0 +1,2 @@ +@import "../../palette/material_glass"; +@import "../core/main"; diff --git a/app/src/web/scss/messenger/themes/material_light.scss b/app/src/web/scss/messenger/themes/material_light.scss new file mode 100644 index 00000000..2a84f449 --- /dev/null +++ b/app/src/web/scss/messenger/themes/material_light.scss @@ -0,0 +1,2 @@ +@import "../../palette/material_light"; +@import "../core/main"; \ No newline at end of file diff --git a/app/src/web/scss/palette/_custom.scss b/app/src/web/scss/palette/_custom.scss new file mode 100644 index 00000000..b35bdfa1 --- /dev/null +++ b/app/src/web/scss/palette/_custom.scss @@ -0,0 +1,12 @@ +$bg_transparent: unquote('$BT$'); +$text: unquote('$T$'); +$link: unquote('$TT$'); +$accent: unquote('$A$'); +$accent_text: unquote('$AT$'); +$background: unquote('$B$'); +$background2: unquote('$BBT$'); +$bg_opaque: unquote('$O$'); +$bg_opaque2: unquote('$OO$'); +$divider: unquote('$D$'); +$card: unquote('$C$'); +$tint: unquote('$TI$'); diff --git a/app/src/web/scss/palette/_material_amoled.scss b/app/src/web/scss/palette/_material_amoled.scss new file mode 100644 index 00000000..3eca36bc --- /dev/null +++ b/app/src/web/scss/palette/_material_amoled.scss @@ -0,0 +1,9 @@ +$text: #fff; +$accent_text: #fff; +$link: #5d86dd; +$accent: #5d86dd; +$background: #000; +$background2: rgba($background, 0.35); +$bg_transparent: $background; +$card: $background2; +$tint: rgba(#fff, 0.2); diff --git a/app/src/web/scss/palette/_material_dark.scss b/app/src/web/scss/palette/_material_dark.scss new file mode 100644 index 00000000..a27627c0 --- /dev/null +++ b/app/src/web/scss/palette/_material_dark.scss @@ -0,0 +1,8 @@ +$text: #fff; +$accent_text: #fff; +$link: #5d86dd; +$accent: #5d86dd; +$background: #303030; +$bg_transparent: $background; +$card: #353535; +$tint: rgba(#fff, 0.2); diff --git a/app/src/web/scss/palette/_material_glass.scss b/app/src/web/scss/palette/_material_glass.scss new file mode 100644 index 00000000..c9e399e7 --- /dev/null +++ b/app/src/web/scss/palette/_material_glass.scss @@ -0,0 +1,8 @@ +$text: #fff; +$accent_text: #fff; +$link: #5d86dd; +$accent: #5d86dd; +$background: rgba(#000, 0.1); +$bg_transparent: transparent; +$card: rgba(#000, 0.25); +$tint: rgba(#fff, 0.15); \ No newline at end of file diff --git a/app/src/web/scss/palette/_material_light.scss b/app/src/web/scss/palette/_material_light.scss new file mode 100644 index 00000000..2a799180 --- /dev/null +++ b/app/src/web/scss/palette/_material_light.scss @@ -0,0 +1,13 @@ +$text: #000; +$accent_text: #fff; +$link: #3b5998; +$accent: #3b5998; +$background: #fafafa; +// this is actually the inverse of material light (bg should be gray, cards should be white), +// but it looks better than the alternative +$background2: rgba(darken($background, 8%), 0.35); + +$bg_transparent: $background; + +$card: #fff; +$tint: #ddd; \ No newline at end of file diff --git a/app/src/web/scss/themes/.gitignore b/app/src/web/scss/themes/.gitignore deleted file mode 100644 index 4c46adff..00000000 --- a/app/src/web/scss/themes/.gitignore +++ /dev/null @@ -1 +0,0 @@ -test.scss diff --git a/app/src/web/scss/themes/custom.scss b/app/src/web/scss/themes/custom.scss deleted file mode 100644 index 50c029fb..00000000 --- a/app/src/web/scss/themes/custom.scss +++ /dev/null @@ -1,14 +0,0 @@ -$bg_transparent: unquote('$BT$'); -$text: unquote('$T$'); -$link: unquote('$TT$'); -$accent: unquote('$A$'); -$accent_text: unquote('$AT$'); -$background: unquote('$B$'); -$background2: unquote('$BBT$'); -$bg_opaque: unquote('$O$'); -$bg_opaque2: unquote('$OO$'); -$divider: unquote('$D$'); -$card: unquote('$C$'); -$tint: unquote('$TI$'); - -@import "../core/main"; diff --git a/app/src/web/scss/themes/material_amoled.scss b/app/src/web/scss/themes/material_amoled.scss deleted file mode 100644 index 19190126..00000000 --- a/app/src/web/scss/themes/material_amoled.scss +++ /dev/null @@ -1,11 +0,0 @@ -$text: #fff; -$accent_text: #fff; -$link: #5d86dd; -$accent: #5d86dd; -$background: #000; -$background2: rgba($background, 0.35); -$bg_transparent: $background; -$card: $background2; -$tint: rgba(#fff, 0.2); - -@import "../core/main"; diff --git a/app/src/web/scss/themes/material_dark.scss b/app/src/web/scss/themes/material_dark.scss deleted file mode 100644 index 18b8b461..00000000 --- a/app/src/web/scss/themes/material_dark.scss +++ /dev/null @@ -1,10 +0,0 @@ -$text: #fff; -$accent_text: #fff; -$link: #5d86dd; -$accent: #5d86dd; -$background: #303030; -$bg_transparent: $background; -$card: #353535; -$tint: rgba(#fff, 0.2); - -@import "../core/main"; diff --git a/app/src/web/scss/themes/material_glass.scss b/app/src/web/scss/themes/material_glass.scss deleted file mode 100644 index 0c61a38c..00000000 --- a/app/src/web/scss/themes/material_glass.scss +++ /dev/null @@ -1,10 +0,0 @@ -$text: #fff; -$accent_text: #fff; -$link: #5d86dd; -$accent: #5d86dd; -$background: rgba(#000, 0.1); -$bg_transparent: transparent; -$card: rgba(#000, 0.25); -$tint: rgba(#fff, 0.15); - -@import "../core/main"; diff --git a/app/src/web/scss/themes/material_light.scss b/app/src/web/scss/themes/material_light.scss deleted file mode 100644 index 7ec58463..00000000 --- a/app/src/web/scss/themes/material_light.scss +++ /dev/null @@ -1,15 +0,0 @@ -$text: #000; -$accent_text: #fff; -$link: #3b5998; -$accent: #3b5998; -$background: #fafafa; -// this is actually the inverse of material light (bg should be gray, cards should be white), -// but it looks better than the alternative -$background2: rgba(darken($background, 8%), 0.35); - -$bg_transparent: $background; - -$card: #fff; -$tint: #ddd; - -@import "../core/main"; \ No newline at end of file -- cgit v1.2.3 From fd2cbf25f5744a939ef6245809a1655e013a6420 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 10 Jan 2021 22:29:01 -0800 Subject: Start converting pref colors into themeProvider colors --- .../kotlin/com/pitchedapps/frost/FrostTestApp.kt | 4 +- .../main/kotlin/com/pitchedapps/frost/FrostApp.kt | 4 +- .../frost/activities/BaseMainActivity.kt | 2 +- .../pitchedapps/frost/activities/DebugActivity.kt | 2 +- .../pitchedapps/frost/activities/ImageActivity.kt | 2 +- .../pitchedapps/frost/activities/LoginActivity.kt | 2 +- .../frost/activities/SelectorActivity.kt | 2 +- .../frost/activities/SettingsActivity.kt | 2 + .../frost/activities/TabCustomizerActivity.kt | 2 +- .../frost/activities/WebOverlayActivity.kt | 2 +- .../kotlin/com/pitchedapps/frost/enums/Theme.kt | 30 +++-- .../com/pitchedapps/frost/injectors/CssAsset.kt | 36 +++++ .../com/pitchedapps/frost/injectors/CssAssets.kt | 115 ---------------- .../pitchedapps/frost/injectors/CssSmallAssets.kt | 36 ----- .../pitchedapps/frost/injectors/ThemeProvider.kt | 146 +++++++++++++++++++++ .../pitchedapps/frost/prefs/sections/ThemePrefs.kt | 2 +- .../com/pitchedapps/frost/settings/Appearance.kt | 6 +- .../kotlin/com/pitchedapps/frost/utils/Utils.kt | 11 +- .../com/pitchedapps/frost/web/DebugWebView.kt | 4 +- .../pitchedapps/frost/web/FrostWebViewClients.kt | 4 +- .../pitchedapps/frost/injectors/CssAssetsTest.kt | 32 ----- .../frost/injectors/ThemeProviderTest.kt | 32 +++++ 22 files changed, 265 insertions(+), 213 deletions(-) create mode 100644 app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAsset.kt delete mode 100644 app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt delete mode 100644 app/src/main/kotlin/com/pitchedapps/frost/injectors/CssSmallAssets.kt create mode 100644 app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt delete mode 100644 app/src/test/kotlin/com/pitchedapps/frost/injectors/CssAssetsTest.kt create mode 100644 app/src/test/kotlin/com/pitchedapps/frost/injectors/ThemeProviderTest.kt diff --git a/app/src/androidTest/kotlin/com/pitchedapps/frost/FrostTestApp.kt b/app/src/androidTest/kotlin/com/pitchedapps/frost/FrostTestApp.kt index 5103a0cf..9d0caae6 100644 --- a/app/src/androidTest/kotlin/com/pitchedapps/frost/FrostTestApp.kt +++ b/app/src/androidTest/kotlin/com/pitchedapps/frost/FrostTestApp.kt @@ -23,6 +23,7 @@ import ca.allanwang.kau.kpref.KPrefFactory import ca.allanwang.kau.kpref.KPrefFactoryInMemory import com.pitchedapps.frost.db.FrostDatabase import com.pitchedapps.frost.facebook.FbCookie +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.prefs.Prefs import org.junit.rules.TestRule import org.junit.runner.Description @@ -70,7 +71,8 @@ class FrostTestApp : Application() { FrostDatabase.module(), prefFactoryModule(), Prefs.module(), - FbCookie.module() + FbCookie.module(), + ThemeProvider.module() ) ) } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt index 40333d25..059b2a0e 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt @@ -26,6 +26,7 @@ import ca.allanwang.kau.logging.KL import ca.allanwang.kau.utils.buildIsLollipopAndUp import com.pitchedapps.frost.db.FrostDatabase import com.pitchedapps.frost.facebook.FbCookie +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.services.scheduleNotificationsFromPrefs import com.pitchedapps.frost.services.setupNotificationChannels @@ -58,7 +59,8 @@ class FrostApp : Application(), KoinComponent { FrostDatabase.module(), prefFactoryModule(), Prefs.module(), - FbCookie.module() + FbCookie.module(), + ThemeProvider.module() ) ) } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt index 0cb037a5..e352b2fc 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt @@ -202,7 +202,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, } drawerWrapperBinding.mainContainer.addView(contentBinding.root) with(contentBinding) { - setFrostColors(prefs) { + setFrostColors { toolbar(toolbar) themeWindow = false header(appbar) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt index 54baa184..6067fa82 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt @@ -71,7 +71,7 @@ class DebugActivity : KauBaseActivity() { } setTitle(R.string.debug_frost) - setFrostColors(prefs) { + setFrostColors { toolbar(toolbar) } debugWebview.loadUrl(FbItem.FEED.url) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt index bcfd9c99..ea81bcde 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt @@ -222,7 +222,7 @@ class ImageActivity : KauBaseActivity() { loadError(e) } }) - setFrostColors(prefs) { + setFrostColors { themeWindow = false } dragHelper = ViewDragHelper.create(imageDrag, ViewDragCallback()).apply { diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt index be53f2c2..601516de 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt @@ -80,7 +80,7 @@ class LoginActivity : BaseActivity() { setContentView(R.layout.activity_login) setSupportActionBar(toolbar) setTitle(R.string.kau_login) - setFrostColors(prefs) { + setFrostColors { toolbar(toolbar) } profileLoader = GlideApp.with(profile) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/SelectorActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/SelectorActivity.kt index a0e3ae42..33215c7e 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/SelectorActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/SelectorActivity.kt @@ -67,7 +67,7 @@ class SelectorActivity : BaseActivity() { } } }) - setFrostColors(prefs) { + setFrostColors { text(text) background(container) } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt index a016ca22..ee0cd669 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt @@ -43,6 +43,7 @@ import com.pitchedapps.frost.R import com.pitchedapps.frost.db.NotificationDao import com.pitchedapps.frost.enums.Support import com.pitchedapps.frost.facebook.FbCookie +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.settings.getAppearancePrefs import com.pitchedapps.frost.settings.getBehaviourPrefs @@ -73,6 +74,7 @@ class SettingsActivity : KPrefActivity() { val fbCookie: FbCookie by inject() val notifDao: NotificationDao by inject() val prefs: Prefs by inject() + val themeProvider: ThemeProvider by inject() private var resultFlag = Activity.RESULT_CANCELED diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/TabCustomizerActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/TabCustomizerActivity.kt index 11126803..589289ab 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/TabCustomizerActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/TabCustomizerActivity.kt @@ -107,7 +107,7 @@ class TabCustomizerActivity : BaseActivity() { fabCancel.setIcon(GoogleMaterial.Icon.gmd_close, prefs.iconColor) fabCancel.backgroundTintList = ColorStateList.valueOf(prefs.accentColor) fabCancel.setOnClickListener { finish() } - setFrostColors(prefs) { + setFrostColors { themeWindow = true } } 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 abc07d57..c21f7362 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt @@ -205,7 +205,7 @@ abstract class WebOverlayActivityBase(private val userAgent: String = USER_AGENT toolbar.navigationIcon = GoogleMaterial.Icon.gmd_close.toDrawable(this, 16, prefs.iconColor) toolbar.setNavigationOnClickListener { finishSlideOut() } - setFrostColors(prefs) { + setFrostColors { toolbar(toolbar) themeWindow = false } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/enums/Theme.kt b/app/src/main/kotlin/com/pitchedapps/frost/enums/Theme.kt index bb2514f5..3dccc446 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/enums/Theme.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/enums/Theme.kt @@ -18,11 +18,10 @@ package com.pitchedapps.frost.enums import android.graphics.Color import androidx.annotation.StringRes +import androidx.annotation.VisibleForTesting import com.pitchedapps.frost.R -import com.pitchedapps.frost.injectors.CssAssets -import com.pitchedapps.frost.injectors.InjectorContract -import com.pitchedapps.frost.injectors.JsActions import com.pitchedapps.frost.prefs.sections.ThemePrefs +import java.util.Locale /** * Created by Allan Wang on 2017-06-14. @@ -32,7 +31,7 @@ const val BLUE_LIGHT = 0xff5d86dd.toInt() enum class Theme( @StringRes val textRes: Int, - val injector: InjectorContract, + file: String?, val textColorGetter: (ThemePrefs) -> Int, val accentColorGetter: (ThemePrefs) -> Int, val backgroundColorGetter: (ThemePrefs) -> Int, @@ -41,7 +40,7 @@ enum class Theme( ) { DEFAULT(R.string.kau_default, - JsActions.EMPTY, + null, { 0xde000000.toInt() }, { FACEBOOK_BLUE }, { 0xfffafafa.toInt() }, @@ -49,7 +48,7 @@ enum class Theme( { Color.WHITE }), LIGHT(R.string.kau_light, - CssAssets.MATERIAL_LIGHT, + "material_light", { 0xde000000.toInt() }, { FACEBOOK_BLUE }, { 0xfffafafa.toInt() }, @@ -57,7 +56,7 @@ enum class Theme( { Color.WHITE }), DARK(R.string.kau_dark, - CssAssets.MATERIAL_DARK, + "material_dark", { Color.WHITE }, { BLUE_LIGHT }, { 0xff303030.toInt() }, @@ -65,7 +64,7 @@ enum class Theme( { Color.WHITE }), AMOLED(R.string.kau_amoled, - CssAssets.MATERIAL_AMOLED, + "material_amoled", { Color.WHITE }, { BLUE_LIGHT }, { Color.BLACK }, @@ -73,7 +72,7 @@ enum class Theme( { Color.WHITE }), GLASS(R.string.kau_glass, - CssAssets.MATERIAL_GLASS, + "material_glass", { Color.WHITE }, { BLUE_LIGHT }, { 0x80000000.toInt() }, @@ -81,15 +80,26 @@ enum class Theme( { Color.WHITE }), CUSTOM(R.string.kau_custom, - CssAssets.CUSTOM, + "custom", { it.customTextColor }, { it.customAccentColor }, { it.customBackgroundColor }, { it.customHeaderColor }, { it.customIconColor }); + @VisibleForTesting + internal val file = file?.let { "${it}.css" } + companion object { val values = values() // save one instance operator fun invoke(index: Int) = values[index] } } + +enum class ThemeCategory { + FACEBOOK, MESSENGER + ; + + @VisibleForTesting + internal val folder = name.toLowerCase(Locale.CANADA) +} diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAsset.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAsset.kt new file mode 100644 index 00000000..b384efad --- /dev/null +++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAsset.kt @@ -0,0 +1,36 @@ +/* + * 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 +import com.pitchedapps.frost.prefs.Prefs + +/** + * Small misc inline css assets + */ +enum class CssAsset(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) + } +} diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt deleted file mode 100644 index e012de3f..00000000 --- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 2018 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.content.Context -import android.graphics.Color -import android.webkit.WebView -import androidx.annotation.VisibleForTesting -import ca.allanwang.kau.utils.adjustAlpha -import ca.allanwang.kau.utils.colorToBackground -import ca.allanwang.kau.utils.colorToForeground -import ca.allanwang.kau.utils.toRgbaString -import ca.allanwang.kau.utils.use -import ca.allanwang.kau.utils.withAlpha -import com.pitchedapps.frost.prefs.Prefs -import com.pitchedapps.frost.utils.L -import java.io.BufferedReader -import java.io.FileNotFoundException -import java.util.Locale -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.withContext - -private const val THEME_FOLDER = "themes" - -/** - * Created by Allan Wang on 2017-05-31. - * Mapping of the available assets - * The enum name must match the css file name - */ -enum class CssAssets(val folder: String = THEME_FOLDER) : InjectorContract { - MATERIAL_LIGHT, MATERIAL_DARK, MATERIAL_AMOLED, MATERIAL_GLASS, CUSTOM - ; - - @VisibleForTesting - internal val file = "${name.toLowerCase(Locale.CANADA)}.css" - - /** - * Note that while this can be loaded from any thread, it is typically done through [load] - */ - private var injector: JsInjector? = null - - private fun injector(context: Context, prefs: Prefs): JsInjector = - injector ?: createInjector(context, prefs).also { injector = it } - - /** - * Note that while this can be loaded from any thread, it is typically done through [load] - */ - private fun createInjector(context: Context, prefs: Prefs): JsInjector = - try { - var content = - context.assets.open("css/$folder/$file").bufferedReader() - .use(BufferedReader::readText) - if (this == CUSTOM) { - val bt = if (Color.alpha(prefs.bgColor) == 255) - prefs.bgColor.toRgbaString() - else - "transparent" - - val bb = prefs.bgColor.colorToForeground(0.35f) - - content = content - .replace("\$T\$", prefs.textColor.toRgbaString()) - .replace("\$TT\$", prefs.textColor.colorToBackground(0.05f).toRgbaString()) - .replace("\$A\$", prefs.accentColor.toRgbaString()) - .replace("\$AT\$", prefs.iconColor.toRgbaString()) - .replace("\$B\$", prefs.bgColor.toRgbaString()) - .replace("\$BT\$", bt) - .replace("\$BBT\$", bb.withAlpha(51).toRgbaString()) - .replace("\$O\$", prefs.bgColor.withAlpha(255).toRgbaString()) - .replace("\$OO\$", bb.withAlpha(255).toRgbaString()) - .replace("\$D\$", prefs.textColor.adjustAlpha(0.3f).toRgbaString()) - .replace("\$TI\$", bb.withAlpha(60).toRgbaString()) - .replace("\$C\$", bt) - } - JsBuilder().css(content).build() - } catch (e: FileNotFoundException) { - L.e(e) { "CssAssets file not found" } - JsInjector(JsActions.EMPTY.function) - } - - override fun inject(webView: WebView, prefs: Prefs) = - injector(webView.context, prefs).inject(webView, prefs) - - fun reset() { - injector = null - } - - companion object { - - // Ensures that all non themes and the selected theme are loaded - suspend fun load(context: Context, prefs: Prefs) { - withContext(Dispatchers.IO) { - val currentTheme = prefs.themeInjector as? CssAssets - val (themes, others) = values().partition { it.folder == THEME_FOLDER } - themes.filter { it != currentTheme }.forEach { it.reset() } - currentTheme?.injector(context, prefs) - others.forEach { it.injector(context, prefs) } - } - } - } -} \ No newline at end of file diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssSmallAssets.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssSmallAssets.kt deleted file mode 100644 index 30ee7a8f..00000000 --- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssSmallAssets.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 -import com.pitchedapps.frost.prefs.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) - } -} diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt new file mode 100644 index 00000000..5a9576d2 --- /dev/null +++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt @@ -0,0 +1,146 @@ +/* + * Copyright 2018 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.content.Context +import android.graphics.Color +import ca.allanwang.kau.utils.adjustAlpha +import ca.allanwang.kau.utils.colorToBackground +import ca.allanwang.kau.utils.colorToForeground +import ca.allanwang.kau.utils.isColorVisibleOn +import ca.allanwang.kau.utils.toRgbaString +import ca.allanwang.kau.utils.use +import ca.allanwang.kau.utils.withAlpha +import com.pitchedapps.frost.enums.FACEBOOK_BLUE +import com.pitchedapps.frost.enums.Theme +import com.pitchedapps.frost.enums.ThemeCategory +import com.pitchedapps.frost.prefs.Prefs +import com.pitchedapps.frost.utils.L +import java.io.BufferedReader +import java.io.FileNotFoundException +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext + +/** + * Created by Allan Wang on 2017-05-31. + * Mapping of the available assets + * The enum name must match the css file name + */ +class ThemeProvider(private val context: Context, private val prefs: Prefs) { + + var theme: Theme = Theme.values[prefs.theme] + + private val injectors: MutableMap = mutableMapOf() + + val textColor: Int + get() = theme.textColorGetter(prefs) + + val accentColor: Int + get() = theme.accentColorGetter(prefs) + + val accentColorForWhite: Int + get() = when { + accentColor.isColorVisibleOn(Color.WHITE) -> accentColor + textColor.isColorVisibleOn(Color.WHITE) -> textColor + else -> FACEBOOK_BLUE + } + + val nativeBgColor: Int + get() = bgColor.withAlpha(30) + + fun nativeBgColor(unread: Boolean) = bgColor + .colorToForeground(if (unread) 0.7f else 0.0f) + .withAlpha(30) + + val bgColor: Int + get() = theme.backgroundColorGetter(prefs) + + val headerColor: Int + get() = theme.headerColorGetter(prefs) + + val iconColor: Int + get() = theme.iconColorGetter(prefs) + + val isCustomTheme: Boolean + get() = theme == Theme.CUSTOM + + /** + * Note that while this can be loaded from any thread, it is typically done through [preload]] + */ + fun injector(category: ThemeCategory): InjectorContract = + injectors.getOrPut(category) { createInjector(category) } + + /** + * Note that while this can be loaded from any thread, it is typically done through [preload] + */ + private fun createInjector(category: ThemeCategory): InjectorContract { + val file = theme.file ?: return JsActions.EMPTY + try { + var content = + context.assets.open("css/${category.folder}/theme/${file}").bufferedReader() + .use(BufferedReader::readText) + if (theme == Theme.CUSTOM) { + val bt = if (Color.alpha(prefs.bgColor) == 255) + prefs.bgColor.toRgbaString() + else + "transparent" + + val bb = prefs.bgColor.colorToForeground(0.35f) + + content = content + .replace("\$T\$", prefs.textColor.toRgbaString()) + .replace("\$TT\$", prefs.textColor.colorToBackground(0.05f).toRgbaString()) + .replace("\$A\$", prefs.accentColor.toRgbaString()) + .replace("\$AT\$", prefs.iconColor.toRgbaString()) + .replace("\$B\$", prefs.bgColor.toRgbaString()) + .replace("\$BT\$", bt) + .replace("\$BBT\$", bb.withAlpha(51).toRgbaString()) + .replace("\$O\$", prefs.bgColor.withAlpha(255).toRgbaString()) + .replace("\$OO\$", bb.withAlpha(255).toRgbaString()) + .replace("\$D\$", prefs.textColor.adjustAlpha(0.3f).toRgbaString()) + .replace("\$TI\$", bb.withAlpha(60).toRgbaString()) + .replace("\$C\$", bt) + } + return JsBuilder().css(content).build() + } catch (e: FileNotFoundException) { + L.e(e) { "CssAssets file not found" } + return JsActions.EMPTY + } + } + + fun setTheme(id: Int) { + theme = Theme.values[id] + reset() + } + + fun reset() { + injectors.clear() + } + + suspend fun preload() { + withContext(Dispatchers.IO) { + reset() + ThemeCategory.values().forEach { injector(it) } + } + } + + companion object { + fun module() = org.koin.dsl.module { + single { ThemeProvider(get(), get()) } + } + } +} \ No newline at end of file diff --git a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ThemePrefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ThemePrefs.kt index 84f64435..a5a66ee9 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ThemePrefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ThemePrefs.kt @@ -106,7 +106,7 @@ class ThemePrefsImpl( private val loader = lazyResettable { Theme.values[theme] } - private val t: Theme by loader + val t: Theme by loader override val textColor: Int get() = t.textColorGetter(this) 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 65e24ab8..a5f7ec28 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt @@ -27,7 +27,7 @@ import com.pitchedapps.frost.R import com.pitchedapps.frost.activities.SettingsActivity import com.pitchedapps.frost.enums.MainActivityLayout import com.pitchedapps.frost.enums.Theme -import com.pitchedapps.frost.injectors.CssAssets +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.utils.REQUEST_NAV import com.pitchedapps.frost.utils.REQUEST_TEXT_ZOOM import com.pitchedapps.frost.utils.frostEvent @@ -44,7 +44,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; themeProvider.setTheme(it) }) { onClick = { materialDialog { title(R.string.theme) @@ -76,7 +76,7 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = { } fun invalidateCustomTheme() { - CssAssets.CUSTOM.reset() + themeProvider.reset() } colorPicker(R.string.text_color, prefs::customTextColor, { 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 ebefa4ca..63483da0 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -67,7 +67,7 @@ import com.pitchedapps.frost.facebook.FbUrlFormatter.Companion.VIDEO_REDIRECT import com.pitchedapps.frost.facebook.USER_AGENT import com.pitchedapps.frost.facebook.formattedFbUri import com.pitchedapps.frost.facebook.formattedFbUrl -import com.pitchedapps.frost.injectors.CssAssets +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.injectors.JsAssets import com.pitchedapps.frost.prefs.Prefs import java.io.File @@ -84,6 +84,8 @@ import org.apache.commons.text.StringEscapeUtils import org.jsoup.Jsoup import org.jsoup.nodes.Document import org.jsoup.nodes.Element +import org.koin.core.component.KoinComponent +import org.koin.core.component.inject /** * Created by Allan Wang on 2017-06-03. @@ -191,7 +193,10 @@ fun Activity.setFrostTheme(prefs: Prefs, forceTransparent: Boolean = false) { } } -class ActivityThemeUtils(val prefs: Prefs) { +class ActivityThemeUtils : KoinComponent { + + private val prefs: Prefs by inject() + private val themeProvider: ThemeProvider by inject() private var toolbar: Toolbar? = null var themeWindow = true @@ -455,6 +460,6 @@ fun String.unescapeHtml(): String = .replace("\\\"", "\"") suspend fun Context.loadAssets(prefs: Prefs): Unit = coroutineScope { - CssAssets.load(this@loadAssets, prefs) + ThemeProvider.load(this@loadAssets, prefs) JsAssets.load(this@loadAssets) } 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 17ab77a7..c68d3f57 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt @@ -26,7 +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.CssAsset import com.pitchedapps.frost.injectors.jsInject import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.L @@ -117,7 +117,7 @@ class DebugWebView @JvmOverloads constructor( (url?.contains("?sk=h_chr") ?: false) && prefs.aggressiveRecents ), - CssSmallAssets.FullSizeImage.maybe(prefs.fullSizeImage), + CssAsset.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 324af69b..cf248baf 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt @@ -29,7 +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.CssAsset import com.pitchedapps.frost.injectors.JsActions import com.pitchedapps.frost.injectors.JsAssets import com.pitchedapps.frost.injectors.jsInject @@ -118,7 +118,7 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() { CssHider.ADS.maybe(!prefs.showFacebookAds), CssHider.POST_ACTIONS.maybe(!prefs.showPostActions), CssHider.POST_REACTIONS.maybe(!prefs.showPostReactions), - CssSmallAssets.FullSizeImage.maybe(prefs.fullSizeImage), + CssAsset.FullSizeImage.maybe(prefs.fullSizeImage), JsAssets.DOCUMENT_WATCHER, JsAssets.HORIZONTAL_SCROLLING, JsAssets.AUTO_RESIZE_TEXTAREA.maybe(prefs.autoExpandTextBox), diff --git a/app/src/test/kotlin/com/pitchedapps/frost/injectors/CssAssetsTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/injectors/CssAssetsTest.kt deleted file mode 100644 index 8894e5b6..00000000 --- a/app/src/test/kotlin/com/pitchedapps/frost/injectors/CssAssetsTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2019 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 java.io.File -import kotlin.test.Test -import kotlin.test.assertTrue - -class CssAssetsTest { - - @Test - fun verifyAssetsExist() { - CssAssets.values().forEach { asset -> - val file = File("src/web/assets/css/${asset.folder}/${asset.file}").absoluteFile - assertTrue(file.exists(), "${asset.name} not found at ${file.path}") - } - } -} diff --git a/app/src/test/kotlin/com/pitchedapps/frost/injectors/ThemeProviderTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/injectors/ThemeProviderTest.kt new file mode 100644 index 00000000..f59980d2 --- /dev/null +++ b/app/src/test/kotlin/com/pitchedapps/frost/injectors/ThemeProviderTest.kt @@ -0,0 +1,32 @@ +/* + * Copyright 2019 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 java.io.File +import kotlin.test.Test +import kotlin.test.assertTrue + +class ThemeProviderTest { + + @Test + fun verifyAssetsExist() { + ThemeProvider.values().forEach { asset -> + val file = File("src/web/assets/css/${asset.folder}/${asset.file}").absoluteFile + assertTrue(file.exists(), "${asset.name} not found at ${file.path}") + } + } +} -- cgit v1.2.3 From 0e5c1ab2dd2b574970883576e18f9a119b058788 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 12 Jan 2021 20:46:02 -0800 Subject: Create themeprovider --- .../kotlin/com/pitchedapps/frost/StartActivity.kt | 4 +++- .../pitchedapps/frost/activities/IntroActivity.kt | 4 +++- .../frost/activities/SettingsActivity.kt | 2 +- .../kotlin/com/pitchedapps/frost/enums/Theme.kt | 2 +- .../com/pitchedapps/frost/facebook/FbConst.kt | 4 +++- .../com/pitchedapps/frost/facebook/FbCookie.kt | 2 +- .../pitchedapps/frost/injectors/ThemeProvider.kt | 20 ++++++++-------- .../pitchedapps/frost/prefs/sections/ThemePrefs.kt | 6 ----- .../com/pitchedapps/frost/settings/Appearance.kt | 1 - .../kotlin/com/pitchedapps/frost/utils/Utils.kt | 28 +++++++++++----------- .../com/pitchedapps/frost/views/FrostWebView.kt | 2 ++ .../com/pitchedapps/frost/web/DebugWebView.kt | 7 ++++-- .../pitchedapps/frost/web/FrostWebViewClients.kt | 7 ++++-- .../com/pitchedapps/frost/web/LoginWebView.kt | 5 +++- 14 files changed, 52 insertions(+), 42 deletions(-) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt index b2031f96..3248eb14 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt @@ -37,6 +37,7 @@ import com.pitchedapps.frost.db.CookieEntity import com.pitchedapps.frost.db.GenericDao import com.pitchedapps.frost.db.selectAll import com.pitchedapps.frost.facebook.FbCookie +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.BiometricUtils import com.pitchedapps.frost.utils.EXTRA_COOKIES @@ -54,6 +55,7 @@ class StartActivity : KauBaseActivity() { private val fbCookie: FbCookie by inject() private val prefs: Prefs by inject() + private val themeProvider: ThemeProvider by inject() private val cookieDao: CookieDao by inject() private val genericDao: GenericDao by inject() @@ -85,7 +87,7 @@ class StartActivity : KauBaseActivity() { transform = CookieEntity::toSensitiveString )}" } - loadAssets(prefs) + loadAssets(themeProvider) authDefer.await() when { cookies.isEmpty() -> launchNewTask() diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt index 337c9678..e8e603ba 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt @@ -39,6 +39,7 @@ import ca.allanwang.kau.utils.statusBarColor import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial import com.pitchedapps.frost.R import com.pitchedapps.frost.databinding.ActivityIntroBinding +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.intro.BaseIntroFragment import com.pitchedapps.frost.intro.IntroAccountFragment import com.pitchedapps.frost.intro.IntroFragmentEnd @@ -66,6 +67,7 @@ class IntroActivity : KauBaseActivity(), ViewPager.PageTransformer, ViewPager.OnPageChangeListener { private val prefs: Prefs by inject() + private val themeProvider: ThemeProvider by inject() lateinit var binding: ActivityIntroBinding private var barHasNext = true @@ -176,7 +178,7 @@ class IntroActivity : KauBaseActivity(), ViewPager.PageTransformer, override fun finish() { launch(NonCancellable) { - loadAssets(prefs) + loadAssets(themeProvider) NotificationWidget.forceUpdate(this@IntroActivity) launchNewTask(cookies(), false) super.finish() diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt index 3f2cb6ce..90bec985 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt @@ -236,7 +236,7 @@ class SettingsActivity : KPrefActivity() { if (!super.backPress()) { setResult(resultFlag) launch(NonCancellable) { - loadAssets(prefs) + loadAssets(themeProvider) finishSlideOut() } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/enums/Theme.kt b/app/src/main/kotlin/com/pitchedapps/frost/enums/Theme.kt index 3dccc446..1f28d271 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/enums/Theme.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/enums/Theme.kt @@ -88,7 +88,7 @@ enum class Theme( { it.customIconColor }); @VisibleForTesting - internal val file = file?.let { "${it}.css" } + internal val file = file?.let { "$it.css" } companion object { val values = values() // save one instance 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 7a65a818..fc4e3fae 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt @@ -21,10 +21,12 @@ package com.pitchedapps.frost.facebook */ const val FACEBOOK_COM = "facebook.com" +const val MESSENGER_COM = "messenger.com" const val FBCDN_NET = "fbcdn.net" const val WWW_FACEBOOK_COM = "www.$FACEBOOK_COM" +const val WWW_MESSENGER_COM = "www.$MESSENGER_COM" const val HTTPS_FACEBOOK_COM = "https://$WWW_FACEBOOK_COM" -const val HTTPS_MESSENGER_COM = "https://www.messenger.com" +const val HTTPS_MESSENGER_COM = "https://$WWW_MESSENGER_COM" const val FACEBOOK_BASE_COM = "m.$FACEBOOK_COM" const val FB_URL_BASE = "https://$FACEBOOK_BASE_COM/" const val FACEBOOK_MBASIC_COM = "mbasic.$FACEBOOK_COM" diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt index 36d51ec9..efaa03ab 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt @@ -28,9 +28,9 @@ import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.cookies import com.pitchedapps.frost.utils.launchLogin -import kotlinx.coroutines.Dispatchers import kotlin.coroutines.resume import kotlin.coroutines.suspendCoroutine +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.NonCancellable import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt index 5a9576d2..23f4b297 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt @@ -49,33 +49,33 @@ class ThemeProvider(private val context: Context, private val prefs: Prefs) { val textColor: Int get() = theme.textColorGetter(prefs) - val accentColor: Int + val accentColor: Int get() = theme.accentColorGetter(prefs) - val accentColorForWhite: Int + val accentColorForWhite: Int get() = when { accentColor.isColorVisibleOn(Color.WHITE) -> accentColor textColor.isColorVisibleOn(Color.WHITE) -> textColor else -> FACEBOOK_BLUE } - val nativeBgColor: Int + val nativeBgColor: Int get() = bgColor.withAlpha(30) - fun nativeBgColor(unread: Boolean) = bgColor + fun nativeBgColor(unread: Boolean) = bgColor .colorToForeground(if (unread) 0.7f else 0.0f) .withAlpha(30) - val bgColor: Int + val bgColor: Int get() = theme.backgroundColorGetter(prefs) - val headerColor: Int + val headerColor: Int get() = theme.headerColorGetter(prefs) - val iconColor: Int + val iconColor: Int get() = theme.iconColorGetter(prefs) - val isCustomTheme: Boolean + val isCustomTheme: Boolean get() = theme == Theme.CUSTOM /** @@ -91,7 +91,7 @@ class ThemeProvider(private val context: Context, private val prefs: Prefs) { val file = theme.file ?: return JsActions.EMPTY try { var content = - context.assets.open("css/${category.folder}/theme/${file}").bufferedReader() + context.assets.open("css/${category.folder}/themes/$file").bufferedReader() .use(BufferedReader::readText) if (theme == Theme.CUSTOM) { val bt = if (Color.alpha(prefs.bgColor) == 255) @@ -143,4 +143,4 @@ class ThemeProvider(private val context: Context, private val prefs: Prefs) { single { ThemeProvider(get(), get()) } } } -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ThemePrefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ThemePrefs.kt index a5a66ee9..d997876a 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ThemePrefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ThemePrefs.kt @@ -26,7 +26,6 @@ import ca.allanwang.kau.utils.withAlpha import com.pitchedapps.frost.BuildConfig import com.pitchedapps.frost.enums.FACEBOOK_BLUE import com.pitchedapps.frost.enums.Theme -import com.pitchedapps.frost.injectors.InjectorContract import com.pitchedapps.frost.prefs.OldPrefs import com.pitchedapps.frost.prefs.PrefsBase import org.koin.core.component.KoinComponent @@ -61,8 +60,6 @@ interface ThemePrefs : PrefsBase { val iconColor: Int - val themeInjector: InjectorContract - val isCustomTheme: Boolean var tintNavBar: Boolean @@ -137,9 +134,6 @@ class ThemePrefsImpl( override val iconColor: Int get() = t.iconColorGetter(this) - override val themeInjector: InjectorContract - get() = t.injector - override val isCustomTheme: Boolean get() = t == Theme.CUSTOM 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 a5f7ec28..4de93a36 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt @@ -27,7 +27,6 @@ import com.pitchedapps.frost.R import com.pitchedapps.frost.activities.SettingsActivity import com.pitchedapps.frost.enums.MainActivityLayout import com.pitchedapps.frost.enums.Theme -import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.utils.REQUEST_NAV import com.pitchedapps.frost.utils.REQUEST_TEXT_ZOOM import com.pitchedapps.frost.utils.frostEvent 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 883ea9aa..ab0e13fd 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -67,8 +67,8 @@ import com.pitchedapps.frost.facebook.FbUrlFormatter.Companion.VIDEO_REDIRECT import com.pitchedapps.frost.facebook.USER_AGENT import com.pitchedapps.frost.facebook.formattedFbUri import com.pitchedapps.frost.facebook.formattedFbUrl -import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.injectors.JsAssets +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.prefs.Prefs import java.io.File import java.io.IOException @@ -222,21 +222,21 @@ class ActivityThemeUtils : KoinComponent { fun theme(activity: Activity) { with(activity) { - statusBarColor = prefs.headerColor.darken(0.1f).withAlpha(255) - if (prefs.tintNavBar) navigationBarColor = prefs.headerColor - if (themeWindow) window.setBackgroundDrawable(ColorDrawable(prefs.bgColor)) - toolbar?.setBackgroundColor(prefs.headerColor) - toolbar?.setTitleTextColor(prefs.iconColor) - toolbar?.overflowIcon?.setTint(prefs.iconColor) - texts.forEach { it.setTextColor(prefs.textColor) } - headers.forEach { it.setBackgroundColor(prefs.headerColor) } - backgrounds.forEach { it.setBackgroundColor(prefs.bgColor) } + statusBarColor = themeProvider.headerColor.darken(0.1f).withAlpha(255) + if (prefs.tintNavBar) navigationBarColor = themeProvider.headerColor + if (themeWindow) window.setBackgroundDrawable(ColorDrawable(themeProvider.bgColor)) + toolbar?.setBackgroundColor(themeProvider.headerColor) + toolbar?.setTitleTextColor(themeProvider.iconColor) + toolbar?.overflowIcon?.setTint(themeProvider.iconColor) + texts.forEach { it.setTextColor(themeProvider.textColor) } + headers.forEach { it.setBackgroundColor(themeProvider.headerColor) } + backgrounds.forEach { it.setBackgroundColor(themeProvider.bgColor) } } } } -inline fun Activity.setFrostColors(prefs: Prefs, builder: ActivityThemeUtils.() -> Unit) { - val themer = ActivityThemeUtils(prefs) +inline fun Activity.setFrostColors(builder: ActivityThemeUtils.() -> Unit) { + val themer = ActivityThemeUtils() themer.builder() themer.theme(this) } @@ -458,7 +458,7 @@ fun String.unescapeHtml(): String = .replace("\\u003C", "<") .replace("\\\"", "\"") -suspend fun Context.loadAssets(prefs: Prefs): Unit = coroutineScope { - ThemeProvider.load(this@loadAssets, prefs) +suspend fun Context.loadAssets(themeProvider: ThemeProvider): Unit = coroutineScope { + themeProvider.preload() JsAssets.load(this@loadAssets) } 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 34bb5204..e4752d1b 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt @@ -34,6 +34,7 @@ import com.pitchedapps.frost.facebook.FB_HOME_URL import com.pitchedapps.frost.facebook.FbCookie import com.pitchedapps.frost.facebook.USER_AGENT import com.pitchedapps.frost.fragments.WebFragment +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.ctxCoroutine @@ -62,6 +63,7 @@ class FrostWebView @JvmOverloads constructor( val fbCookie: FbCookie by inject() val prefs: Prefs by inject() + val themeProvider: ThemeProvider by inject() val cookieDao: CookieDao by inject() override fun reload(animate: Boolean) { 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 c68d3f57..a454584e 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt @@ -24,9 +24,11 @@ import android.util.AttributeSet import android.view.View import android.webkit.WebView import ca.allanwang.kau.utils.withAlpha +import com.pitchedapps.frost.enums.ThemeCategory import com.pitchedapps.frost.facebook.USER_AGENT -import com.pitchedapps.frost.injectors.CssHider import com.pitchedapps.frost.injectors.CssAsset +import com.pitchedapps.frost.injectors.CssHider +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.injectors.jsInject import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.L @@ -50,6 +52,7 @@ class DebugWebView @JvmOverloads constructor( ) : WebView(context, attrs, defStyleAttr), KoinComponent { private val prefs: Prefs by inject() + private val themeProvider: ThemeProvider by inject() var onPageFinished: (String?) -> Unit = {} init { @@ -112,7 +115,7 @@ class DebugWebView @JvmOverloads constructor( CssHider.STORIES.maybe(!prefs.showStories), CssHider.PEOPLE_YOU_MAY_KNOW.maybe(!prefs.showSuggestedFriends), CssHider.SUGGESTED_GROUPS.maybe(!prefs.showSuggestedGroups), - prefs.themeInjector, + themeProvider.injector(ThemeCategory.FACEBOOK), CssHider.NON_RECENT.maybe( (url?.contains("?sk=h_chr") ?: false) && prefs.aggressiveRecents 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 cf248baf..fce4c75a 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt @@ -23,15 +23,17 @@ import android.webkit.WebResourceResponse import android.webkit.WebView import android.webkit.WebViewClient import ca.allanwang.kau.utils.withAlpha +import com.pitchedapps.frost.enums.ThemeCategory import com.pitchedapps.frost.facebook.FACEBOOK_BASE_COM import com.pitchedapps.frost.facebook.FbCookie 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.CssAsset +import com.pitchedapps.frost.injectors.CssHider import com.pitchedapps.frost.injectors.JsActions import com.pitchedapps.frost.injectors.JsAssets +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.injectors.jsInject import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.L @@ -70,6 +72,7 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() { private val fbCookie: FbCookie get() = web.fbCookie private val prefs: Prefs get() = web.prefs + private val themeProvider: ThemeProvider get() = web.themeProvider private val refresh: SendChannel = web.parent.refreshChannel private val isMain = web.parent.baseEnum != null @@ -110,7 +113,7 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() { CssHider.STORIES.maybe(!prefs.showStories), CssHider.PEOPLE_YOU_MAY_KNOW.maybe(!prefs.showSuggestedFriends), CssHider.SUGGESTED_GROUPS.maybe(!prefs.showSuggestedGroups), - prefs.themeInjector, + themeProvider.injector(ThemeCategory.FACEBOOK), CssHider.NON_RECENT.maybe( (web.url?.contains("?sk=h_chr") ?: false) && prefs.aggressiveRecents diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt index 1a081d2e..fadbadf9 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt @@ -30,12 +30,14 @@ import ca.allanwang.kau.utils.fadeIn import ca.allanwang.kau.utils.isVisible import ca.allanwang.kau.utils.launchMain import com.pitchedapps.frost.db.CookieEntity +import com.pitchedapps.frost.enums.ThemeCategory import com.pitchedapps.frost.facebook.FB_LOGIN_URL import com.pitchedapps.frost.facebook.FB_USER_MATCHER import com.pitchedapps.frost.facebook.FbCookie import com.pitchedapps.frost.facebook.USER_AGENT import com.pitchedapps.frost.facebook.get import com.pitchedapps.frost.injectors.CssHider +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.injectors.jsInject import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.L @@ -56,6 +58,7 @@ class LoginWebView @JvmOverloads constructor( private val fbCookie: FbCookie by inject() private val prefs: Prefs by inject() + private val themeProvider: ThemeProvider by inject() private val completable: CompletableDeferred = CompletableDeferred() private lateinit var progressCallback: (Int) -> Unit @@ -105,7 +108,7 @@ class LoginWebView @JvmOverloads constructor( if (url.isFacebookUrl) view.jsInject( CssHider.CORE, - prefs.themeInjector, + themeProvider.injector(ThemeCategory.FACEBOOK), prefs = prefs ) } -- cgit v1.2.3 From e01e51574613459a036c1d60383bfb229799a407 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 12 Jan 2021 21:15:08 -0800 Subject: Convert all theme access to themeprovider --- .../main/kotlin/com/pitchedapps/frost/FrostApp.kt | 4 +- .../pitchedapps/frost/activities/AboutActivity.kt | 11 ++-- .../pitchedapps/frost/activities/BaseActivity.kt | 5 +- .../frost/activities/BaseMainActivity.kt | 40 ++++++------- .../pitchedapps/frost/activities/DebugActivity.kt | 9 +-- .../pitchedapps/frost/activities/ImageActivity.kt | 17 +++--- .../pitchedapps/frost/activities/IntroActivity.kt | 24 ++++---- .../frost/activities/SettingsActivity.kt | 20 +++---- .../frost/activities/TabCustomizerActivity.kt | 14 ++--- .../frost/activities/WebOverlayActivity.kt | 14 ++--- .../pitchedapps/frost/enums/MainActivityLayout.kt | 6 +- .../pitchedapps/frost/fragments/FragmentBase.kt | 7 ++- .../com/pitchedapps/frost/iitems/GenericIItems.kt | 13 +++-- .../pitchedapps/frost/iitems/NotificationIItem.kt | 11 ++-- .../com/pitchedapps/frost/iitems/TabIItem.kt | 6 +- .../pitchedapps/frost/injectors/ThemeProvider.kt | 24 ++++---- .../pitchedapps/frost/intro/IntroFragmentTheme.kt | 2 +- .../pitchedapps/frost/intro/IntroImageFragments.kt | 32 +++++------ .../pitchedapps/frost/intro/IntroMainFragments.kt | 9 ++- .../kotlin/com/pitchedapps/frost/prefs/Prefs.kt | 4 +- .../pitchedapps/frost/prefs/sections/ThemePrefs.kt | 67 ++-------------------- .../frost/services/NotificationUtils.kt | 11 ++-- .../com/pitchedapps/frost/settings/Appearance.kt | 12 ++-- .../kotlin/com/pitchedapps/frost/utils/Utils.kt | 18 +++--- .../com/pitchedapps/frost/views/AccountItem.kt | 8 +-- .../com/pitchedapps/frost/views/BadgedIcon.kt | 10 ++-- .../pitchedapps/frost/views/FrostContentView.kt | 8 ++- .../pitchedapps/frost/views/FrostVideoViewer.kt | 8 ++- .../kotlin/com/pitchedapps/frost/views/Keywords.kt | 16 +++--- .../com/pitchedapps/frost/web/DebugWebView.kt | 2 +- .../pitchedapps/frost/web/FrostWebViewClients.kt | 2 +- .../frost/widgets/NotificationWidget.kt | 16 +++--- 32 files changed, 213 insertions(+), 237 deletions(-) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt index 059b2a0e..100aeecb 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt @@ -47,6 +47,7 @@ import org.koin.dsl.module class FrostApp : Application(), KoinComponent { private lateinit var prefs: Prefs + private lateinit var themeProvider: ThemeProvider override fun onCreate() { startKoin { @@ -69,6 +70,7 @@ class FrostApp : Application(), KoinComponent { return } prefs = get() + themeProvider = get() initPrefs() L.i { "Begin Frost for Facebook" } @@ -76,7 +78,7 @@ class FrostApp : Application(), KoinComponent { super.onCreate() - setupNotificationChannels(this, prefs) + setupNotificationChannels(this, themeProvider) scheduleNotificationsFromPrefs(prefs) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt index 17cac703..74d876cb 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt @@ -47,9 +47,11 @@ import com.mikepenz.iconics.typeface.library.community.material.CommunityMateria import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial import com.pitchedapps.frost.BuildConfig import com.pitchedapps.frost.R +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.L import org.koin.android.ext.android.inject +import org.koin.core.component.inject /** * Created by Allan Wang on 2017-06-26. @@ -57,12 +59,13 @@ import org.koin.android.ext.android.inject class AboutActivity : AboutActivityBase(null) { private val prefs: Prefs by inject() + private val themeProvider: ThemeProvider by inject() override fun Configs.buildConfigs() { - textColor = prefs.textColor - accentColor = prefs.accentColor - backgroundColor = prefs.bgColor.withMinAlpha(200) - cutoutForeground = prefs.accentColor + textColor = themeProvider.textColor + accentColor = themeProvider.accentColor + backgroundColor = themeProvider.bgColor.withMinAlpha(200) + cutoutForeground = themeProvider.accentColor cutoutDrawableRes = R.drawable.frost_f_200 faqPageTitleRes = R.string.faq_title faqXmlRes = R.xml.frost_faq diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseActivity.kt index d2ba0a92..0553086c 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseActivity.kt @@ -22,9 +22,11 @@ import ca.allanwang.kau.internal.KauBaseActivity import ca.allanwang.kau.searchview.SearchViewHolder import com.pitchedapps.frost.contracts.VideoViewHolder import com.pitchedapps.frost.facebook.FbCookie +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.setFrostTheme import org.koin.android.ext.android.inject +import org.koin.core.component.inject /** * Created by Allan Wang on 2017-06-12. @@ -33,6 +35,7 @@ abstract class BaseActivity : KauBaseActivity() { val fbCookie: FbCookie by inject() val prefs: Prefs by inject() + val themeProvider: ThemeProvider by inject() /** * Inherited consumer to customize back press @@ -48,7 +51,7 @@ abstract class BaseActivity : KauBaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - if (this !is WebOverlayActivityBase) setFrostTheme(prefs) + if (this !is WebOverlayActivityBase) setFrostTheme(themeProvider) } override fun onStop() { diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt index e352b2fc..394969cb 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt @@ -210,7 +210,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, } setSupportActionBar(toolbar) viewpager.adapter = adapter - tabs.setBackgroundColor(prefs.mainActivityLayout.backgroundColor(prefs)) + tabs.setBackgroundColor(prefs.mainActivityLayout.backgroundColor(themeProvider)) } onNestedCreate(savedInstanceState) L.i { "Main finished loading UI in ${System.currentTimeMillis() - start} ms" } @@ -288,7 +288,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, drawer.addDrawerListener(toggle) toggle.syncState() - val foregroundColor = ColorStateList.valueOf(prefs.textColor) + val foregroundColor = ColorStateList.valueOf(themeProvider.textColor) with(navigation) { FrostMenuBuilder(this@BaseMainActivity, menu).apply { @@ -317,9 +317,9 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, launchWebOverlay(item.url, fbCookie, prefs) false } - val navBg = prefs.bgColor.withMinAlpha(200) + val navBg = themeProvider.bgColor.withMinAlpha(200) setBackgroundColor(navBg) - itemBackground = createNavDrawable(prefs.accentColor, navBg) + itemBackground = createNavDrawable(themeProvider.accentColor, navBg) itemTextColor = foregroundColor itemIconTintList = foregroundColor @@ -331,7 +331,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, private fun ActivityMainContentBinding.initFab() { hasFab = false shouldShow = false - fab.backgroundTintList = ColorStateList.valueOf(prefs.headerColor.withMinAlpha(200)) + fab.backgroundTintList = ColorStateList.valueOf(themeProvider.headerColor.withMinAlpha(200)) fab.hide() appbar.addOnOffsetChangedListener(AppBarLayout.OnOffsetChangedListener { appBarLayout, verticalOffset -> if (!hasFab) return@OnOffsetChangedListener @@ -351,12 +351,12 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, if (shouldShow) { if (fab.isShown) { fab.fadeScaleTransition { - setIcon(iicon, color = prefs.iconColor) + setIcon(iicon, color = themeProvider.iconColor) } return } } - fab.setIcon(iicon, color = prefs.iconColor) + fab.setIcon(iicon, color = themeProvider.iconColor) fab.showIf(shouldShow) } } @@ -383,7 +383,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, private var pendingUpdate: Boolean = false private val binding = ViewNavHeaderBinding.inflate(layoutInflater) val root: View get() = binding.root - private val optionsBackground = prefs.bgColor.withMinAlpha(200).colorToForeground( + private val optionsBackground = themeProvider.bgColor.withMinAlpha(200).colorToForeground( 0.1f ) @@ -448,7 +448,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, animator.start() } - val textColor = prefs.textColor + val textColor = themeProvider.textColor fun TextView.setOptionsIcon(iicon: IIcon) { setCompoundDrawablesRelativeWithIntrinsicBounds( @@ -458,7 +458,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, null ) setTextColor(textColor) - background = createNavDrawable(prefs.accentColor, optionsBackground) + background = createNavDrawable(themeProvider.accentColor, optionsBackground) } with(optionsLogout) { @@ -506,7 +506,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, arrow.setImageDrawable( GoogleMaterial.Icon.gmd_arrow_drop_down.toDrawable( this@BaseMainActivity, - color = prefs.textColor + color = themeProvider.textColor ) ) } @@ -531,10 +531,10 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, avatarTertiary.setAccount(orderedAccounts.getOrNull(2), false) optionsAccountsContainer.removeAllViews() name.text = orderedAccounts.getOrNull(0)?.name - name.setTextColor(prefs.textColor) + name.setTextColor(themeProvider.textColor) val glide = Glide.with(root) val accountSize = dimenPixelSize(R.dimen.drawer_account_avatar_size) - val textColor = prefs.textColor + val textColor = themeProvider.textColor orderedAccounts.forEach { cookie -> val tv = TextView( @@ -568,7 +568,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, }) tv.text = cookie.name tv.setTextColor(textColor) - tv.background = createNavDrawable(prefs.accentColor, optionsBackground) + tv.background = createNavDrawable(themeProvider.accentColor, optionsBackground) tv.setOnClickListener { switchAccount(cookie.id) } @@ -626,9 +626,9 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.menu_main, menu) - contentBinding.toolbar.tint(prefs.iconColor) + contentBinding.toolbar.tint(themeProvider.iconColor) setMenuIcons( - menu, prefs.iconColor, + menu, themeProvider.iconColor, R.id.action_settings to GoogleMaterial.Icon.gmd_settings, R.id.action_search to GoogleMaterial.Icon.gmd_search ) @@ -638,7 +638,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, private fun bindSearchView(menu: Menu) { searchViewBindIfNull { - bindSearchView(menu, R.id.action_search, prefs.iconColor) { + bindSearchView(menu, R.id.action_search, themeProvider.iconColor) { textCallback = { query, searchView -> val results = searchViewCache[query] if (results != null) @@ -671,8 +671,8 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, ); true } closeListener = { _ -> searchViewCache.clear() } - foregroundColor = prefs.textColor - backgroundColor = prefs.bgColor.withMinAlpha(200) + foregroundColor = themeProvider.textColor + backgroundColor = themeProvider.bgColor.withMinAlpha(200) onItemClick = { _, key, _, _ -> launchWebOverlay(key, fbCookie, prefs) } } } @@ -731,7 +731,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, fragmentChannel.offer(REQUEST_REFRESH) } if (hasRequest(REQUEST_NAV)) { - frostNavigationBar(prefs) + frostNavigationBar(prefs, themeProvider) } if (hasRequest(REQUEST_TEXT_ZOOM)) { fragmentChannel.offer(REQUEST_TEXT_ZOOM) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt index 6067fa82..935b88c9 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt @@ -30,7 +30,7 @@ import com.pitchedapps.frost.R import com.pitchedapps.frost.databinding.ActivityDebugBinding import com.pitchedapps.frost.facebook.FbItem import com.pitchedapps.frost.injectors.JsActions -import com.pitchedapps.frost.prefs.Prefs +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.createFreshDir import com.pitchedapps.frost.utils.setFrostColors @@ -39,6 +39,7 @@ import kotlin.coroutines.resume import kotlin.coroutines.suspendCoroutine import kotlinx.coroutines.CoroutineExceptionHandler import org.koin.android.ext.android.inject +import org.koin.core.component.inject /** * Created by Allan Wang on 05/01/18. @@ -52,7 +53,7 @@ class DebugActivity : KauBaseActivity() { fun baseDir(context: Context) = File(context.externalCacheDir, "offline_debug") } - private val prefs: Prefs by inject() + private val themeProvider: ThemeProvider by inject() lateinit var binding: ActivityDebugBinding @@ -79,8 +80,8 @@ class DebugActivity : KauBaseActivity() { swipeRefresh.setOnRefreshListener(debugWebview::reload) - fab.visible().setIcon(GoogleMaterial.Icon.gmd_bug_report, prefs.iconColor) - fab.backgroundTintList = ColorStateList.valueOf(prefs.accentColor) + fab.visible().setIcon(GoogleMaterial.Icon.gmd_bug_report, themeProvider.iconColor) + fab.backgroundTintList = ColorStateList.valueOf(themeProvider.accentColor) fab.setOnClickListener { _ -> fab.hide() diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt index 609ed049..7b8ee4d3 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt @@ -55,6 +55,7 @@ import com.pitchedapps.frost.facebook.get import com.pitchedapps.frost.facebook.requests.call import com.pitchedapps.frost.facebook.requests.getFullSizedImageUrl import com.pitchedapps.frost.facebook.requests.requestBuilder +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.services.LocalService import com.pitchedapps.frost.utils.ARG_COOKIE @@ -78,6 +79,7 @@ import kotlinx.coroutines.async import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import org.koin.android.ext.android.inject +import org.koin.core.component.inject /** * Created by Allan Wang on 2017-07-15. @@ -85,6 +87,7 @@ import org.koin.android.ext.android.inject class ImageActivity : KauBaseActivity() { private val prefs: Prefs by inject() + private val themeProvider: ThemeProvider by inject() @Volatile internal var errorRef: Throwable? = null @@ -128,7 +131,7 @@ class ImageActivity : KauBaseActivity() { private var bottomBehavior: BottomSheetBehavior? = null private val baseBackgroundColor = if (prefs.blackMediaBg) Color.BLACK - else prefs.bgColor.withMinAlpha(235) + else themeProvider.bgColor.withMinAlpha(235) private fun loadError(e: Throwable) { if (e.message?.contains("") == true) { @@ -178,7 +181,7 @@ class ImageActivity : KauBaseActivity() { if (text.isNullOrBlank()) { imageText.gone() } else { - imageText.setTextColor(if (prefs.blackMediaBg) Color.WHITE else prefs.textColor) + imageText.setTextColor(if (prefs.blackMediaBg) Color.WHITE else themeProvider.textColor) imageText.setBackgroundColor( baseBackgroundColor.colorToForeground(0.2f).withAlpha(255) ) @@ -197,7 +200,7 @@ class ImageActivity : KauBaseActivity() { imageText.bringToFront() } } - val foregroundTint = if (prefs.blackMediaBg) Color.WHITE else prefs.accentColor + val foregroundTint = if (prefs.blackMediaBg) Color.WHITE else themeProvider.accentColor fun ImageView.setState(state: FabStates) { setIcon(state.iicon, color = foregroundTint, sizeDp = 24) @@ -352,7 +355,7 @@ class ImageActivity : KauBaseActivity() { internal enum class FabStates( val iicon: IIcon, - val iconColorProvider: (Prefs) -> Int = { it.iconColor }, + val iconColorProvider: (ThemeProvider) -> Int = { it.iconColor }, val backgroundTint: Int = Int.MAX_VALUE ) { ERROR(GoogleMaterial.Icon.gmd_error, { Color.WHITE }, Color.RED) { @@ -405,9 +408,9 @@ internal enum class FabStates( * https://github.com/AllanWang/KAU/issues/184 * */ - fun update(fab: FloatingActionButton, prefs: Prefs) { - val tint = if (backgroundTint != Int.MAX_VALUE) backgroundTint else prefs.accentColor - val iconColor = iconColorProvider(prefs) + fun update(fab: FloatingActionButton, themeProvider: ThemeProvider) { + val tint = if (backgroundTint != Int.MAX_VALUE) backgroundTint else themeProvider.accentColor + val iconColor = iconColorProvider(themeProvider) if (fab.isHidden) { fab.setIcon(iicon, color = iconColor) fab.backgroundTintList = ColorStateList.valueOf(tint) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt index e8e603ba..f06c3a37 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt @@ -100,21 +100,21 @@ class IntroActivity : KauBaseActivity(), ViewPager.PageTransformer, else finish(next.x + next.pivotX, next.y + next.pivotY) } skip.setOnClickListener { finish() } - ripple.set(prefs.bgColor) + ripple.set(themeProvider.bgColor) theme() } fun theme() { - statusBarColor = prefs.headerColor - navigationBarColor = prefs.headerColor + statusBarColor = themeProvider.headerColor + navigationBarColor = themeProvider.headerColor with(binding) { - skip.setTextColor(prefs.textColor) - next.imageTintList = ColorStateList.valueOf(prefs.textColor) - indicator.setColour(prefs.textColor) + skip.setTextColor(themeProvider.textColor) + next.imageTintList = ColorStateList.valueOf(themeProvider.textColor) + indicator.setColour(themeProvider.textColor) indicator.invalidate() } fragments.forEach { it.themeFragment() } - setFrostTheme(prefs, true) + setFrostTheme(themeProvider, true) } /** @@ -152,21 +152,21 @@ class IntroActivity : KauBaseActivity(), ViewPager.PageTransformer, ).forEach { it?.animate()?.alpha(0f)?.setDuration(600)?.start() } - if (prefs.textColor != Color.WHITE) { + if (themeProvider.textColor != Color.WHITE) { val f = lastView?.findViewById(R.id.intro_image)?.drawable if (f != null) ValueAnimator.ofFloat(0f, 1f).apply { addUpdateListener { - f.setTint(prefs.textColor.blendWith(Color.WHITE, it.animatedValue as Float)) + f.setTint(themeProvider.textColor.blendWith(Color.WHITE, it.animatedValue as Float)) } duration = 600 start() } } - if (prefs.headerColor != blue) { + if (themeProvider.headerColor != blue) { ValueAnimator.ofFloat(0f, 1f).apply { addUpdateListener { - val c = prefs.headerColor.blendWith(blue, it.animatedValue as Float) + val c = themeProvider.headerColor.blendWith(blue, it.animatedValue as Float) statusBarColor = c navigationBarColor = c } @@ -209,7 +209,7 @@ class IntroActivity : KauBaseActivity(), ViewPager.PageTransformer, binding.next.fadeScaleTransition { setIcon( if (barHasNext) GoogleMaterial.Icon.gmd_navigate_next else GoogleMaterial.Icon.gmd_done, - color = prefs.textColor + color = themeProvider.textColor ) } binding.skip.animate().scaleXY(if (barHasNext) 1f else 0f) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt index 90bec985..9ce16ec7 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt @@ -134,8 +134,8 @@ class SettingsActivity : KPrefActivity() { } override fun kPrefCoreAttributes(): CoreAttributeContract.() -> Unit = { - textColor = { prefs.textColor } - accentColor = { prefs.accentColor } + textColor = { themeProvider.textColor } + accentColor = { themeProvider.accentColor } } override fun onCreateKPrefs(savedInstanceState: Bundle?): KPrefAdapterBuilder.() -> Unit = { @@ -218,18 +218,18 @@ class SettingsActivity : KPrefActivity() { @SuppressLint("MissingSuperCall") override fun onCreate(savedInstanceState: Bundle?) { - setFrostTheme(prefs, true) + setFrostTheme(themeProvider, true) super.onCreate(savedInstanceState) animate = prefs.animate themeExterior(false) } fun themeExterior(animate: Boolean = true) { - if (animate) bgCanvas.fade(prefs.bgColor) - else bgCanvas.set(prefs.bgColor) - if (animate) toolbarCanvas.ripple(prefs.headerColor, RippleCanvas.MIDDLE, RippleCanvas.END) - else toolbarCanvas.set(prefs.headerColor) - frostNavigationBar(prefs) + if (animate) bgCanvas.fade(themeProvider.bgColor) + else bgCanvas.set(themeProvider.bgColor) + if (animate) toolbarCanvas.ripple(themeProvider.headerColor, RippleCanvas.MIDDLE, RippleCanvas.END) + else toolbarCanvas.set(themeProvider.headerColor) + frostNavigationBar(prefs, themeProvider) } override fun onBackPressed() { @@ -244,9 +244,9 @@ class SettingsActivity : KPrefActivity() { override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.menu_settings, menu) - toolbar.tint(prefs.iconColor) + toolbar.tint(themeProvider.iconColor) setMenuIcons( - menu, prefs.iconColor, + menu, themeProvider.iconColor, R.id.action_github to CommunityMaterial.Icon2.cmd_github, R.id.action_changelog to GoogleMaterial.Icon.gmd_info ) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/TabCustomizerActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/TabCustomizerActivity.kt index 589289ab..f2827397 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/TabCustomizerActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/TabCustomizerActivity.kt @@ -69,15 +69,15 @@ class TabCustomizerActivity : BaseActivity() { } fun ActivityTabCustomizerBinding.init() { - pseudoToolbar.setBackgroundColor(prefs.headerColor) + pseudoToolbar.setBackgroundColor(themeProvider.headerColor) tabRecycler.layoutManager = GridLayoutManager(this@TabCustomizerActivity, TAB_COUNT, RecyclerView.VERTICAL, false) tabRecycler.adapter = adapter tabRecycler.setHasFixedSize(true) - divider.setBackgroundColor(prefs.textColor.withAlpha(30)) - instructions.setTextColor(prefs.textColor) + divider.setBackgroundColor(themeProvider.textColor.withAlpha(30)) + instructions.setTextColor(themeProvider.textColor) launch { val tabs = genericDao.getTabs().toMutableList() @@ -94,8 +94,8 @@ class TabCustomizerActivity : BaseActivity() { setResult(Activity.RESULT_CANCELED) - fabSave.setIcon(GoogleMaterial.Icon.gmd_check, prefs.iconColor) - fabSave.backgroundTintList = ColorStateList.valueOf(prefs.accentColor) + fabSave.setIcon(GoogleMaterial.Icon.gmd_check, themeProvider.iconColor) + fabSave.backgroundTintList = ColorStateList.valueOf(themeProvider.accentColor) fabSave.setOnClickListener { launchMain(NonCancellable) { val tabs = adapter.adapterItems.subList(0, TAB_COUNT).map(TabIItem::item) @@ -104,8 +104,8 @@ class TabCustomizerActivity : BaseActivity() { finish() } } - fabCancel.setIcon(GoogleMaterial.Icon.gmd_close, prefs.iconColor) - fabCancel.backgroundTintList = ColorStateList.valueOf(prefs.accentColor) + fabCancel.setIcon(GoogleMaterial.Icon.gmd_close, themeProvider.iconColor) + fabCancel.backgroundTintList = ColorStateList.valueOf(themeProvider.accentColor) fabCancel.setOnClickListener { finish() } setFrostColors { themeWindow = true 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 c21f7362..42d84eb7 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt @@ -202,14 +202,14 @@ abstract class WebOverlayActivityBase(private val userAgent: String = USER_AGENT setSupportActionBar(toolbar) supportActionBar?.setDisplayShowHomeEnabled(true) supportActionBar?.setDisplayHomeAsUpEnabled(true) - toolbar.navigationIcon = GoogleMaterial.Icon.gmd_close.toDrawable(this, 16, prefs.iconColor) + toolbar.navigationIcon = GoogleMaterial.Icon.gmd_close.toDrawable(this, 16, themeProvider.iconColor) toolbar.setNavigationOnClickListener { finishSlideOut() } setFrostColors { toolbar(toolbar) themeWindow = false } - coordinator.setBackgroundColor(prefs.bgColor.withAlpha(255)) + coordinator.setBackgroundColor(themeProvider.bgColor.withAlpha(255)) content.bind(this) @@ -268,13 +268,13 @@ abstract class WebOverlayActivityBase(private val userAgent: String = USER_AGENT * Our theme for the overlay should be fully opaque */ fun theme() { - val opaqueAccent = prefs.headerColor.withAlpha(255) + val opaqueAccent = themeProvider.headerColor.withAlpha(255) statusBarColor = opaqueAccent.darken() navigationBarColor = opaqueAccent toolbar.setBackgroundColor(opaqueAccent) - toolbar.setTitleTextColor(prefs.iconColor) - coordinator.setBackgroundColor(prefs.bgColor.withAlpha(255)) - toolbar.overflowIcon?.setTint(prefs.iconColor) + toolbar.setTitleTextColor(themeProvider.iconColor) + coordinator.setBackgroundColor(themeProvider.bgColor.withAlpha(255)) + toolbar.overflowIcon?.setTint(themeProvider.iconColor) } override fun onResume() { @@ -309,7 +309,7 @@ abstract class WebOverlayActivityBase(private val userAgent: String = USER_AGENT override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.menu_web, menu) overlayContext?.onMenuCreate(this, menu) - toolbar.tint(prefs.iconColor) + toolbar.tint(themeProvider.iconColor) return true } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/enums/MainActivityLayout.kt b/app/src/main/kotlin/com/pitchedapps/frost/enums/MainActivityLayout.kt index 79a6f188..ec438df1 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/enums/MainActivityLayout.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/enums/MainActivityLayout.kt @@ -17,15 +17,15 @@ package com.pitchedapps.frost.enums import com.pitchedapps.frost.R -import com.pitchedapps.frost.prefs.Prefs +import com.pitchedapps.frost.injectors.ThemeProvider /** * Created by Allan Wang on 2017-08-19. */ enum class MainActivityLayout( val titleRes: Int, - val backgroundColor: (Prefs) -> Int, - val iconColor: (Prefs) -> Int + val backgroundColor: (ThemeProvider) -> Int, + val iconColor: (ThemeProvider) -> Int ) { TOP_BAR(R.string.top_bar, diff --git a/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt b/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt index 0232694e..c07884bc 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt @@ -34,6 +34,7 @@ import com.pitchedapps.frost.contracts.MainFabContract import com.pitchedapps.frost.enums.FeedSort import com.pitchedapps.frost.facebook.FbCookie import com.pitchedapps.frost.facebook.FbItem +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.ARG_URL import com.pitchedapps.frost.utils.L @@ -49,6 +50,7 @@ import kotlinx.coroutines.channels.ReceiveChannel import kotlinx.coroutines.isActive import kotlinx.coroutines.launch import org.koin.android.ext.android.inject +import org.koin.core.component.inject /** * Created by Allan Wang on 2017-11-07. @@ -84,6 +86,7 @@ abstract class BaseFragment : Fragment(), CoroutineScope, FragmentContract, protected val fbCookie: FbCookie by inject() protected val prefs: Prefs by inject() + protected val themeProvider: ThemeProvider by inject() open lateinit var job: Job override val coroutineContext: CoroutineContext get() = ContextHelper.dispatcher + job @@ -201,10 +204,10 @@ abstract class BaseFragment : Fragment(), CoroutineScope, FragmentContract, protected fun FloatingActionButton.update(iicon: IIcon, click: () -> Unit) { if (isShown) { fadeScaleTransition { - setIcon(iicon, prefs.iconColor) + setIcon(iicon, themeProvider.iconColor) } } else { - setIcon(iicon, prefs.iconColor) + setIcon(iicon, themeProvider.iconColor) show() } setOnClickListener { click() } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/iitems/GenericIItems.kt b/app/src/main/kotlin/com/pitchedapps/frost/iitems/GenericIItems.kt index 47a362b4..0c53a2b1 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/iitems/GenericIItems.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/iitems/GenericIItems.kt @@ -28,6 +28,7 @@ import com.mikepenz.fastadapter.IAdapter import com.mikepenz.fastadapter.select.selectExtension import com.pitchedapps.frost.R import com.pitchedapps.frost.facebook.FbCookie +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.launchWebOverlay import org.koin.core.component.KoinComponent @@ -79,14 +80,14 @@ open class HeaderIItem( class ViewHolder(itemView: View) : FastAdapter.ViewHolder(itemView), KoinComponent { - private val prefs: Prefs by inject() + private val themeProvider: ThemeProvider by inject() val text: TextView by bindView(R.id.item_header_text) override fun bindView(item: HeaderIItem, payloads: List) { - text.setTextColor(prefs.accentColor) + text.setTextColor(themeProvider.accentColor) text.text = item.text - text.setBackgroundColor(prefs.nativeBgColor) + text.setBackgroundColor(themeProvider.nativeBgColor) } override fun unbindView(item: HeaderIItem) { @@ -108,14 +109,14 @@ open class TextIItem( class ViewHolder(itemView: View) : FastAdapter.ViewHolder(itemView), KoinComponent { - private val prefs: Prefs by inject() + private val themeProvider: ThemeProvider by inject() val text: TextView by bindView(R.id.item_text_view) override fun bindView(item: TextIItem, payloads: List) { - text.setTextColor(prefs.textColor) + text.setTextColor(themeProvider.textColor) text.text = item.text - text.background = createSimpleRippleDrawable(prefs.bgColor, prefs.nativeBgColor) + text.background = createSimpleRippleDrawable(themeProvider.bgColor, themeProvider.nativeBgColor) } override fun unbindView(item: TextIItem) { diff --git a/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt b/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt index 56e27ccd..8e0d5bec 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt @@ -36,6 +36,7 @@ import com.pitchedapps.frost.facebook.FbItem import com.pitchedapps.frost.facebook.parsers.FrostNotif import com.pitchedapps.frost.glide.FrostGlide import com.pitchedapps.frost.glide.GlideApp +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.isIndependent import com.pitchedapps.frost.utils.launchWebOverlay @@ -103,7 +104,7 @@ class NotificationIItem(val notification: FrostNotif, val cookie: String) : class ViewHolder(itemView: View) : FastAdapter.ViewHolder(itemView), KoinComponent { - private val prefs: Prefs by inject() + private val themeProvider: ThemeProvider by inject() private val frame: ViewGroup by bindView(R.id.item_frame) private val avatar: ImageView by bindView(R.id.item_avatar) @@ -117,11 +118,11 @@ class NotificationIItem(val notification: FrostNotif, val cookie: String) : override fun bindView(item: NotificationIItem, payloads: List) { val notif = item.notification frame.background = createSimpleRippleDrawable( - prefs.textColor, - prefs.nativeBgColor(notif.unread) + themeProvider.textColor, + themeProvider.nativeBgColor(notif.unread) ) - content.setTextColor(prefs.textColor) - date.setTextColor(prefs.textColor.withAlpha(150)) + content.setTextColor(themeProvider.textColor) + date.setTextColor(themeProvider.textColor.withAlpha(150)) val glide = glide glide.load(notif.img) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/iitems/TabIItem.kt b/app/src/main/kotlin/com/pitchedapps/frost/iitems/TabIItem.kt index 6f278fe2..0fd39d5c 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/iitems/TabIItem.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/iitems/TabIItem.kt @@ -29,7 +29,7 @@ import com.mikepenz.fastadapter.FastAdapter import com.mikepenz.fastadapter.drag.IDraggable import com.pitchedapps.frost.R import com.pitchedapps.frost.facebook.FbItem -import com.pitchedapps.frost.prefs.Prefs +import com.pitchedapps.frost.injectors.ThemeProvider import org.koin.core.component.KoinComponent import org.koin.core.component.inject @@ -45,14 +45,14 @@ class TabIItem(val item: FbItem) : KauIItem( class ViewHolder(itemView: View) : FastAdapter.ViewHolder(itemView), KoinComponent { - private val prefs: Prefs by inject() + private val themeProvider: ThemeProvider by inject() val image: ImageView by bindView(R.id.image) val text: TextView by bindView(R.id.text) override fun bindView(item: TabIItem, payloads: List) { val isInToolbar = adapterPosition < 4 - val color = if (isInToolbar) prefs.iconColor else prefs.textColor + val color = if (isInToolbar) themeProvider.iconColor else themeProvider.textColor image.setIcon(item.item.icon, 20, color) if (isInToolbar) text.invisible() diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt index 23f4b297..666a6bc5 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt @@ -34,6 +34,7 @@ import java.io.BufferedReader import java.io.FileNotFoundException import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext +import org.koin.core.context.GlobalContext /** * Created by Allan Wang on 2017-05-31. @@ -94,24 +95,24 @@ class ThemeProvider(private val context: Context, private val prefs: Prefs) { context.assets.open("css/${category.folder}/themes/$file").bufferedReader() .use(BufferedReader::readText) if (theme == Theme.CUSTOM) { - val bt = if (Color.alpha(prefs.bgColor) == 255) - prefs.bgColor.toRgbaString() + val bt = if (Color.alpha(bgColor) == 255) + bgColor.toRgbaString() else "transparent" - val bb = prefs.bgColor.colorToForeground(0.35f) + val bb = bgColor.colorToForeground(0.35f) content = content - .replace("\$T\$", prefs.textColor.toRgbaString()) - .replace("\$TT\$", prefs.textColor.colorToBackground(0.05f).toRgbaString()) - .replace("\$A\$", prefs.accentColor.toRgbaString()) - .replace("\$AT\$", prefs.iconColor.toRgbaString()) - .replace("\$B\$", prefs.bgColor.toRgbaString()) + .replace("\$T\$", textColor.toRgbaString()) + .replace("\$TT\$", textColor.colorToBackground(0.05f).toRgbaString()) + .replace("\$A\$", accentColor.toRgbaString()) + .replace("\$AT\$", iconColor.toRgbaString()) + .replace("\$B\$", bgColor.toRgbaString()) .replace("\$BT\$", bt) .replace("\$BBT\$", bb.withAlpha(51).toRgbaString()) - .replace("\$O\$", prefs.bgColor.withAlpha(255).toRgbaString()) + .replace("\$O\$", bgColor.withAlpha(255).toRgbaString()) .replace("\$OO\$", bb.withAlpha(255).toRgbaString()) - .replace("\$D\$", prefs.textColor.adjustAlpha(0.3f).toRgbaString()) + .replace("\$D\$", textColor.adjustAlpha(0.3f).toRgbaString()) .replace("\$TI\$", bb.withAlpha(60).toRgbaString()) .replace("\$C\$", bt) } @@ -139,6 +140,9 @@ class ThemeProvider(private val context: Context, private val prefs: Prefs) { } companion object { + + fun get(): ThemeProvider = GlobalContext.get().get() + fun module() = org.koin.dsl.module { single { ThemeProvider(get(), get()) } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroFragmentTheme.kt b/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroFragmentTheme.kt index 6e735e5b..486b09a9 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroFragmentTheme.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroFragmentTheme.kt @@ -66,7 +66,7 @@ class IntroFragmentTheme : BaseIntroFragment(R.layout.intro_theme) { setOnClickListener { v -> prefs.theme = theme.ordinal (activity as IntroActivity).apply { - binding.ripple.ripple(prefs.bgColor, v.x + v.pivotX, v.y + v.pivotY) + binding.ripple.ripple(themeProvider.bgColor, v.x + v.pivotX, v.y + v.pivotY) theme() } themeList.forEach { it.animate().scaleXY(if (it == this) 1.6f else 0.8f).start() } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroImageFragments.kt b/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroImageFragments.kt index 429171dd..e27d4fee 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroImageFragments.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroImageFragments.kt @@ -57,10 +57,10 @@ abstract class BaseImageIntroFragment( override fun themeFragmentImpl() { super.themeFragmentImpl() - title.setTextColor(prefs.textColor) - desc.setTextColor(prefs.textColor) - phone.tint(prefs.textColor) - screen.tint(prefs.bgColor) + title.setTextColor(themeProvider.textColor) + desc.setTextColor(themeProvider.textColor) + phone.tint(themeProvider.textColor) + screen.tint(themeProvider.bgColor) } fun themeImageComponent(color: Int, vararg id: Int) { @@ -96,9 +96,9 @@ class IntroAccountFragment : BaseImageIntroFragment( override fun themeFragmentImpl() { super.themeFragmentImpl() - themeImageComponent(prefs.iconColor, R.id.intro_phone_avatar_1, R.id.intro_phone_avatar_2) - themeImageComponent(prefs.bgColor.colorToForeground(), R.id.intro_phone_nav) - themeImageComponent(prefs.headerColor, R.id.intro_phone_header) + themeImageComponent(themeProvider.iconColor, R.id.intro_phone_avatar_1, R.id.intro_phone_avatar_2) + themeImageComponent(themeProvider.bgColor.colorToForeground(), R.id.intro_phone_nav) + themeImageComponent(themeProvider.headerColor, R.id.intro_phone_header) } override fun onPageScrolledImpl(positionOffset: Float) { @@ -122,14 +122,14 @@ class IntroTabTouchFragment : BaseImageIntroFragment( override fun themeFragmentImpl() { super.themeFragmentImpl() themeImageComponent( - prefs.iconColor, + themeProvider.iconColor, R.id.intro_phone_icon_1, R.id.intro_phone_icon_2, R.id.intro_phone_icon_3, R.id.intro_phone_icon_4 ) - themeImageComponent(prefs.headerColor, R.id.intro_phone_tab) - themeImageComponent(prefs.textColor.withAlpha(80), R.id.intro_phone_icon_ripple) + themeImageComponent(themeProvider.headerColor, R.id.intro_phone_tab) + themeImageComponent(themeProvider.textColor.withAlpha(80), R.id.intro_phone_icon_ripple) } } @@ -141,21 +141,21 @@ class IntroTabContextFragment : BaseImageIntroFragment( override fun themeFragmentImpl() { super.themeFragmentImpl() - themeImageComponent(prefs.headerColor, R.id.intro_phone_toolbar) - themeImageComponent(prefs.bgColor.colorToForeground(0.1f), R.id.intro_phone_image) + themeImageComponent(themeProvider.headerColor, R.id.intro_phone_toolbar) + themeImageComponent(themeProvider.bgColor.colorToForeground(0.1f), R.id.intro_phone_image) themeImageComponent( - prefs.bgColor.colorToForeground(0.2f), + themeProvider.bgColor.colorToForeground(0.2f), R.id.intro_phone_like, R.id.intro_phone_share ) - themeImageComponent(prefs.bgColor.colorToForeground(0.3f), R.id.intro_phone_comment) + themeImageComponent(themeProvider.bgColor.colorToForeground(0.3f), R.id.intro_phone_comment) themeImageComponent( - prefs.bgColor.colorToForeground(0.1f), + themeProvider.bgColor.colorToForeground(0.1f), R.id.intro_phone_card_1, R.id.intro_phone_card_2 ) themeImageComponent( - prefs.textColor, + themeProvider.textColor, R.id.intro_phone_image_indicator, R.id.intro_phone_comment_indicator, R.id.intro_phone_card_indicator diff --git a/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroMainFragments.kt b/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroMainFragments.kt index d160bee4..8003cb2e 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroMainFragments.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroMainFragments.kt @@ -33,9 +33,11 @@ import ca.allanwang.kau.utils.bindViewResettable import ca.allanwang.kau.utils.setOnSingleTapListener import com.pitchedapps.frost.R import com.pitchedapps.frost.activities.IntroActivity +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.prefs.Prefs import kotlin.math.abs import org.koin.android.ext.android.inject +import org.koin.core.component.inject /** * Created by Allan Wang on 2017-07-28. @@ -49,6 +51,7 @@ import org.koin.android.ext.android.inject abstract class BaseIntroFragment(val layoutRes: Int) : Fragment() { protected val prefs: Prefs by inject() + protected val themeProvider: ThemeProvider by inject() val screenWidth get() = resources.displayMetrics.widthPixels @@ -105,7 +108,7 @@ abstract class BaseIntroFragment(val layoutRes: Int) : Fragment() { } protected open fun themeFragmentImpl() { - (view as? ViewGroup)?.children?.forEach { (it as? TextView)?.setTextColor(prefs.textColor) } + (view as? ViewGroup)?.children?.forEach { (it as? TextView)?.setTextColor(themeProvider.textColor) } } protected val viewArray: Array> by lazyResettableRegistered { viewArray() } @@ -134,7 +137,7 @@ class IntroFragmentWelcome : BaseIntroFragment(R.layout.intro_welcome) { override fun themeFragmentImpl() { super.themeFragmentImpl() - image.imageTintList = ColorStateList.valueOf(prefs.textColor) + image.imageTintList = ColorStateList.valueOf(themeProvider.textColor) } } @@ -146,7 +149,7 @@ class IntroFragmentEnd : BaseIntroFragment(R.layout.intro_end) { override fun themeFragmentImpl() { super.themeFragmentImpl() - image.imageTintList = ColorStateList.valueOf(prefs.textColor) + image.imageTintList = ColorStateList.valueOf(themeProvider.textColor) } @SuppressLint("ClickableViewAccessibility") diff --git a/app/src/main/kotlin/com/pitchedapps/frost/prefs/Prefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/prefs/Prefs.kt index 2714b930..d31be432 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/prefs/Prefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/prefs/Prefs.kt @@ -28,7 +28,7 @@ import com.pitchedapps.frost.prefs.sections.ShowcasePrefs import com.pitchedapps.frost.prefs.sections.ShowcasePrefsImpl import com.pitchedapps.frost.prefs.sections.ThemePrefs import com.pitchedapps.frost.prefs.sections.ThemePrefsImpl -import org.koin.core.context.KoinContextHandler +import org.koin.core.context.GlobalContext import org.koin.dsl.module /** @@ -48,7 +48,7 @@ interface Prefs : ShowcasePrefs, PrefsBase { companion object { - fun get(): Prefs = KoinContextHandler.get().get() + fun get(): Prefs = GlobalContext.get().get() fun module() = module { single { BehaviourPrefsImpl(factory = get()) } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ThemePrefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ThemePrefs.kt index d997876a..47496d6d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ThemePrefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ThemePrefs.kt @@ -16,16 +16,10 @@ */ package com.pitchedapps.frost.prefs.sections -import android.graphics.Color -import ca.allanwang.kau.kotlin.lazyResettable import ca.allanwang.kau.kpref.KPref import ca.allanwang.kau.kpref.KPrefFactory -import ca.allanwang.kau.utils.colorToForeground -import ca.allanwang.kau.utils.isColorVisibleOn -import ca.allanwang.kau.utils.withAlpha import com.pitchedapps.frost.BuildConfig -import com.pitchedapps.frost.enums.FACEBOOK_BLUE -import com.pitchedapps.frost.enums.Theme +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.prefs.OldPrefs import com.pitchedapps.frost.prefs.PrefsBase import org.koin.core.component.KoinComponent @@ -44,24 +38,6 @@ interface ThemePrefs : PrefsBase { var customIconColor: Int - val textColor: Int - - val accentColor: Int - - val accentColorForWhite: Int - - val nativeBgColor: Int - - fun nativeBgColor(unread: Boolean): Int - - val bgColor: Int - - val headerColor: Int - - val iconColor: Int - - val isCustomTheme: Boolean - var tintNavBar: Boolean } @@ -71,9 +47,10 @@ class ThemePrefsImpl( ThemePrefs, KoinComponent { private val oldPrefs: OldPrefs by inject() + private val themeProvider: ThemeProvider by inject() - override var theme: Int by kpref("theme", oldPrefs.theme /* 0 */) { _: Int -> - loader.invalidate() + override var theme: Int by kpref("theme", oldPrefs.theme /* 0 */) { + themeProvider.setTheme(it) } override var customTextColor: Int by kpref( @@ -101,41 +78,5 @@ class ThemePrefsImpl( oldPrefs.customIconColor /* 0xffeceff1.toInt() */ ) - private val loader = lazyResettable { Theme.values[theme] } - - val t: Theme by loader - - override val textColor: Int - get() = t.textColorGetter(this) - - override val accentColor: Int - get() = t.accentColorGetter(this) - - override val accentColorForWhite: Int - get() = when { - accentColor.isColorVisibleOn(Color.WHITE) -> accentColor - textColor.isColorVisibleOn(Color.WHITE) -> textColor - else -> FACEBOOK_BLUE - } - - override val nativeBgColor: Int - get() = bgColor.withAlpha(30) - - override fun nativeBgColor(unread: Boolean) = bgColor - .colorToForeground(if (unread) 0.7f else 0.0f) - .withAlpha(30) - - override val bgColor: Int - get() = t.backgroundColorGetter(this) - - override val headerColor: Int - get() = t.headerColorGetter(this) - - override val iconColor: Int - get() = t.iconColorGetter(this) - - override val isCustomTheme: Boolean - get() = t == Theme.CUSTOM - override var tintNavBar: Boolean by kpref("tint_nav_bar", oldPrefs.tintNavBar /* true */) } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt index 0a90895e..0bb9d254 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt @@ -31,6 +31,7 @@ import androidx.core.app.NotificationCompat import ca.allanwang.kau.utils.color import ca.allanwang.kau.utils.string import com.pitchedapps.frost.R +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.frostUri @@ -41,13 +42,13 @@ import com.pitchedapps.frost.utils.frostUri const val NOTIF_CHANNEL_GENERAL = "general" const val NOTIF_CHANNEL_MESSAGES = "messages" -fun setupNotificationChannels(c: Context, prefs: Prefs) { +fun setupNotificationChannels(c: Context, themeProvider: ThemeProvider) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return val manager = c.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager val appName = c.string(R.string.frost_name) val msg = c.string(R.string.messages) - manager.createNotificationChannel(NOTIF_CHANNEL_GENERAL, appName, prefs) - manager.createNotificationChannel(NOTIF_CHANNEL_MESSAGES, "$appName: $msg", prefs) + manager.createNotificationChannel(NOTIF_CHANNEL_GENERAL, appName, themeProvider) + manager.createNotificationChannel(NOTIF_CHANNEL_MESSAGES, "$appName: $msg", themeProvider) manager.notificationChannels .filter { it.id != NOTIF_CHANNEL_GENERAL && @@ -61,14 +62,14 @@ fun setupNotificationChannels(c: Context, prefs: Prefs) { private fun NotificationManager.createNotificationChannel( id: String, name: String, - prefs: Prefs + themeProvider: ThemeProvider ): NotificationChannel { val channel = NotificationChannel( id, name, NotificationManager.IMPORTANCE_DEFAULT ) channel.enableLights(true) - channel.lightColor = prefs.accentColor + channel.lightColor = themeProvider.accentColor channel.lockscreenVisibility = Notification.VISIBILITY_PUBLIC createNotificationChannel(channel) return channel 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 4de93a36..64d9dba2 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt @@ -43,7 +43,7 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = { header(R.string.theme_customization) - text(R.string.theme, prefs::theme, { prefs.theme = it; themeProvider.setTheme(it) }) { + text(R.string.theme, prefs::theme, { prefs.theme = it }) { onClick = { materialDialog { title(R.string.theme) @@ -55,7 +55,7 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = { item.pref = index shouldRestartMain() reload() - setFrostTheme(prefs, true) + setFrostTheme(themeProvider, true) themeExterior() invalidateOptionsMenu() frostEvent("Theme", "Count" to Theme(index).name) @@ -69,7 +69,7 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = { } fun KPrefColorPicker.KPrefColorContract.dependsOnCustom() { - enabler = prefs::isCustomTheme + enabler = themeProvider::isCustomTheme onDisabledClick = { frostSnackbar(R.string.requires_custom_theme) } allowCustom = true } @@ -102,7 +102,7 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = { prefs.customBackgroundColor = it bgCanvas.ripple(it, duration = 500L) invalidateCustomTheme() - setFrostTheme(prefs, true) + setFrostTheme(themeProvider, true) shouldRestartMain() }) { dependsOnCustom() @@ -111,7 +111,7 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = { colorPicker(R.string.header_color, prefs::customHeaderColor, { prefs.customHeaderColor = it - frostNavigationBar(prefs) + frostNavigationBar(prefs, themeProvider) toolbarCanvas.ripple(it, RippleCanvas.MIDDLE, RippleCanvas.END, duration = 500L) reload() shouldRestartMain() @@ -160,7 +160,7 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = { checkbox(R.string.tint_nav, prefs::tintNavBar, { prefs.tintNavBar = it - frostNavigationBar(prefs) + frostNavigationBar(prefs, themeProvider) setFrostResult(REQUEST_NAV) }) { descRes = R.string.tint_nav_desc 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 ab0e13fd..92bea27a 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -183,10 +183,10 @@ fun WebOverlayActivity.url(): String { return intent.getStringExtra(ARG_URL) ?: FbItem.FEED.url } -fun Activity.setFrostTheme(prefs: Prefs, forceTransparent: Boolean = false) { +fun Activity.setFrostTheme(themeProvider: ThemeProvider, forceTransparent: Boolean = false) { val isTransparent = - forceTransparent || (Color.alpha(prefs.bgColor) != 255) || (Color.alpha(prefs.headerColor) != 255) - if (prefs.bgColor.isColorDark) { + forceTransparent || (Color.alpha(themeProvider.bgColor) != 255) || (Color.alpha(themeProvider.headerColor) != 255) + if (themeProvider.bgColor.isColorDark) { setTheme(if (isTransparent) R.style.FrostTheme_Transparent else R.style.FrostTheme) } else { setTheme(if (isTransparent) R.style.FrostTheme_Light_Transparent else R.style.FrostTheme_Light) @@ -263,19 +263,19 @@ fun View.frostSnackbar(@StringRes text: Int, builder: Snackbar.() -> Unit = {}) @SuppressLint("RestrictedApi") private inline fun frostSnackbar(crossinline builder: Snackbar.() -> Unit): Snackbar.() -> Unit = { - val prefs = Prefs.get() + val themeProvider = ThemeProvider.get() builder() // hacky workaround, but it has proper checks and shouldn't crash ((view as? FrameLayout)?.getChildAt(0) as? SnackbarContentLayout)?.apply { - messageView.setTextColor(prefs.textColor) - actionView.setTextColor(prefs.accentColor) + messageView.setTextColor(themeProvider.textColor) + actionView.setTextColor(themeProvider.accentColor) // only set if previous text colors are set - view.setBackgroundColor(prefs.bgColor.withAlpha(255).colorToForeground(0.1f)) + view.setBackgroundColor(themeProvider.bgColor.withAlpha(255).colorToForeground(0.1f)) } } -fun Activity.frostNavigationBar(prefs: Prefs) { - navigationBarColor = if (prefs.tintNavBar) prefs.headerColor else Color.BLACK +fun Activity.frostNavigationBar(prefs: Prefs, themeProvider: ThemeProvider) { + navigationBarColor = if (prefs.tintNavBar) themeProvider.headerColor else Color.BLACK } @Throws(IOException::class) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt index 6ba9ff4d..6eebd36f 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt @@ -37,7 +37,7 @@ import com.pitchedapps.frost.db.CookieEntity import com.pitchedapps.frost.facebook.profilePictureUrl import com.pitchedapps.frost.glide.FrostGlide import com.pitchedapps.frost.glide.GlideApp -import com.pitchedapps.frost.prefs.Prefs +import com.pitchedapps.frost.injectors.ThemeProvider import org.koin.core.component.KoinComponent import org.koin.core.component.inject @@ -48,13 +48,13 @@ class AccountItem(val cookie: CookieEntity?) : KauIItem(R.layout.view_account, { ViewHolder(it) }, R.id.item_account), KoinComponent { - private val prefs: Prefs by inject() + private val themeProvider: ThemeProvider by inject() override fun bindView(holder: ViewHolder, payloads: List) { super.bindView(holder, payloads) with(holder) { text.invisible() - text.setTextColor(prefs.textColor) + text.setTextColor(themeProvider.textColor) if (cookie != null) { text.text = cookie.name GlideApp.with(itemView).load(profilePictureUrl(cookie.id)) @@ -86,7 +86,7 @@ class AccountItem(val cookie: CookieEntity?) : GoogleMaterial.Icon.gmd_add_circle_outline.toDrawable( itemView.context, 100, - prefs.textColor + themeProvider.textColor ) ) text.text = itemView.context.getString(R.string.kau_add_account) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt index ed94b59f..78af4edf 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt @@ -29,6 +29,7 @@ import ca.allanwang.kau.utils.visible import ca.allanwang.kau.utils.withAlpha import com.mikepenz.iconics.typeface.IIcon import com.pitchedapps.frost.databinding.ViewBadgedIconBinding +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.prefs.Prefs import org.koin.core.component.KoinComponent import org.koin.core.component.inject @@ -43,6 +44,7 @@ class BadgedIcon @JvmOverloads constructor( ) : ConstraintLayout(context, attrs, defStyleAttr), KoinComponent { private val prefs: Prefs by inject() + private val themeProvider: ThemeProvider by inject() private val binding: ViewBadgedIconBinding = ViewBadgedIconBinding.inflate(LayoutInflater.from(context), this, true) @@ -52,7 +54,7 @@ class BadgedIcon @JvmOverloads constructor( private fun ViewBadgedIconBinding.init() { val badgeColor = - prefs.mainActivityLayout.backgroundColor(prefs).withAlpha(255).colorToForeground(0.2f) + prefs.mainActivityLayout.backgroundColor(themeProvider).withAlpha(255).colorToForeground(0.2f) val badgeBackground = GradientDrawable( GradientDrawable.Orientation.BOTTOM_TOP, @@ -60,7 +62,7 @@ class BadgedIcon @JvmOverloads constructor( ) badgeBackground.cornerRadius = 13.dpToPx.toFloat() badgeText.background = badgeBackground - badgeText.setTextColor(prefs.mainActivityLayout.iconColor(prefs)) + badgeText.setTextColor(prefs.mainActivityLayout.iconColor(themeProvider)) } var iicon: IIcon? = null @@ -70,13 +72,13 @@ class BadgedIcon @JvmOverloads constructor( value?.toDrawable( context, sizeDp = 20, - color = prefs.mainActivityLayout.iconColor(prefs) + color = prefs.mainActivityLayout.iconColor(themeProvider) ) ) } fun setAllAlpha(alpha: Float) { - // badgeTextView.setTextColor(prefs.textColor.withAlpha(alpha.toInt())) + // badgeTextView.setTextColor(themeProvider.textColor.withAlpha(alpha.toInt())) binding.badgeImage.drawable.alpha = alpha.toInt() } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt index 55f41807..e25b603e 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt @@ -39,6 +39,7 @@ import com.pitchedapps.frost.contracts.FrostContentCore import com.pitchedapps.frost.contracts.FrostContentParent import com.pitchedapps.frost.facebook.FbItem import com.pitchedapps.frost.facebook.WEB_LOAD_DELAY +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.kotlin.subscribeDuringJob import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.L @@ -80,6 +81,7 @@ abstract class FrostContentView @JvmOverloads constructor( FrostContentParent, KoinComponent where T : View, T : FrostContentCore { private val prefs: Prefs by inject() + private val themeProvider: ThemeProvider by inject() private val refresh: SwipeRefreshLayout by bindView(R.id.content_refresh) private val progress: ProgressBar by bindView(R.id.content_progress) val coreView: T by bindView(R.id.content_core) @@ -156,9 +158,9 @@ abstract class FrostContentView @JvmOverloads constructor( } override fun reloadThemeSelf() { - progress.tint(prefs.textColor.withAlpha(180)) - refresh.setColorSchemeColors(prefs.iconColor) - refresh.setProgressBackgroundColorSchemeColor(prefs.headerColor.withAlpha(255)) + progress.tint(themeProvider.textColor.withAlpha(180)) + refresh.setColorSchemeColors(themeProvider.iconColor) + refresh.setProgressBackgroundColorSchemeColor(themeProvider.headerColor.withAlpha(255)) } override fun reloadTextSizeSelf() { 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 09be1184..169e7f73 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt @@ -43,6 +43,7 @@ import com.pitchedapps.frost.R import com.pitchedapps.frost.databinding.ViewVideoBinding import com.pitchedapps.frost.db.CookieDao import com.pitchedapps.frost.db.currentCookie +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.ctxCoroutine @@ -88,6 +89,7 @@ class FrostVideoViewer @JvmOverloads constructor( } private val prefs: Prefs by inject() + private val themeProvider: ThemeProvider by inject() private val cookieDao: CookieDao by inject() private val binding: ViewVideoBinding = @@ -100,8 +102,8 @@ class FrostVideoViewer @JvmOverloads constructor( fun ViewVideoBinding.init() { alpha = 0f videoBackground.setBackgroundColor( - if (!prefs.blackMediaBg && prefs.bgColor.isColorDark) - prefs.bgColor.withMinAlpha(200) + if (!prefs.blackMediaBg && themeProvider.bgColor.isColorDark) + themeProvider.bgColor.withMinAlpha(200) else Color.BLACK ) @@ -109,7 +111,7 @@ class FrostVideoViewer @JvmOverloads constructor( video.pause() videoToolbar.inflateMenu(R.menu.menu_video) context.setMenuIcons( - videoToolbar.menu, prefs.iconColor, + videoToolbar.menu, themeProvider.iconColor, R.id.action_pip to GoogleMaterial.Icon.gmd_picture_in_picture_alt, R.id.action_download to GoogleMaterial.Icon.gmd_file_download ) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/Keywords.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/Keywords.kt index 0d53608b..c3d5a90e 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/Keywords.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/Keywords.kt @@ -37,6 +37,7 @@ import com.mikepenz.fastadapter.listeners.ClickEventHook import com.mikepenz.iconics.typeface.IIcon import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial import com.pitchedapps.frost.R +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.prefs.Prefs import org.koin.core.component.KoinComponent import org.koin.core.component.inject @@ -51,6 +52,7 @@ class Keywords @JvmOverloads constructor( ) : ConstraintLayout(context, attrs, defStyleAttr), KoinComponent { private val prefs: Prefs by inject() + private val themeProvider: ThemeProvider by inject() val editText: AppCompatEditText by bindView(R.id.edit_text) val addIcon: ImageView by bindView(R.id.add_icon) val recycler: RecyclerView by bindView(R.id.recycler) @@ -58,8 +60,8 @@ class Keywords @JvmOverloads constructor( init { inflate(context, R.layout.view_keywords, this) - editText.tint(prefs.textColor) - addIcon.setImageDrawable(GoogleMaterial.Icon.gmd_add.keywordDrawable(context, prefs)) + editText.tint(themeProvider.textColor) + addIcon.setImageDrawable(GoogleMaterial.Icon.gmd_add.keywordDrawable(context, themeProvider)) addIcon.setOnClickListener { if (editText.text.isNullOrEmpty()) editText.error = context.string(R.string.empty_keyword) @@ -91,8 +93,8 @@ class Keywords @JvmOverloads constructor( } } -private fun IIcon.keywordDrawable(context: Context, prefs: Prefs): Drawable = - toDrawable(context, 20, prefs.textColor) +private fun IIcon.keywordDrawable(context: Context, themeProvider: ThemeProvider): Drawable = + toDrawable(context, 20, themeProvider.textColor) class KeywordItem(val keyword: String) : AbstractItem() { @@ -116,16 +118,16 @@ class KeywordItem(val keyword: String) : AbstractItem() class ViewHolder(v: View) : RecyclerView.ViewHolder(v), KoinComponent { - private val prefs: Prefs by inject() + private val themeProvider: ThemeProvider by inject() val text: AppCompatTextView by bindView(R.id.keyword_text) val delete: ImageView by bindView(R.id.keyword_delete) init { - text.setTextColor(prefs.textColor) + text.setTextColor(themeProvider.textColor) delete.setImageDrawable( GoogleMaterial.Icon.gmd_delete.keywordDrawable( itemView.context, - prefs + themeProvider ) ) } 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 a454584e..fe85ab9c 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt @@ -100,7 +100,7 @@ class DebugWebView @JvmOverloads constructor( private fun injectBackgroundColor() { setBackgroundColor( - if (url.isFacebookUrl) prefs.bgColor.withAlpha(255) + if (url.isFacebookUrl) themeProvider.bgColor.withAlpha(255) else Color.WHITE ) } 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 fce4c75a..b5874bf2 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt @@ -144,7 +144,7 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() { web.setBackgroundColor( when { isMain -> Color.TRANSPARENT - web.url.isFacebookUrl -> prefs.bgColor.withAlpha(255) + web.url.isFacebookUrl -> themeProvider.bgColor.withAlpha(255) else -> Color.WHITE } ) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/widgets/NotificationWidget.kt b/app/src/main/kotlin/com/pitchedapps/frost/widgets/NotificationWidget.kt index aef3fada..3bf37f7d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/widgets/NotificationWidget.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/widgets/NotificationWidget.kt @@ -43,6 +43,7 @@ import com.pitchedapps.frost.db.NotificationDao import com.pitchedapps.frost.db.selectNotificationsSync import com.pitchedapps.frost.glide.FrostGlide import com.pitchedapps.frost.glide.GlideApp +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.services.NotificationContent import com.pitchedapps.frost.services.NotificationType @@ -53,6 +54,7 @@ import org.koin.core.component.inject class NotificationWidget : AppWidgetProvider(), KoinComponent { private val prefs: Prefs by inject() + private val themeProvider: ThemeProvider by inject() override fun onUpdate( context: Context, @@ -66,14 +68,14 @@ class NotificationWidget : AppWidgetProvider(), KoinComponent { for (id in appWidgetIds) { val views = RemoteViews(context.packageName, R.layout.widget_notifications) - views.setBackgroundColor(R.id.widget_layout_toolbar, prefs.headerColor) - views.setIcon(R.id.img_frost, context, R.drawable.frost_f_24, prefs.iconColor) + views.setBackgroundColor(R.id.widget_layout_toolbar, themeProvider.headerColor) + views.setIcon(R.id.img_frost, context, R.drawable.frost_f_24, themeProvider.iconColor) views.setOnClickPendingIntent( R.id.img_frost, PendingIntent.getActivity(context, 0, Intent(context, MainActivity::class.java), 0) ) - views.setBackgroundColor(R.id.widget_notification_list, prefs.bgColor) + views.setBackgroundColor(R.id.widget_notification_list, themeProvider.bgColor) views.setRemoteAdapter(R.id.widget_notification_list, intent) val pendingIntentTemplate = PendingIntent.getActivity( @@ -156,7 +158,7 @@ class NotificationWidgetDataProvider(val context: Context, val intent: Intent) : RemoteViewsService.RemoteViewsFactory, KoinComponent { - private val prefs: Prefs by inject() + private val themeProvider: ThemeProvider by inject() private val notifDao: NotificationDao by inject() @@ -192,10 +194,10 @@ class NotificationWidgetDataProvider(val context: Context, val intent: Intent) : val views = RemoteViews(context.packageName, R.layout.widget_notification_item) try { val notif = content[position] - views.setBackgroundColor(R.id.item_frame, prefs.nativeBgColor(notif.unread)) - views.setTextColor(R.id.item_content, prefs.textColor) + views.setBackgroundColor(R.id.item_frame, themeProvider.nativeBgColor(notif.unread)) + views.setTextColor(R.id.item_content, themeProvider.textColor) views.setTextViewText(R.id.item_content, notif.text) - views.setTextColor(R.id.item_date, prefs.textColor.withAlpha(150)) + views.setTextColor(R.id.item_date, themeProvider.textColor.withAlpha(150)) views.setTextViewText(R.id.item_date, notif.timestamp.toReadableTime(context)) val avatar = glide.load(notif.profileUrl).transform(FrostGlide.circleCrop) -- cgit v1.2.3 From c0eeb83cfc8e5021f3a7904d8cc7b33d07cd92ea Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 12 Jan 2021 22:23:12 -0800 Subject: Start mapping messenger injections --- .../kotlin/com/pitchedapps/frost/utils/Utils.kt | 4 ++ .../pitchedapps/frost/web/FrostWebViewClients.kt | 48 ++++++++++++++++------ app/src/web/scss/messenger/core/_core_bg.scss | 4 ++ app/src/web/scss/messenger/core/_core_vars.scss | 10 +++++ app/src/web/scss/messenger/core/core.scss | 1 + 5 files changed, 54 insertions(+), 13 deletions(-) create mode 100644 app/src/web/scss/messenger/core/_core_vars.scss 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 92bea27a..2d3a10c8 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -64,6 +64,7 @@ import com.pitchedapps.frost.facebook.FBCDN_NET import com.pitchedapps.frost.facebook.FbCookie import com.pitchedapps.frost.facebook.FbItem import com.pitchedapps.frost.facebook.FbUrlFormatter.Companion.VIDEO_REDIRECT +import com.pitchedapps.frost.facebook.MESSENGER_COM import com.pitchedapps.frost.facebook.USER_AGENT import com.pitchedapps.frost.facebook.formattedFbUri import com.pitchedapps.frost.facebook.formattedFbUrl @@ -311,6 +312,9 @@ fun Context.resolveActivityForUri(uri: Uri): Boolean { inline val String?.isFacebookUrl get() = this != null && (contains(FACEBOOK_COM) || contains(FBCDN_NET)) +inline val String?.isMessengerUrl +get() = this != null && contains(MESSENGER_COM) + /** * [true] if url is a video and can be accepted by VideoViewer */ 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 b5874bf2..7a7bc293 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt @@ -41,6 +41,7 @@ import com.pitchedapps.frost.utils.isExplicitIntent import com.pitchedapps.frost.utils.isFacebookUrl import com.pitchedapps.frost.utils.isImageUrl import com.pitchedapps.frost.utils.isIndirectImageUrl +import com.pitchedapps.frost.utils.isMessengerUrl import com.pitchedapps.frost.utils.launchImageActivity import com.pitchedapps.frost.utils.resolveActivityForUri import com.pitchedapps.frost.views.FrostWebView @@ -133,6 +134,13 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() { ) } + private fun WebView.messengerJsInject() { + jsInject( + themeProvider.injector(ThemeCategory.MESSENGER), + prefs = prefs + ) + } + override fun onPageStarted(view: WebView, url: String?, favicon: Bitmap?) { super.onPageStarted(view, url, favicon) if (url == null) return @@ -153,18 +161,25 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() { override fun onPageCommitVisible(view: WebView, url: String?) { super.onPageCommitVisible(view, url) injectBackgroundColor() - if (url.isFacebookUrl) { - v { "Page commit visible" } - view.facebookJsInject() - } else { - refresh.offer(false) + when { + url.isFacebookUrl -> { + v { "FB Page commit visible" } + view.facebookJsInject() + } + url.isMessengerUrl -> { + v { "Messenger Page commit visible" } + view.messengerJsInject() + } + else -> { + refresh.offer(false) + } } } override fun onPageFinished(view: WebView, url: String?) { url ?: return v { "finished $url" } - if (!url.isFacebookUrl) { + if (!url.isFacebookUrl && !url.isMessengerUrl) { refresh.offer(false) return } @@ -182,13 +197,20 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() { v { "page finished reveal" } refresh.offer(false) injectBackgroundColor() - web.jsInject( - JsActions.LOGIN_CHECK, - JsAssets.TEXTAREA_LISTENER, - JsAssets.HEADER_BADGES.maybe(isMain), - prefs = prefs - ) - web.facebookJsInject() + when { + web.url.isFacebookUrl -> { + web.jsInject( + JsActions.LOGIN_CHECK, + JsAssets.TEXTAREA_LISTENER, + JsAssets.HEADER_BADGES.maybe(isMain), + prefs = prefs + ) + web.facebookJsInject() + } + web.url.isMessengerUrl -> { + web.messengerJsInject() + } + } } open fun handleHtml(html: String?) { diff --git a/app/src/web/scss/messenger/core/_core_bg.scss b/app/src/web/scss/messenger/core/_core_bg.scss index e69de29b..92d3dd85 100644 --- a/app/src/web/scss/messenger/core/_core_bg.scss +++ b/app/src/web/scss/messenger/core/_core_bg.scss @@ -0,0 +1,4 @@ +html, body, :root, #root, +[style*="background-color: #FFFFFF"], [style*="background-color: #E4E6EB"] { + background: $bg_transparent !important; +} diff --git a/app/src/web/scss/messenger/core/_core_vars.scss b/app/src/web/scss/messenger/core/_core_vars.scss new file mode 100644 index 00000000..f15c936c --- /dev/null +++ b/app/src/web/scss/messenger/core/_core_vars.scss @@ -0,0 +1,10 @@ +:root, .__fb-light-mode { + // Main background; needs to be opaque to hide gradient used for sender card + --messenger-card-background: $bg_transparent !important; + // Date + --placeholder-text: $text !important; + // Emoji background + --surface-background: $bg_opaque2 !important; + --primary-text: $text !important; + --web-wash: #f0f !important; +} \ No newline at end of file diff --git a/app/src/web/scss/messenger/core/core.scss b/app/src/web/scss/messenger/core/core.scss index f6a92475..d5cb691a 100644 --- a/app/src/web/scss/messenger/core/core.scss +++ b/app/src/web/scss/messenger/core/core.scss @@ -1,5 +1,6 @@ @import "../../core/colors"; @import "../../core/base"; +@import "core_vars"; @import "core_text"; @import "core_bg"; @import "core_border"; \ No newline at end of file -- cgit v1.2.3 From ce9e44a742638eaaad5833f39d394535ddfd67a2 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 12 Jan 2021 22:32:23 -0800 Subject: Disable swipe refresh for messenger --- app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt | 1 + 1 file changed, 1 insertion(+) 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 7a7bc293..99473a11 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt @@ -95,6 +95,7 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() { private fun urlSupportsRefresh(url: String?): Boolean { if (url == null) return false + if (url.isMessengerUrl) return false if (!url.isFacebookUrl) return true if (url.contains("soft=composer")) return false if (url.contains("sharer.php") || url.contains("sharer-dialog.php")) return false -- cgit v1.2.3 From 5aec10ce0fe191d78399869074c7e118256848ea Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 12 Jan 2021 23:07:02 -0800 Subject: Fix swipe disable logic and disable for messenger --- .../pitchedapps/frost/activities/LoginActivity.kt | 2 -- .../frost/contracts/FrostContentContract.kt | 12 +++++++++--- .../pitchedapps/frost/views/FrostContentView.kt | 22 ++++++++++++++++------ .../pitchedapps/frost/views/SwipeRefreshLayout.kt | 5 ----- .../kotlin/com/pitchedapps/frost/web/FrostJSI.kt | 4 ++-- .../pitchedapps/frost/web/FrostWebViewClients.kt | 2 +- 6 files changed, 28 insertions(+), 19 deletions(-) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt index 601516de..5cbbfafe 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt @@ -86,9 +86,7 @@ class LoginActivity : BaseActivity() { profileLoader = GlideApp.with(profile) launch { for (refreshing in refreshChannel.uniqueOnly(this)) { - if (refreshing) swipeRefresh.isEnabled = true swipeRefresh.isRefreshing = refreshing - if (!refreshing) swipeRefresh.isEnabled = false } } launch { diff --git a/app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostContentContract.kt b/app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostContentContract.kt index 8a6e57af..b8d0d86f 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostContentContract.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostContentContract.kt @@ -73,11 +73,17 @@ interface FrostContentParent : DynamicUiContract { var baseEnum: FbItem? + val swipeEnabled: Boolean get() = swipeAllowedByPage && !swipeDisabledByAction + + /** + * Temporary disable swiping based on action + */ + var swipeDisabledByAction: Boolean + /** - * Toggle state for allowing swipes - * Allowed on any thread + * Decides if swipe should be allowed for the current page */ - var swipeEnabled: Boolean + var swipeAllowedByPage: Boolean /** * Binds the container to self diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt index e25b603e..177b8862 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt @@ -22,7 +22,6 @@ import android.util.AttributeSet import android.view.View import android.widget.FrameLayout import android.widget.ProgressBar -import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import ca.allanwang.kau.utils.ContextHelper import ca.allanwang.kau.utils.bindView import ca.allanwang.kau.utils.circularReveal @@ -104,14 +103,26 @@ abstract class FrostContentView @JvmOverloads constructor( protected abstract val layoutRes: Int - override var swipeEnabled = true + @Volatile + override var swipeDisabledByAction = false set(value) { - if (field == value) - return field = value - refresh.post { refresh.isEnabled = value } + updateSwipeEnabler() } + @Volatile + override var swipeAllowedByPage: Boolean = true + set(value) { + field = value + updateSwipeEnabler() + } + + private fun updateSwipeEnabler() { + val swipeEnabled = swipeAllowedByPage && !swipeDisabledByAction + if (refresh.isEnabled == swipeEnabled) return + refresh.post { refresh.isEnabled = swipeEnabled } + } + /** * Sets up everything * Called by [bind] @@ -136,7 +147,6 @@ abstract class FrostContentView @JvmOverloads constructor( refreshChannel.subscribeDuringJob(scope, ContextHelper.coroutineContext) { r -> refresh.isRefreshing = r - refresh.isEnabled = true } progressChannel.subscribeDuringJob(scope, ContextHelper.coroutineContext) { p -> diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/SwipeRefreshLayout.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/SwipeRefreshLayout.kt index 9e9c2340..f02adcf0 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/SwipeRefreshLayout.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/SwipeRefreshLayout.kt @@ -101,9 +101,4 @@ class SwipeRefreshLayout @JvmOverloads constructor(context: Context, attrs: Attr super.onNestedScroll(target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed) } } - - /** - * Alias for adding on refresh listener - */ - interface OnRefreshListener : SwipeRefreshLayout.OnRefreshListener } 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 40a048af..4e8e8cee 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt @@ -97,7 +97,7 @@ class FrostJSI(val web: FrostWebView) { fun longClick(start: Boolean) { activity?.contentBinding?.viewpager?.enableSwipe = !start if (web.frostWebClient.urlSupportsRefresh) { - web.parent.swipeEnabled = !start + web.parent.swipeDisabledByAction = start } } @@ -109,7 +109,7 @@ class FrostJSI(val web: FrostWebView) { if (!web.frostWebClient.urlSupportsRefresh) { return } - web.parent.swipeEnabled = !disable + web.parent.swipeDisabledByAction = disable if (disable) { // locked onto an input field; ensure content is visible (context as? MainActivityContract)?.collapseAppBar() 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 99473a11..8ec5f975 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt @@ -85,7 +85,7 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() { override fun doUpdateVisitedHistory(view: WebView, url: String?, isReload: Boolean) { super.doUpdateVisitedHistory(view, url, isReload) urlSupportsRefresh = urlSupportsRefresh(url) - web.parent.swipeEnabled = urlSupportsRefresh + web.parent.swipeAllowedByPage = urlSupportsRefresh view.jsInject( JsAssets.AUTO_RESIZE_TEXTAREA.maybe(prefs.autoExpandTextBox), prefs = prefs -- cgit v1.2.3 From 31dc27d568d40d37cccb09e31c8a8c8b9cf8f897 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 12 Jan 2021 23:57:16 -0800 Subject: Update messenger theme --- .../pitchedapps/frost/injectors/ThemeProvider.kt | 1 + app/src/web/scss/core/_colors.scss | 1 + app/src/web/scss/messenger/core/_core_vars.scss | 38 +++++++++++++++++----- app/src/web/scss/palette/_custom.scss | 1 + 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt index 666a6bc5..142a69e7 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt @@ -105,6 +105,7 @@ class ThemeProvider(private val context: Context, private val prefs: Prefs) { content = content .replace("\$T\$", textColor.toRgbaString()) .replace("\$TT\$", textColor.colorToBackground(0.05f).toRgbaString()) + .replace("\$TD\$", textColor.adjustAlpha(0.6f).toRgbaString()) .replace("\$A\$", accentColor.toRgbaString()) .replace("\$AT\$", iconColor.toRgbaString()) .replace("\$B\$", bgColor.toRgbaString()) diff --git a/app/src/web/scss/core/_colors.scss b/app/src/web/scss/core/_colors.scss index 7610572c..ea75cc15 100644 --- a/app/src/web/scss/core/_colors.scss +++ b/app/src/web/scss/core/_colors.scss @@ -4,6 +4,7 @@ $bg_transparent: rgba(#f0f, 0.02) !default; //Our default colors are test colors; production files should always import the actual colors $text: #d7b0d7 !default; +$text_disabled: rgba($text, 0.6) !default; // must be visible with accent as the background $accent_text: #76d7c2 !default; $link: #9266d5 !default; diff --git a/app/src/web/scss/messenger/core/_core_vars.scss b/app/src/web/scss/messenger/core/_core_vars.scss index f15c936c..cdc5b7cf 100644 --- a/app/src/web/scss/messenger/core/_core_vars.scss +++ b/app/src/web/scss/messenger/core/_core_vars.scss @@ -1,10 +1,30 @@ :root, .__fb-light-mode { - // Main background; needs to be opaque to hide gradient used for sender card - --messenger-card-background: $bg_transparent !important; - // Date - --placeholder-text: $text !important; - // Emoji background - --surface-background: $bg_opaque2 !important; - --primary-text: $text !important; - --web-wash: #f0f !important; -} \ No newline at end of file + --attachment-footer-background: #{$bg_opaque} !important; + --card-background-flat: #{$bg_opaque} !important; + --card-background: #{$bg_opaque} !important; + --comment-background: #{$bg_opaque} !important; + --comment-footer-background: #{$bg_opaque} !important; + --disabled-button-background: #{$bg_opaque} !important; + --disabled-icon: #{$text_disabled} !important; + --disabled-text: #{$text_disabled} !important; + --divider: #{$divider} !important; + --hero-banner-background: #{$bg_opaque} !important; + --highlight-bg: #{$bg_opaque2} !important; + --media-outer-border: #{$bg_opaque} !important; + --messenger-card-background: #{$bg_opaque} !important; + --messenger-card-background: #{$bg_opaque} !important; // Main background; needs to be opaque to hide gradient used for sender card + --messenger-reply-background: #{$bg_opaque2} !important; + --nav-bar-background-gradient-wash: #{$bg_opaque} !important; + --nav-bar-background-gradient: #{$bg_opaque} !important; + --nav-bar-background: #{$bg_opaque} !important; + --new-notification-background: #{$bg_opaque2} !important; + --placeholder-text: #{$text} !important; // Date + --primary-icon: #{$text} !important; + --primary-text: #{$text} !important; + --secondary-icon: #{$text} !important; + --secondary-text: #{$text} !important; + --surface-background: #{$bg_opaque2} !important; // Emoji background + --toggle-active-background: #{$bg_opaque2} !important; + --web-wash: #{$bg_opaque2} !important; + --web-wash: #{$bg_opaque2} !important; +} diff --git a/app/src/web/scss/palette/_custom.scss b/app/src/web/scss/palette/_custom.scss index b35bdfa1..0adb7768 100644 --- a/app/src/web/scss/palette/_custom.scss +++ b/app/src/web/scss/palette/_custom.scss @@ -1,5 +1,6 @@ $bg_transparent: unquote('$BT$'); $text: unquote('$T$'); +$text_disabled: unquote('$TD$'); $link: unquote('$TT$'); $accent: unquote('$A$'); $accent_text: unquote('$AT$'); -- cgit v1.2.3 From a99ce272195c132c23379f28278339c88b356da1 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Wed, 13 Jan 2021 00:29:41 -0800 Subject: Update theme --- app/src/web/scss/core/_base.scss | 14 +++++++++++++- app/src/web/scss/messenger/core/_core_border.scss | 3 +++ app/src/web/scss/messenger/core/_core_vars.scss | 8 ++++++-- app/src/web/scss/messenger/core/core.scss | 16 +++++++++++++++- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/app/src/web/scss/core/_base.scss b/app/src/web/scss/core/_base.scss index 472319fe..6fa9c3fd 100644 --- a/app/src/web/scss/core/_base.scss +++ b/app/src/web/scss/core/_base.scss @@ -16,6 +16,13 @@ } } +@mixin fill-available { + width: 100%; + max-width: -webkit-fill-available; + max-width: -moz-available; + max-width: fill-available; +} + @mixin keyframes($name) { @-webkit-keyframes #{$name} { @content; @@ -38,7 +45,12 @@ @function str-replace($string, $search, $replace: "") { $index: str-index($string, $search); - @return if($index, str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace), $string); + @return if( + $index, + str-slice($string, 1, $index - 1) + $replace + + str-replace(str-slice($string, $index + str-length($search)), $search, $replace), + $string + ); } // https://css-tricks.com/probably-dont-base64-svg/ diff --git a/app/src/web/scss/messenger/core/_core_border.scss b/app/src/web/scss/messenger/core/_core_border.scss index e69de29b..10495a02 100644 --- a/app/src/web/scss/messenger/core/_core_border.scss +++ b/app/src/web/scss/messenger/core/_core_border.scss @@ -0,0 +1,3 @@ +[role="navigation"] { + border-right: 2px solid $bg_opaque2 !important; +} \ No newline at end of file diff --git a/app/src/web/scss/messenger/core/_core_vars.scss b/app/src/web/scss/messenger/core/_core_vars.scss index cdc5b7cf..66795299 100644 --- a/app/src/web/scss/messenger/core/_core_vars.scss +++ b/app/src/web/scss/messenger/core/_core_vars.scss @@ -2,7 +2,7 @@ --attachment-footer-background: #{$bg_opaque} !important; --card-background-flat: #{$bg_opaque} !important; --card-background: #{$bg_opaque} !important; - --comment-background: #{$bg_opaque} !important; + --comment-background: #{$bg_opaque2} !important; --comment-footer-background: #{$bg_opaque} !important; --disabled-button-background: #{$bg_opaque} !important; --disabled-icon: #{$text_disabled} !important; @@ -25,6 +25,10 @@ --secondary-text: #{$text} !important; --surface-background: #{$bg_opaque2} !important; // Emoji background --toggle-active-background: #{$bg_opaque2} !important; + --wash: #{$bg_opaque2} !important; --web-wash: #{$bg_opaque2} !important; - --web-wash: #{$bg_opaque2} !important; + + [role="navigation"] { + --surface-background: #{$bg_opaque} !important; // Nav background + } } diff --git a/app/src/web/scss/messenger/core/core.scss b/app/src/web/scss/messenger/core/core.scss index d5cb691a..7d49422d 100644 --- a/app/src/web/scss/messenger/core/core.scss +++ b/app/src/web/scss/messenger/core/core.scss @@ -3,4 +3,18 @@ @import "core_vars"; @import "core_text"; @import "core_bg"; -@import "core_border"; \ No newline at end of file +@import "core_border"; + +// Sizing adjustments +[role="navigation"] { + .rq0escxv.l9j0dhe7.du4w35lb.j83agx80.g5gj957u.rj1gh0hx.buofh1pr.hpfvmrgz.i1fnvgqd.bp9cbjyn.owycx6da.btwxx1t3.dflh9lhu.scb9dxdr.sj5x9vvc.cxgpxx05.sn0e7ne5.f6rbj1fe.l3ldwz01 /* New! Messenger app for windows */, + .rq0escxv.l9j0dhe7.du4w35lb.n851cfcs.aahdfvyu /* Search messenger */, + .wkznzc2l /* Top left chat + menu entry */ { + display: none !important; + } +} + +.rq0escxv.l9j0dhe7.du4w35lb.j83agx80.cbu4d94t.pfnyh3mw.d2edcug0.hpfvmrgz.p8fzw8mz.pcp91wgn.iuny7tx3.ipjc6fyt /* Top bar call video info icons */, +.kuivcneq /* Right sidebar */ { + display: none !important; +} -- cgit v1.2.3 From 8fe2427cff223a509441545227ac58b215903929 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Wed, 13 Jan 2021 00:32:09 -0800 Subject: Fix theme provider test --- .../com/pitchedapps/frost/injectors/ThemeProviderTest.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/test/kotlin/com/pitchedapps/frost/injectors/ThemeProviderTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/injectors/ThemeProviderTest.kt index f59980d2..e1ef6225 100644 --- a/app/src/test/kotlin/com/pitchedapps/frost/injectors/ThemeProviderTest.kt +++ b/app/src/test/kotlin/com/pitchedapps/frost/injectors/ThemeProviderTest.kt @@ -16,6 +16,8 @@ */ package com.pitchedapps.frost.injectors +import com.pitchedapps.frost.enums.Theme +import com.pitchedapps.frost.enums.ThemeCategory import java.io.File import kotlin.test.Test import kotlin.test.assertTrue @@ -24,9 +26,11 @@ class ThemeProviderTest { @Test fun verifyAssetsExist() { - ThemeProvider.values().forEach { asset -> - val file = File("src/web/assets/css/${asset.folder}/${asset.file}").absoluteFile - assertTrue(file.exists(), "${asset.name} not found at ${file.path}") + ThemeCategory.values().forEach { category -> + Theme.values.filter { it != Theme.DEFAULT }.forEach { theme -> + val file = File("src/web/assets/css/${category.folder}/themes/${theme.file}").absoluteFile + assertTrue(file.exists(), "${theme.name} not found at ${file.path}") + } } } } -- cgit v1.2.3 From ffefc86e0af62845a4493359c0d00b6d77290b26 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Wed, 13 Jan 2021 00:39:32 -0800 Subject: Update theme provider docs --- .../main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt index 142a69e7..570f3719 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt @@ -37,13 +37,12 @@ import kotlinx.coroutines.withContext import org.koin.core.context.GlobalContext /** - * Created by Allan Wang on 2017-05-31. - * Mapping of the available assets - * The enum name must match the css file name + * Provides [InjectorContract] for each [ThemeCategory]. + * Can be reloaded to take in changes from [Prefs] */ class ThemeProvider(private val context: Context, private val prefs: Prefs) { - var theme: Theme = Theme.values[prefs.theme] + private var theme: Theme = Theme.values[prefs.theme] private val injectors: MutableMap = mutableMapOf() -- cgit v1.2.3 From 28e7848e0da91be7f841e133ed989769bfcc6dca Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Wed, 13 Jan 2021 00:42:22 -0800 Subject: Update changelog --- app/src/main/play/en-US/whatsnew | 6 +++--- app/src/main/res/xml/frost_changelog.xml | 6 ++++++ docs/Changelog.md | 4 ++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/src/main/play/en-US/whatsnew b/app/src/main/play/en-US/whatsnew index 5e14d894..fad19c9d 100644 --- a/app/src/main/play/en-US/whatsnew +++ b/app/src/main/play/en-US/whatsnew @@ -1,4 +1,4 @@ -v2.4.7 +v3.0.0 -* Fix theme not always sticking on refresh -* Disable long press menu from appearing immediately after scrolling \ No newline at end of file +* Removed email support. Please use GitHub for all inquiries as I no longer have time to look through all emails +* Added initial support for messenger.com \ 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 6a526ccb..8badfc5f 100644 --- a/app/src/main/res/xml/frost_changelog.xml +++ b/app/src/main/res/xml/frost_changelog.xml @@ -6,6 +6,12 @@ --> + + + + + + diff --git a/docs/Changelog.md b/docs/Changelog.md index caf30a00..f53b43d4 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -1,5 +1,9 @@ # Changelog +## v3.0.0 +* Removed email support. Please use GitHub for all inquiries as I no longer have time to look through all emails +* Added initial support for messenger.com + ## v2.4.7 * Fix theme not always sticking on refresh * Disable long press menu from appearing immediately after scrolling -- cgit v1.2.3 From 2a0d6f895a7d48bd86ca4849c742dd0ca39ff8c5 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 24 Jan 2021 16:09:13 -0800 Subject: Fix messenger theme for default --- app/src/main/kotlin/com/pitchedapps/frost/enums/Theme.kt | 2 +- app/src/main/play/en-US/whatsnew | 3 ++- app/src/main/res/xml/frost_changelog.xml | 5 ++--- app/src/web/scss/facebook/core/_core_hider.scss | 4 ++++ app/src/web/scss/facebook/core/core.scss | 6 +----- app/src/web/scss/facebook/themes/default.scss | 1 + app/src/web/scss/messenger/core/_core_hider.scss | 13 +++++++++++++ app/src/web/scss/messenger/core/core.scss | 15 +-------------- app/src/web/scss/messenger/themes/default.scss | 1 + docs/Changelog.md | 1 + 10 files changed, 27 insertions(+), 24 deletions(-) create mode 100644 app/src/web/scss/facebook/core/_core_hider.scss create mode 100644 app/src/web/scss/facebook/themes/default.scss create mode 100644 app/src/web/scss/messenger/core/_core_hider.scss create mode 100644 app/src/web/scss/messenger/themes/default.scss diff --git a/app/src/main/kotlin/com/pitchedapps/frost/enums/Theme.kt b/app/src/main/kotlin/com/pitchedapps/frost/enums/Theme.kt index 1f28d271..1c9d6aa5 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/enums/Theme.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/enums/Theme.kt @@ -40,7 +40,7 @@ enum class Theme( ) { DEFAULT(R.string.kau_default, - null, + "default", { 0xde000000.toInt() }, { FACEBOOK_BLUE }, { 0xfffafafa.toInt() }, diff --git a/app/src/main/play/en-US/whatsnew b/app/src/main/play/en-US/whatsnew index fad19c9d..a02cbb99 100644 --- a/app/src/main/play/en-US/whatsnew +++ b/app/src/main/play/en-US/whatsnew @@ -1,4 +1,5 @@ v3.0.0 * Removed email support. Please use GitHub for all inquiries as I no longer have time to look through all emails -* Added initial support for messenger.com \ No newline at end of file +* Added initial support for messenger.com +* Fix swipe to refresh not disabling for certain pages \ 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 8badfc5f..e03eceb2 100644 --- a/app/src/main/res/xml/frost_changelog.xml +++ b/app/src/main/res/xml/frost_changelog.xml @@ -9,15 +9,14 @@ + + - - - diff --git a/app/src/web/scss/facebook/core/_core_hider.scss b/app/src/web/scss/facebook/core/_core_hider.scss new file mode 100644 index 00000000..a166db3b --- /dev/null +++ b/app/src/web/scss/facebook/core/_core_hider.scss @@ -0,0 +1,4 @@ +[data-sigil=m_login_upsell], +[data-sigil="m-loading-indicator-animate m-loading-indicator-root"] { + display: none !important; +} \ No newline at end of file diff --git a/app/src/web/scss/facebook/core/core.scss b/app/src/web/scss/facebook/core/core.scss index dd8fd398..ab77c091 100644 --- a/app/src/web/scss/facebook/core/core.scss +++ b/app/src/web/scss/facebook/core/core.scss @@ -4,6 +4,7 @@ @import "core_bg"; @import "core_border"; @import "core_messages"; +@import "core_hider"; //GLOBAL overrides; use with caution *, *::after, *::before { @@ -15,11 +16,6 @@ // box-shadow: none !important; // } -[data-sigil=m_login_upsell], -[data-sigil="m-loading-indicator-animate m-loading-indicator-root"] { - display: none !important; -} - @include placeholder { color: $text !important; } diff --git a/app/src/web/scss/facebook/themes/default.scss b/app/src/web/scss/facebook/themes/default.scss new file mode 100644 index 00000000..92e352a7 --- /dev/null +++ b/app/src/web/scss/facebook/themes/default.scss @@ -0,0 +1 @@ +@import "../core/core_hider"; diff --git a/app/src/web/scss/messenger/core/_core_hider.scss b/app/src/web/scss/messenger/core/_core_hider.scss new file mode 100644 index 00000000..94d2d87f --- /dev/null +++ b/app/src/web/scss/messenger/core/_core_hider.scss @@ -0,0 +1,13 @@ +// Sizing adjustments +[role="navigation"] { + .rq0escxv.l9j0dhe7.du4w35lb.j83agx80.g5gj957u.rj1gh0hx.buofh1pr.hpfvmrgz.i1fnvgqd.bp9cbjyn.owycx6da.btwxx1t3.dflh9lhu.scb9dxdr.sj5x9vvc.cxgpxx05.sn0e7ne5.f6rbj1fe.l3ldwz01 /* New! Messenger app for windows */, + .rq0escxv.l9j0dhe7.du4w35lb.n851cfcs.aahdfvyu /* Search messenger */, + .wkznzc2l /* Top left chat + menu entry */ { + display: none !important; + } +} + +.rq0escxv.l9j0dhe7.du4w35lb.j83agx80.cbu4d94t.pfnyh3mw.d2edcug0.hpfvmrgz.p8fzw8mz.pcp91wgn.iuny7tx3.ipjc6fyt /* Top bar call video info icons */, +.kuivcneq /* Right sidebar */ { + display: none !important; +} diff --git a/app/src/web/scss/messenger/core/core.scss b/app/src/web/scss/messenger/core/core.scss index 7d49422d..3f09b42e 100644 --- a/app/src/web/scss/messenger/core/core.scss +++ b/app/src/web/scss/messenger/core/core.scss @@ -4,17 +4,4 @@ @import "core_text"; @import "core_bg"; @import "core_border"; - -// Sizing adjustments -[role="navigation"] { - .rq0escxv.l9j0dhe7.du4w35lb.j83agx80.g5gj957u.rj1gh0hx.buofh1pr.hpfvmrgz.i1fnvgqd.bp9cbjyn.owycx6da.btwxx1t3.dflh9lhu.scb9dxdr.sj5x9vvc.cxgpxx05.sn0e7ne5.f6rbj1fe.l3ldwz01 /* New! Messenger app for windows */, - .rq0escxv.l9j0dhe7.du4w35lb.n851cfcs.aahdfvyu /* Search messenger */, - .wkznzc2l /* Top left chat + menu entry */ { - display: none !important; - } -} - -.rq0escxv.l9j0dhe7.du4w35lb.j83agx80.cbu4d94t.pfnyh3mw.d2edcug0.hpfvmrgz.p8fzw8mz.pcp91wgn.iuny7tx3.ipjc6fyt /* Top bar call video info icons */, -.kuivcneq /* Right sidebar */ { - display: none !important; -} +@import "core_hider"; diff --git a/app/src/web/scss/messenger/themes/default.scss b/app/src/web/scss/messenger/themes/default.scss new file mode 100644 index 00000000..92e352a7 --- /dev/null +++ b/app/src/web/scss/messenger/themes/default.scss @@ -0,0 +1 @@ +@import "../core/core_hider"; diff --git a/docs/Changelog.md b/docs/Changelog.md index f53b43d4..e1b1e889 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -3,6 +3,7 @@ ## v3.0.0 * Removed email support. Please use GitHub for all inquiries as I no longer have time to look through all emails * Added initial support for messenger.com +* Fix swipe to refresh not disabling for certain pages ## v2.4.7 * Fix theme not always sticking on refresh -- cgit v1.2.3 From e0f289862bb76c36c01db9b092cafeb4cf8f6ebc Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 24 Jan 2021 16:55:33 -0800 Subject: Update db to include messenger cookie --- app/build.gradle | 2 +- .../pitchedapps/frost/db/CookieMigrationTest.kt | 58 ++++++ .../kotlin/com/pitchedapps/frost/db/CookiesDb.kt | 16 +- .../kotlin/com/pitchedapps/frost/db/Database.kt | 4 +- .../com/pitchedapps/frost/facebook/FbCookie.kt | 7 +- .../2.json | 201 +++++++++++++++++++++ buildSrc/src/main/kotlin/Versions.kt | 2 +- 7 files changed, 283 insertions(+), 7 deletions(-) create mode 100644 app/src/androidTest/kotlin/com/pitchedapps/frost/db/CookieMigrationTest.kt create mode 100644 app/src/schemas/com.pitchedapps.frost.db.FrostPrivateDatabase/2.json diff --git a/app/build.gradle b/app/build.gradle index c6e1aef8..2a0f7768 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -314,7 +314,7 @@ dependencies { implementation "androidx.room:room-ktx:${Versions.room}" implementation "androidx.room:room-runtime:${Versions.room}" kapt "androidx.room:room-compiler:${Versions.room}" - testImplementation "androidx.room:room-testing:${Versions.room}" + androidTestImplementation "androidx.room:room-testing:${Versions.room}" } diff --git a/app/src/androidTest/kotlin/com/pitchedapps/frost/db/CookieMigrationTest.kt b/app/src/androidTest/kotlin/com/pitchedapps/frost/db/CookieMigrationTest.kt new file mode 100644 index 00000000..6ba6e0b6 --- /dev/null +++ b/app/src/androidTest/kotlin/com/pitchedapps/frost/db/CookieMigrationTest.kt @@ -0,0 +1,58 @@ +/* + * Copyright 2021 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.db + +import androidx.room.Room +import androidx.room.testing.MigrationTestHelper +import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.platform.app.InstrumentationRegistry +import kotlin.test.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4::class) +class CookieMigrationTest { + + private val TEST_DB = "cookie_migration_test" + + private val ALL_MIGRATIONS = arrayOf(COOKIES_MIGRATION_1_2) + + val helper: MigrationTestHelper = MigrationTestHelper( + InstrumentationRegistry.getInstrumentation(), + FrostPrivateDatabase::class.java.canonicalName, + FrameworkSQLiteOpenHelperFactory() + ) + + @Test + fun migrateAll() { + // Create earliest version of the database. + helper.createDatabase(TEST_DB, 1).apply { + close() + } + + // Open latest version of the database. Room will validate the schema + // once all migrations execute. + Room.databaseBuilder( + InstrumentationRegistry.getInstrumentation().targetContext, + FrostPrivateDatabase::class.java, + TEST_DB + ).addMigrations(*ALL_MIGRATIONS).build().apply { + openHelper.writableDatabase + close() + } + } +} diff --git a/app/src/main/kotlin/com/pitchedapps/frost/db/CookiesDb.kt b/app/src/main/kotlin/com/pitchedapps/frost/db/CookiesDb.kt index 388edfe6..163d151b 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/db/CookiesDb.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/db/CookiesDb.kt @@ -23,6 +23,8 @@ import androidx.room.Entity import androidx.room.Insert import androidx.room.OnConflictStrategy import androidx.room.Query +import androidx.room.migration.Migration +import androidx.sqlite.db.SupportSQLiteDatabase import com.pitchedapps.frost.prefs.Prefs import kotlinx.android.parcel.Parcelize @@ -37,7 +39,8 @@ data class CookieEntity( @ColumnInfo(name = "cookie_id") val id: Long, val name: String?, - val cookie: String? + val cookie: String?, + val cookieMessenger: String? = null // Version 2 ) : Parcelable { override fun toString(): String = "CookieEntity(${hashCode()})" @@ -61,6 +64,9 @@ interface CookieDao { @Query("DELETE FROM cookies WHERE cookie_id = :id") fun _deleteById(id: Long) + + @Query("UPDATE cookies SET cookieMessenger = :cookie WHERE cookie_id = :id") + fun _updateMessengerCookie(id: Long, cookie: String?) } suspend fun CookieDao.selectAll() = dao { _selectAll() } @@ -69,3 +75,11 @@ suspend fun CookieDao.save(cookie: CookieEntity) = dao { _save(cookie) } suspend fun CookieDao.save(cookies: List) = dao { _save(cookies) } suspend fun CookieDao.deleteById(id: Long) = dao { _deleteById(id) } suspend fun CookieDao.currentCookie(prefs: Prefs) = selectById(prefs.userId) +suspend fun CookieDao.updateMessengerCookie(id: Long, cookie: String?) = + dao { _updateMessengerCookie(id, cookie) } + +val COOKIES_MIGRATION_1_2 = object : Migration(1, 2) { + override fun migrate(database: SupportSQLiteDatabase) { + database.execSQL("ALTER TABLE cookies ADD COLUMN cookieMessenger TEXT") + } +} diff --git a/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt b/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt index 21a2f1dc..bd0b4ee0 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt @@ -31,7 +31,7 @@ interface FrostPrivateDao { @Database( entities = [CookieEntity::class, NotificationEntity::class, CacheEntity::class], - version = 1, + version = 2, exportSchema = true ) abstract class FrostPrivateDatabase : RoomDatabase(), FrostPrivateDao { @@ -84,7 +84,7 @@ class FrostDatabase( val privateDb = Room.databaseBuilder( context, FrostPrivateDatabase::class.java, FrostPrivateDatabase.DATABASE_NAME - ).frostBuild() + ).addMigrations(COOKIES_MIGRATION_1_2).frostBuild() val publicDb = Room.databaseBuilder( context, FrostPublicDatabase::class.java, FrostPublicDatabase.DATABASE_NAME diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt index efaa03ab..db40495b 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt @@ -24,6 +24,7 @@ import com.pitchedapps.frost.db.CookieEntity import com.pitchedapps.frost.db.deleteById import com.pitchedapps.frost.db.save import com.pitchedapps.frost.db.selectById +import com.pitchedapps.frost.db.updateMessengerCookie import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.cookies @@ -115,14 +116,16 @@ class FbCookie(private val prefs: Prefs, private val cookieDao: CookieDao) { L.d { "Switching User; null cookie" } return } + val currentId = prefs.userId withContext(Dispatchers.IO + NonCancellable) { L.d { "Switching User" } - // TODO save old messenger cookie + // Save current messenger cookie state. + cookieDao.updateMessengerCookie(currentId, messengerCookie) prefs.userId = cookie.id CookieManager.getInstance().apply { removeAllCookies() suspendSetWebCookie(FB_COOKIE_DOMAIN, cookie.cookie) - // TODO set messenger cookie + suspendSetWebCookie(MESSENGER_COOKIE_DOMAIN, cookie.cookieMessenger) flush() } } diff --git a/app/src/schemas/com.pitchedapps.frost.db.FrostPrivateDatabase/2.json b/app/src/schemas/com.pitchedapps.frost.db.FrostPrivateDatabase/2.json new file mode 100644 index 00000000..066f4478 --- /dev/null +++ b/app/src/schemas/com.pitchedapps.frost.db.FrostPrivateDatabase/2.json @@ -0,0 +1,201 @@ +{ + "formatVersion": 1, + "database": { + "version": 2, + "identityHash": "c7625cc0226e291f14c14f528a11e739", + "entities": [ + { + "tableName": "cookies", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`cookie_id` INTEGER NOT NULL, `name` TEXT, `cookie` TEXT, `cookieMessenger` TEXT, PRIMARY KEY(`cookie_id`))", + "fields": [ + { + "fieldPath": "id", + "columnName": "cookie_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "cookie", + "columnName": "cookie", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "cookieMessenger", + "columnName": "cookieMessenger", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "cookie_id" + ], + "autoGenerate": false + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "notifications", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`notif_id` INTEGER NOT NULL, `userId` INTEGER NOT NULL, `href` TEXT NOT NULL, `title` TEXT, `text` TEXT NOT NULL, `timestamp` INTEGER NOT NULL, `profileUrl` TEXT, `type` TEXT NOT NULL, `unread` INTEGER NOT NULL, PRIMARY KEY(`notif_id`, `userId`), FOREIGN KEY(`userId`) REFERENCES `cookies`(`cookie_id`) ON UPDATE NO ACTION ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "id", + "columnName": "notif_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "userId", + "columnName": "userId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "href", + "columnName": "href", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "title", + "columnName": "title", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "text", + "columnName": "text", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "timestamp", + "columnName": "timestamp", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "profileUrl", + "columnName": "profileUrl", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "unread", + "columnName": "unread", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "notif_id", + "userId" + ], + "autoGenerate": false + }, + "indices": [ + { + "name": "index_notifications_notif_id", + "unique": false, + "columnNames": [ + "notif_id" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_notifications_notif_id` ON `${TABLE_NAME}` (`notif_id`)" + }, + { + "name": "index_notifications_userId", + "unique": false, + "columnNames": [ + "userId" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_notifications_userId` ON `${TABLE_NAME}` (`userId`)" + } + ], + "foreignKeys": [ + { + "table": "cookies", + "onDelete": "CASCADE", + "onUpdate": "NO ACTION", + "columns": [ + "userId" + ], + "referencedColumns": [ + "cookie_id" + ] + } + ] + }, + { + "tableName": "frost_cache", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `type` TEXT NOT NULL, `lastUpdated` INTEGER NOT NULL, `contents` TEXT NOT NULL, PRIMARY KEY(`id`, `type`), FOREIGN KEY(`id`) REFERENCES `cookies`(`cookie_id`) ON UPDATE NO ACTION ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "lastUpdated", + "columnName": "lastUpdated", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "contents", + "columnName": "contents", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "id", + "type" + ], + "autoGenerate": false + }, + "indices": [], + "foreignKeys": [ + { + "table": "cookies", + "onDelete": "CASCADE", + "onUpdate": "NO ACTION", + "columns": [ + "id" + ], + "referencedColumns": [ + "cookie_id" + ] + } + ] + } + ], + "views": [], + "setupQueries": [ + "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'c7625cc0226e291f14c14f528a11e739')" + ] + } +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index 6ed9d7b9..fc6aae95 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -16,7 +16,7 @@ object Versions { // https://square.github.io/okhttp/changelog/ const val okhttp = "4.9.0" // https://developer.android.com/jetpack/androidx/releases/room - const val room = "2.2.5" + const val room = "2.2.6" // http://robolectric.org/getting-started/ const val roboelectric = "4.4" // https://github.com/davemorrissey/subsampling-scale-image-view#quick-start -- cgit v1.2.3 From c2f7e2e0c611e79b62ca43c7d8712b367796f5b5 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 24 Jan 2021 17:19:08 -0800 Subject: Require main thread for cookiemanager calls --- .../kotlin/com/pitchedapps/frost/facebook/FbCookie.kt | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt index db40495b..65955bdc 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt @@ -29,14 +29,14 @@ import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.cookies import com.pitchedapps.frost.utils.launchLogin -import kotlin.coroutines.resume -import kotlin.coroutines.suspendCoroutine import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.NonCancellable import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.withContext import org.koin.dsl.module +import kotlin.coroutines.resume +import kotlin.coroutines.suspendCoroutine /** * Created by Allan Wang on 2017-05-30. @@ -64,7 +64,10 @@ class FbCookie(private val prefs: Prefs, private val cookieDao: CookieDao) { val messengerCookie: String? get() = CookieManager.getInstance().getCookie(HTTPS_MESSENGER_COM) - private suspend fun CookieManager.suspendSetWebCookie(domain: String, cookie: String?): Boolean { + private suspend fun CookieManager.suspendSetWebCookie( + domain: String, + cookie: String? + ): Boolean { cookie ?: return true return withContext(NonCancellable) { // Save all cookies regardless of result, then check if all succeeded @@ -100,9 +103,11 @@ class FbCookie(private val prefs: Prefs, private val cookieDao: CookieDao) { suspend fun reset() { prefs.userId = -1L - with(CookieManager.getInstance()) { - removeAllCookies() - flush() + withContext(Dispatchers.Main + NonCancellable) { + with(CookieManager.getInstance()) { + removeAllCookies() + flush() + } } } @@ -117,7 +122,7 @@ class FbCookie(private val prefs: Prefs, private val cookieDao: CookieDao) { return } val currentId = prefs.userId - withContext(Dispatchers.IO + NonCancellable) { + withContext(Dispatchers.Main + NonCancellable) { L.d { "Switching User" } // Save current messenger cookie state. cookieDao.updateMessengerCookie(currentId, messengerCookie) -- cgit v1.2.3 From 43a33ed0256a86efa885f97f678b13881d1c5b01 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 24 Jan 2021 17:26:59 -0800 Subject: Spotless --- app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt index 65955bdc..b02ec941 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt @@ -29,14 +29,14 @@ import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.cookies import com.pitchedapps.frost.utils.launchLogin +import kotlin.coroutines.resume +import kotlin.coroutines.suspendCoroutine import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.NonCancellable import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.withContext import org.koin.dsl.module -import kotlin.coroutines.resume -import kotlin.coroutines.suspendCoroutine /** * Created by Allan Wang on 2017-05-30. -- cgit v1.2.3 From be88f69e7863b8df2923ab456481e419de29b33b Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 24 Jan 2021 17:54:09 -0800 Subject: Theme updates --- app/src/web/scss/core/_base.scss | 8 ++++++++ app/src/web/scss/facebook/core/core.scss | 2 +- app/src/web/scss/messenger/core/_core_hider.scss | 2 ++ app/src/web/scss/messenger/core/_core_text.scss | 3 +++ app/src/web/scss/messenger/core/core.scss | 4 ++++ 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/src/web/scss/core/_base.scss b/app/src/web/scss/core/_base.scss index 6fa9c3fd..f6b5c903 100644 --- a/app/src/web/scss/core/_base.scss +++ b/app/src/web/scss/core/_base.scss @@ -1,4 +1,8 @@ @mixin placeholder { + ::placeholder { + @content; + } + ::-webkit-input-placeholder { @content; } @@ -14,6 +18,10 @@ :-ms-input-placeholder { @content; } + + ::-ms-input-placeholder { + @content; + } } @mixin fill-available { diff --git a/app/src/web/scss/facebook/core/core.scss b/app/src/web/scss/facebook/core/core.scss index ab77c091..d7e790d1 100644 --- a/app/src/web/scss/facebook/core/core.scss +++ b/app/src/web/scss/facebook/core/core.scss @@ -17,7 +17,7 @@ // } @include placeholder { - color: $text !important; + color: $text_disabled !important; } .excessItem { diff --git a/app/src/web/scss/messenger/core/_core_hider.scss b/app/src/web/scss/messenger/core/_core_hider.scss index 94d2d87f..a2dbeb48 100644 --- a/app/src/web/scss/messenger/core/_core_hider.scss +++ b/app/src/web/scss/messenger/core/_core_hider.scss @@ -7,6 +7,8 @@ } } +header[role="banner"] /* login banner */, +._90px._9gb7 /* login bottom banner */, .rq0escxv.l9j0dhe7.du4w35lb.j83agx80.cbu4d94t.pfnyh3mw.d2edcug0.hpfvmrgz.p8fzw8mz.pcp91wgn.iuny7tx3.ipjc6fyt /* Top bar call video info icons */, .kuivcneq /* Right sidebar */ { display: none !important; diff --git a/app/src/web/scss/messenger/core/_core_text.scss b/app/src/web/scss/messenger/core/_core_text.scss index e69de29b..7409cc4e 100644 --- a/app/src/web/scss/messenger/core/_core_text.scss +++ b/app/src/web/scss/messenger/core/_core_text.scss @@ -0,0 +1,3 @@ +html, body, input { + color: $text !important; +} \ No newline at end of file diff --git a/app/src/web/scss/messenger/core/core.scss b/app/src/web/scss/messenger/core/core.scss index 3f09b42e..89199222 100644 --- a/app/src/web/scss/messenger/core/core.scss +++ b/app/src/web/scss/messenger/core/core.scss @@ -5,3 +5,7 @@ @import "core_bg"; @import "core_border"; @import "core_hider"; + +@include placeholder { + color: $text_disabled !important; +} \ No newline at end of file -- cgit v1.2.3 From 58068ce55e9e203a77c67dfee78fb2658e3bb6aa Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 24 Jan 2021 19:10:09 -0800 Subject: Create messenger client with cookie checking --- .../kotlin/com/pitchedapps/frost/db/CookiesDb.kt | 3 +- .../com/pitchedapps/frost/facebook/FbConst.kt | 1 + .../com/pitchedapps/frost/facebook/FbCookie.kt | 4 -- .../pitchedapps/frost/fragments/WebFragments.kt | 2 + .../kotlin/com/pitchedapps/frost/utils/Utils.kt | 20 ++++---- .../pitchedapps/frost/views/FrostVideoViewer.kt | 2 +- .../com/pitchedapps/frost/views/FrostWebView.kt | 2 +- .../kotlin/com/pitchedapps/frost/web/FrostJSI.kt | 2 +- .../pitchedapps/frost/web/FrostWebViewClients.kt | 55 +++++++++++++++++++--- .../com/pitchedapps/frost/facebook/FbConstTest.kt | 37 +++++++++++++++ 10 files changed, 101 insertions(+), 27 deletions(-) create mode 100644 app/src/test/kotlin/com/pitchedapps/frost/facebook/FbConstTest.kt diff --git a/app/src/main/kotlin/com/pitchedapps/frost/db/CookiesDb.kt b/app/src/main/kotlin/com/pitchedapps/frost/db/CookiesDb.kt index 163d151b..8c2e32a7 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/db/CookiesDb.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/db/CookiesDb.kt @@ -44,7 +44,8 @@ data class CookieEntity( ) : Parcelable { override fun toString(): String = "CookieEntity(${hashCode()})" - fun toSensitiveString(): String = "CookieEntity(id=$id, name=$name, cookie=$cookie)" + fun toSensitiveString(): String = + "CookieEntity(id=$id, name=$name, cookie=$cookie cookieMessenger=$cookieMessenger)" } @Dao 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 fc4e3fae..b0846864 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt @@ -34,6 +34,7 @@ const val FB_URL_MBASIC_BASE = "https://$FACEBOOK_MBASIC_COM/" fun profilePictureUrl(id: Long) = "https://graph.facebook.com/$id/picture?type=large" const val FB_LOGIN_URL = "${FB_URL_BASE}login" const val FB_HOME_URL = "${FB_URL_BASE}home.php" +const val MESSENGER_THREAD_PREFIX = "$HTTPS_MESSENGER_COM/t/" /* * User agent candidates. diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt index b02ec941..4e932d09 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt @@ -24,7 +24,6 @@ import com.pitchedapps.frost.db.CookieEntity import com.pitchedapps.frost.db.deleteById import com.pitchedapps.frost.db.save import com.pitchedapps.frost.db.selectById -import com.pitchedapps.frost.db.updateMessengerCookie import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.cookies @@ -121,11 +120,8 @@ class FbCookie(private val prefs: Prefs, private val cookieDao: CookieDao) { L.d { "Switching User; null cookie" } return } - val currentId = prefs.userId withContext(Dispatchers.Main + NonCancellable) { L.d { "Switching User" } - // Save current messenger cookie state. - cookieDao.updateMessengerCookie(currentId, messengerCookie) prefs.userId = cookie.id CookieManager.getInstance().apply { removeAllCookies() diff --git a/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragments.kt b/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragments.kt index 502c37fb..3cac92af 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragments.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragments.kt @@ -26,6 +26,7 @@ import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.views.FrostWebView import com.pitchedapps.frost.web.FrostWebViewClient import com.pitchedapps.frost.web.FrostWebViewClientMenu +import com.pitchedapps.frost.web.FrostWebViewClientMessenger /** * Created by Allan Wang on 27/12/17. @@ -41,6 +42,7 @@ class WebFragment : BaseFragment() { * Given a webview, output a client */ fun client(web: FrostWebView) = when (baseEnum) { + FbItem.MESSENGER -> FrostWebViewClientMessenger(web) FbItem.MENU -> FrostWebViewClientMenu(web) else -> FrostWebViewClient(web) } 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 2d3a10c8..13ce2920 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -35,6 +35,7 @@ import ca.allanwang.kau.email.sendEmail import ca.allanwang.kau.mediapicker.createMediaFile import ca.allanwang.kau.mediapicker.createPrivateMediaFile import ca.allanwang.kau.utils.colorToForeground +import ca.allanwang.kau.utils.ctxCoroutine import ca.allanwang.kau.utils.darken import ca.allanwang.kau.utils.isColorDark import ca.allanwang.kau.utils.navigationBarColor @@ -77,8 +78,6 @@ import java.net.URLEncoder import java.nio.charset.StandardCharsets import java.util.ArrayList import java.util.Locale -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.launch import org.apache.commons.text.StringEscapeUtils @@ -98,14 +97,6 @@ const val ARG_IMAGE_URL = "arg_image_url" const val ARG_TEXT = "arg_text" const val ARG_COOKIE = "arg_cookie" -/** - * Most context items implement [CoroutineScope] by default. - * We will add a fallback just in case. - * It is expected that the scope returned always has the Android main dispatcher as part of the context. - */ -internal inline val Context.ctxCoroutine: CoroutineScope - get() = this as? CoroutineScope ?: GlobalScope - inline fun Context.launchNewTask( cookieList: ArrayList = arrayListOf(), clearStack: Boolean = false @@ -186,7 +177,9 @@ fun WebOverlayActivity.url(): String { fun Activity.setFrostTheme(themeProvider: ThemeProvider, forceTransparent: Boolean = false) { val isTransparent = - forceTransparent || (Color.alpha(themeProvider.bgColor) != 255) || (Color.alpha(themeProvider.headerColor) != 255) + forceTransparent || (Color.alpha(themeProvider.bgColor) != 255) || (Color.alpha( + themeProvider.headerColor + ) != 255) if (themeProvider.bgColor.isColorDark) { setTheme(if (isTransparent) R.style.FrostTheme_Transparent else R.style.FrostTheme) } else { @@ -313,7 +306,10 @@ inline val String?.isFacebookUrl get() = this != null && (contains(FACEBOOK_COM) || contains(FBCDN_NET)) inline val String?.isMessengerUrl -get() = this != null && contains(MESSENGER_COM) + get() = this != null && contains(MESSENGER_COM) + +inline val String?.isFbCookie + get() = this != null && contains("c_user") /** * [true] if url is a video and can be accepted by VideoViewer 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 169e7f73..a76aeea0 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt @@ -25,6 +25,7 @@ import android.view.LayoutInflater import android.view.MotionEvent import android.view.ViewTreeObserver import android.widget.FrameLayout +import ca.allanwang.kau.utils.ctxCoroutine import ca.allanwang.kau.utils.fadeIn import ca.allanwang.kau.utils.fadeOut import ca.allanwang.kau.utils.gone @@ -46,7 +47,6 @@ import com.pitchedapps.frost.db.currentCookie import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.L -import com.pitchedapps.frost.utils.ctxCoroutine import com.pitchedapps.frost.utils.frostDownload import org.koin.core.component.KoinComponent import org.koin.core.component.inject 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 e4752d1b..ecd8c093 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt @@ -24,6 +24,7 @@ import android.util.AttributeSet import android.view.View import android.view.ViewGroup import ca.allanwang.kau.utils.AnimHolder +import ca.allanwang.kau.utils.ctxCoroutine import ca.allanwang.kau.utils.launchMain import com.pitchedapps.frost.contracts.FrostContentContainer import com.pitchedapps.frost.contracts.FrostContentCore @@ -37,7 +38,6 @@ import com.pitchedapps.frost.fragments.WebFragment import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.L -import com.pitchedapps.frost.utils.ctxCoroutine import com.pitchedapps.frost.utils.frostDownload import com.pitchedapps.frost.web.FrostChromeClient import com.pitchedapps.frost.web.FrostJSI 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 4e8e8cee..12e10e10 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt @@ -18,6 +18,7 @@ package com.pitchedapps.frost.web import android.content.Context import android.webkit.JavascriptInterface +import ca.allanwang.kau.utils.ctxCoroutine import com.pitchedapps.frost.activities.MainActivity import com.pitchedapps.frost.activities.WebOverlayActivityBase import com.pitchedapps.frost.contracts.MainActivityContract @@ -28,7 +29,6 @@ import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.WebContext import com.pitchedapps.frost.utils.cookies -import com.pitchedapps.frost.utils.ctxCoroutine import com.pitchedapps.frost.utils.isIndependent import com.pitchedapps.frost.utils.launchImageActivity import com.pitchedapps.frost.utils.showWebContextMenu 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 8ec5f975..1495b2e0 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt @@ -22,11 +22,17 @@ import android.webkit.WebResourceRequest import android.webkit.WebResourceResponse import android.webkit.WebView import android.webkit.WebViewClient +import ca.allanwang.kau.utils.ctxCoroutine import ca.allanwang.kau.utils.withAlpha +import com.pitchedapps.frost.db.CookieDao +import com.pitchedapps.frost.db.currentCookie +import com.pitchedapps.frost.db.updateMessengerCookie import com.pitchedapps.frost.enums.ThemeCategory import com.pitchedapps.frost.facebook.FACEBOOK_BASE_COM import com.pitchedapps.frost.facebook.FbCookie import com.pitchedapps.frost.facebook.FbItem +import com.pitchedapps.frost.facebook.HTTPS_MESSENGER_COM +import com.pitchedapps.frost.facebook.MESSENGER_THREAD_PREFIX import com.pitchedapps.frost.facebook.WWW_FACEBOOK_COM import com.pitchedapps.frost.facebook.formattedFbUrl import com.pitchedapps.frost.injectors.CssAsset @@ -39,6 +45,7 @@ import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.isExplicitIntent import com.pitchedapps.frost.utils.isFacebookUrl +import com.pitchedapps.frost.utils.isFbCookie import com.pitchedapps.frost.utils.isImageUrl import com.pitchedapps.frost.utils.isIndirectImageUrl import com.pitchedapps.frost.utils.isMessengerUrl @@ -46,6 +53,7 @@ import com.pitchedapps.frost.utils.launchImageActivity import com.pitchedapps.frost.utils.resolveActivityForUri import com.pitchedapps.frost.views.FrostWebView import kotlinx.coroutines.channels.SendChannel +import kotlinx.coroutines.launch /** * Created by Allan Wang on 2017-05-31. @@ -71,11 +79,11 @@ open class BaseWebViewClient : WebViewClient() { */ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() { - private val fbCookie: FbCookie get() = web.fbCookie - private val prefs: Prefs get() = web.prefs - private val themeProvider: ThemeProvider get() = web.themeProvider - private val refresh: SendChannel = web.parent.refreshChannel - private val isMain = web.parent.baseEnum != null + protected val fbCookie: FbCookie get() = web.fbCookie + protected val prefs: Prefs get() = web.prefs + protected val themeProvider: ThemeProvider get() = web.themeProvider + protected val refresh: SendChannel = web.parent.refreshChannel + protected val isMain = web.parent.baseEnum != null /** * True if current url supports refresh. See [doUpdateVisitedHistory] for updates @@ -279,8 +287,6 @@ private const val EMIT_FINISH = 0 */ class FrostWebViewClientMenu(web: FrostWebView) : FrostWebViewClient(web) { - private val prefs: Prefs get() = web.prefs - override fun onPageFinished(view: WebView, url: String?) { super.onPageFinished(view, url) if (url == null) { @@ -302,3 +308,38 @@ class FrostWebViewClientMenu(web: FrostWebView) : FrostWebViewClient(web) { // Skip } } + +class FrostWebViewClientMessenger(web: FrostWebView) : FrostWebViewClient(web) { + + override fun onPageFinished(view: WebView, url: String?) { + super.onPageFinished(view, url) + messengerCookieCheck(url!!) + } + + private val cookieDao: CookieDao get() = web.cookieDao + private var hasCookie = fbCookie.messengerCookie.isFbCookie + + /** + * Check cookie changes. Unlike fb checks, we will continuously poll for cookie changes during loading. + * There is no lifecycle association between messenger login and facebook login, + * so we'll try to be smart about when to check for state changes. + * + * From testing, it looks like this is called after redirects. + * We can therefore classify no login as pointing to messenger.com, + * and login as pointing to messenger.com/t/[thread id] + */ + private fun messengerCookieCheck(url: String?) { + if (url?.startsWith(HTTPS_MESSENGER_COM) != true) return + val shouldHaveCookie = url.startsWith(MESSENGER_THREAD_PREFIX) + L._d { "Messenger client: $url $shouldHaveCookie" } + if (shouldHaveCookie == hasCookie) return + hasCookie = shouldHaveCookie + web.context.ctxCoroutine.launch { + cookieDao.updateMessengerCookie( + prefs.userId, + if (shouldHaveCookie) fbCookie.messengerCookie else null + ) + L._d { "New cookie ${cookieDao.currentCookie(prefs)?.toSensitiveString()}" } + } + } +} diff --git a/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbConstTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbConstTest.kt new file mode 100644 index 00000000..8a8c42d6 --- /dev/null +++ b/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbConstTest.kt @@ -0,0 +1,37 @@ +package com.pitchedapps.frost.facebook + +import kotlin.test.Test +import kotlin.test.assertFalse + +class FbConstTest { + + private val constants = listOf( + FACEBOOK_COM, + MESSENGER_COM, + FBCDN_NET, + WWW_FACEBOOK_COM, + WWW_MESSENGER_COM, + HTTPS_FACEBOOK_COM, + HTTPS_MESSENGER_COM, + FACEBOOK_BASE_COM, + FB_URL_BASE, + FACEBOOK_MBASIC_COM, + FB_URL_MBASIC_BASE, + FB_LOGIN_URL, + FB_HOME_URL, + MESSENGER_THREAD_PREFIX + ) + + /** + * Make sure we don't have accidental double forward slashes after appending + */ + @Test + fun doubleForwardSlashTest() { + constants.forEach { + assertFalse( + it.replace("https://", "").contains("//"), + "Accidental forward slash for $it" + ) + } + } +} \ No newline at end of file -- cgit v1.2.3 From 4c2c8a9ce4872e8bbb2a55c8b527e4f7b22ef633 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 24 Jan 2021 19:52:51 -0800 Subject: Add option to log out for messenger --- .../frost/activities/BaseMainActivity.kt | 11 ++++++- .../frost/contracts/FrostContentContract.kt | 37 ++++++++++++++++++++++ .../com/pitchedapps/frost/facebook/FbCookie.kt | 16 ++++++++++ .../pitchedapps/frost/fragments/FragmentBase.kt | 2 ++ .../frost/fragments/FragmentContract.kt | 2 ++ .../pitchedapps/frost/views/FrostRecyclerView.kt | 9 ++++++ .../com/pitchedapps/frost/views/FrostWebView.kt | 5 +++ app/src/main/res/values/strings.xml | 2 ++ .../com/pitchedapps/frost/facebook/FbConstTest.kt | 18 ++++++++++- 9 files changed, 100 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt index 394969cb..99c11b4d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt @@ -846,7 +846,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, .setCustomView(BadgedIcon(this@BaseMainActivity).apply { iicon = fbItem.icon }.also { - it.setAllAlpha(if (index == 0) SELECTED_TAB_ALPHA else UNSELECTED_TAB_ALPHA) + it.init(index, fbItem) }) ) } @@ -861,6 +861,15 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, } } + private fun BadgedIcon.init(index: Int, fbItem: FbItem) { + setAllAlpha(if (index == 0) SELECTED_TAB_ALPHA else UNSELECTED_TAB_ALPHA) + setOnLongClickListener { + if (index != contentBinding.viewpager.currentItem) return@setOnLongClickListener false + currentFragment?.onTabLongClick() + true + } + } + fun saveInstanceState(outState: Bundle) { outState.putStringArrayList(STATE_FORCE_FALLBACK, ArrayList(forcedFallbacks)) } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostContentContract.kt b/app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostContentContract.kt index b8d0d86f..a5d4e191 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostContentContract.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostContentContract.kt @@ -16,11 +16,19 @@ */ package com.pitchedapps.frost.contracts +import android.content.Context import android.view.View +import ca.allanwang.kau.utils.materialDialog +import com.pitchedapps.frost.R +import com.pitchedapps.frost.db.CookieDao +import com.pitchedapps.frost.db.updateMessengerCookie +import com.pitchedapps.frost.facebook.FbCookie import com.pitchedapps.frost.facebook.FbItem +import com.pitchedapps.frost.prefs.Prefs import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.channels.BroadcastChannel +import kotlinx.coroutines.launch /** * Created by Allan Wang on 20/12/17. @@ -171,8 +179,37 @@ interface FrostContentCore : DynamicUiContract { */ fun onTabClicked() + /** + * Triggered when view is within viewpager + * and tab is long clicked + */ + fun onTabLongClicked() + /** * Signal destruction to release some content manually */ fun destroy() } + +internal fun FrostContentCore.onTabLongClicked( + context: Context, + prefs: Prefs, + fbCookie: FbCookie, + cookieDao: CookieDao +) { + when (parent.baseEnum) { + FbItem.MESSENGER -> { + context.materialDialog { + message(R.string.messenger_logout) + positiveButton(R.string.kau_logout) { + scope.launch { + fbCookie.removeMessengerCookie() + cookieDao.updateMessengerCookie(prefs.userId, null) + reloadBase(true) + } + } + negativeButton(R.string.kau_cancel) + } + } + } +} diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt index 4e932d09..eb3580d4 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt @@ -110,6 +110,22 @@ class FbCookie(private val prefs: Prefs, private val cookieDao: CookieDao) { } } + /** + * As far as I'm aware there is no way to remove a specific cookie. + * As we only care about fb and messenger cookies, this is a workaround + * in which we remove all cookies then add back the fb one. + */ + suspend fun removeMessengerCookie() { + withContext(Dispatchers.Main + NonCancellable) { + val fbCookie = webCookie + with(CookieManager.getInstance()) { + removeAllCookies() + suspendSetWebCookie(FB_COOKIE_DOMAIN, fbCookie) + flush() + } + } + } + suspend fun switchUser(id: Long) { val cookie = cookieDao.selectById(id) ?: return L.e { "No cookie for id" } switchUser(cookie) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt b/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt index c07884bc..e91069c8 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt @@ -251,4 +251,6 @@ abstract class BaseFragment : Fragment(), CoroutineScope, FragmentContract, override fun onBackPressed(): Boolean = content?.core?.onBackPressed() ?: false override fun onTabClick(): Unit = content?.core?.onTabClicked() ?: Unit + + override fun onTabLongClick(): Unit = content?.core?.onTabLongClicked() ?: Unit } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentContract.kt b/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentContract.kt index 10c612c5..3cd06bc9 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentContract.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentContract.kt @@ -96,6 +96,8 @@ interface FragmentContract : FrostContentContainer { fun onBackPressed(): Boolean fun onTabClick() + + fun onTabLongClick() } interface RecyclerContentContract { diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostRecyclerView.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostRecyclerView.kt index 89009b56..f4f0fe11 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostRecyclerView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostRecyclerView.kt @@ -26,6 +26,9 @@ import ca.allanwang.kau.utils.fadeOut import com.pitchedapps.frost.contracts.FrostContentContainer import com.pitchedapps.frost.contracts.FrostContentCore import com.pitchedapps.frost.contracts.FrostContentParent +import com.pitchedapps.frost.contracts.onTabLongClicked +import com.pitchedapps.frost.db.CookieDao +import com.pitchedapps.frost.facebook.FbCookie import com.pitchedapps.frost.fragments.RecyclerContentContract import com.pitchedapps.frost.prefs.Prefs import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -47,6 +50,8 @@ class FrostRecyclerView @JvmOverloads constructor( FrostContentCore { private val prefs: Prefs by inject() + private val fbCookie: FbCookie by inject() + private val cookieDao: CookieDao by inject() override fun reload(animate: Boolean) = reloadBase(animate) @@ -107,6 +112,10 @@ class FrostRecyclerView @JvmOverloads constructor( else scrollToTop() } + override fun onTabLongClicked() { + onTabLongClicked(context, prefs, fbCookie, cookieDao) + } + private fun scrollToTop() { stopScroll() smoothScrollToPosition(0) 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 ecd8c093..887d17f0 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt @@ -29,6 +29,7 @@ import ca.allanwang.kau.utils.launchMain import com.pitchedapps.frost.contracts.FrostContentContainer import com.pitchedapps.frost.contracts.FrostContentCore import com.pitchedapps.frost.contracts.FrostContentParent +import com.pitchedapps.frost.contracts.onTabLongClicked import com.pitchedapps.frost.db.CookieDao import com.pitchedapps.frost.db.currentCookie import com.pitchedapps.frost.facebook.FB_HOME_URL @@ -196,6 +197,10 @@ class FrostWebView @JvmOverloads constructor( private fun smoothScrollBy(y: Int) = smoothScrollTo(max(0, scrollY + y)) + override fun onTabLongClicked() { + onTabLongClicked(context, prefs, fbCookie, cookieDao) + } + override var active: Boolean = true set(value) { if (field == value) return diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 860895e5..53b291a2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -79,4 +79,6 @@ Disclaimer + Log out of Messenger? + diff --git a/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbConstTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbConstTest.kt index 8a8c42d6..83bce973 100644 --- a/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbConstTest.kt +++ b/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbConstTest.kt @@ -1,3 +1,19 @@ +/* + * Copyright 2021 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.facebook import kotlin.test.Test @@ -34,4 +50,4 @@ class FbConstTest { ) } } -} \ No newline at end of file +} -- cgit v1.2.3 From 2c85dae785b67241ef72500ac3c43fdff86bbad0 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 24 Jan 2021 20:02:12 -0800 Subject: Revert "Add option to log out for messenger" This reverts commit 4c2c8a9ce4872e8bbb2a55c8b527e4f7b22ef633. --- .../frost/activities/BaseMainActivity.kt | 11 +------ .../frost/contracts/FrostContentContract.kt | 37 ---------------------- .../com/pitchedapps/frost/facebook/FbCookie.kt | 16 ---------- .../pitchedapps/frost/fragments/FragmentBase.kt | 2 -- .../frost/fragments/FragmentContract.kt | 2 -- .../pitchedapps/frost/views/FrostRecyclerView.kt | 9 ------ .../com/pitchedapps/frost/views/FrostWebView.kt | 5 --- app/src/main/res/values/strings.xml | 2 -- .../com/pitchedapps/frost/facebook/FbConstTest.kt | 18 +---------- 9 files changed, 2 insertions(+), 100 deletions(-) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt index 99c11b4d..394969cb 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt @@ -846,7 +846,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, .setCustomView(BadgedIcon(this@BaseMainActivity).apply { iicon = fbItem.icon }.also { - it.init(index, fbItem) + it.setAllAlpha(if (index == 0) SELECTED_TAB_ALPHA else UNSELECTED_TAB_ALPHA) }) ) } @@ -861,15 +861,6 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, } } - private fun BadgedIcon.init(index: Int, fbItem: FbItem) { - setAllAlpha(if (index == 0) SELECTED_TAB_ALPHA else UNSELECTED_TAB_ALPHA) - setOnLongClickListener { - if (index != contentBinding.viewpager.currentItem) return@setOnLongClickListener false - currentFragment?.onTabLongClick() - true - } - } - fun saveInstanceState(outState: Bundle) { outState.putStringArrayList(STATE_FORCE_FALLBACK, ArrayList(forcedFallbacks)) } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostContentContract.kt b/app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostContentContract.kt index a5d4e191..b8d0d86f 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostContentContract.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostContentContract.kt @@ -16,19 +16,11 @@ */ package com.pitchedapps.frost.contracts -import android.content.Context import android.view.View -import ca.allanwang.kau.utils.materialDialog -import com.pitchedapps.frost.R -import com.pitchedapps.frost.db.CookieDao -import com.pitchedapps.frost.db.updateMessengerCookie -import com.pitchedapps.frost.facebook.FbCookie import com.pitchedapps.frost.facebook.FbItem -import com.pitchedapps.frost.prefs.Prefs import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.channels.BroadcastChannel -import kotlinx.coroutines.launch /** * Created by Allan Wang on 20/12/17. @@ -179,37 +171,8 @@ interface FrostContentCore : DynamicUiContract { */ fun onTabClicked() - /** - * Triggered when view is within viewpager - * and tab is long clicked - */ - fun onTabLongClicked() - /** * Signal destruction to release some content manually */ fun destroy() } - -internal fun FrostContentCore.onTabLongClicked( - context: Context, - prefs: Prefs, - fbCookie: FbCookie, - cookieDao: CookieDao -) { - when (parent.baseEnum) { - FbItem.MESSENGER -> { - context.materialDialog { - message(R.string.messenger_logout) - positiveButton(R.string.kau_logout) { - scope.launch { - fbCookie.removeMessengerCookie() - cookieDao.updateMessengerCookie(prefs.userId, null) - reloadBase(true) - } - } - negativeButton(R.string.kau_cancel) - } - } - } -} diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt index eb3580d4..4e932d09 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt @@ -110,22 +110,6 @@ class FbCookie(private val prefs: Prefs, private val cookieDao: CookieDao) { } } - /** - * As far as I'm aware there is no way to remove a specific cookie. - * As we only care about fb and messenger cookies, this is a workaround - * in which we remove all cookies then add back the fb one. - */ - suspend fun removeMessengerCookie() { - withContext(Dispatchers.Main + NonCancellable) { - val fbCookie = webCookie - with(CookieManager.getInstance()) { - removeAllCookies() - suspendSetWebCookie(FB_COOKIE_DOMAIN, fbCookie) - flush() - } - } - } - suspend fun switchUser(id: Long) { val cookie = cookieDao.selectById(id) ?: return L.e { "No cookie for id" } switchUser(cookie) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt b/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt index e91069c8..c07884bc 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt @@ -251,6 +251,4 @@ abstract class BaseFragment : Fragment(), CoroutineScope, FragmentContract, override fun onBackPressed(): Boolean = content?.core?.onBackPressed() ?: false override fun onTabClick(): Unit = content?.core?.onTabClicked() ?: Unit - - override fun onTabLongClick(): Unit = content?.core?.onTabLongClicked() ?: Unit } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentContract.kt b/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentContract.kt index 3cd06bc9..10c612c5 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentContract.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentContract.kt @@ -96,8 +96,6 @@ interface FragmentContract : FrostContentContainer { fun onBackPressed(): Boolean fun onTabClick() - - fun onTabLongClick() } interface RecyclerContentContract { diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostRecyclerView.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostRecyclerView.kt index f4f0fe11..89009b56 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostRecyclerView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostRecyclerView.kt @@ -26,9 +26,6 @@ import ca.allanwang.kau.utils.fadeOut import com.pitchedapps.frost.contracts.FrostContentContainer import com.pitchedapps.frost.contracts.FrostContentCore import com.pitchedapps.frost.contracts.FrostContentParent -import com.pitchedapps.frost.contracts.onTabLongClicked -import com.pitchedapps.frost.db.CookieDao -import com.pitchedapps.frost.facebook.FbCookie import com.pitchedapps.frost.fragments.RecyclerContentContract import com.pitchedapps.frost.prefs.Prefs import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -50,8 +47,6 @@ class FrostRecyclerView @JvmOverloads constructor( FrostContentCore { private val prefs: Prefs by inject() - private val fbCookie: FbCookie by inject() - private val cookieDao: CookieDao by inject() override fun reload(animate: Boolean) = reloadBase(animate) @@ -112,10 +107,6 @@ class FrostRecyclerView @JvmOverloads constructor( else scrollToTop() } - override fun onTabLongClicked() { - onTabLongClicked(context, prefs, fbCookie, cookieDao) - } - private fun scrollToTop() { stopScroll() smoothScrollToPosition(0) 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 887d17f0..ecd8c093 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt @@ -29,7 +29,6 @@ import ca.allanwang.kau.utils.launchMain import com.pitchedapps.frost.contracts.FrostContentContainer import com.pitchedapps.frost.contracts.FrostContentCore import com.pitchedapps.frost.contracts.FrostContentParent -import com.pitchedapps.frost.contracts.onTabLongClicked import com.pitchedapps.frost.db.CookieDao import com.pitchedapps.frost.db.currentCookie import com.pitchedapps.frost.facebook.FB_HOME_URL @@ -197,10 +196,6 @@ class FrostWebView @JvmOverloads constructor( private fun smoothScrollBy(y: Int) = smoothScrollTo(max(0, scrollY + y)) - override fun onTabLongClicked() { - onTabLongClicked(context, prefs, fbCookie, cookieDao) - } - override var active: Boolean = true set(value) { if (field == value) return diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 53b291a2..860895e5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -79,6 +79,4 @@ Disclaimer - Log out of Messenger? - diff --git a/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbConstTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbConstTest.kt index 83bce973..8a8c42d6 100644 --- a/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbConstTest.kt +++ b/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbConstTest.kt @@ -1,19 +1,3 @@ -/* - * Copyright 2021 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.facebook import kotlin.test.Test @@ -50,4 +34,4 @@ class FbConstTest { ) } } -} +} \ No newline at end of file -- cgit v1.2.3 From 53392bc41b7315896f520cdc9d3d59cc4f0fcabc Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 24 Jan 2021 20:03:49 -0800 Subject: Disable kotlin android extensions --- app/build.gradle | 7 +------ .../com/pitchedapps/frost/facebook/FbConstTest.kt | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 2a0f7768..24fdd28e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,6 +1,6 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' +apply plugin: 'kotlin-parcelize' apply plugin: 'kotlin-kapt' //apply plugin: 'com.getkeepsafe.dexcount' apply plugin: 'com.gladed.androidgitversion' @@ -204,11 +204,6 @@ android { } } - androidExtensions { - experimental = true - features = ["parcelize"] - } - } node { diff --git a/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbConstTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbConstTest.kt index 8a8c42d6..83bce973 100644 --- a/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbConstTest.kt +++ b/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbConstTest.kt @@ -1,3 +1,19 @@ +/* + * Copyright 2021 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.facebook import kotlin.test.Test @@ -34,4 +50,4 @@ class FbConstTest { ) } } -} \ No newline at end of file +} -- cgit v1.2.3 From 35adc9529f1466e3ae45ee1934536f696bc24547 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 24 Jan 2021 22:04:23 -0800 Subject: Update changelog --- app/src/main/play/en-US/whatsnew | 2 +- app/src/main/res/xml/frost_changelog.xml | 2 +- docs/Changelog.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/play/en-US/whatsnew b/app/src/main/play/en-US/whatsnew index a02cbb99..dc12e80e 100644 --- a/app/src/main/play/en-US/whatsnew +++ b/app/src/main/play/en-US/whatsnew @@ -1,5 +1,5 @@ v3.0.0 * Removed email support. Please use GitHub for all inquiries as I no longer have time to look through all emails -* Added initial support for messenger.com +* Added initial support for messenger.com (settings > appearance > main activity tabs) * Fix swipe to refresh not disabling for certain pages \ 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 e03eceb2..bdece3ae 100644 --- a/app/src/main/res/xml/frost_changelog.xml +++ b/app/src/main/res/xml/frost_changelog.xml @@ -8,7 +8,7 @@ - + diff --git a/docs/Changelog.md b/docs/Changelog.md index e1b1e889..9f4712c5 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -2,7 +2,7 @@ ## v3.0.0 * Removed email support. Please use GitHub for all inquiries as I no longer have time to look through all emails -* Added initial support for messenger.com +* Added initial support for messenger.com (settings > appearance > main activity tabs) * Fix swipe to refresh not disabling for certain pages ## v2.4.7 -- cgit v1.2.3