1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-11-08 12:02:33 +01:00

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
This commit is contained in:
Allan Wang 2018-11-06 22:35:58 -05:00 committed by GitHub
parent bffa6474f3
commit da63f00eb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 47 additions and 11 deletions

View File

@ -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+"

View File

@ -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",

View File

@ -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
}
}

View File

@ -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)

View File

@ -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)

View File

@ -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
*/

View File

@ -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
}

View File

@ -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}"

View File

@ -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

View File

@ -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