diff --git a/app/src/main/kotlin/com/github/gotify/GotifyApplication.kt b/app/src/main/kotlin/com/github/gotify/GotifyApplication.kt index 6e157b81..8f75c2b9 100644 --- a/app/src/main/kotlin/com/github/gotify/GotifyApplication.kt +++ b/app/src/main/kotlin/com/github/gotify/GotifyApplication.kt @@ -45,7 +45,6 @@ class GotifyApplication : Application() { Logger.info("Migration of legacy CA cert succeeded") } catch (e: IOException) { Logger.error(e, "Migration of legacy CA cert failed") - if (legacyCert != null) settings.legacyCert = legacyCert } } super.onCreate() diff --git a/app/src/main/kotlin/com/github/gotify/login/AdvancedDialog.kt b/app/src/main/kotlin/com/github/gotify/login/AdvancedDialog.kt index 11018d6d..6cf34042 100644 --- a/app/src/main/kotlin/com/github/gotify/login/AdvancedDialog.kt +++ b/app/src/main/kotlin/com/github/gotify/login/AdvancedDialog.kt @@ -14,7 +14,6 @@ internal class AdvancedDialog( private val context: Context, private val layoutInflater: LayoutInflater ) { - private lateinit var dialog: AlertDialog private lateinit var dialogDoneButton: Button private lateinit var binding: AdvancedSettingsDialogBinding private var onCheckedChangeListener: CompoundButton.OnCheckedChangeListener? = null @@ -82,7 +81,7 @@ internal class AdvancedDialog( binding.clientCertPasswordEdittext.doOnTextChanged { _, _, _, _ -> showPasswordMissing(binding.clientCertPasswordEdittext.text.toString().isEmpty()) } - dialog = MaterialAlertDialogBuilder(context) + val dialog = MaterialAlertDialogBuilder(context) .setView(binding.root) .setTitle(R.string.advanced_settings) .setPositiveButton(context.getString(R.string.done), null) diff --git a/app/src/main/kotlin/com/github/gotify/login/LoginActivity.kt b/app/src/main/kotlin/com/github/gotify/login/LoginActivity.kt index 3308f4c2..8b37e5d3 100644 --- a/app/src/main/kotlin/com/github/gotify/login/LoginActivity.kt +++ b/app/src/main/kotlin/com/github/gotify/login/LoginActivity.kt @@ -65,7 +65,7 @@ internal class LoginActivity : AppCompatActivity() { copyStreamToFile(fileStream, destinationFile) // temporarily store it (don't store to settings until they decide to login) - caCertCN = getNameOfCertContent(destinationFile)!! + caCertCN = getNameOfCertContent(destinationFile) ?: "unknown" caCertPath = destinationFile.absolutePath advancedDialog.showRemoveCaCertificate(caCertCN!!) } catch (e: Exception) { @@ -220,7 +220,7 @@ internal class LoginActivity : AppCompatActivity() { } private fun getNameOfCertContent(file: File): String? { - val ca = CertUtils.parseCertificate(FileInputStream(file)) + val ca = FileInputStream(file).use { CertUtils.parseCertificate(it) } return (ca as X509Certificate).subjectX500Principal.name }