aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/utils
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Downloader.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt21
3 files changed, 20 insertions, 5 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Downloader.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Downloader.kt
index 2c638dfd..aab79e00 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Downloader.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Downloader.kt
@@ -58,7 +58,7 @@ fun Context.frostDownload(uri: Uri?,
request.setMimeType(mimeType)
val cookie = loadFbCookie(Prefs.userId) ?: return@kauRequestPermissions
val title = URLUtil.guessFileName(uri.toString(), contentDisposition, mimeType)
- request.addRequestHeader("cookie", cookie.cookie)
+ request.addRequestHeader("Cookie", cookie.cookie)
request.addRequestHeader("User-Agent", userAgent)
request.setDescription(string(R.string.downloading))
request.setTitle(title)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
index 94bf0016..cc5ee733 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
@@ -43,6 +43,8 @@ object Prefs : KPref() {
var versionCode: Int by kpref("version_code", -1)
+ var prevVersionCode: Int by kpref("prev_version_code", -1)
+
var installDate: Long by kpref("install_date", -1L)
var identifier: Int by kpref("identifier", -1)
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 5a83c3f3..0ca068b5 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
@@ -229,12 +229,23 @@ inline val String?.isVideoUrl
/**
* [true] if url can be displayed in a different webview
*/
-inline val String?.isIndependent
- get() = this == null || (startsWith("http") && !isFacebookUrl)
- || dependentSet.all { !contains(it) }
+inline val String?.isIndependent: Boolean
+ get() {
+ if (this == null || length < 5) return false // ignore short queries
+ if (this[0] == '#' && !contains('/')) return false // ignore element values
+ if (startsWith("http") && !isFacebookUrl) return true // ignore non facebook urls
+ if (dependentSet.any { contains(it) }) return false // ignore known dependent segments
+ return true
+ }
val dependentSet = setOf(
- "photoset_token", "direct_action_execute"
+ "photoset_token", "direct_action_execute", "messages/?pageNum", "sharer.php",
+ /*
+ * Facebook messages have the following cases for the tid query
+ * mid* or id* for newer threads, which can be launched in new windows
+ * or a hash for old threads, which must be loaded on old threads
+ */
+ "messages/read/?tid=id", "messages/read/?tid=mid"
)
inline val String?.isExplicitIntent
@@ -254,6 +265,8 @@ inline fun Context.sendFrostEmail(@StringRes subjectId: Int, crossinline builder
inline fun Context.sendFrostEmail(subjectId: String, crossinline builder: EmailBuilder.() -> Unit)
= sendEmail(string(R.string.dev_email), subjectId) {
builder()
+
+ addItem("Prev version", Prefs.prevVersionCode.toString())
val proTag = if (IS_FROST_PRO) "TY" else "FP"
addItem("Random Frost ID", "${Prefs.frostId}-$proTag")
}