diff options
author | Allan Wang <me@allanwang.ca> | 2018-01-25 00:23:44 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-25 00:23:44 -0500 |
commit | 8bfbbac2b8f364bb03866712b113cd2f5de8b9d9 (patch) | |
tree | 8001dd1e467ddd22e4dcec84a9c9e3aa36d2bbb8 /app/src/main/kotlin/com/pitchedapps/frost/utils | |
parent | 6fe7bd43581d5dfbb85e4e0deb524e65d07b5ce6 (diff) | |
download | frost-8bfbbac2b8f364bb03866712b113cd2f5de8b9d9.tar.gz frost-8bfbbac2b8f364bb03866712b113cd2f5de8b9d9.tar.bz2 frost-8bfbbac2b8f364bb03866712b113cd2f5de8b9d9.zip |
Enhancement/video (#669)v1.8.0
* Test stricter video extractor
* Mess around with mutations
* Revert back to strict click listener
* Update theme
* Update dependencies
* Update theme
* Create pip toggle
* Add pip disabler
* Update theme
* Update theme
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt | 2 | ||||
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt | 25 |
2 files changed, 12 insertions, 15 deletions
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 7422fb36..f9f471df 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt @@ -133,6 +133,8 @@ object Prefs : KPref() { var messageScrollToBottom: Boolean by kpref("message_scroll_to_bottom", false) + var enablePip: Boolean by kpref("enable_pip", true) + /** * Cache like value to determine if user has or had pro * In most cases, [com.pitchedapps.frost.utils.iab.IS_FROST_PRO] should be looked at instead 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 6a3b80ca..144e65ef 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -199,11 +199,9 @@ fun Throwable?.logFrostAnswers(text: String) { frostAnswersCustom("Errors", "text" to text, "message" to (this?.message ?: "NA")) } -fun Activity.frostSnackbar(@StringRes text: Int, builder: Snackbar.() -> Unit = {}) - = snackbar(text, Snackbar.LENGTH_LONG, frostSnackbar(builder)) +fun Activity.frostSnackbar(@StringRes text: Int, builder: Snackbar.() -> Unit = {}) = snackbar(text, Snackbar.LENGTH_LONG, frostSnackbar(builder)) -fun View.frostSnackbar(@StringRes text: Int, builder: Snackbar.() -> Unit = {}) - = snackbar(text, Snackbar.LENGTH_LONG, frostSnackbar(builder)) +fun View.frostSnackbar(@StringRes text: Int, builder: Snackbar.() -> Unit = {}) = snackbar(text, Snackbar.LENGTH_LONG, frostSnackbar(builder)) @SuppressLint("RestrictedApi") private inline fun frostSnackbar(crossinline builder: Snackbar.() -> Unit): Snackbar.() -> Unit = { @@ -245,19 +243,20 @@ fun Context.resolveActivityForUri(uri: Uri): Boolean { * [true] if url contains [FACEBOOK_COM] */ inline val String?.isFacebookUrl - get() = this != null && (contains(FACEBOOK_COM) || contains("fbcdn.net")) + get() = this != null && (contains(FACEBOOK_COM) || contains(FBCDN_NET)) /** * [true] if url is a video and can be accepted by VideoViewer */ inline val String.isVideoUrl - get() = startsWith(VIDEO_REDIRECT) || startsWith("https://video-") + get() = startsWith(VIDEO_REDIRECT) || + (startsWith("https://video-") && contains(FBCDN_NET)) /** * [true] if url is or redirects to an explicit facebook image */ inline val String.isImageUrl - get() = contains("fbcdn.net") && (contains(".png") || contains(".jpg")) + get() = contains(FBCDN_NET) && (contains(".png") || contains(".jpg")) /** * [true] if url can be displayed in a different webview @@ -302,11 +301,9 @@ fun Context.frostUriFromFile(file: File): Uri = BuildConfig.APPLICATION_ID + ".provider", file) -inline fun Context.sendFrostEmail(@StringRes subjectId: Int, crossinline builder: EmailBuilder.() -> Unit) - = sendFrostEmail(string(subjectId), builder) +inline fun Context.sendFrostEmail(@StringRes subjectId: Int, crossinline builder: EmailBuilder.() -> Unit) = sendFrostEmail(string(subjectId), builder) -inline fun Context.sendFrostEmail(subjectId: String, crossinline builder: EmailBuilder.() -> Unit) - = sendEmail(string(R.string.dev_email), subjectId) { +inline fun Context.sendFrostEmail(subjectId: String, crossinline builder: EmailBuilder.() -> Unit) = sendEmail(string(R.string.dev_email), subjectId) { builder() addFrostDetails() } @@ -318,11 +315,9 @@ fun EmailBuilder.addFrostDetails() { addItem("Locale", Locale.getDefault().displayName) } -fun frostJsoup(url: String) - = frostJsoup(FbCookie.webCookie, url) +fun frostJsoup(url: String) = frostJsoup(FbCookie.webCookie, url) -fun frostJsoup(cookie: String?, url: String) - = Jsoup.connect(url).cookie(FACEBOOK_COM, cookie).userAgent(USER_AGENT_BASIC).get()!! +fun frostJsoup(cookie: String?, url: String) = Jsoup.connect(url).cookie(FACEBOOK_COM, cookie).userAgent(USER_AGENT_BASIC).get()!! fun Element.first(vararg select: String): Element? { select.forEach { |