mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-06-05 21:49:23 +02:00
Merge pull request #536 from ismailnurudeen/fix/on_dismiss_select_sim_dialog
fix: close DailerActivity when SelectSIMDialog dismissed.
This commit is contained in:
@@ -15,7 +15,12 @@ import com.simplemobiletools.dialer.extensions.getAvailableSIMCardLabels
|
|||||||
import kotlinx.android.synthetic.main.dialog_select_sim.view.*
|
import kotlinx.android.synthetic.main.dialog_select_sim.view.*
|
||||||
|
|
||||||
@SuppressLint("MissingPermission")
|
@SuppressLint("MissingPermission")
|
||||||
class SelectSIMDialog(val activity: BaseSimpleActivity, val phoneNumber: String, val callback: (handle: PhoneAccountHandle?) -> Unit) {
|
class SelectSIMDialog(
|
||||||
|
val activity: BaseSimpleActivity,
|
||||||
|
val phoneNumber: String,
|
||||||
|
onDismiss: () -> Unit = {},
|
||||||
|
val callback: (handle: PhoneAccountHandle?) -> Unit
|
||||||
|
) {
|
||||||
private var dialog: AlertDialog? = null
|
private var dialog: AlertDialog? = null
|
||||||
private val view = activity.layoutInflater.inflate(R.layout.dialog_select_sim, null)
|
private val view = activity.layoutInflater.inflate(R.layout.dialog_select_sim, null)
|
||||||
|
|
||||||
@@ -42,6 +47,10 @@ class SelectSIMDialog(val activity: BaseSimpleActivity, val phoneNumber: String,
|
|||||||
dialog = alertDialog
|
dialog = alertDialog
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dialog?.setOnDismissListener {
|
||||||
|
onDismiss()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun selectedSIM(handle: PhoneAccountHandle, label: String) {
|
private fun selectedSIM(handle: PhoneAccountHandle, label: String) {
|
||||||
|
@@ -83,7 +83,11 @@ fun SimpleActivity.getHandleToUse(intent: Intent?, phoneNumber: String, callback
|
|||||||
}
|
}
|
||||||
defaultHandle != null -> callback(defaultHandle)
|
defaultHandle != null -> callback(defaultHandle)
|
||||||
else -> {
|
else -> {
|
||||||
SelectSIMDialog(this, phoneNumber) { handle ->
|
SelectSIMDialog(this, phoneNumber, onDismiss = {
|
||||||
|
if (this is DialerActivity) {
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}) { handle ->
|
||||||
callback(handle)
|
callback(handle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user