- Ask POST_NOTIFICATIONS permission on Android 13+ devices
This commit is contained in:
@ -19,6 +19,7 @@
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
|
||||
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
|
||||
@ -630,7 +630,10 @@ class MainActivity : AppCompatActivity() {
|
||||
BaresipService.callActionUri = URLDecoder.decode(intent.data.toString(), "UTF-8")
|
||||
}
|
||||
|
||||
if (!BaresipService.isServiceRunning)
|
||||
requestPermissionLauncher =
|
||||
registerForActivityResult(ActivityResultContracts.RequestPermission()) {}
|
||||
|
||||
if (!BaresipService.isServiceRunning) {
|
||||
if (File(filesDir.absolutePath + "/accounts").exists()) {
|
||||
val accounts = String(
|
||||
Utils.getFileContents(filesDir.absolutePath + "/accounts")!!,
|
||||
@ -642,15 +645,13 @@ class MainActivity : AppCompatActivity() {
|
||||
firstRun = true
|
||||
startBaresip()
|
||||
}
|
||||
}
|
||||
|
||||
if (Preferences(applicationContext).displayTheme != AppCompatDelegate.getDefaultNightMode()) {
|
||||
AppCompatDelegate.setDefaultNightMode(Preferences(applicationContext).displayTheme)
|
||||
delegate.applyDayNight()
|
||||
}
|
||||
|
||||
requestPermissionLauncher =
|
||||
registerForActivityResult(ActivityResultContracts.RequestPermission()) {}
|
||||
|
||||
} // OnCreate
|
||||
|
||||
override fun onStart() {
|
||||
@ -1180,7 +1181,6 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
handleNextEvent()
|
||||
|
||||
}
|
||||
|
||||
private fun reStart() {
|
||||
@ -1560,10 +1560,40 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun startBaresip() {
|
||||
baresipService.action = "Start"
|
||||
startService(baresipService)
|
||||
if (atStartup)
|
||||
moveTaskToBack(true)
|
||||
if (Build.VERSION.SDK_INT >= 33) {
|
||||
when {
|
||||
ContextCompat.checkSelfPermission(
|
||||
this,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
) == PackageManager.PERMISSION_GRANTED -> {
|
||||
Log.d(TAG, "Notifications permission granted")
|
||||
baresipService.action = "Start"
|
||||
startService(baresipService)
|
||||
if (atStartup)
|
||||
moveTaskToBack(true)
|
||||
}
|
||||
ActivityCompat.shouldShowRequestPermissionRationale(
|
||||
this, Manifest.permission.POST_NOTIFICATIONS
|
||||
) -> {
|
||||
layout.showSnackBar(
|
||||
binding.root,
|
||||
getString(R.string.no_notifications),
|
||||
Snackbar.LENGTH_INDEFINITE,
|
||||
getString(R.string.ok)
|
||||
) {
|
||||
requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
baresipService.action = "Start"
|
||||
startService(baresipService)
|
||||
if (atStartup)
|
||||
moveTaskToBack(true)
|
||||
}
|
||||
}
|
||||
|
||||
private fun backup(password: String) {
|
||||
|
||||
@ -534,12 +534,11 @@
|
||||
Android versioon 9 saakka tarkista myös Asetukset → Sovellukset → baresip → Käyttöluvat →
|
||||
Tallennustila ja että tiedosto \'%1$s\' on Download-kansiossa.
|
||||
</string>
|
||||
<string name="no_calls">Et voi soittaa puheluita tai vastata niihin ilman Mikrofoni-käyttöoikeutta.</string>
|
||||
<string name="no_video_calls">Salli Kamera-sovelluslupa jotta voit soittaa videopuheluita ja vastata niihin.</string>
|
||||
<string name="no_backup">Et voi tallentaa sovelluksen tietoja ilman
|
||||
Tallennustila-käyttöoikeutta.</string>
|
||||
<string name="no_restore">Et voi palauttaa sovelluksen tietoja ilman
|
||||
Tallennustila-käyttöoikeutta.</string>
|
||||
<string name="no_notifications">Et voi käyttää tätä sovellusta ilman Ilmoitukset-lupaa.</string>
|
||||
<string name="no_calls">Et voi soittaa puheluita tai vastata niihin ilman Mikrofoni-lupaa.</string>
|
||||
<string name="no_video_calls">Salli Kamera-lupa jotta voit soittaa videopuheluita ja vastata niihin.</string>
|
||||
<string name="no_backup">Et voi tallentaa sovelluksen tietoja ilman Tallennustila-lupaa.</string>
|
||||
<string name="no_restore">Et voi palauttaa sovelluksen tietoja ilman Tallennustila-lupaa.</string>
|
||||
<string name="no_cameras">Sinulla ei ole yhtään tuettua video-kameraa.</string>
|
||||
<string name="show_password">Näytä salasana</string>
|
||||
<string name="no_network">Ei verkkoyhteyttä!</string>
|
||||
|
||||
@ -506,6 +506,8 @@
|
||||
also check Apps → baresip → Permissions → Storage and that file \'%1$s\' exists
|
||||
in Download folder.
|
||||
</string>
|
||||
<string name="no_notifications">You are not able to use this application without \"Notifications\"
|
||||
permission.</string>
|
||||
<string name="no_calls">You are not able to make or answer calls without \"Microphone\"
|
||||
permission.</string>
|
||||
<string name="no_video_calls">Grant \"Camera\" permission to make or answer video calls.</string>
|
||||
|
||||
Reference in New Issue
Block a user