aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-09-27 20:15:11 -0400
committerAllan Wang <me@allanwang.ca>2018-09-27 20:15:11 -0400
commit2e22f2ae6a963a2e00dc4b50b4a308c80ebe68e2 (patch)
treeb0bfb3d1bede59bc6f54030c3b2ea51b3482ee28 /app/src/main/kotlin/com
parent3aa44ba16e52ceaf37dd28a8075b302c42785526 (diff)
downloadfrost-2e22f2ae6a963a2e00dc4b50b4a308c80ebe68e2.tar.gz
frost-2e22f2ae6a963a2e00dc4b50b4a308c80ebe68e2.tar.bz2
frost-2e22f2ae6a963a2e00dc4b50b4a308c80ebe68e2.zip
Fix more lints
Diffstat (limited to 'app/src/main/kotlin/com')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt6
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt5
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/SelectorActivity.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt6
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostUrlData.kt25
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/debugger/OfflineWebsite.kt10
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt5
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/MessageParser.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/NotifParser.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/FbRequest.kt8
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Notifications.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt3
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt8
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt5
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt7
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/AdBlocker.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt8
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt4
21 files changed, 56 insertions, 68 deletions
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 4d92cbcb..2fce69a8 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
@@ -308,10 +308,10 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
else {
val data = SearchParser.query(FbCookie.webCookie, query)?.data?.results
if (data != null) {
- val items = data.map(FrostSearch::toSearchItem).toMutableList()
+ val items = data.mapTo(mutableListOf(), FrostSearch::toSearchItem)
if (items.isNotEmpty())
items.add(SearchItem("${FbItem._SEARCH.url}?q=$query", string(R.string.show_all_results), iicon = null))
- searchViewCache.put(query, items)
+ searchViewCache[query] = items
searchView.results = items
}
}
@@ -417,7 +417,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
positiveText(R.string.kau_yes)
negativeText(R.string.kau_no)
onPositive { _, _ -> finish() }
- checkBoxPromptRes(R.string.kau_do_not_show_again, false, { _, b -> Prefs.exitConfirmation = !b })
+ checkBoxPromptRes(R.string.kau_do_not_show_again, false) { _, b -> Prefs.exitConfirmation = !b }
}
return true
}
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 30f12c1d..139066a5 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt
@@ -64,6 +64,7 @@ class DebugActivity : KauBaseActivity() {
fab.visible().setIcon(GoogleMaterial.Icon.gmd_bug_report, Prefs.iconColor)
fab.backgroundTintList = ColorStateList.valueOf(Prefs.accentColor)
fab.setOnClickListener {
+ _ ->
fab.hide()
val parent = baseDir(this)
@@ -76,11 +77,11 @@ class DebugActivity : KauBaseActivity() {
emitter.onSuccess(it)
}
}.subscribeOn(AndroidSchedulers.mainThread())
- Single.zip(listOf(rxScreenshot, rxBody), {
+ Single.zip(listOf(rxScreenshot, rxBody)) {
val screenshot = it[0] == true
val body = it[1] as? String
screenshot to body
- }).observeOn(AndroidSchedulers.mainThread())
+ }.observeOn(AndroidSchedulers.mainThread())
.subscribe { (screenshot, body), err ->
if (err != null) {
L.e { "DebugActivity error ${err.message}" }
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
index 11ed4525..bf8120de 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
@@ -71,7 +71,7 @@ class MainActivity : BaseMainActivity() {
val requests = it.select("[data-sigil*=requests] [data-sigil=count]")
val messages = it.select("[data-sigil*=messages] [data-sigil=count]")
val notifications = it.select("[data-sigil*=notifications] [data-sigil=count]")
- return@map arrayOf(feed, requests, messages, notifications).map { it?.getOrNull(0)?.ownText() }
+ return@map arrayOf(feed, requests, messages, notifications).map { e -> e?.getOrNull(0)?.ownText() }
}
.observeOn(AndroidSchedulers.mainThread())
.subscribe { (feed, requests, messages, notifications) ->
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/SelectorActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/SelectorActivity.kt
index a9658eb1..58ab3dac 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/SelectorActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/SelectorActivity.kt
@@ -39,7 +39,7 @@ class SelectorActivity : BaseActivity() {
override fun onClick(v: View, position: Int, fastAdapter: FastAdapter<AccountItem>, item: AccountItem) {
if (item.cookie == null) this@SelectorActivity.launchNewTask<LoginActivity>()
- else FbCookie.switchUser(item.cookie, { launchNewTask<MainActivity>(cookies()) })
+ else FbCookie.switchUser(item.cookie) { launchNewTask<MainActivity>(cookies()) }
}
})
setFrostColors {
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 3081c463..323a2eb5 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt
@@ -75,17 +75,17 @@ class FrostWebActivity : WebOverlayActivityBase(false) {
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()
- if (url == null) {
+ return if (url == null) {
L.i { "Attempted to share a non-url" }
L._i { "Shared text: $text" }
copyToClipboard(text, "Text to Share", showToast = false)
intent.putExtra(ARG_URL, FbItem.FEED.url)
- return false
+ false
} else {
L.i { "Sharing url through overlay" }
L._i { "Url: $url" }
intent.putExtra(ARG_URL, "${FB_URL_BASE}sharer/sharer.php?u=$url")
- return true
+ true
}
}
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostUrlData.kt b/app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostUrlData.kt
deleted file mode 100644
index 18467fa4..00000000
--- a/app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostUrlData.kt
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.pitchedapps.frost.contracts
-
-import com.pitchedapps.frost.facebook.FbItem
-
-/**
- * Created by Allan Wang on 19/12/17.
- */
-interface FrostUrlData {
-
- /**
- * The main (and fallback) url
- */
- var baseUrl: String
-
- /**
- * Only base viewpager should pass an enum
- */
- var baseEnum: FbItem?
-
- fun passUrlDataTo(other: FrostUrlData) {
- other.baseUrl = baseUrl
- other.baseEnum = baseEnum
- }
-
-} \ No newline at end of file
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 f5f7463d..6298f1f9 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/debugger/OfflineWebsite.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/debugger/OfflineWebsite.kt
@@ -182,7 +182,7 @@ class OfflineWebsite(private val url: String,
delete()
}
- baseDir.listFiles({ _, n -> n != "$name.zip" }).forEach { it.zip() }
+ baseDir.listFiles { _, n -> n != "$name.zip" }.forEach { it.zip() }
assetDir.listFiles().forEach {
it.zip("assets/${it.name}")
}
@@ -208,7 +208,7 @@ class OfflineWebsite(private val url: String,
}
private fun downloadFiles() = fileQueue.clean().toTypedArray().zip<String, Boolean, Boolean>({
- it.all { it }
+ it.all { self -> self }
}, {
it.downloadUrl({ false }) { file, body ->
body.byteStream().use { input ->
@@ -222,8 +222,8 @@ class OfflineWebsite(private val url: String,
private fun downloadCss() = cssQueue.clean().toTypedArray().zip<String, Set<String>, Set<String>>({
it.flatMap { l -> l }.toSet()
- }, {
- it.downloadUrl({ emptySet() }) { file, body ->
+ }, { cssUrl ->
+ cssUrl.downloadUrl({ emptySet() }) { file, body ->
var content = body.string()
val links = FB_CSS_URL_MATCHER.findAll(content).mapNotNull { it[1] }
val absLinks = links.mapNotNull {
@@ -303,7 +303,7 @@ class OfflineWebsite(private val url: String,
if (newUrl.endsWith(".js"))
newUrl = "$newUrl.txt"
- urlMapper.put(this, newUrl)
+ urlMapper[this] = newUrl
return newUrl
}
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 38de6150..2f0ef616 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt
@@ -30,14 +30,15 @@ object FbCookie {
private fun setWebCookie(cookie: String?, callback: (() -> Unit)?) {
with(CookieManager.getInstance()) {
removeAllCookies {
+ _ ->
if (cookie == null) {
callback?.invoke()
return@removeAllCookies
}
L.d { "Setting cookie" }
val cookies = cookie.split(";").map { Pair(it, SingleSubject.create<Boolean>()) }
- cookies.forEach { (cookie, callback) -> setCookie(FB_URL_BASE, cookie, { callback.onSuccess(it) }) }
- Observable.zip<Boolean, Unit>(cookies.map { (_, callback) -> callback.toObservable() }, {})
+ cookies.forEach { (cookie, callback) -> setCookie(FB_URL_BASE, cookie) { callback.onSuccess(it) } }
+ Observable.zip<Boolean, Unit>(cookies.map { (_, callback) -> callback.toObservable() }) {}
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
callback?.invoke()
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/MessageParser.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/MessageParser.kt
index f32c3452..a3ebf998 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/MessageParser.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/MessageParser.kt
@@ -35,7 +35,7 @@ data class FrostMessages(val threads: List<FrostThread>,
}.toString()
override fun getUnreadNotifications(data: CookieModel) =
- threads.filter(FrostThread::unread).map {
+ threads.asSequence().filter(FrostThread::unread).map {
with(it) {
NotificationContent(
data = data,
@@ -47,7 +47,7 @@ data class FrostMessages(val threads: List<FrostThread>,
profileUrl = img
)
}
- }
+ }.toList()
}
/**
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/NotifParser.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/NotifParser.kt
index 03b913c7..410a0e84 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/NotifParser.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/NotifParser.kt
@@ -24,7 +24,7 @@ data class FrostNotifs(
}.toString()
override fun getUnreadNotifications(data: CookieModel) =
- notifs.filter(FrostNotif::unread).map {
+ notifs.asSequence().filter(FrostNotif::unread).map {
with(it) {
NotificationContent(
data = data,
@@ -36,7 +36,7 @@ data class FrostNotifs(
profileUrl = img
)
}
- }
+ }.toList()
}
/**
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/FbRequest.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/FbRequest.kt
index a4b0a347..500c4102 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/FbRequest.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/FbRequest.kt
@@ -115,8 +115,8 @@ fun String.getAuth(): RequestAuth {
.url(FB_URL_BASE)
.get()
.call()
- call.execute().body()?.charStream()?.useLines {
- it.forEach {
+ call.execute().body()?.charStream()?.useLines { lines ->
+ lines.forEach {
val text = StringEscapeUtils.unescapeEcmaScript(it)
val fb_dtsg = FB_DTSG_MATCHER.find(text)[1]
if (fb_dtsg != null) {
@@ -153,8 +153,8 @@ inline fun <T, reified R : Any, O> Array<T>.zip(crossinline mapper: (List<R>) ->
fun executeForNoError(call: Call): Boolean {
val body = call.execute().body() ?: return false
var empty = true
- body.charStream().useLines {
- it.forEach {
+ body.charStream().useLines { lines ->
+ lines.forEach {
if (it.contains("error")) return false
if (empty && it.isNotEmpty()) empty = false
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Notifications.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Notifications.kt
index 82a9364b..0d3926dc 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Notifications.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Notifications.kt
@@ -23,5 +23,5 @@ fun RequestAuth.markNotificationRead(notifId: Long): FrostRequest<Boolean> {
fun RequestAuth.markNotificationsRead(vararg notifId: Long) =
notifId.toTypedArray().zip<Long, Boolean, Boolean>(
- { it.all { it } },
+ { it.all { self -> self } },
{ markNotificationRead(it).invoke() }) \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt
index 21d660b8..980481a4 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt
@@ -3,6 +3,7 @@ package com.pitchedapps.frost.injectors
import android.webkit.WebView
import ca.allanwang.kau.kotlin.lazyContext
import com.pitchedapps.frost.utils.L
+import java.io.BufferedReader
import java.io.FileNotFoundException
import java.util.*
@@ -19,7 +20,7 @@ enum class JsAssets : InjectorContract {
var file = "${name.toLowerCase(Locale.CANADA)}.js"
var injector = lazyContext {
try {
- val content = it.assets.open("js/$file").bufferedReader().use { it.readText() }
+ val content = it.assets.open("js/$file").bufferedReader().use(BufferedReader::readText)
JsBuilder().js(content).single(name).build()
} catch (e: FileNotFoundException) {
L.e(e) { "JsAssets file not found" }
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 e45e86b1..acda2d9b 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt
@@ -110,6 +110,6 @@ fun FrostWebViewClient.jsInject(vararg injectors: InjectorContract,
*/
class JsInjector(val function: String) : InjectorContract {
override fun inject(webView: WebView, callback: (() -> Unit)?) {
- webView.evaluateJavascript(function, { callback?.invoke() })
+ webView.evaluateJavascript(function) { callback?.invoke() }
}
} \ No newline at end of file
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 279b4027..6d73b1c6 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt
@@ -19,12 +19,12 @@ import com.pitchedapps.frost.dbflow.NotificationModel
import com.pitchedapps.frost.dbflow.lastNotificationTime
import com.pitchedapps.frost.enums.OverlayContext
import com.pitchedapps.frost.facebook.FbItem
-import com.pitchedapps.frost.glide.FrostGlide
-import com.pitchedapps.frost.glide.GlideApp
import com.pitchedapps.frost.facebook.parsers.FrostParser
import com.pitchedapps.frost.facebook.parsers.MessageParser
import com.pitchedapps.frost.facebook.parsers.NotifParser
import com.pitchedapps.frost.facebook.parsers.ParseNotification
+import com.pitchedapps.frost.glide.FrostGlide
+import com.pitchedapps.frost.glide.GlideApp
import com.pitchedapps.frost.utils.ARG_USER_ID
import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.Prefs
@@ -99,8 +99,8 @@ enum class NotificationType(
L.v { "$name notification data not found" }
return -1
}
- val notifContents = response.data.getUnreadNotifications(data).filter {
- val text = it.text
+ val notifContents = response.data.getUnreadNotifications(data).filter { notif ->
+ val text = notif.text
Prefs.notificationKeywords.none { text.contains(it, true) }
}
if (notifContents.isEmpty()) return 0
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt
index 314590e2..9253d926 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt
@@ -149,7 +149,10 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = {
list.add(KPrefTextSeekbar(
KPrefSeekbar.KPrefSeekbarBuilder(
globalOptions,
- R.string.web_text_scaling, Prefs::webTextScaling, { Prefs.webTextScaling = it; setFrostResult(REQUEST_TEXT_ZOOM) })))
+ R.string.web_text_scaling, Prefs::webTextScaling) {
+ Prefs.webTextScaling = it
+ setFrostResult(REQUEST_TEXT_ZOOM)
+ }))
checkbox(R.string.enforce_black_media_bg, Prefs::blackMediaBg, {
Prefs.blackMediaBg = it
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt
index 5de68e21..402322ad 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Feed.kt
@@ -20,13 +20,13 @@ fun SettingsActivity.getFeedPrefs(): KPrefAdapterBuilder.() -> Unit = {
materialDialogThemed {
title(R.string.newsfeed_sort)
items(FeedSort.values().map { string(it.textRes) })
- itemsCallbackSingleChoice(item.pref, { _, _, which, _ ->
+ itemsCallbackSingleChoice(item.pref) { _, _, which, _ ->
if (item.pref != which) {
item.pref = which
shouldRestartMain()
}
true
- })
+ }
}
}
textGetter = { string(FeedSort(it).textRes) }
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 962e60ae..83f1f827 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt
@@ -36,11 +36,11 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = {
materialDialogThemed {
title(R.string.notification_frequency)
items(texts)
- itemsCallbackSingleChoice(options.indexOf(item.pref), { _, _, which, _ ->
+ itemsCallbackSingleChoice(options.indexOf(item.pref)) { _, _, which, _ ->
item.pref = options[which]
scheduleNotifications(item.pref)
true
- })
+ }
}
}
enabler = {
@@ -155,7 +155,8 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = {
plainText(R.string.reset_notif_epoch) {
onClick = {
loadFbCookiesAsync {
- it.map { NotificationModel(it.id) }.forEach { it.save() }
+ cookies ->
+ cookies.map { NotificationModel(it.id) }.forEach { it.save() }
}
}
}
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 20041370..1bb0449b 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/AdBlocker.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/AdBlocker.kt
@@ -23,7 +23,9 @@ open class AdBlocker(val assetPath: String) {
fun init(context: Context) {
doAsync {
- val content = context.assets.open(assetPath).bufferedReader().use { it.readLines().filter { !it.startsWith("#") } }
+ val content = context.assets.open(assetPath).bufferedReader().use { f ->
+ f.readLines().filter { !it.startsWith("#") }
+ }
data.addAll(content)
L.i { "Initialized adblock for $assetPath with ${data.size} hosts" }
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
index dbd4d0d1..9f068a58 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
@@ -61,9 +61,11 @@ object Prefs : KPref() {
get() = t.accentColor
inline val accentColorForWhite: Int
- get() = if (accentColor.isColorVisibleOn(Color.WHITE)) accentColor
- else if (textColor.isColorVisibleOn(Color.WHITE)) textColor
- else FACEBOOK_BLUE
+ get() = when {
+ accentColor.isColorVisibleOn(Color.WHITE) -> accentColor
+ textColor.isColorVisibleOn(Color.WHITE) -> textColor
+ else -> FACEBOOK_BLUE
+ }
inline val nativeBgColor: Int
get() = Prefs.bgColor.withAlpha(30)
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 b58f1a16..b83002a3 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt
@@ -76,7 +76,9 @@ fun FrostWebView.requestWebOverlay(url: String): Boolean {
/**
* If the url contains any one of the whitelist segments, switch to the chat overlay
*/
-val messageWhitelist = setOf(FbItem.MESSAGES, FbItem.CHAT, FbItem.FEED_MOST_RECENT, FbItem.FEED_TOP_STORIES).map { it.url }.toSet()
+val messageWhitelist: Set<String> =
+ setOf(FbItem.MESSAGES, FbItem.CHAT, FbItem.FEED_MOST_RECENT, FbItem.FEED_TOP_STORIES)
+ .mapTo(mutableSetOf(), FbItem::url)
val String.shouldUseBasicAgent: Boolean
get() {