diff options
Diffstat (limited to 'app/src')
21 files changed, 120 insertions, 31 deletions
diff --git a/app/src/androidTest/kotlin/com/pitchedapps/frost/db/GenericDbTest.kt b/app/src/androidTest/kotlin/com/pitchedapps/frost/db/GenericDbTest.kt index 76b2d677..39b9f513 100644 --- a/app/src/androidTest/kotlin/com/pitchedapps/frost/db/GenericDbTest.kt +++ b/app/src/androidTest/kotlin/com/pitchedapps/frost/db/GenericDbTest.kt @@ -31,7 +31,13 @@ class GenericDbTest : BaseDbTest() { */ @Test fun save() { - val tabs = listOf(FbItem.ACTIVITY_LOG, FbItem.BIRTHDAYS, FbItem.EVENTS, FbItem.MARKETPLACE, FbItem.ACTIVITY_LOG) + val tabs = listOf( + FbItem.ACTIVITY_LOG, + FbItem.BIRTHDAYS, + FbItem.EVENTS, + FbItem.MARKETPLACE, + FbItem.ACTIVITY_LOG + ) runBlocking { dao.saveTabs(tabs) assertEquals(tabs, dao.getTabs(), "Tab saving failed") @@ -51,7 +57,12 @@ class GenericDbTest : BaseDbTest() { @Test fun ignoreErrors() { runBlocking { - dao._save(GenericEntity(GenericDao.TYPE_TABS, "${FbItem.ACTIVITY_LOG.name},unknown,${FbItem.EVENTS.name}")) + dao._save( + GenericEntity( + GenericDao.TYPE_TABS, + "${FbItem.ACTIVITY_LOG.name},unknown,${FbItem.EVENTS.name}" + ) + ) assertEquals( listOf(FbItem.ACTIVITY_LOG, FbItem.EVENTS), dao.getTabs(), diff --git a/app/src/androidTest/kotlin/com/pitchedapps/frost/db/NotificationDbTest.kt b/app/src/androidTest/kotlin/com/pitchedapps/frost/db/NotificationDbTest.kt index ed49439c..60b6ee05 100644 --- a/app/src/androidTest/kotlin/com/pitchedapps/frost/db/NotificationDbTest.kt +++ b/app/src/androidTest/kotlin/com/pitchedapps/frost/db/NotificationDbTest.kt @@ -51,7 +51,11 @@ class NotificationDbTest : BaseDbTest() { db.cookieDao().save(cookie) dao.saveNotifications(NOTIF_CHANNEL_GENERAL, notifs) val dbNotifs = dao.selectNotifications(cookie.id, NOTIF_CHANNEL_GENERAL) - assertEquals(notifs.sortedByDescending { it.timestamp }, dbNotifs, "Incorrect notification list received") + assertEquals( + notifs.sortedByDescending { it.timestamp }, + dbNotifs, + "Incorrect notification list received" + ) } } @@ -126,10 +130,18 @@ class NotificationDbTest : BaseDbTest() { // Unique unsorted ids val notifs = listOf(0L, 4L, 2L, 6L, 99L, 3L).map { notifContent(it, cookie) } runBlocking { - assertEquals(-1L, dao.latestEpoch(cookie.id, NOTIF_CHANNEL_GENERAL), "Default epoch failed") + assertEquals( + -1L, + dao.latestEpoch(cookie.id, NOTIF_CHANNEL_GENERAL), + "Default epoch failed" + ) db.cookieDao().save(cookie) dao.saveNotifications(NOTIF_CHANNEL_GENERAL, notifs) - assertEquals(99L, dao.latestEpoch(cookie.id, NOTIF_CHANNEL_GENERAL), "Latest epoch failed") + assertEquals( + 99L, + dao.latestEpoch(cookie.id, NOTIF_CHANNEL_GENERAL), + "Latest epoch failed" + ) } } diff --git a/app/src/androidTest/kotlin/com/pitchedapps/frost/facebook/FbCookieTest.kt b/app/src/androidTest/kotlin/com/pitchedapps/frost/facebook/FbCookieTest.kt index 3cd7dbf2..a39aa6d2 100644 --- a/app/src/androidTest/kotlin/com/pitchedapps/frost/facebook/FbCookieTest.kt +++ b/app/src/androidTest/kotlin/com/pitchedapps/frost/facebook/FbCookieTest.kt @@ -24,6 +24,9 @@ class FbCookieTest { @Test fun managerAcceptsCookie() { - assertTrue(CookieManager.getInstance().acceptCookie(), "Cookie manager should accept cookie by default") + assertTrue( + CookieManager.getInstance().acceptCookie(), + "Cookie manager should accept cookie by default" + ) } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt index bfb87a2f..58e7d629 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt @@ -661,7 +661,13 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, } textDebounceInterval = 300 searchCallback = - { query, _ -> launchWebOverlay("${FbItem._SEARCH.url}/?q=$query", fbCookie, prefs); true } + { query, _ -> + launchWebOverlay( + "${FbItem._SEARCH.url}/?q=$query", + fbCookie, + prefs + ); true + } closeListener = { _ -> searchViewCache.clear() } foregroundColor = prefs.textColor backgroundColor = prefs.bgColor.withMinAlpha(200) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt index 51b1134a..03980a21 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt @@ -39,7 +39,6 @@ import kotlin.coroutines.resume import kotlin.coroutines.suspendCoroutine import kotlinx.coroutines.CoroutineExceptionHandler import org.koin.android.ext.android.inject -import org.koin.core.inject /** * Created by Allan Wang on 05/01/18. 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 1028287a..70f911a8 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/iitems/NotificationIItem.kt b/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt index 9d3b59eb..3150ce6d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt @@ -65,7 +65,11 @@ class NotificationIItem(val notification: FrostNotif, val cookie: String) : ) } // TODO temp fix. If url is dependent, we cannot load it directly - v!!.context.launchWebOverlay(if (notif.url.isIndependent) notif.url else FbItem.NOTIFICATIONS.url, fbCookie, prefs) + v!!.context.launchWebOverlay( + if (notif.url.isIndependent) notif.url else FbItem.NOTIFICATIONS.url, + fbCookie, + prefs + ) true } } @@ -96,7 +100,8 @@ class NotificationIItem(val notification: FrostNotif, val cookie: String) : } } - class ViewHolder(itemView: View) : FastAdapter.ViewHolder<NotificationIItem>(itemView), KoinComponent { + class ViewHolder(itemView: View) : FastAdapter.ViewHolder<NotificationIItem>(itemView), + KoinComponent { private val prefs: Prefs by inject() diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt index 18c51161..b801a871 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt @@ -101,7 +101,8 @@ fun WebView.jsInject(vararg injectors: InjectorContract, prefs: Prefs) { } } -fun FrostWebViewClient.jsInject(vararg injectors: InjectorContract, prefs: Prefs) = web.jsInject(*injectors, prefs = prefs) +fun FrostWebViewClient.jsInject(vararg injectors: InjectorContract, prefs: Prefs) = + web.jsInject(*injectors, prefs = prefs) /** * Wrapper class to convert a function into an injector diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt index 562b1dd9..c4f71452 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt @@ -112,7 +112,12 @@ enum class NotificationType( * Returns the number of notifications generated, * or -1 if an error occurred */ - suspend fun fetch(context: Context, data: CookieEntity, prefs: Prefs, notifDao: NotificationDao): Int { + suspend fun fetch( + context: Context, + data: CookieEntity, + prefs: Prefs, + notifDao: NotificationDao + ): Int { val response = try { parser.parse(data.cookie) } catch (ignored: Exception) { @@ -306,7 +311,12 @@ data class FrostNotification( val notif: NotificationCompat.Builder ) { - fun withAlert(context: Context, enable: Boolean, ringtone: String, prefs: Prefs): FrostNotification { + fun withAlert( + context: Context, + enable: Boolean, + ringtone: String, + prefs: Prefs + ): FrostNotification { notif.setFrostAlert(context, enable, ringtone, prefs) return this } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt index a86d4062..3a2d7732 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt @@ -40,7 +40,6 @@ import com.pitchedapps.frost.utils.frostSnackbar import com.pitchedapps.frost.utils.frostUri import com.pitchedapps.frost.views.Keywords import kotlinx.coroutines.launch -import org.koin.android.ext.android.get /** * Created by Allan Wang on 2017-06-29. diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/BiometricUtils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/BiometricUtils.kt index ab64ff55..21be4168 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/BiometricUtils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/BiometricUtils.kt @@ -73,7 +73,11 @@ object BiometricUtils { * Note that the underlying request will call [androidx.fragment.app.FragmentTransaction.commit], * so this cannot happen after onSaveInstanceState. */ - fun authenticate(activity: FragmentActivity, prefs: Prefs, force: Boolean = false): BiometricDeferred { + fun authenticate( + activity: FragmentActivity, + prefs: Prefs, + force: Boolean = false + ): BiometricDeferred { val deferred: BiometricDeferred = CompletableDeferred() if (!force && !shouldPrompt(activity, prefs)) { deferred.complete(null) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt index 8a76c424..374488fd 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt @@ -46,7 +46,7 @@ import org.koin.core.inject */ class AccountItem(val cookie: CookieEntity?) : KauIItem<AccountItem.ViewHolder>(R.layout.view_account, { ViewHolder(it) }, R.id.item_account), -KoinComponent { + KoinComponent { private val prefs: Prefs by inject() diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/Keywords.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/Keywords.kt index ff8a5bb7..f2386e81 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/Keywords.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/Keywords.kt @@ -122,7 +122,12 @@ class KeywordItem(val keyword: String) : AbstractItem<KeywordItem.ViewHolder>() init { text.setTextColor(prefs.textColor) - delete.setImageDrawable(GoogleMaterial.Icon.gmd_delete.keywordDrawable(itemView.context, prefs)) + delete.setImageDrawable( + GoogleMaterial.Icon.gmd_delete.keywordDrawable( + itemView.context, + prefs + ) + ) } } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt index 05248153..f7b15ed2 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt @@ -81,7 +81,12 @@ class FrostJSI(val web: FrostWebView) { @JavascriptInterface fun contextMenu(url: String?, text: String?) { // url will be formatted through webcontext - web.post { context.showWebContextMenu(WebContext(url.takeIf { it.isIndependent }, text), fbCookie) } + web.post { + context.showWebContextMenu( + WebContext(url.takeIf { it.isIndependent }, text), + fbCookie + ) + } } /** 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 20c0878f..4064a5ff 100644 --- a/app/src/test/kotlin/com/pitchedapps/frost/debugger/OfflineWebsiteTest.kt +++ b/app/src/test/kotlin/com/pitchedapps/frost/debugger/OfflineWebsiteTest.kt @@ -137,7 +137,9 @@ class OfflineWebsiteTest { server.dispatcher = object : Dispatcher() { override fun dispatch(request: RecordedRequest): MockResponse = when { - request.path?.contains(cssUrl.encodedPath) == true -> MockResponse().setBody(css1) + request.path?.contains(cssUrl.encodedPath) == true -> MockResponse().setBody( + css1 + ) else -> MockResponse().setBody(content) } } diff --git a/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbRegexTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbRegexTest.kt index fc96ef2e..08957ea9 100644 --- a/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbRegexTest.kt +++ b/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbRegexTest.kt @@ -27,7 +27,8 @@ class FbRegexTest { @Test fun userIdRegex() { val id = 12349876L - val cookie = "wd=1366x615; c_user=$id; act=1234%2F12; m_pixel_ratio=1; presence=hello; x-referer=asdfasdf" + val cookie = + "wd=1366x615; c_user=$id; act=1234%2F12; m_pixel_ratio=1; presence=hello; x-referer=asdfasdf" assertEquals(id, FB_USER_MATCHER.find(cookie)[1]?.toLong()) } @@ -41,13 +42,17 @@ class FbRegexTest { @Test fun ppRegex() { - val img = "https\\3a //scontent-yyz1-1.xx.fbcdn.net/v/asdf1234.jpg?efg\\3d 333\\26 oh\\3d 77\\26 oe\\3d 444" + val img = + "https\\3a //scontent-yyz1-1.xx.fbcdn.net/v/asdf1234.jpg?efg\\3d 333\\26 oh\\3d 77\\26 oe\\3d 444" val imgUnescaped = StringEscapeUtils.unescapeCsv(img) val ppStyleSingleQuote = "background:#d8dce6 url('$img') no-repeat center;" val ppStyleDoubleQuote = "background:#d8dce6 url(\"$img\") no-repeat center;" val ppStyleNoQuote = "background:#d8dce6 url($img) no-repeat center;" listOf(ppStyleSingleQuote, ppStyleDoubleQuote, ppStyleNoQuote).forEach { - assertEquals(imgUnescaped, StringEscapeUtils.unescapeCsv(FB_CSS_URL_MATCHER.find(it)[1])) + assertEquals( + imgUnescaped, + StringEscapeUtils.unescapeCsv(FB_CSS_URL_MATCHER.find(it)[1]) + ) } } @@ -55,9 +60,17 @@ class FbRegexTest { fun msgNotifIdRegex() { val id = 1273491646093428L val data = "threadlist_row_other_user_fbid_thread_fbid_$id" - assertEquals(id, FB_MESSAGE_NOTIF_ID_MATCHER.find(data)[1]?.toLong(), "thread_fbid mismatch") + assertEquals( + id, + FB_MESSAGE_NOTIF_ID_MATCHER.find(data)[1]?.toLong(), + "thread_fbid mismatch" + ) val userData = "threadlist_row_other_user_fbid_${id}thread_fbid_" - assertEquals(id, FB_MESSAGE_NOTIF_ID_MATCHER.find(userData)[1]?.toLong(), "user_fbid mismatch") + assertEquals( + id, + FB_MESSAGE_NOTIF_ID_MATCHER.find(userData)[1]?.toLong(), + "user_fbid mismatch" + ) } @Test @@ -70,7 +83,8 @@ class FbRegexTest { @Test fun imageIdRegex() { val id = 123456L - val img = "https://scontent-yyz1-1.xx.fbcdn.net/v/t31.0-8/fr/cp0/e15/q65/89056_${id}_98239_o.jpg" + val img = + "https://scontent-yyz1-1.xx.fbcdn.net/v/t31.0-8/fr/cp0/e15/q65/89056_${id}_98239_o.jpg" assertEquals(id, FB_IMAGE_ID_MATCHER.find(img)[1]?.toLongOrNull()) } } diff --git a/app/src/test/kotlin/com/pitchedapps/frost/internal/Internal.kt b/app/src/test/kotlin/com/pitchedapps/frost/internal/Internal.kt index b83cb62e..17ce847c 100644 --- a/app/src/test/kotlin/com/pitchedapps/frost/internal/Internal.kt +++ b/app/src/test/kotlin/com/pitchedapps/frost/internal/Internal.kt @@ -79,7 +79,10 @@ fun Any.assertComponentsNotEmpty() { val result = it.call(this) as String assertTrue(result.isNotEmpty(), "${it.name} returned empty string") if (result.startsWith("https")) - assertTrue(result.startsWith("https://"), "${it.name} has poorly formatted output $result") + assertTrue( + result.startsWith("https://"), + "${it.name} has poorly formatted output $result" + ) } } } diff --git a/app/src/test/kotlin/com/pitchedapps/frost/kotlin/FlyweightTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/kotlin/FlyweightTest.kt index bcc86974..20cdd5ec 100644 --- a/app/src/test/kotlin/com/pitchedapps/frost/kotlin/FlyweightTest.kt +++ b/app/src/test/kotlin/com/pitchedapps/frost/kotlin/FlyweightTest.kt @@ -107,7 +107,10 @@ class FlyweightTest { } catch (ignore: CancellationException) { } try { - assertFalse(longRunningResult.isActive, "Long running result should no longer be active") + assertFalse( + longRunningResult.isActive, + "Long running result should no longer be active" + ) longRunningResult.await() fail("Flyweight should have cancelled previously running requests") } catch (ignore: CancellationException) { diff --git a/app/src/test/kotlin/com/pitchedapps/frost/utils/BuildUtilsTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/utils/BuildUtilsTest.kt index 7b1fcfcf..596693e7 100644 --- a/app/src/test/kotlin/com/pitchedapps/frost/utils/BuildUtilsTest.kt +++ b/app/src/test/kotlin/com/pitchedapps/frost/utils/BuildUtilsTest.kt @@ -28,7 +28,10 @@ class BuildUtilsTest { fun matchingVersions() { assertNull(BuildUtils.match("unknown")) assertEquals(BuildUtils.Data("v1.0.0", ""), BuildUtils.match("1.0.0")) - assertEquals(BuildUtils.Data("v2.0.1", "26-af40533-debug"), BuildUtils.match("2.0.1-26-af40533-debug")) + assertEquals( + BuildUtils.Data("v2.0.1", "26-af40533-debug"), + BuildUtils.match("2.0.1-26-af40533-debug") + ) } @Test diff --git a/app/src/test/kotlin/com/pitchedapps/frost/utils/CoroutineTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/utils/CoroutineTest.kt index 7faf2b67..cb427faa 100644 --- a/app/src/test/kotlin/com/pitchedapps/frost/utils/CoroutineTest.kt +++ b/app/src/test/kotlin/com/pitchedapps/frost/utils/CoroutineTest.kt @@ -61,7 +61,10 @@ class CoroutineTest { } } - private suspend fun <T> listen(channel: ReceiveChannel<T>, shouldEnd: suspend (T) -> Boolean = { false }): List<T> = + private suspend fun <T> listen( + channel: ReceiveChannel<T>, + shouldEnd: suspend (T) -> Boolean = { false } + ): List<T> = withContext(Dispatchers.IO) { val data = mutableListOf<T>() for (c in channel) { diff --git a/app/src/test/kotlin/com/pitchedapps/frost/utils/JsoupCleanerTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/utils/JsoupCleanerTest.kt index 13dc7ac6..7c277dc7 100644 --- a/app/src/test/kotlin/com/pitchedapps/frost/utils/JsoupCleanerTest.kt +++ b/app/src/test/kotlin/com/pitchedapps/frost/utils/JsoupCleanerTest.kt @@ -26,7 +26,8 @@ class JsoupCleanerTest { val whitespaceRegex = Regex("\\s+") - fun String.cleanWhitespace() = replace("\n", "").replace(whitespaceRegex, " ").replace("> <", "><") + fun String.cleanWhitespace() = + replace("\n", "").replace(whitespaceRegex, " ").replace("> <", "><") private fun String.assertCleanHtml(expected: String) { assertEquals(expected.cleanWhitespace(), cleanHtml().cleanWhitespace()) |