diff options
author | Allan Wang <me@allanwang.ca> | 2019-12-08 00:29:40 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-08 00:29:40 -0800 |
commit | 15494d3b42315fa6fa7ae5daeb5ddf1f964b3932 (patch) | |
tree | c53221689ddeef3619572276fa530e8368abbde0 /app | |
parent | f9129dd7b59b4b3119805a49c21315e1f5a5e336 (diff) | |
download | frost-15494d3b42315fa6fa7ae5daeb5ddf1f964b3932.tar.gz frost-15494d3b42315fa6fa7ae5daeb5ddf1f964b3932.tar.bz2 frost-15494d3b42315fa6fa7ae5daeb5ddf1f964b3932.zip |
Update versions (#1591)
* Update versions
* Update travis android sdk
* Fix api updates
* Update dex plugin version
Diffstat (limited to 'app')
9 files changed, 67 insertions, 43 deletions
diff --git a/app/build.gradle b/app/build.gradle index ee8cf5d3..c89bf1f4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -244,7 +244,8 @@ dependencies { //noinspection GradleDependency implementation kau.Dependencies.kau('searchview', KAU) - implementation "androidx.core:core-ktx:${Versions.ktx}" + implementation kau.Dependencies.coreKtx + implementation kau.Dependencies.swipeRefreshLayout implementation "androidx.biometric:biometric:${Versions.andxBiometric}" 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 diff --git a/app/src/test/kotlin/com/pitchedapps/frost/debugger/OfflineWebsiteTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/debugger/OfflineWebsiteTest.kt index b832cda5..1d886292 100644 --- a/app/src/test/kotlin/com/pitchedapps/frost/debugger/OfflineWebsiteTest.kt +++ b/app/src/test/kotlin/com/pitchedapps/frost/debugger/OfflineWebsiteTest.kt @@ -44,7 +44,8 @@ class OfflineWebsiteTest { @BeforeTest fun before() { - val buildPath = if (File("").absoluteFile.name == "app") "build/offline_test" else "app/build/offline_test" + val buildPath = + if (File("").absoluteFile.name == "app") "build/offline_test" else "app/build/offline_test" baseDir = File(buildPath) assertTrue(baseDir.deleteRecursively(), "Failed to clean base dir") server = MockWebServer() @@ -56,7 +57,10 @@ class OfflineWebsiteTest { server.shutdown() } - private fun zipAndFetch(url: String = server.url("/").toString(), cookie: String = ""): ZipFile { + private fun zipAndFetch( + url: String = server.url("/").toString(), + cookie: String = "" + ): ZipFile { val name = "test${System.currentTimeMillis()}" runBlocking { val success = OfflineWebsite(url, cookie, baseDir = baseDir) @@ -75,7 +79,8 @@ class OfflineWebsiteTest { val actualContent = getInputStream(entry).bufferedReader().use { it.readText() } assertEquals( content.replace(tagWhitespaceRegex, "><").toLowerCase(), - actualContent.replace(tagWhitespaceRegex, "><").toLowerCase(), "Content mismatch for $path" + actualContent.replace(tagWhitespaceRegex, "><").toLowerCase(), + "Content mismatch for $path" ) } @@ -129,13 +134,13 @@ class OfflineWebsiteTest { } """.trimIndent() - server.setDispatcher(object : Dispatcher() { + server.dispatcher = object : Dispatcher() { override fun dispatch(request: RecordedRequest): MockResponse = when { - request.path.contains(cssUrl.encodedPath()) -> MockResponse().setBody(css1) + request.path?.contains(cssUrl.encodedPath) == true -> MockResponse().setBody(css1) else -> MockResponse().setBody(content) } - }) + } val zip = zipAndFetch() @@ -163,18 +168,21 @@ class OfflineWebsiteTest { console.log('hello'); """.trimIndent() - server.setDispatcher(object : Dispatcher() { + server.dispatcher = object : Dispatcher() { override fun dispatch(request: RecordedRequest): MockResponse = when { - request.path.contains(jsUrl.encodedPath()) -> MockResponse().setBody(js1) + request.path?.contains(jsUrl.encodedPath) == true -> MockResponse().setBody(js1) else -> MockResponse().setBody(content) } - }) + } val zip = zipAndFetch() assertEquals(2, zip.size(), "2 files expected") - zip.assertContentEquals("index.html", content.replace(jsUrl.toString(), "assets/a0_1.js.txt")) + zip.assertContentEquals( + "index.html", + content.replace(jsUrl.toString(), "assets/a0_1.js.txt") + ) zip.assertContentEquals("assets/a0_1.js.txt", js1) } @@ -220,16 +228,18 @@ class OfflineWebsiteTest { console.log('world'); """.trimIndent() - server.setDispatcher(object : Dispatcher() { - override fun dispatch(request: RecordedRequest): MockResponse = - when { - request.path.contains(css1Url.encodedPath()) -> MockResponse().setBody(css1) - request.path.contains(css2Url.encodedPath()) -> MockResponse().setBody(css2) - request.path.contains(js1Url.encodedPath()) -> MockResponse().setBody(js1) - request.path.contains(js2Url.encodedPath()) -> MockResponse().setBody(js2) + server.dispatcher=object : Dispatcher() { + override fun dispatch(request: RecordedRequest): MockResponse { + val path = request.path ?: return MockResponse().setBody(content) + return when { + path.contains(css1Url.encodedPath) -> MockResponse().setBody(css1) + path.contains(css2Url.encodedPath) -> MockResponse().setBody(css2) + path.contains(js1Url.encodedPath) -> MockResponse().setBody(js1) + path.contains(js2Url.encodedPath) -> MockResponse().setBody(js2) else -> MockResponse().setBody(content) } - }) + } + } val zip = zipAndFetch() |