Skip to content

Commit 85c2d78

Browse files
committed
reformat
1 parent a008f6f commit 85c2d78

File tree

79 files changed

+1607
-1619
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1607
-1619
lines changed

android/app/src/main/kotlin/com/yubico/authenticator/ActivityUtil.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,4 @@ class ActivityUtil(private val activity: Activity) {
109109
const val NDEF_ACTIVITY_ALIAS = "AliasNdefActivity"
110110
const val MAIN_ACTIVITY_ALIAS = "AliasMainActivity"
111111
}
112-
113-
}
112+
}

android/app/src/main/kotlin/com/yubico/authenticator/AppContextChannel.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ package com.yubico.authenticator
1818

1919
import io.flutter.plugin.common.BinaryMessenger
2020
import io.flutter.plugin.common.MethodChannel
21-
2221
import kotlinx.coroutines.CoroutineScope
23-
2422
import org.slf4j.LoggerFactory
2523

2624
class AppContextChannel(
@@ -47,4 +45,4 @@ class AppContextChannel(
4745
logger.debug("App context is now {}", appContext)
4846
return NULL
4947
}
50-
}
48+
}

android/app/src/main/kotlin/com/yubico/authenticator/AppContextManager.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,16 @@ package com.yubico.authenticator
1919
import com.yubico.authenticator.device.DeviceListener
2020
import com.yubico.authenticator.device.DeviceManager
2121
import com.yubico.yubikit.core.YubiKeyDevice
22+
import java.util.concurrent.Executors
2223
import kotlinx.coroutines.CoroutineScope
2324
import kotlinx.coroutines.SupervisorJob
2425
import kotlinx.coroutines.asCoroutineDispatcher
2526
import kotlinx.coroutines.cancel
26-
import java.util.concurrent.Executors
2727

