From d96d1d06a7c1581b97c042f2a74e7cd5b1c2546e Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 17 Apr 2021 17:49:18 -0700 Subject: Update theme providers and readd koin modules --- .../com/pitchedapps/frost/utils/BiometricUtils.kt | 2 +- .../kotlin/com/pitchedapps/frost/utils/Utils.kt | 55 +++++++++++++--------- .../com/pitchedapps/frost/utils/WebContextMenu.kt | 3 +- 3 files changed, 36 insertions(+), 24 deletions(-) (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils') 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 80f83c8d..1860d6f6 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/BiometricUtils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/BiometricUtils.kt @@ -27,10 +27,10 @@ import androidx.lifecycle.OnLifecycleEvent import ca.allanwang.kau.utils.string import com.pitchedapps.frost.R import com.pitchedapps.frost.prefs.Prefs +import kotlinx.coroutines.CompletableDeferred import java.util.concurrent.Executor import java.util.concurrent.ExecutorService import java.util.concurrent.Executors -import kotlinx.coroutines.CompletableDeferred typealias BiometricDeferred = CompletableDeferred diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt index 13ce2920..ccc04145 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -72,12 +72,6 @@ import com.pitchedapps.frost.facebook.formattedFbUrl import com.pitchedapps.frost.injectors.JsAssets import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.prefs.Prefs -import java.io.File -import java.io.IOException -import java.net.URLEncoder -import java.nio.charset.StandardCharsets -import java.util.ArrayList -import java.util.Locale import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.launch import org.apache.commons.text.StringEscapeUtils @@ -86,6 +80,12 @@ import org.jsoup.nodes.Document import org.jsoup.nodes.Element import org.koin.core.component.KoinComponent import org.koin.core.component.inject +import java.io.File +import java.io.IOException +import java.net.URLEncoder +import java.nio.charset.StandardCharsets +import java.util.ArrayList +import java.util.Locale /** * Created by Allan Wang on 2017-06-03. @@ -101,9 +101,12 @@ inline fun Context.launchNewTask( cookieList: ArrayList = arrayListOf(), clearStack: Boolean = false ) { - startActivity(clearStack, intentBuilder = { - putParcelableArrayListExtra(EXTRA_COOKIES, cookieList) - }) + startActivity( + clearStack, + intentBuilder = { + putParcelableArrayListExtra(EXTRA_COOKIES, cookieList) + } + ) } fun Context.launchLogin(cookieList: ArrayList, clearStack: Boolean = true) { @@ -133,9 +136,12 @@ private inline fun Context.launchWebOverlay fbCookie.logout(this@launchWebOverlayImpl) } } else if (!(prefs.linksInDefaultApp && resolveActivityForUri(Uri.parse(argUrl)))) { - startActivity(false, intentBuilder = { - putExtra(ARG_URL, argUrl) - }) + startActivity( + false, + intentBuilder = { + putExtra(ARG_URL, argUrl) + } + ) } } @@ -155,12 +161,14 @@ private fun Context.fadeBundle() = ActivityOptions.makeCustomAnimation( ).toBundle() fun Context.launchImageActivity(imageUrl: String, text: String? = null, cookie: String? = null) { - startActivity(intentBuilder = { - putExtras(fadeBundle()) - putExtra(ARG_IMAGE_URL, imageUrl) - putExtra(ARG_TEXT, text) - putExtra(ARG_COOKIE, cookie) - }) + startActivity( + intentBuilder = { + putExtras(fadeBundle()) + putExtra(ARG_IMAGE_URL, imageUrl) + putExtra(ARG_TEXT, text) + putExtra(ARG_COOKIE, cookie) + } + ) } fun Activity.launchTabCustomizerActivity() { @@ -168,7 +176,8 @@ fun Activity.launchTabCustomizerActivity() { SettingsActivity.ACTIVITY_REQUEST_TABS, bundleBuilder = { with(fadeBundle()) - }) + } + ) } fun WebOverlayActivity.url(): String { @@ -177,9 +186,11 @@ fun WebOverlayActivity.url(): String { fun Activity.setFrostTheme(themeProvider: ThemeProvider, forceTransparent: Boolean = false) { val isTransparent = - forceTransparent || (Color.alpha(themeProvider.bgColor) != 255) || (Color.alpha( - themeProvider.headerColor - ) != 255) + forceTransparent || (Color.alpha(themeProvider.bgColor) != 255) || ( + Color.alpha( + themeProvider.headerColor + ) != 255 + ) if (themeProvider.bgColor.isColorDark) { setTheme(if (isTransparent) R.style.FrostTheme_Transparent else R.style.FrostTheme) } else { diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt index 03dbb9fb..2e88141d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt @@ -72,7 +72,8 @@ enum class WebContextType( OPEN_LINK( R.string.open_link, { it.hasUrl }, - { c, wc, fc -> c.launchWebOverlay(wc.url!!, fc, Prefs.get()) }), + { c, wc, fc -> c.launchWebOverlay(wc.url!!, fc, Prefs.get()) } + ), COPY_LINK(R.string.copy_link, { it.hasUrl }, { c, wc, _ -> c.copyToClipboard(wc.url) }), COPY_TEXT(R.string.copy_text, { it.hasText }, { c, wc, _ -> c.copyToClipboard(wc.text) }), SHARE_LINK(R.string.share_link, { it.hasUrl }, { c, wc, _ -> c.shareText(wc.url) }) -- cgit v1.2.3