diff options
author | Allan Wang <me@allanwang.ca> | 2017-08-31 00:56:22 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-31 00:56:22 -0400 |
commit | fa00faa72c9764c72c6075e52e13df5c3561693b (patch) | |
tree | 9fc29179852098b1fb57f0ee3b2929f1c9581d64 /app/src/main/kotlin | |
parent | 8cc37e754cfe96470caf613728bdb6e07ac513cd (diff) | |
download | frost-fa00faa72c9764c72c6075e52e13df5c3561693b.tar.gz frost-fa00faa72c9764c72c6075e52e13df5c3561693b.tar.bz2 frost-fa00faa72c9764c72c6075e52e13df5c3561693b.zip |
Reduce scontent trimming (#245)
* Reduce scontent trimming
* Update changelog
Diffstat (limited to 'app/src/main/kotlin')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt | 10 | ||||
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt | 14 |
2 files changed, 13 insertions, 11 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt index 9a5f3c6e..1a253fa8 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt @@ -71,14 +71,13 @@ class ImageActivity : KauBaseActivity() { value.update(fab) } - val imageUrl: String - get() = intent.extras.getString(ARG_IMAGE_URL) + val imageUrl: String by lazy { intent.extras.getString(ARG_IMAGE_URL).trim('"') } - val text: String? - get() = intent.extras.getString(ARG_TEXT) + val text: String? by lazy { intent.extras.getString(ARG_TEXT) } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + L.i("Displaying image $imageUrl") val layout = if (!text.isNullOrBlank()) R.layout.activity_image else R.layout.activity_image_textless setContentView(layout) container.setBackgroundColor(Prefs.bgColor.withMinAlpha(222)) @@ -166,8 +165,7 @@ class ImageActivity : KauBaseActivity() { } internal fun downloadImage() { - kauRequestPermissions(PERMISSION_WRITE_EXTERNAL_STORAGE) { - granted, _ -> + kauRequestPermissions(PERMISSION_WRITE_EXTERNAL_STORAGE) { granted, _ -> L.d("Download image callback granted: $granted") if (granted) { doAsync { 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 69b2ba41..3d016909 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt @@ -15,7 +15,7 @@ class FbUrlFormatter(url: String) { val cleaned: String init { - if (url.isNullOrBlank()) cleaned = "" + if (url.isBlank()) cleaned = "" else { var cleanedUrl = url discardable.forEach { cleanedUrl = cleanedUrl.replace(it, "", true) } @@ -50,7 +50,8 @@ class FbUrlFormatter(url: String) { fun toLogList(): List<String> { val list = mutableListOf(cleaned) - queries.forEach { (k, v) -> list.add("- $k\t=\t$v") } + queries.forEach { (k, v) -> list.add("\n- $k\t=\t$v") } + list.add("\n\n${toString()}") return list } @@ -60,7 +61,8 @@ class FbUrlFormatter(url: String) { * Taken from FaceSlim * https://github.com/indywidualny/FaceSlim/blob/master/app/src/main/java/org/indywidualni/fblite/util/Miscellany.java */ - @JvmStatic val discardable = arrayOf( + @JvmStatic + val discardable = arrayOf( "http://lm.facebook.com/l.php?u=", "https://lm.facebook.com/l.php?u=", "http://m.facebook.com/l.php?u=", @@ -70,9 +72,11 @@ class FbUrlFormatter(url: String) { "/video_redirect/?src=" ) - @JvmStatic val discardableQueries = arrayOf("ref", "refid") + @JvmStatic + val discardableQueries = arrayOf("ref", "refid") - @JvmStatic val decoder = mapOf( + @JvmStatic + val decoder = mapOf( "%3C" to "<", "%3E" to ">", "%23" to "#", "%25" to "%", "%7B" to "{", "%7D" to "}", "%7C" to "|", "%5C" to "\\", "%5E" to "^", "%7E" to "~", "%5B" to "[", "%5D" to "]", |