mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 15:15:51 +03:00
Simplify variable namings
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
be55d52c79
commit
3a932b0082
1 changed files with 36 additions and 33 deletions
|
@ -44,16 +44,16 @@ import javax.inject.Inject
|
||||||
* the certificate from different classes.
|
* the certificate from different classes.
|
||||||
*/
|
*/
|
||||||
open class SslUntrustedCertDialog : DialogFragment(), Injectable {
|
open class SslUntrustedCertDialog : DialogFragment(), Injectable {
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
@Inject
|
@Inject
|
||||||
var viewThemeUtils: ViewThemeUtils? = null
|
var viewThemeUtils: ViewThemeUtils? = null
|
||||||
|
|
||||||
protected var binding: SslUntrustedCertLayoutBinding? = null
|
protected var binding: SslUntrustedCertLayoutBinding? = null
|
||||||
protected var mHandler: SslErrorHandler? = null
|
protected var sslErrorHandler: SslErrorHandler? = null
|
||||||
protected var m509Certificate: X509Certificate? = null
|
protected var x509Certificate: X509Certificate? = null
|
||||||
|
private var errorViewAdapter: ErrorViewAdapter? = null
|
||||||
private var mErrorViewAdapter: ErrorViewAdapter? = null
|
private var certificateViewAdapter: CertificateViewAdapter? = null
|
||||||
private var mCertificateViewAdapter: CertificateViewAdapter? = null
|
|
||||||
|
|
||||||
override fun onAttach(context: Context) {
|
override fun onAttach(context: Context) {
|
||||||
Log_OC.d(TAG, "onAttach")
|
Log_OC.d(TAG, "onAttach")
|
||||||
|
@ -79,26 +79,29 @@ open class SslUntrustedCertDialog : DialogFragment(), Injectable {
|
||||||
val layoutBinding = SslUntrustedCertLayoutBinding.inflate(layoutInflater, null, false)
|
val layoutBinding = SslUntrustedCertLayoutBinding.inflate(layoutInflater, null, false)
|
||||||
this.binding = layoutBinding
|
this.binding = layoutBinding
|
||||||
|
|
||||||
layoutBinding.detailsScroll.visibility = View.GONE
|
layoutBinding.run {
|
||||||
mErrorViewAdapter?.updateErrorView(layoutBinding)
|
detailsScroll.visibility = View.GONE
|
||||||
|
errorViewAdapter?.updateErrorView(layoutBinding)
|
||||||
|
|
||||||
layoutBinding.ok.setOnClickListener(OnCertificateTrusted())
|
ok.setOnClickListener(OnCertificateTrusted())
|
||||||
|
|
||||||
layoutBinding.cancel.setOnClickListener(OnCertificateNotTrusted())
|
cancel.setOnClickListener(OnCertificateNotTrusted())
|
||||||
|
|
||||||
layoutBinding.detailsBtn.setOnClickListener { v: View ->
|
detailsBtn.setOnClickListener { v: View ->
|
||||||
if (layoutBinding.detailsScroll.visibility == View.VISIBLE) {
|
if (detailsScroll.visibility == View.VISIBLE) {
|
||||||
layoutBinding.detailsScroll.visibility = View.GONE
|
detailsScroll.visibility = View.GONE
|
||||||
(v as Button).setText(R.string.ssl_validator_btn_details_see)
|
(v as Button).setText(R.string.ssl_validator_btn_details_see)
|
||||||
} else {
|
} else {
|
||||||
layoutBinding.detailsScroll.visibility = View.VISIBLE
|
detailsScroll.visibility = View.VISIBLE
|
||||||
(v as Button).setText(R.string.ssl_validator_btn_details_hide)
|
(v as Button).setText(R.string.ssl_validator_btn_details_hide)
|
||||||
mCertificateViewAdapter?.updateCertificateView(layoutBinding)
|
certificateViewAdapter?.updateCertificateView(layoutBinding)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val builder = MaterialAlertDialogBuilder(requireContext())
|
val builder = MaterialAlertDialogBuilder(requireContext()).apply {
|
||||||
builder.setView(layoutBinding.getRoot())
|
setView(layoutBinding.getRoot())
|
||||||
|
}
|
||||||
|
|
||||||
viewThemeUtils?.dialog?.colorMaterialAlertDialogBackground(requireContext(), builder)
|
viewThemeUtils?.dialog?.colorMaterialAlertDialogBackground(requireContext(), builder)
|
||||||
|
|
||||||
|
@ -118,16 +121,16 @@ open class SslUntrustedCertDialog : DialogFragment(), Injectable {
|
||||||
private inner class OnCertificateNotTrusted : View.OnClickListener {
|
private inner class OnCertificateNotTrusted : View.OnClickListener {
|
||||||
override fun onClick(v: View) {
|
override fun onClick(v: View) {
|
||||||
dialog?.cancel()
|
dialog?.cancel()
|
||||||
mHandler?.cancel()
|
sslErrorHandler?.cancel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class OnCertificateTrusted : View.OnClickListener {
|
private inner class OnCertificateTrusted : View.OnClickListener {
|
||||||
override fun onClick(v: View) {
|
override fun onClick(v: View) {
|
||||||
dismiss()
|
dismiss()
|
||||||
mHandler?.proceed()
|
sslErrorHandler?.proceed()
|
||||||
|
|
||||||
if (m509Certificate == null) {
|
if (x509Certificate == null) {
|
||||||
Log_OC.d(TAG, "m509Certificate is null onClick dismissed")
|
Log_OC.d(TAG, "m509Certificate is null onClick dismissed")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -139,7 +142,7 @@ open class SslUntrustedCertDialog : DialogFragment(), Injectable {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// TODO make this asynchronously, it can take some time
|
// TODO make this asynchronously, it can take some time
|
||||||
NetworkUtils.addCertToKnownServersStore(m509Certificate, activity)
|
NetworkUtils.addCertToKnownServersStore(x509Certificate, activity)
|
||||||
(activity as OnSslUntrustedCertListener?)?.onSavedCertificate()
|
(activity as OnSslUntrustedCertListener?)?.onSavedCertificate()
|
||||||
} catch (e: GeneralSecurityException) {
|
} catch (e: GeneralSecurityException) {
|
||||||
(activity as OnSslUntrustedCertListener?)?.onFailedSavingCertificate()
|
(activity as OnSslUntrustedCertListener?)?.onFailedSavingCertificate()
|
||||||
|
@ -173,9 +176,9 @@ open class SslUntrustedCertDialog : DialogFragment(), Injectable {
|
||||||
requireNotNull(handler) { "Trying to create instance with parameter handler == null" }
|
requireNotNull(handler) { "Trying to create instance with parameter handler == null" }
|
||||||
|
|
||||||
return SslUntrustedCertDialog().apply {
|
return SslUntrustedCertDialog().apply {
|
||||||
mHandler = handler
|
sslErrorHandler = handler
|
||||||
mErrorViewAdapter = SslErrorViewAdapter(error)
|
errorViewAdapter = SslErrorViewAdapter(error)
|
||||||
mCertificateViewAdapter = SslCertificateViewAdapter(error.certificate)
|
certificateViewAdapter = SslCertificateViewAdapter(error.certificate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,9 +187,9 @@ open class SslUntrustedCertDialog : DialogFragment(), Injectable {
|
||||||
requireNotNull(sslException) { "Trying to create instance with parameter sslException == null" }
|
requireNotNull(sslException) { "Trying to create instance with parameter sslException == null" }
|
||||||
|
|
||||||
return SslUntrustedCertDialog().apply {
|
return SslUntrustedCertDialog().apply {
|
||||||
m509Certificate = sslException.serverCertificate
|
x509Certificate = sslException.serverCertificate
|
||||||
mErrorViewAdapter = CertificateCombinedExceptionViewAdapter(sslException)
|
errorViewAdapter = CertificateCombinedExceptionViewAdapter(sslException)
|
||||||
mCertificateViewAdapter = X509CertificateViewAdapter(sslException.serverCertificate)
|
certificateViewAdapter = X509CertificateViewAdapter(sslException.serverCertificate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,10 +203,10 @@ open class SslUntrustedCertDialog : DialogFragment(), Injectable {
|
||||||
requireNotNull(handler) { "Trying to create instance with parameter handler == null" }
|
requireNotNull(handler) { "Trying to create instance with parameter handler == null" }
|
||||||
|
|
||||||
return SslUntrustedCertDialog().apply {
|
return SslUntrustedCertDialog().apply {
|
||||||
m509Certificate = cert
|
x509Certificate = cert
|
||||||
mHandler = handler
|
sslErrorHandler = handler
|
||||||
mErrorViewAdapter = SslErrorViewAdapter(error)
|
errorViewAdapter = SslErrorViewAdapter(error)
|
||||||
mCertificateViewAdapter = X509CertificateViewAdapter(cert)
|
certificateViewAdapter = X509CertificateViewAdapter(cert)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue