- Improved asking of RECORD_AUDIO permission.

This commit is contained in:
Juha Heinanen
2020-04-10 15:11:32 +03:00
parent 457df09497
commit 43f5a003f2
2 changed files with 9 additions and 5 deletions

View File

@ -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 ->

View File

@ -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()
}