From 4799eebdc642f740b55aad2e0d9a3624fc11c53f Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Fri, 19 Nov 2021 21:09:43 -0800 Subject: Snapshot work --- .idea/compiler.xml | 4 ++- .../pitchedapps/frost/activities/ImageActivity.kt | 30 ++++++++++++---------- .../com/pitchedapps/frost/facebook/FbCookie.kt | 2 +- .../pitchedapps/frost/facebook/requests/Images.kt | 8 ++++-- .../frost/web/FrostUrlOverlayValidator.kt | 10 ++++---- settings.gradle.kts | 3 +++ 6 files changed, 35 insertions(+), 22 deletions(-) create mode 100644 settings.gradle.kts diff --git a/.idea/compiler.xml b/.idea/compiler.xml index fb7f4a8a..fcfdfd20 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,6 +1,8 @@ - + + + \ No newline at end of file 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 b5e41751..6d618347 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt @@ -43,6 +43,7 @@ import ca.allanwang.kau.utils.tint import ca.allanwang.kau.utils.toast import ca.allanwang.kau.utils.withAlpha import ca.allanwang.kau.utils.withMinAlpha +import com.github.piasy.biv.view.ImageShownCallback import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.floatingactionbutton.FloatingActionButton import com.mikepenz.iconics.typeface.IIcon @@ -166,7 +167,9 @@ class ImageActivity : KauBaseActivity() { val result = if (!imageUrl.isIndirectImageUrl) imageUrl else cookie?.getFullSizedImageUrl(imageUrl) ?: imageUrl if (result != imageUrl) - L.v { "Launching with true url $result" } + L.v { "Launching image with true url $result" } + else + L.v { "Launching image with url $result" } result } binding = ActivityImage2Binding.inflate(layoutInflater) @@ -175,15 +178,22 @@ class ImageActivity : KauBaseActivity() { launch(CoroutineExceptionHandler { _, throwable -> loadError(throwable) }) { val tempFile = downloadTempImage() this@ImageActivity.tempFile = tempFile - binding.imageProgress.fadeOut() -// binding.imagePhoto.setImageURI(frostUriFromFile(tempFile)) -// Glide.with(binding.imagePhoto).asFile().load(trueImageUrl) - binding.imagePhoto.showImage(Uri.parse(trueImageUrl.await())) -// binding.imagePhoto.setImage(ImageSource.uri(frostUriFromFile(tempFile))) - binding.imagePhoto.animate().alpha(1f).scaleXY(1f).start() + binding.showImage(trueImageUrl.await()) } } + private fun ActivityImage2Binding.showImage(url: String) { + imageProgress.fadeOut() + imagePhoto.showImage(Uri.parse(url)) + imagePhoto.setImageShownCallback(object : ImageShownCallback { + override fun onThumbnailShown() {} + + override fun onMainImageShown() { + imagePhoto.animate().alpha(1f).scaleXY(1f).start() + } + }) + } + private fun ActivityImage2Binding.init() { imageContainer.setBackgroundColor(baseBackgroundColor) toolbar.setBackgroundColor(baseBackgroundColor) @@ -228,12 +238,6 @@ class ImageActivity : KauBaseActivity() { share.apply { setState(FabStates.SHARE) } -// imagePhoto.setOnImageEventListener(object : -// SubsamplingScaleImageView.DefaultOnImageEventListener() { -// override fun onImageLoadError(e: Exception) { -// loadError(e) -// } -// }) activityThemer.setFrostColors { themeWindow = false } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt index 1a714374..ab041adc 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt @@ -60,7 +60,7 @@ class FbCookie @Inject internal constructor( * Note that this is a synchronized call */ val webCookie: String? - get() = CookieManager.getInstance().getCookie(FB_COOKIE_DOMAIN) + get() = CookieManager.getInstance().getCookie(HTTPS_FACEBOOK_COM) val messengerCookie: String? get() = CookieManager.getInstance().getCookie(HTTPS_MESSENGER_COM) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Images.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Images.kt index 70f911a8..37f8fab3 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Images.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Images.kt @@ -31,12 +31,15 @@ import kotlinx.coroutines.withTimeout /** * Attempts to get the fbcdn url of the supplied image redirect url */ -suspend fun String.getFullSizedImageUrl(url: String, timeout: Long = 3000): String? = - withContext(Dispatchers.IO) { +suspend fun String.getFullSizedImageUrl(url: String, timeout: Long = 3000): String? { + L.v { "Image full size 1 from $url" } + return withContext(Dispatchers.IO) { try { withTimeout(timeout) { + L.v { "Image full size from $url" } val redirect = requestBuilder().url(url).get().call() .execute().body?.string() ?: return@withTimeout null + L.v { "Image full size from redirect $redirect" } FB_REDIRECT_URL_MATCHER.find(redirect)[1]?.formattedFbUrl } } catch (e: Exception) { @@ -44,3 +47,4 @@ suspend fun String.getFullSizedImageUrl(url: String, timeout: Long = 3000): Stri null } } +} diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt index 94300348..a0842267 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt @@ -61,16 +61,16 @@ fun FrostWebView.requestWebOverlay(url: String): Boolean { context.runOnUiThread { context.showVideo(url) } return true } - if (url.isImageUrl) { - L.d { "Found fb image" } - context.launchImageActivity(url) - return true - } if (url.isIndirectImageUrl) { L.d { "Found indirect fb image" } context.launchImageActivity(url, cookie = fbCookie.webCookie) return true } + if (url.isImageUrl) { + L.d { "Found fb image" } + context.launchImageActivity(url) + return true + } if (!url.isIndependent) { L.d { "Forbid overlay switch" } return false diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..270f7597 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,3 @@ +include(":app", ":gradle-plugin") + +project(":gradle-plugin").projectDir = file("buildSrc") \ No newline at end of file -- cgit v1.2.3