From 15494d3b42315fa6fa7ae5daeb5ddf1f964b3932 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 8 Dec 2019 00:29:40 -0800 Subject: Update versions (#1591) * Update versions * Update travis android sdk * Fix api updates * Update dex plugin version --- .../pitchedapps/frost/activities/AboutActivity.kt | 35 ++++++++++++++-------- .../pitchedapps/frost/activities/ImageActivity.kt | 2 +- .../frost/activities/WebOverlayActivity.kt | 3 +- .../pitchedapps/frost/debugger/OfflineWebsite.kt | 9 +++--- .../pitchedapps/frost/facebook/requests/Images.kt | 2 +- .../com/pitchedapps/frost/utils/AdBlocker.kt | 5 ++-- .../frost/web/FrostRequestInterceptor.kt | 5 ++-- 7 files changed, 37 insertions(+), 24 deletions(-) (limited to 'app/src/main/kotlin/com') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt index 92cb7609..0ef70bcd 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt @@ -78,7 +78,12 @@ class AboutActivity : AboutActivityBase(null, { "subsamplingscaleimageview" ) - val l = libs.prepareLibraries(this, include, null, false, true, true) + val l = libs.prepareLibraries( + this, include, emptyArray(), + autoDetect = false, + checkCachedDetection = true, + sort = true + ) if (BuildConfig.DEBUG) l.forEach { KL.d { "Lib ${it.definedName}" } } return l @@ -91,18 +96,22 @@ class AboutActivity : AboutActivityBase(null, { /** * Frost may not be a library but we're conveying the same info */ - val frost = Library().apply { - libraryName = string(R.string.frost_name) - author = string(R.string.dev_name) - libraryWebsite = string(R.string.github_url) - isOpenSource = true - libraryDescription = string(R.string.frost_description) - libraryVersion = BuildConfig.VERSION_NAME - license = License().apply { - licenseName = "GNU GPL v3" - licenseWebsite = "https://www.gnu.org/licenses/gpl-3.0.en.html" - } - } + val frost = Library( + definedName = "frost", + libraryName = string(R.string.frost_name), + author = string(R.string.dev_name), + libraryWebsite = string(R.string.github_url), + isOpenSource = true, + libraryDescription = string(R.string.frost_description), + libraryVersion = BuildConfig.VERSION_NAME, + license = License( + definedName = "gplv3", + licenseName = "GNU GPL v3", + licenseWebsite = "https://www.gnu.org/licenses/gpl-3.0.en.html", + licenseDescription = "", + licenseShortDescription = "" + ) + ) adapter.add(LibraryIItem(frost)).add(AboutLinks()) adapter.onClickListener = { _, _, item, _ -> if (item is LibraryIItem) { 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 10138595..d7876888 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt @@ -368,7 +368,7 @@ class ImageActivity : KauBaseActivity() { imgExtension = getImageExtension(response.header("Content-Type")) ?: ".jpg" - val body = response.body() ?: throw IOException("Failed to retrieve image body") + val body = response.body ?: throw IOException("Failed to retrieve image body") file.copyFromInputStream(body.byteStream()) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt index c3d77dc5..823da768 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt @@ -78,6 +78,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.launch import okhttp3.HttpUrl +import okhttp3.HttpUrl.Companion.toHttpUrlOrNull /** * Created by Allan Wang on 2017-06-01. @@ -125,7 +126,7 @@ class FrostWebActivity : WebOverlayActivityBase() { private fun parseActionSend(): Boolean { if (intent.action != Intent.ACTION_SEND || intent.type != "text/plain") return true val text = intent.getStringExtra(Intent.EXTRA_TEXT) ?: return true - val url = HttpUrl.parse(text)?.toString() + val url = text.toHttpUrlOrNull()?.toString() return if (url == null) { L.i { "Attempted to share a non-url" } L._i { "Shared text: $text" } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/debugger/OfflineWebsite.kt b/app/src/main/kotlin/com/pitchedapps/frost/debugger/OfflineWebsite.kt index bc453250..75a13295 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/debugger/OfflineWebsite.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/debugger/OfflineWebsite.kt @@ -31,6 +31,7 @@ import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.withContext import kotlinx.coroutines.yield import okhttp3.HttpUrl +import okhttp3.HttpUrl.Companion.toHttpUrlOrNull import okhttp3.Request import org.jsoup.Jsoup import org.jsoup.nodes.Document @@ -66,8 +67,8 @@ class OfflineWebsite( * Supplied url without the queries */ private val baseUrl: String = baseUrl ?: run { - val url: HttpUrl = HttpUrl.parse(url) ?: throw IllegalArgumentException("Malformed url") - return@run "${url.scheme()}://${url.host()}" + val url: HttpUrl = url.toHttpUrlOrNull() ?: throw IllegalArgumentException("Malformed url") + return@run "${url.scheme}://${url.host}" } private val mainFile = File(baseDir, "index.html") @@ -237,7 +238,7 @@ class OfflineWebsite( return try { val file = File(assetDir, fileName(url)) file.createNewFile() - val stream = request(url).execute().body()?.byteStream() + val stream = request(url).execute().body?.byteStream() ?: throw IllegalArgumentException("Response body not found for $url") file.copyFromInputStream(stream) true @@ -252,7 +253,7 @@ class OfflineWebsite( val file = File(assetDir, fileName(url)) file.createNewFile() - var content = request(url).execute().body()?.string() + var content = request(url).execute().body?.string() ?: throw IllegalArgumentException("Response body not found for $url") val links = FB_CSS_URL_MATCHER.findAll(content).mapNotNull { it[1] } val absLinks = links.mapNotNull { 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 0115d6fc..1028287a 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 @@ -36,7 +36,7 @@ suspend fun String.getFullSizedImageUrl(url: String, timeout: Long = 3000): Stri try { withTimeout(timeout) { val redirect = requestBuilder().url(url).get().call() - .execute().body()?.string() ?: return@withTimeout null + .execute().body?.string() ?: return@withTimeout null FB_REDIRECT_URL_MATCHER.find(redirect)[1]?.formattedFbUrl } } catch (e: Exception) { diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/AdBlocker.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/AdBlocker.kt index d14c6cd3..92b44ffd 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/AdBlocker.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/AdBlocker.kt @@ -22,6 +22,7 @@ import ca.allanwang.kau.utils.use import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import okhttp3.HttpUrl +import okhttp3.HttpUrl.Companion.toHttpUrlOrNull /** * Created by Allan Wang on 2017-09-24. @@ -50,8 +51,8 @@ open class AdBlocker(val assetPath: String) { fun isAd(url: String?): Boolean { url ?: return false - val httpUrl = HttpUrl.parse(url) ?: return false - return isAdHost(httpUrl.host()) + val httpUrl = url.toHttpUrlOrNull() ?: return false + return isAdHost(httpUrl.host) } tailrec fun isAdHost(host: String): Boolean { diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostRequestInterceptor.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostRequestInterceptor.kt index ab910ebc..c4c6b81f 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostRequestInterceptor.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostRequestInterceptor.kt @@ -22,6 +22,7 @@ import android.webkit.WebView import com.pitchedapps.frost.utils.FrostPglAdBlock import com.pitchedapps.frost.utils.L import okhttp3.HttpUrl +import okhttp3.HttpUrl.Companion.toHttpUrlOrNull import java.io.ByteArrayInputStream /** @@ -40,8 +41,8 @@ private val blankResource: WebResourceResponse by lazy { fun WebView.shouldFrostInterceptRequest(request: WebResourceRequest): WebResourceResponse? { val requestUrl = request.url?.toString() ?: return null - val httpUrl = HttpUrl.parse(requestUrl) ?: return null - val host = httpUrl.host() + val httpUrl = requestUrl.toHttpUrlOrNull() ?: return null + val host = httpUrl.host val url = httpUrl.toString() if (host.contains("facebook") || host.contains("fbcdn")) return null if (FrostPglAdBlock.isAd(host)) return blankResource -- cgit v1.2.3