- Improved asking of RECORD_AUDIO permission.
This commit is contained in:
@ -913,9 +913,10 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
RECORD_PERMISSION_REQUEST_CODE -> {
|
||||
if ((grantResults.size > 0) && (grantResults[0] != PackageManager.PERMISSION_GRANTED))
|
||||
Toast.makeText(applicationContext, getString(R.string.no_calls),
|
||||
Toast.LENGTH_LONG).show()
|
||||
startBaresip()
|
||||
Utils.alertView(this, getString(R.string.notice),
|
||||
getString(R.string.no_calls), ::startBaresip)
|
||||
else
|
||||
startBaresip()
|
||||
}
|
||||
|
||||
BACKUP_PERMISSION_REQUEST_CODE ->
|
||||
|
||||
@ -50,12 +50,15 @@ object Utils {
|
||||
return result
|
||||
}
|
||||
|
||||
fun alertView(context: Context, title: String, message: String) {
|
||||
fun alertView(context: Context, title: String, message: String, action: () -> (Unit) = {}) {
|
||||
val builder = AlertDialog.Builder(context)
|
||||
builder.setTitle(title)
|
||||
.setMessage(message)
|
||||
.setPositiveButton(R.string.ok)
|
||||
{ dialog, _ -> dialog.dismiss() }
|
||||
{ dialog, _ ->
|
||||
dialog.dismiss()
|
||||
action()
|
||||
}
|
||||
.show()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user