2828
/**
2929
* Provides behavior to run when a YubiKey is inserted/tapped for a specific view of the app.
3030
*/
31-
abstract class AppContextManager(
32-
protected val deviceManager: DeviceManager
33-
) : DeviceListener {
31+
abstract class AppContextManager(protected val deviceManager: DeviceManager) : DeviceListener {
3432

3533
private val dispatcher = Executors.newSingleThreadExecutor().asCoroutineDispatcher()
3634
protected val coroutineScope = CoroutineScope(SupervisorJob() + dispatcher)
@@ -55,7 +53,7 @@ abstract class AppContextManager(
5553

5654
open fun onError(e: Exception) {}
5755

58-
abstract fun hasPending() : Boolean
56+
abstract fun hasPending(): Boolean
5957
}
6058

61-
class FunctionalityMissingException : Exception()
59+
class FunctionalityMissingException : Exception()

android/app/src/main/kotlin/com/yubico/authenticator/AppPreferences.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package com.yubico.authenticator
1919
import android.content.Context
2020
import android.content.SharedPreferences
2121
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
22-
2322
import org.slf4j.LoggerFactory
2423

2524
class AppPreferences(context: Context) {
@@ -89,4 +88,4 @@ class AppPreferences(context: Context) {
8988
prefs.unregisterOnSharedPreferenceChangeListener(listener)
9089
logger.debug("unregistered change listener")
9190
}
92-
}
91+
}

android/app/src/main/kotlin/com/yubico/authenticator/ChannelHelper.kt

Lines changed: 44 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@ import androidx.lifecycle.Observer
2222
import io.flutter.plugin.common.BinaryMessenger
2323
import io.flutter.plugin.common.EventChannel
2424
import io.flutter.plugin.common.MethodChannel
25+
import java.io.Closeable
26+
import kotlin.coroutines.resume
27+
import kotlin.coroutines.resumeWithException
28+
import kotlin.coroutines.suspendCoroutine
2529
import kotlinx.coroutines.CoroutineScope
2630
import kotlinx.coroutines.Dispatchers
2731
import kotlinx.coroutines.launch
2832
import kotlinx.coroutines.withContext
2933
import kotlinx.serialization.encodeToString
30-
import java.io.Closeable
31-
import kotlin.coroutines.resume
32-
import kotlin.coroutines.resumeWithException
33-
import kotlin.coroutines.suspendCoroutine
3434

3535
interface JsonSerializable {
36-
fun toJson() : String
36+
fun toJson(): String
3737
}
3838

3939
sealed interface ViewModelData {
@@ -45,7 +45,11 @@ sealed interface ViewModelData {
4545
/**
4646
* Observes a LiveData value, sending each change to Flutter via an EventChannel.
4747
*/
48-
inline fun <reified T> LiveData<T>.streamTo(lifecycleOwner: LifecycleOwner, messenger: BinaryMessenger, channelName: String): Closeable {
48+
inline fun <reified T> LiveData<T>.streamTo(
49+
lifecycleOwner: LifecycleOwner,
50+
messenger: BinaryMessenger,
51+
channelName: String
52+
): Closeable {
4953
val channel = EventChannel(messenger, channelName)
5054
var sink: EventChannel.EventSink? = null
5155

@@ -75,7 +79,11 @@ inline fun <reified T> LiveData<T>.streamTo(lifecycleOwner: LifecycleOwner, mess
7579
* Observes a ViewModelData LiveData value, sending each change to Flutter via an EventChannel.
7680
*/
7781
@JvmName("streamViewModelData")
78-
inline fun <reified T : ViewModelData> LiveData<T>.streamTo(lifecycleOwner: LifecycleOwner, messenger: BinaryMessenger, channelName: String): Closeable {
82+
inline fun <reified T : ViewModelData> LiveData<T>.streamTo(
83+
lifecycleOwner: LifecycleOwner,
84+
messenger: BinaryMessenger,
85+
channelName: String
86+
): Closeable {
7987
val channel = EventChannel(messenger, channelName)
8088
var sink: EventChannel.EventSink? = null
8189

@@ -134,9 +142,10 @@ fun MethodChannel.setHandler(scope: CoroutineScope, handler: MethodHandler) {
134142
result.error(
135143
error.javaClass.simpleName,
136144
error.toString(),
137-
"Cause: " + error.cause + ", Stacktrace: " + android.util.Log.getStackTraceString(
138-
error
139-
)
145+
"Cause: " + error.cause + ", Stacktrace: " +
146+
android.util.Log.getStackTraceString(
147+
error
148+
)
140149
)
141150
}
142151
}
@@ -146,28 +155,28 @@ fun MethodChannel.setHandler(scope: CoroutineScope, handler: MethodHandler) {
146155
/**
147156
* Coroutine-based method invocation to call a Flutter method and get a result.
148157
*/
149-
suspend fun MethodChannel.invoke(method: String, args: Any?): Any? =
150-
withContext(Dispatchers.Main) {
151-
suspendCoroutine { continuation ->
152-
invokeMethod(
153-
method,
154-
args,
155-
object : MethodChannel.Result {
156-
override fun success(result: Any?) {
157-
continuation.resume(result)
158-
}
159-
160-
override fun error(
161-
errorCode: String,
162-
errorMessage: String?,
163-
errorDetails: Any?
164-
) {
165-
continuation.resumeWithException(Exception("$errorCode: $errorMessage - $errorDetails"))
166-
}
167-
168-
override fun notImplemented() {
169-
continuation.resumeWithException(NotImplementedError("Method not implemented: $method"))
170-
}
171-
})
172-
}
173-
}
158+
suspend fun MethodChannel.invoke(method: String, args: Any?): Any? = withContext(Dispatchers.Main) {
159+
suspendCoroutine { continuation ->
160+
invokeMethod(
161+
method,
162+
args,
163+
object : MethodChannel.Result {
164+
override fun success(result: Any?) {
165+
continuation.resume(result)
166+
}
167+
168+
override fun error(errorCode: String, errorMessage: String?, errorDetails: Any?) {
169+
continuation.resumeWithException(
170+
Exception("$errorCode: $errorMessage - $errorDetails")
171+
)
172+
}
173+
174+
override fun notImplemented() {
175+
continuation.resumeWithException(
176+
NotImplementedError("Method not implemented: $method")
177+
)
178+
}
179+
}
180+
)
181+
}
182+
}

android/app/src/main/kotlin/com/yubico/authenticator/ClipboardUtil.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import android.content.ClipboardManager
2323
import android.content.Context
2424
import android.os.Build
2525
import android.os.PersistableBundle
26-
2726
import org.slf4j.LoggerFactory
2827

2928
object ClipboardUtil {
@@ -42,7 +41,7 @@ object ClipboardUtil {
4241

4342
clipboardManager.setPrimaryClip(clipData)
4443
} catch (e: Exception) {
45-
logger.error( "Failed to set string to clipboard", e)
44+
logger.error("Failed to set string to clipboard", e)
4645
throw UnsupportedOperationException()
4746
}
4847
}
@@ -53,4 +52,4 @@ object ClipboardUtil {
5352
putBoolean(ClipDescription.EXTRA_IS_SENSITIVE, isSensitive)
5453
}
5554
}
56-
}
55+
}

android/app/src/main/kotlin/com/yubico/authenticator/CompatUtil.kt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,15 @@ class CompatUtil(private val sdkVersion: Int) {
6060
* @return unwrapped value or result of [block]
6161
*/
6262
@Suppress("UNCHECKED_CAST")
63-
fun otherwise(block: () -> T): T =
64-
if (hasValue) {
65-
if (value == null) {
66-
null as T
67-
} else {
68-
value!!
69-
}
63+
fun otherwise(block: () -> T): T = if (hasValue) {
64+
if (value == null) {
65+
null as T
7066
} else {
71-
block()
67+
value!!
7268
}
69+
} else {
70+
block()
71+
}
7372

7473
/**
7574
* @return unwrapped value or [value]
@@ -104,4 +103,4 @@ class CompatUtil(private val sdkVersion: Int) {
104103
}
105104
}
106105

107-
val compatUtil = CompatUtil(Build.VERSION.SDK_INT)
106+
val compatUtil = CompatUtil(Build.VERSION.SDK_INT)

android/app/src/main/kotlin/com/yubico/authenticator/HomeContextManager.kt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,11 @@ class HomeContextManager(deviceManager: DeviceManager) : AppContextManager(devic
3939
super.deactivate()
4040
}
4141

42-
override suspend fun processYubiKey(device: YubiKeyDevice): Boolean {
43-
return true
44-
}
42+
override suspend fun processYubiKey(device: YubiKeyDevice): Boolean = true
4543

46-
override fun hasPending(): Boolean {
47-
return false
48-
}
44+
override fun hasPending(): Boolean = false
4945

5046
companion object {
5147
private val logger = LoggerFactory.getLogger(HomeContextManager::class.java)
5248
}
53-
}
49+
}

android/app/src/main/kotlin/com/yubico/authenticator/JsonSerializer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ const val LOADING = "\"loading\""
2525
val jsonSerializer = Json {
2626
// creates properties for default values
2727
encodeDefaults = true
28-
}
28+
}

0 commit comments

Comments
 (0)