From 9b32e6c884797985e72deb18c05ea3d434a966ac Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 28 Sep 2019 23:26:22 -0700 Subject: Use mobile agent for non facebook urls --- app/src/main/AndroidManifest.xml | 19 +++++++++++---- .../frost/activities/WebOverlayActivity.kt | 18 +++++++++++++- .../com/pitchedapps/frost/facebook/FbConst.kt | 4 ++-- .../kotlin/com/pitchedapps/frost/utils/Utils.kt | 7 ++++++ .../frost/web/FrostUrlOverlayValidator.kt | 28 ++++++++++++++++++---- app/src/main/play/en-US/whatsnew | 5 ++-- app/src/main/res/values-ar-rSA/strings.xml | 1 - app/src/main/res/values-cs-rCZ/strings.xml | 1 - app/src/main/res/values-da-rDK/strings.xml | 1 - app/src/main/res/values-de-rDE/strings.xml | 1 - app/src/main/res/values-es-rES/strings.xml | 1 - app/src/main/res/values-fr-rFR/strings.xml | 1 - app/src/main/res/values-gl-rES/strings.xml | 1 - app/src/main/res/values-gr-rGR/strings.xml | 1 - app/src/main/res/values-hu-rHU/strings.xml | 1 - app/src/main/res/values-in-rID/strings.xml | 1 - app/src/main/res/values-it-rIT/strings.xml | 1 - app/src/main/res/values-nl-rNL/strings.xml | 1 - app/src/main/res/values-no-rNO/strings.xml | 1 - app/src/main/res/values-pl-rPL/strings.xml | 1 - app/src/main/res/values-pt-rBR/strings.xml | 1 - app/src/main/res/values-pt-rPT/strings.xml | 1 - app/src/main/res/values-ro-rRO/strings.xml | 1 - app/src/main/res/values-ru-rRU/strings.xml | 1 - app/src/main/res/values-sr-rSP/strings.xml | 1 - app/src/main/res/values-sv-rSE/strings.xml | 1 - app/src/main/res/values-th-rTH/strings.xml | 1 - app/src/main/res/values-tl-rPH/strings.xml | 1 - app/src/main/res/values-tr-rTR/strings.xml | 1 - app/src/main/res/values-uk-rUA/strings.xml | 1 - app/src/main/res/values-vi-rVN/strings.xml | 1 - app/src/main/res/values-zh-rTW/strings.xml | 1 - app/src/main/res/values/strings.xml | 1 - app/src/main/res/xml/frost_changelog.xml | 7 +++++- 34 files changed, 72 insertions(+), 43 deletions(-) (limited to 'app') diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d30b5177..34ce0f49 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -59,6 +59,20 @@ android:label="@string/frost_name" android:launchMode="singleTop" android:theme="@style/FrostTheme.Overlay.Slide" /> + + - Context.launchWebOverlay fun Context.launchWebOverlay(url: String) = launchWebOverlayImpl(url) +// TODO Currently, default is overlay. Switch this if default changes +fun Context.launchWebOverlayDesktop(url: String) = launchWebOverlay(url) + +fun Context.launchWebOverlayMobile(url: String) = + launchWebOverlayImpl(url) + private fun Context.fadeBundle() = ActivityOptions.makeCustomAnimation( this, android.R.anim.fade_in, android.R.anim.fade_out diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt index 24608a8b..3df3b2c2 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt @@ -22,15 +22,19 @@ import com.pitchedapps.frost.activities.WebOverlayActivityBase import com.pitchedapps.frost.contracts.VideoViewHolder import com.pitchedapps.frost.facebook.FbCookie import com.pitchedapps.frost.facebook.FbItem +import com.pitchedapps.frost.facebook.USER_AGENT_DESKTOP_CONST import com.pitchedapps.frost.facebook.formattedFbUrl import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.Prefs +import com.pitchedapps.frost.utils.isFacebookUrl import com.pitchedapps.frost.utils.isImageUrl import com.pitchedapps.frost.utils.isIndependent import com.pitchedapps.frost.utils.isIndirectImageUrl import com.pitchedapps.frost.utils.isVideoUrl import com.pitchedapps.frost.utils.launchImageActivity import com.pitchedapps.frost.utils.launchWebOverlay +import com.pitchedapps.frost.utils.launchWebOverlayDesktop +import com.pitchedapps.frost.utils.launchWebOverlayMobile import com.pitchedapps.frost.views.FrostWebView /** @@ -50,21 +54,22 @@ import com.pitchedapps.frost.views.FrostWebView * as we have no need of sending a new intent to the same activity */ fun FrostWebView.requestWebOverlay(url: String): Boolean { + @Suppress("NAME_SHADOWING") val url = url.formattedFbUrl L.v { "Request web overlay: $url" } val context = context // finalize reference if (url.isVideoUrl && context is VideoViewHolder) { L.d { "Found video through overlay" } - context.runOnUiThread { context.showVideo(url.formattedFbUrl) } + context.runOnUiThread { context.showVideo(url) } return true } if (url.isImageUrl) { L.d { "Found fb image" } - context.launchImageActivity(url.formattedFbUrl) + context.launchImageActivity(url) return true } if (url.isIndirectImageUrl) { L.d { "Found indirect fb image" } - context.launchImageActivity(url.formattedFbUrl, cookie = FbCookie.webCookie) + context.launchImageActivity(url, cookie = FbCookie.webCookie) return true } if (!url.isIndependent) { @@ -72,7 +77,22 @@ fun FrostWebView.requestWebOverlay(url: String): Boolean { return false } if (!Prefs.overlayEnabled) return false - if (context is WebOverlayActivityBase) return false + if (context is WebOverlayActivityBase) { + val shouldUseDesktop = url.isFacebookUrl + //already overlay; manage user agent + if (userAgentString != USER_AGENT_DESKTOP_CONST && shouldUseDesktop) { + L._i { "Switch to desktop agent overlay" } + context.launchWebOverlayDesktop(url) + return true + } + if (userAgentString == USER_AGENT_DESKTOP_CONST && !shouldUseDesktop) { + L._i { "Switch from desktop agent" } + context.launchWebOverlayMobile(url) + return true + } + L._i { "return false switch" } + return false + } L.v { "Request web overlay passed" } context.launchWebOverlay(url) return true diff --git a/app/src/main/play/en-US/whatsnew b/app/src/main/play/en-US/whatsnew index a3653b1b..ecd8a131 100644 --- a/app/src/main/play/en-US/whatsnew +++ b/app/src/main/play/en-US/whatsnew @@ -1,4 +1,3 @@ -v2.4.0 +v2.4.1 -* Removed request services, which potentially caused phishing warnings. -* Save images with the correct extensions. \ No newline at end of file +* Convert facebook desktop urls to mobile ones \ No newline at end of file diff --git a/app/src/main/res/values-ar-rSA/strings.xml b/app/src/main/res/values-ar-rSA/strings.xml index 2210fa86..4f73b164 100644 --- a/app/src/main/res/values-ar-rSA/strings.xml +++ b/app/src/main/res/values-ar-rSA/strings.xml @@ -24,7 +24,6 @@ مرحبًا %s قم باختيار حساب فيسبوك الحساب الحالي غير موجود في قاعدة البيانات - طلبات Frost إشعارات Frost يتطلب ثيم مخصص الموضوع diff --git a/app/src/main/res/values-cs-rCZ/strings.xml b/app/src/main/res/values-cs-rCZ/strings.xml index ce0da721..b7253172 100644 --- a/app/src/main/res/values-cs-rCZ/strings.xml +++ b/app/src/main/res/values-cs-rCZ/strings.xml @@ -23,7 +23,6 @@ Vítej %s! Zvolte Facebookový profil Tento účet není v databázi - Frost žádosti Frost upozornění Vyžaduje vlastní motiv Předmět diff --git a/app/src/main/res/values-da-rDK/strings.xml b/app/src/main/res/values-da-rDK/strings.xml index d1839bef..01545155 100644 --- a/app/src/main/res/values-da-rDK/strings.xml +++ b/app/src/main/res/values-da-rDK/strings.xml @@ -23,7 +23,6 @@ Velkommen %s Vælg Facebook-konto Aktuel konto er ikke i databasen - Frost anmodninger Frost notifikationer Kræver brugerdefineret tema Emne diff --git a/app/src/main/res/values-de-rDE/strings.xml b/app/src/main/res/values-de-rDE/strings.xml index bfe54112..ffa71028 100644 --- a/app/src/main/res/values-de-rDE/strings.xml +++ b/app/src/main/res/values-de-rDE/strings.xml @@ -24,7 +24,6 @@ Willkommen %s Facebook-Account auswählen Der aktuelle Account besteht nicht in der Datenbank - Frost Anfragen Frost Benachrichtigungen Erfordert benutzerdefiniertes Thema Betreff diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index 0c1281c9..a2acd120 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -24,7 +24,6 @@ Bienvenido %s Seleccionar cuenta de Facebook El perfil actual no está en la base de datos - Solicitudes de Frost Notificaciones de Frost Requiere tema personalizado Asunto diff --git a/app/src/main/res/values-fr-rFR/strings.xml b/app/src/main/res/values-fr-rFR/strings.xml index 7b366def..a252bb12 100644 --- a/app/src/main/res/values-fr-rFR/strings.xml +++ b/app/src/main/res/values-fr-rFR/strings.xml @@ -24,7 +24,6 @@ Bienvenue %s Sélectionnez le compte Facebook Le compte actuel n’est pas dans la base de données - Demandes Frost Notifications Frost Nécessite un thème personnalisé Sujet diff --git a/app/src/main/res/values-gl-rES/strings.xml b/app/src/main/res/values-gl-rES/strings.xml index 5b8985ff..61ae2f58 100644 --- a/app/src/main/res/values-gl-rES/strings.xml +++ b/app/src/main/res/values-gl-rES/strings.xml @@ -24,7 +24,6 @@ Benvido/a %s Seleccionar conta do Facebook A conta actual non está na base de datos - Solicitudes a Frost Notificacións de Frost Cómpre personalizar o tema Asunto diff --git a/app/src/main/res/values-gr-rGR/strings.xml b/app/src/main/res/values-gr-rGR/strings.xml index cc5866d8..a8d376cf 100644 --- a/app/src/main/res/values-gr-rGR/strings.xml +++ b/app/src/main/res/values-gr-rGR/strings.xml @@ -24,7 +24,6 @@ Διάλεξε λογαριασμό Facebook Ο συγκεκριμένος λογαριασμός δεν βρίσκεται στη βάση δεδομένων - Frost Αιτήματα Frost Ειδοποιήσεις Απαιτείται δικό σου θέμα diff --git a/app/src/main/res/values-hu-rHU/strings.xml b/app/src/main/res/values-hu-rHU/strings.xml index 4ed3523e..bba7ae0a 100644 --- a/app/src/main/res/values-hu-rHU/strings.xml +++ b/app/src/main/res/values-hu-rHU/strings.xml @@ -24,7 +24,6 @@ Üdv, %s Válaszd ki a Facebook-fiókod A jelenlegi fiók nem szerepel az adatbázisban - Frost kérések Frost értesítések Egyéni téma szükséges Tárgy diff --git a/app/src/main/res/values-in-rID/strings.xml b/app/src/main/res/values-in-rID/strings.xml index 2a92c3cd..5be6d6e3 100644 --- a/app/src/main/res/values-in-rID/strings.xml +++ b/app/src/main/res/values-in-rID/strings.xml @@ -23,7 +23,6 @@ Selamat Datang %s Pilih Akun Facebook Akun saat ini tidak ada dalam database - Permintaan Frost Pemberitahuan Frost Memerlukan tema kustom Perihal diff --git a/app/src/main/res/values-it-rIT/strings.xml b/app/src/main/res/values-it-rIT/strings.xml index 5516b5ef..7f3bb2f0 100644 --- a/app/src/main/res/values-it-rIT/strings.xml +++ b/app/src/main/res/values-it-rIT/strings.xml @@ -24,7 +24,6 @@ Benvenuto %s Scegli l\'Account Facebook L\'account non è presente nel database - Richieste a Frost Notifiche di Frost Richiede un tema personalizzato Argomento diff --git a/app/src/main/res/values-nl-rNL/strings.xml b/app/src/main/res/values-nl-rNL/strings.xml index b96867e3..ecc24bdb 100644 --- a/app/src/main/res/values-nl-rNL/strings.xml +++ b/app/src/main/res/values-nl-rNL/strings.xml @@ -24,7 +24,6 @@ Welkom %s Selecteer een Facebook-account Het huidige account is niet opgeslagen in de database - Frost Verzoeken Frost Notificaties Aangepast thema vereist Onderwerp diff --git a/app/src/main/res/values-no-rNO/strings.xml b/app/src/main/res/values-no-rNO/strings.xml index b3665284..68a6f26c 100644 --- a/app/src/main/res/values-no-rNO/strings.xml +++ b/app/src/main/res/values-no-rNO/strings.xml @@ -23,7 +23,6 @@ Velkommen %s Velg Facebook-konto Gjeldende konto er ikke i databasen - Frost forespørsel Frost varsler Krever tilpasset tema Emne diff --git a/app/src/main/res/values-pl-rPL/strings.xml b/app/src/main/res/values-pl-rPL/strings.xml index 3a539696..27e05ad7 100644 --- a/app/src/main/res/values-pl-rPL/strings.xml +++ b/app/src/main/res/values-pl-rPL/strings.xml @@ -23,7 +23,6 @@ Witaj %s Wybierz konto Facebooka Obecnego konta nie ma w bazie danych - Żądania Frost Powiadomienia Frost Wymaga motywu niestandardowego Temat diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 5f71b2e0..3d2132cc 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -24,7 +24,6 @@ Bem-vindo(a) %s Selecione a conta do Facebook A conta atual não está no banco de dados - Solicitações de Frost Notificações do Frost Requer tema personalizado Sujeito diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index 1d0ca4cb..022aef0f 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -23,7 +23,6 @@ Olá %s Selecionar conta de Facebook A conta atual não está na base de dados - Pedidos Frost Notificações Frost Requer tema personalizado Assunto diff --git a/app/src/main/res/values-ro-rRO/strings.xml b/app/src/main/res/values-ro-rRO/strings.xml index 5a887606..2af6e074 100644 --- a/app/src/main/res/values-ro-rRO/strings.xml +++ b/app/src/main/res/values-ro-rRO/strings.xml @@ -23,7 +23,6 @@ Bună, %s! Alege contul Facebook Contul curect nu este în baza de date - Cerințe Frost Notificări Frost Teme custom cerute Subiect diff --git a/app/src/main/res/values-ru-rRU/strings.xml b/app/src/main/res/values-ru-rRU/strings.xml index e8fc5388..066d1d21 100644 --- a/app/src/main/res/values-ru-rRU/strings.xml +++ b/app/src/main/res/values-ru-rRU/strings.xml @@ -24,7 +24,6 @@ Добро пожаловать, %s Выберите учётную запись Facebook Учётная запись не существует - Требования Frost Приостановить уведомления Требования пользовательской темы Тема diff --git a/app/src/main/res/values-sr-rSP/strings.xml b/app/src/main/res/values-sr-rSP/strings.xml index 5dec35b4..050cd2f4 100644 --- a/app/src/main/res/values-sr-rSP/strings.xml +++ b/app/src/main/res/values-sr-rSP/strings.xml @@ -23,7 +23,6 @@ Добродошли %s Одаберите Фејсбук налог Одабрани налог не постоји у бази - Фрост Захтеви Фрост нотификације Захтева модификовану тему Тема diff --git a/app/src/main/res/values-sv-rSE/strings.xml b/app/src/main/res/values-sv-rSE/strings.xml index 5132c5ee..b28c5dd5 100644 --- a/app/src/main/res/values-sv-rSE/strings.xml +++ b/app/src/main/res/values-sv-rSE/strings.xml @@ -23,7 +23,6 @@ Välkommen %s Välj Facebook-konto Kontot existerar inte - Frost Requests Frost-Notifikationer Kräver anpassat tema Ämne diff --git a/app/src/main/res/values-th-rTH/strings.xml b/app/src/main/res/values-th-rTH/strings.xml index 62f186d4..377988db 100644 --- a/app/src/main/res/values-th-rTH/strings.xml +++ b/app/src/main/res/values-th-rTH/strings.xml @@ -23,7 +23,6 @@ ยินดีต้อนรับ%s เลือกบัญชี Facebook บัญชีปัจจุบันไม่ได้อยู่ในฐานข้อมูล - ร้องขอ Frost การแจ้งเตือน Frost ขอชุดรูปแบบที่กำหนดเอง เรื่อง diff --git a/app/src/main/res/values-tl-rPH/strings.xml b/app/src/main/res/values-tl-rPH/strings.xml index 22cbae5c..830c1fa5 100644 --- a/app/src/main/res/values-tl-rPH/strings.xml +++ b/app/src/main/res/values-tl-rPH/strings.xml @@ -23,7 +23,6 @@ Maligayang Pagdating %s Pumili ng Akawnt ng Facebook Ang kasalukuyang akawnt ay wala duon sa database - Ang mga kahilingan sa Frost Ang mga Notipikasyon ng Frost Ang pasadyang tema ay kinakailangan Paksa diff --git a/app/src/main/res/values-tr-rTR/strings.xml b/app/src/main/res/values-tr-rTR/strings.xml index a2f7b562..ac7796c2 100644 --- a/app/src/main/res/values-tr-rTR/strings.xml +++ b/app/src/main/res/values-tr-rTR/strings.xml @@ -24,7 +24,6 @@ Hoşgeldiniz %s Facebook hesabını seç Cari hesap veritabanı değil - Donma talebi Frost bildirimleri Özel Tema gerektirir Başlık diff --git a/app/src/main/res/values-uk-rUA/strings.xml b/app/src/main/res/values-uk-rUA/strings.xml index adb894d5..8c65f743 100644 --- a/app/src/main/res/values-uk-rUA/strings.xml +++ b/app/src/main/res/values-uk-rUA/strings.xml @@ -24,7 +24,6 @@ Вітаємо %s Обрати аккаунт Facebook Даний аккаунт не міститься у базі даних - Frost запити Frost сповіщення Потребує користувацької теми Тема diff --git a/app/src/main/res/values-vi-rVN/strings.xml b/app/src/main/res/values-vi-rVN/strings.xml index 07be8849..02492c5b 100644 --- a/app/src/main/res/values-vi-rVN/strings.xml +++ b/app/src/main/res/values-vi-rVN/strings.xml @@ -24,7 +24,6 @@ Chào mừng %s Chọn tài khoản Facebook Tài khoản không có trong dữ liệu - Yêu cầu Frost Thông báo từ Frost Yêu cầu gói giao diện riêng Chủ đề diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 17034287..f411cf62 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -24,7 +24,6 @@ 欢迎,%s! 選擇 Facebook 帳戶 當前帳戶不在資料庫中 - Frost for Facebook 要求 Frost 通知 需要自訂主題 主題 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c2660c6a..dda6c789 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -26,7 +26,6 @@ Select Facebook Account Current account is not in the database - Frost Requests Frost Notifications Requires custom theme diff --git a/app/src/main/res/xml/frost_changelog.xml b/app/src/main/res/xml/frost_changelog.xml index 3e267f69..fbafce76 100644 --- a/app/src/main/res/xml/frost_changelog.xml +++ b/app/src/main/res/xml/frost_changelog.xml @@ -6,10 +6,15 @@ --> + + + + + + - -- cgit v1.2.3