Skip to content

Commit

Permalink
Apply some smaller changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cyb3rko committed Jun 2, 2024
1 parent d74bca7 commit 5b7aff0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
1 change: 0 additions & 1 deletion app/src/main/kotlin/com/github/gotify/GotifyApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/kotlin/com/github/gotify/login/LoginActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 5b7aff0

Please sign in to comment.