aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/utils
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2019-08-06 00:49:58 -0700
committerAllan Wang <me@allanwang.ca>2019-08-06 00:49:58 -0700
commit55bf3e4b5b4af5baa3c230ca82f74988608971a3 (patch)
tree3db856e037b70257aaef19e34db6b0856bda6412 /app/src/main/kotlin/com/pitchedapps/frost/utils
parent99953f087f2c363dad05ae3f86b5bcba22484e43 (diff)
downloadfrost-55bf3e4b5b4af5baa3c230ca82f74988608971a3.tar.gz
frost-55bf3e4b5b4af5baa3c230ca82f74988608971a3.tar.bz2
frost-55bf3e4b5b4af5baa3c230ca82f74988608971a3.zip
Format kotlin
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/BiometricUtils.kt3
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/TimeUtils.kt14
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt8
3 files changed, 20 insertions, 5 deletions
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 db901073..4ececc8b 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/BiometricUtils.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/BiometricUtils.kt
@@ -53,7 +53,8 @@ object BiometricUtils {
@Suppress("DEPRECATION")
fun isSupported(context: Context): Boolean {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return false
- val fingerprintManager = context.getSystemService(FingerprintManager::class.java) ?: return false
+ val fingerprintManager =
+ context.getSystemService(FingerprintManager::class.java) ?: return false
return fingerprintManager.isHardwareDetected && fingerprintManager.hasEnrolledFingerprints()
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/TimeUtils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/TimeUtils.kt
index c0feab1e..6156badb 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/TimeUtils.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/TimeUtils.kt
@@ -39,8 +39,18 @@ fun Long.toReadableTime(context: Context): String {
val timeFormatter = SimpleDateFormat.getTimeInstance(DateFormat.SHORT)
val time = timeFormatter.format(Date(this))
val day = when {
- cal >= Calendar.getInstance().apply { add(Calendar.DAY_OF_MONTH, -1) } -> context.string(R.string.today)
- cal >= Calendar.getInstance().apply { add(Calendar.DAY_OF_MONTH, -2) } -> context.string(R.string.yesterday)
+ cal >= Calendar.getInstance().apply {
+ add(
+ Calendar.DAY_OF_MONTH,
+ -1
+ )
+ } -> context.string(R.string.today)
+ cal >= Calendar.getInstance().apply {
+ add(
+ Calendar.DAY_OF_MONTH,
+ -2
+ )
+ } -> context.string(R.string.yesterday)
else -> {
val dayFormatter = SimpleDateFormat("MMM dd", Locale.getDefault())
dayFormatter.format(Date(this))
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 0a3be830..7fdd485d 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt
@@ -33,7 +33,8 @@ import com.pitchedapps.frost.facebook.formattedFbUrl
fun Context.showWebContextMenu(wc: WebContext) {
if (wc.isEmpty) return
var title = wc.url ?: string(R.string.menu)
- title = title.substring(title.indexOf("m/") + 1) //just so if defaults to 0 in case it's not .com/
+ title =
+ title.substring(title.indexOf("m/") + 1) //just so if defaults to 0 in case it's not .com/
if (title.length > 100) title = title.substring(0, 100) + '\u2026'
val menuItems = WebContextType.values
@@ -63,7 +64,10 @@ enum class WebContextType(
val constraint: (wc: WebContext) -> Boolean,
val onClick: (c: Context, wc: WebContext) -> Unit
) {
- OPEN_LINK(R.string.open_link, { it.hasUrl }, { c, wc -> c.launchWebOverlay(wc.unformattedUrl!!) }),
+ OPEN_LINK(
+ R.string.open_link,
+ { it.hasUrl },
+ { c, wc -> c.launchWebOverlay(wc.unformattedUrl!!) }),
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) }),