aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-11-06 22:35:58 -0500
committerGitHub <noreply@github.com>2018-11-06 22:35:58 -0500
commitda63f00eb50a8c413ee55652eff8a4fcc5f83e5a (patch)
tree33b2eb5da6963ba267877ae836ecba0dcef344ca /app/src/main
parentbffa6474f36b990c1de0eaeb8df2cf80d094d3fa (diff)
downloadfrost-da63f00eb50a8c413ee55652eff8a4fcc5f83e5a.tar.gz
frost-da63f00eb50a8c413ee55652eff8a4fcc5f83e5a.tar.bz2
frost-da63f00eb50a8c413ee55652eff8a4fcc5f83e5a.zip
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
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt1
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt7
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt5
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt8
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt6
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt15
7 files changed, 38 insertions, 8 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 33f6ebe4..2b881d1c 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 add35154..62675df6 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 61e8b6c4..06bc0604 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 2bb1b5c5..295dbe0c 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 4f31f5f5..bee2f49b 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 66ef9723..6c78d922 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 14596935..8230c338 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
}