diff options
12 files changed, 76 insertions, 53 deletions
diff --git a/.travis.yml b/.travis.yml index f1f59e97..49c54d02 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ jdk: - oraclejdk8 env: global: - - ANDROID_API=28 + - ANDROID_API=29 - ANDROID_BUILD_TOOLS=29.0.0 - secure: X3J97ccW+8K0bXPXhX608vPx7Pr/G4ju7quxydqMaYGgClHxoL/WpXOBAyyllde5P28PY4kioaqcI21BEhnAw0QUbmnzVLA1Qd5VS7aMPHpEnInKuOxGZ2d570OZd1f+ozFVt05vzG0VBJlBAkVhz2GWNxQdmIV1sO28MH526JMuYaEREuuywVSZmAeY7AAbW9MeCC2wvHvNmhk2nk6NLRQcsrDHcBsimy9fnnQ9lT/QsvToi1ZJd/MN7YkGDUULR+YmaotBzG546UJ1EiZQX91bFEJfP0oL43Pk7t5snzmHnKjLOr8Mt5QsIUXaiy/uzhUVmuDh1i0GEpZmhqM7nz/T6P7ogaLbbyJeauNmf15nu+e3hSvNiTzKyIwfSSflv8Do3g8/Eo3dKfIi3I8/OKF/uZ76kywh2LRqtZAqxRDiAMDZVwsRgD4aztoWm5AWa3tSoGy1J7i1eoqX6bNqokRbjgheTqcjN13kCdSZi3pZX7UBYm2Vumhn4izhTume19Rh9SqTmRgQ8jM7ynxHh7vVsJPPJG0HbQ623xz+d9mtXGy1fAb0dcUJMXdOhFN3m6AnKuHiF7cmsqje7Euk/TOZyqZmu0xEhTkugMbNKwGrklJiwRr3IoLtPdhLE38u3/auloUqBQ4K/iA9ZdhAreTSHEaI9d3J4N6kqCj3U30= android: 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() diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index 9ddde207..9d8e8ca7 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -1,8 +1,9 @@ object Versions { - const val targetSdk = 28 + const val targetSdk = 29 - const val andxBiometric = "1.0.0-alpha04" + // https://developer.android.com/jetpack/androidx/releases/biometric + const val andxBiometric = "1.0.0" // https://mvnrepository.com/artifact/org.apache.commons/commons-text // Updates blocked due to javax.script dependency @@ -13,21 +14,19 @@ object Versions { const val koin = "2.0.1" // https://github.com/mockk/mockk/releases const val mockk = "1.9.3" - // https://mvnrepository.com/artifact/androidx.core/core-ktx?repo=google - const val ktx = "1.1.0" // https://github.com/jhy/jsoup/releases - const val jsoup = "1.11.3" + const val jsoup = "1.12.1" // https://github.com/square/leakcanary/releases const val leakCanary = "1.6.2" // https://github.com/zsmb13/MaterialDrawerKt/releases const val materialDrawerKt = "3.0.0-rc01" // https://github.com/square/okhttp/releases - const val okhttp = "3.14.1" + const val okhttp = "4.2.2" // https://developer.android.com/jetpack/androidx/releases/room - const val room = "2.1.0" + const val room = "2.2.2" // http://robolectric.org/getting-started/ - const val roboelectric = "4.2" + const val roboelectric = "4.3" // https://github.com/davemorrissey/subsampling-scale-image-view#quick-start const val scaleImageView = "3.10.0" // https://github.com/srs/gradle-node-plugin/releases diff --git a/gradle.properties b/gradle.properties index 85c9e4ee..76cb9e27 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,7 +16,7 @@ org.gradle.daemon = true APP_ID=Frost APP_GROUP=com.pitchedapps -KAU=dba4c72 +KAU=490fa00 android.useAndroidX=true android.enableJetifier=true |