From da63f00eb50a8c413ee55652eff8a4fcc5f83e5a Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 6 Nov 2018 22:35:58 -0500 Subject: [PATCH] Fix/duplicate back (#1177) * Merge potential fix for text zoom * Actually fix the duplicate back * Prepare fixing dependent notifications * Add notification fallback url * Add back acontext to url, fixes #1137 --- .../com/pitchedapps/frost/facebook/FbConst.kt | 1 + .../pitchedapps/frost/facebook/FbUrlFormatter.kt | 7 ++++++- .../pitchedapps/frost/iitems/NotificationIItem.kt | 5 ++++- .../frost/services/FrostNotifications.kt | 8 +++----- .../main/kotlin/com/pitchedapps/frost/utils/L.kt | 6 ++++++ .../kotlin/com/pitchedapps/frost/utils/Utils.kt | 4 ++++ .../com/pitchedapps/frost/views/FrostWebView.kt | 15 ++++++++++++++- build.gradle | 2 +- docs/Changelog.md | 6 ++++++ gradle.properties | 4 ++-- 10 files changed, 47 insertions(+), 11 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 33f6ebe4e..2b881d1c4 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt @@ -10,6 +10,7 @@ const val HTTPS_FACEBOOK_COM = "https://$FACEBOOK_COM" const val FB_URL_BASE = "https://m.$FACEBOOK_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 USER_AGENT_FULL = "Mozilla/5.0 (Linux; Android 4.4.2; en-us; SAMSUNG SM-G900T Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.6 Chrome/28.0.1500.94 Mobile Safari/537.36" const val USER_AGENT_BASIC_OLD = "Mozilla/5.0 (Linux; Android 6.0) AppleWebKit/537.10+ (KHTML, like Gecko) Version/10.1.0.4633 Mobile Safari/537.10+" diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt index add35154b..62675df69 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt @@ -100,7 +100,12 @@ class FbUrlFormatter(url: String) { VIDEO_REDIRECT ) - val discardableQueries = arrayOf("ref", "refid", "acontext", "SharedWith") + /** + * Queries that are not necessary for independent links + * + * acontext is not required for "friends interested in" notifications + */ + val discardableQueries = arrayOf("ref", "refid", "SharedWith") val converter = listOf( "\\3C " to "%3C", "\\3E " to "%3E", "\\23 " to "%23", "\\25 " to "%25", 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 61e8b6c44..06bc06042 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt @@ -14,11 +14,13 @@ import com.mikepenz.fastadapter.FastAdapter import com.mikepenz.fastadapter.adapters.ItemAdapter import com.mikepenz.fastadapter.commons.utils.DiffCallback import com.pitchedapps.frost.R +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.services.FrostRunnable import com.pitchedapps.frost.utils.Prefs +import com.pitchedapps.frost.utils.isIndependent import com.pitchedapps.frost.utils.launchWebOverlay /** @@ -37,7 +39,8 @@ class NotificationIItem(val notification: FrostNotif, val cookie: String) : KauI FrostRunnable.markNotificationRead(v!!.context, notif.id, item.cookie) adapter.set(position, NotificationIItem(notif.copy(unread = false), item.cookie)) } - v!!.context.launchWebOverlay(notif.url) + // TODO temp fix. If url is dependent, we cannot load it directly + v!!.context.launchWebOverlay(if (notif.url.isIndependent) notif.url else FbItem.NOTIFICATIONS.url) true } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt index 2bb1b5c51..295dbe0c5 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt @@ -26,10 +26,7 @@ import com.pitchedapps.frost.facebook.parsers.NotifParser import com.pitchedapps.frost.facebook.parsers.ParseNotification import com.pitchedapps.frost.glide.FrostGlide import com.pitchedapps.frost.glide.GlideApp -import com.pitchedapps.frost.utils.ARG_USER_ID -import com.pitchedapps.frost.utils.L -import com.pitchedapps.frost.utils.Prefs -import com.pitchedapps.frost.utils.frostEvent +import com.pitchedapps.frost.utils.* import java.util.* /** @@ -152,7 +149,8 @@ enum class NotificationType( private fun createNotification(context: Context, content: NotificationContent): FrostNotification = with(content) { val intent = Intent(context, FrostWebActivity::class.java) - intent.data = Uri.parse(href) + // TODO temp fix; we will show notification page for dependent urls. We can trigger a click next time + intent.data = Uri.parse(if (href.isIndependent) href else FbItem.NOTIFICATIONS.url) intent.putExtra(ARG_USER_ID, data.id) overlayContext.put(intent) bindRequest(intent, content, data.cookie) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt index 4f31f5f5c..bee2f49bc 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt @@ -19,6 +19,12 @@ object L : KauLogger("Frost", { } }) { + inline fun test(message: () -> Any?) { + _d { + "Test1234 ${message()}" + } + } + inline fun _i(message: () -> Any?) { if (BuildConfig.DEBUG) i(message) 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 66ef97238..6c78d922c 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -273,6 +273,10 @@ inline val String?.isIndependent: Boolean val dependentSegments = arrayOf( "photoset_token", "direct_action_execute", "messages/?pageNum", "sharer.php", "events/permalink", "events/feed/watch", + /* + * Add new members to groups + */ + "madminpanel", /** * Editing images */ 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 14596935b..8230c3388 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt @@ -11,6 +11,7 @@ import ca.allanwang.kau.utils.AnimHolder import com.pitchedapps.frost.contracts.FrostContentContainer import com.pitchedapps.frost.contracts.FrostContentCore import com.pitchedapps.frost.contracts.FrostContentParent +import com.pitchedapps.frost.facebook.FB_HOME_URL import com.pitchedapps.frost.facebook.USER_AGENT_BASIC import com.pitchedapps.frost.fragments.WebFragment import com.pitchedapps.frost.utils.Prefs @@ -88,8 +89,20 @@ class FrostWebView @JvmOverloads constructor( loadUrl(parent.baseUrl, animate) } + /** + * By 2018-10-17, facebook automatically adds their home page to the back stack, + * regardless of the loaded url. We will make sure we skip it when going back. + */ override fun onBackPressed(): Boolean { - if (canGoBack()) { + if (canGoBackOrForward(-2)) { + goBack() + return true + } + val list = copyBackForwardList() + if (list.currentIndex == 1 && list.getItemAtIndex(0).url == FB_HOME_URL) { + return false + } + if (list.currentIndex > 0) { goBack() return true } diff --git a/build.gradle b/build.gradle index 4ca350ba0..21aabc429 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { dependencies { classpath "ca.allanwang:kau:${KAU}" - classpath 'com.android.tools.build:gradle:3.2.0' + classpath 'com.android.tools.build:gradle:3.2.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${KOTLIN}" classpath "com.bugsnag:bugsnag-android-gradle-plugin:${BUGSNAG_PLUGIN}" classpath "com.getkeepsafe.dexcount:dexcount-gradle-plugin:${DEX_PLUGIN}" diff --git a/docs/Changelog.md b/docs/Changelog.md index 14758ca3e..3c504e36d 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -1,5 +1,11 @@ # Changelog +## v2.1.0 +* Changed signing key; requires clean install +* Update lots of theme components +* Fix create post button +* Add translations for Danish, Ukranian, and Swedish + ## v2.0.1 * Update theme * Catch crashes if device has no webview diff --git a/gradle.properties b/gradle.properties index 43b45257a..a350b51b2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,8 +14,8 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryErro APP_ID=Frost APP_GROUP=com.pitchedapps -KAU=11f0d0f -KOTLIN=1.2.71 +KAU=572d470 +KOTLIN=1.3.0 # https://github.com/bugsnag/bugsnag-android/releases BUGSNAG=4.8.2