@@ -8,6 +8,7 @@ import android.view.View.VISIBLE
8
8
import android.widget.Button
9
9
// import android.widget.ProgressBar
10
10
import android.widget.TextView
11
+ import androidx.appcompat.app.AlertDialog
11
12
// import androidx.appcompat.widget.SwitchCompat
12
13
// import androidx.constraintlayout.widget.ConstraintLayout
13
14
import androidx.core.os.bundleOf
@@ -147,9 +148,9 @@ class EKirjastoAccountFragment : Fragment(R.layout.account_ekirjasto){
147
148
override fun onStart () {
148
149
super .onStart()
149
150
this .configureToolbar()
150
- this .buttonLogout.setOnClickListener() {
151
+ this .buttonLogout.setOnClickListener {
151
152
this .logger.debug(" Logout clicked" )
152
- this .viewModel.tryLogout ()
153
+ this .confirmLogout ()
153
154
}
154
155
this .buttonLoginSuomiFi.setOnClickListener {
155
156
this .logger.debug(" Login with Suomi.Fi clicked" )
@@ -463,6 +464,26 @@ class EKirjastoAccountFragment : Fragment(R.layout.account_ekirjasto){
463
464
this .subscriptions.clear()
464
465
}
465
466
467
+ /* *
468
+ * Show a popup that informs user of logout and asks confirmation.
469
+ */
470
+ private fun confirmLogout () {
471
+ val builder: AlertDialog .Builder = AlertDialog .Builder (this .requireContext())
472
+ builder
473
+ .setTitle(R .string.logoutConfirmTitle)
474
+ .setMessage(R .string.logoutConfirmMessage)
475
+ .setPositiveButton(R .string.logoutConfirmConfirm) { dialog, which ->
476
+ // Trigger logout
477
+ this .viewModel.tryLogout()
478
+ }
479
+ .setNeutralButton(R .string.logoutConfirmCancel) { dialog, which ->
480
+ // do nothing
481
+ }
482
+
483
+ val dialog: AlertDialog = builder.create()
484
+ dialog.show()
485
+ }
486
+
466
487
private fun isPasskeySupported (): Boolean {
467
488
return android.os.Build .VERSION .SDK_INT >= 28
468
489
}
0 commit comments