浏览代码

reformat kotlin

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 3 年之前
父节点
当前提交
4685bced16

+ 18 - 12
app/src/main/java/com/nextcloud/talk/controllers/ServerSelectionController.kt

@@ -59,11 +59,10 @@ import java.security.cert.CertificateException
 import javax.inject.Inject
 
 @AutoInjector(NextcloudTalkApplication::class)
-class ServerSelectionController : NewBaseController(R.layout.controller_server_selection) {
-    private val binding: ControllerServerSelectionBinding by viewBinding(ControllerServerSelectionBinding::bind)
+class ServerSelectionController :
+    NewBaseController(R.layout.controller_server_selection) {
 
-    override val appBarLayoutType: AppBarLayoutType
-        get() = AppBarLayoutType.EMPTY
+    private val binding: ControllerServerSelectionBinding by viewBinding(ControllerServerSelectionBinding::bind)
 
     @Inject
     lateinit var ncApi: NcApi
@@ -75,14 +74,18 @@ class ServerSelectionController : NewBaseController(R.layout.controller_server_s
 
     fun onCertClick() {
         if (activity != null) {
-            KeyChain.choosePrivateKeyAlias(activity!!, { alias: String? ->
-                if (alias != null) {
-                    appPreferences!!.temporaryClientCertAlias = alias
-                } else {
-                    appPreferences!!.removeTemporaryClientCertAlias()
-                }
-                setCertTextView()
-            }, arrayOf("RSA", "EC"), null, null, -1, null)
+            KeyChain.choosePrivateKeyAlias(
+                activity!!,
+                { alias: String? ->
+                    if (alias != null) {
+                        appPreferences!!.temporaryClientCertAlias = alias
+                    } else {
+                        appPreferences!!.removeTemporaryClientCertAlias()
+                    }
+                    setCertTextView()
+                },
+                arrayOf("RSA", "EC"), null, null, -1, null
+            )
         }
     }
 
@@ -367,6 +370,9 @@ class ServerSelectionController : NewBaseController(R.layout.controller_server_s
         statusQueryDisposable = null
     }
 
+    override val appBarLayoutType: AppBarLayoutType
+        get() = AppBarLayoutType.EMPTY
+
     companion object {
         const val TAG = "ServerSelectionController"
         const val MIN_SERVER_MAJOR_VERSION = 13

+ 31 - 23
app/src/main/java/com/nextcloud/talk/controllers/WebViewLoginController.kt

@@ -241,31 +241,39 @@ class WebViewLoginController(args: Bundle? = null) : NewBaseController(
                         }
                     }.start()
                 } else {
-                    KeyChain.choosePrivateKeyAlias(activity!!, { chosenAlias: String? ->
-                        if (chosenAlias != null) {
-                            appPreferences!!.temporaryClientCertAlias = chosenAlias
-                            Thread {
-                                var privateKey: PrivateKey? = null
-                                try {
-                                    privateKey = KeyChain.getPrivateKey(activity!!, chosenAlias)
-                                    val certificates = KeyChain.getCertificateChain(
-                                        activity!!, chosenAlias
-                                    )
-                                    if (privateKey != null && certificates != null) {
-                                        request.proceed(privateKey, certificates)
-                                    } else {
+                    KeyChain.choosePrivateKeyAlias(
+                        activity!!,
+                        { chosenAlias: String? ->
+                            if (chosenAlias != null) {
+                                appPreferences!!.temporaryClientCertAlias = chosenAlias
+                                Thread {
+                                    var privateKey: PrivateKey? = null
+                                    try {
+                                        privateKey = KeyChain.getPrivateKey(activity!!, chosenAlias)
+                                        val certificates = KeyChain.getCertificateChain(
+                                            activity!!, chosenAlias
+                                        )
+                                        if (privateKey != null && certificates != null) {
+                                            request.proceed(privateKey, certificates)
+                                        } else {
+                                            request.cancel()
+                                        }
+                                    } catch (e: KeyChainException) {
+                                        request.cancel()
+                                    } catch (e: InterruptedException) {
                                         request.cancel()
                                     }
-                                } catch (e: KeyChainException) {
-                                    request.cancel()
-                                } catch (e: InterruptedException) {
-                                    request.cancel()
-                                }
-                            }.start()
-                        } else {
-                            request.cancel()
-                        }
-                    }, arrayOf("RSA", "EC"), null, request.host, request.port, null)
+                                }.start()
+                            } else {
+                                request.cancel()
+                            }
+                        },
+                        arrayOf("RSA", "EC"),
+                        null,
+                        request.host,
+                        request.port,
+                        null
+                    )
                 }
             }