Commit 3b0b1f8b authored by Patrick Lang's avatar Patrick Lang
Browse files

Replaced Toast by Snackbar and added createInstallIntent()

parent 14d433de
Pipeline #216169287 passed with stage
in 7 minutes and 54 seconds
......@@ -24,6 +24,7 @@ import androidx.fragment.app.viewModels
import at.bitfire.davdroid.R
import at.bitfire.davdroid.databinding.LoginCredentialsFragmentBinding
import at.bitfire.davdroid.model.Credentials
import com.google.android.material.snackbar.Snackbar
import java.net.URI
import java.net.URISyntaxException
......@@ -45,8 +46,16 @@ class DefaultLoginCredentialsFragment : Fragment() {
v.selectCertificate.setOnClickListener {
KeyChain.choosePrivateKeyAlias(requireActivity(), { alias ->
Handler(Looper.getMainLooper()).post {
if (alias == null)
Toast.makeText(activity,"No Certificate found/selected",Toast.LENGTH_LONG).show();
// Show a Snackbar to add a certificate if no certificate was found
// API Versions < 29 still handle this automatically
if (alias == null && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
Snackbar.make(v.root, R.string.login_no_certificate_found, Snackbar.LENGTH_LONG)
.setAction(R.string.login_install_certificate) {
startActivity(KeyChain.createInstallIntent())
}
.show()
}
else
model.certificateAlias.value = alias
}
......
......@@ -233,6 +233,8 @@
<string name="login_type_advanced">Advanced login (special use cases)</string>
<string name="login_use_username_password">Use username/password</string>
<string name="login_use_client_certificate">Use client certificate</string>
<string name="login_no_certificate_found">No certificate found</string>
<string name="login_install_certificate">Install certificate</string>
<string name="login_configuration_detection">Configuration detection</string>
<string name="login_querying_server">Please wait, querying server…</string>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment