Enabled OnBackInvokedCallback in all activities
This commit is contained in:
@ -22,7 +22,7 @@ android {
|
|||||||
}
|
}
|
||||||
ndk {
|
ndk {
|
||||||
// noinspection ChromeOsAbiSupport
|
// noinspection ChromeOsAbiSupport
|
||||||
abiFilters.addAll(listOf("armeabi-v7a", "arm64-v8a"/*, "x86_64"*/))
|
abiFilters.addAll(listOf("armeabi-v7a", "arm64-v8a", "x86_64"))
|
||||||
}
|
}
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,7 +45,7 @@
|
|||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:largeHeap="true"
|
android:largeHeap="true"
|
||||||
android:enableOnBackInvokedCallback="false"
|
android:enableOnBackInvokedCallback="true"
|
||||||
android:theme="@style/Theme.Material3.DayNight.NoActionBar"
|
android:theme="@style/Theme.Material3.DayNight.NoActionBar"
|
||||||
tools:remove="android:appComponentFactory"
|
tools:remove="android:appComponentFactory"
|
||||||
tools:targetApi="33">
|
tools:targetApi="33">
|
||||||
@ -55,7 +55,6 @@
|
|||||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
android:enableOnBackInvokedCallback="true"
|
|
||||||
android:windowSoftInputMode="adjustResize" >
|
android:windowSoftInputMode="adjustResize" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
@ -77,6 +76,14 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".AboutActivity"
|
||||||
|
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||||
|
android:label="@string/about_title"
|
||||||
|
android:windowSoftInputMode="adjustResize"
|
||||||
|
android:parentActivityName=".MainActivity" >
|
||||||
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".AccountsActivity"
|
android:name=".AccountsActivity"
|
||||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||||
@ -171,14 +178,6 @@
|
|||||||
android:label="@string/chat" >
|
android:label="@string/chat" >
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity
|
|
||||||
android:name=".AboutActivity"
|
|
||||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
|
||||||
android:label="@string/about_title"
|
|
||||||
android:windowSoftInputMode="adjustResize"
|
|
||||||
android:parentActivityName=".MainActivity" >
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".BaresipService"
|
android:name=".BaresipService"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
package com.tutpro.baresip
|
package com.tutpro.baresip
|
||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.window.OnBackInvokedCallback
|
||||||
|
import android.window.OnBackInvokedDispatcher
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.OnBackPressedCallback
|
import androidx.activity.OnBackPressedCallback
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
@ -34,6 +37,10 @@ import androidx.compose.ui.unit.dp
|
|||||||
|
|
||||||
class AboutActivity : ComponentActivity() {
|
class AboutActivity : ComponentActivity() {
|
||||||
|
|
||||||
|
private val backInvokedCallback = OnBackInvokedCallback {
|
||||||
|
goBack()
|
||||||
|
}
|
||||||
|
|
||||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||||
override fun handleOnBackPressed() {
|
override fun handleOnBackPressed() {
|
||||||
goBack()
|
goBack()
|
||||||
@ -46,6 +53,14 @@ class AboutActivity : ComponentActivity() {
|
|||||||
|
|
||||||
enableEdgeToEdge()
|
enableEdgeToEdge()
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 33)
|
||||||
|
onBackInvokedDispatcher.registerOnBackInvokedCallback(
|
||||||
|
OnBackInvokedDispatcher.PRIORITY_DEFAULT,
|
||||||
|
backInvokedCallback
|
||||||
|
)
|
||||||
|
else
|
||||||
|
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||||
|
|
||||||
Utils.addActivity("about")
|
Utils.addActivity("about")
|
||||||
|
|
||||||
val aboutTitle = String.format(getString(R.string.about_title))
|
val aboutTitle = String.format(getString(R.string.about_title))
|
||||||
@ -62,9 +77,6 @@ class AboutActivity : ComponentActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@ -114,6 +126,15 @@ class AboutActivity : ComponentActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
if (Build.VERSION.SDK_INT >= 33) {
|
||||||
|
onBackInvokedDispatcher.unregisterOnBackInvokedCallback(backInvokedCallback)
|
||||||
|
} else {
|
||||||
|
onBackPressedCallback.remove()
|
||||||
|
}
|
||||||
|
super.onDestroy()
|
||||||
|
}
|
||||||
|
|
||||||
private fun goBack() {
|
private fun goBack() {
|
||||||
BaresipService.activities.remove("about")
|
BaresipService.activities.remove("about")
|
||||||
setResult(RESULT_CANCELED, Intent())
|
setResult(RESULT_CANCELED, Intent())
|
||||||
|
|||||||
@ -2,7 +2,10 @@ package com.tutpro.baresip
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.window.OnBackInvokedCallback
|
||||||
|
import android.window.OnBackInvokedDispatcher
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.OnBackPressedCallback
|
import androidx.activity.OnBackPressedCallback
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
@ -133,6 +136,10 @@ class AccountActivity : ComponentActivity() {
|
|||||||
private val showAlert = mutableStateOf(false)
|
private val showAlert = mutableStateOf(false)
|
||||||
private val showStun = mutableStateOf(false)
|
private val showStun = mutableStateOf(false)
|
||||||
|
|
||||||
|
private val backInvokedCallback = OnBackInvokedCallback {
|
||||||
|
goBack()
|
||||||
|
}
|
||||||
|
|
||||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||||
override fun handleOnBackPressed() {
|
override fun handleOnBackPressed() {
|
||||||
goBack()
|
goBack()
|
||||||
@ -145,6 +152,14 @@ class AccountActivity : ComponentActivity() {
|
|||||||
|
|
||||||
enableEdgeToEdge()
|
enableEdgeToEdge()
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 33)
|
||||||
|
onBackInvokedDispatcher.registerOnBackInvokedCallback(
|
||||||
|
OnBackInvokedDispatcher.PRIORITY_DEFAULT,
|
||||||
|
backInvokedCallback
|
||||||
|
)
|
||||||
|
else
|
||||||
|
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||||
|
|
||||||
aor = intent.getStringExtra("aor")!!
|
aor = intent.getStringExtra("aor")!!
|
||||||
|
|
||||||
Utils.addActivity("account,$aor")
|
Utils.addActivity("account,$aor")
|
||||||
@ -207,10 +222,6 @@ class AccountActivity : ComponentActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
|
||||||
|
|
||||||
// Api.account_debug(acc.accp)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@ -1619,6 +1630,15 @@ class AccountActivity : ComponentActivity() {
|
|||||||
super.onPause()
|
super.onPause()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
if (Build.VERSION.SDK_INT >= 33) {
|
||||||
|
onBackInvokedDispatcher.unregisterOnBackInvokedCallback(backInvokedCallback)
|
||||||
|
} else {
|
||||||
|
onBackPressedCallback.remove()
|
||||||
|
}
|
||||||
|
super.onDestroy()
|
||||||
|
}
|
||||||
|
|
||||||
private fun returnResult(code: Int) {
|
private fun returnResult(code: Int) {
|
||||||
val i = Intent()
|
val i = Intent()
|
||||||
if (code == RESULT_OK)
|
if (code == RESULT_OK)
|
||||||
|
|||||||
@ -2,8 +2,11 @@ package com.tutpro.baresip
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.SystemClock
|
import android.os.SystemClock
|
||||||
|
import android.window.OnBackInvokedCallback
|
||||||
|
import android.window.OnBackInvokedDispatcher
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.OnBackPressedCallback
|
import androidx.activity.OnBackPressedCallback
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
@ -82,6 +85,10 @@ class AccountsActivity : ComponentActivity() {
|
|||||||
private val alertMessage = mutableStateOf("")
|
private val alertMessage = mutableStateOf("")
|
||||||
private val showAlert = mutableStateOf(false)
|
private val showAlert = mutableStateOf(false)
|
||||||
|
|
||||||
|
private val backInvokedCallback = OnBackInvokedCallback {
|
||||||
|
goBack()
|
||||||
|
}
|
||||||
|
|
||||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||||
override fun handleOnBackPressed() {
|
override fun handleOnBackPressed() {
|
||||||
goBack()
|
goBack()
|
||||||
@ -94,6 +101,14 @@ class AccountsActivity : ComponentActivity() {
|
|||||||
|
|
||||||
enableEdgeToEdge()
|
enableEdgeToEdge()
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 33)
|
||||||
|
onBackInvokedDispatcher.registerOnBackInvokedCallback(
|
||||||
|
OnBackInvokedDispatcher.PRIORITY_DEFAULT,
|
||||||
|
backInvokedCallback
|
||||||
|
)
|
||||||
|
else
|
||||||
|
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||||
|
|
||||||
val title = String.format(getString(R.string.accounts))
|
val title = String.format(getString(R.string.accounts))
|
||||||
|
|
||||||
aor = intent.getStringExtra("aor")!!
|
aor = intent.getStringExtra("aor")!!
|
||||||
@ -114,9 +129,6 @@ class AccountsActivity : ComponentActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@ -468,6 +480,15 @@ class AccountsActivity : ComponentActivity() {
|
|||||||
showAccounts.value = true
|
showAccounts.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
if (Build.VERSION.SDK_INT >= 33) {
|
||||||
|
onBackInvokedDispatcher.unregisterOnBackInvokedCallback(backInvokedCallback)
|
||||||
|
} else {
|
||||||
|
onBackPressedCallback.remove()
|
||||||
|
}
|
||||||
|
super.onDestroy()
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
fun saveAccounts() {
|
fun saveAccounts() {
|
||||||
|
|||||||
@ -4,7 +4,10 @@ import android.app.Activity
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.window.OnBackInvokedCallback
|
||||||
|
import android.window.OnBackInvokedDispatcher
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.OnBackPressedCallback
|
import androidx.activity.OnBackPressedCallback
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
@ -61,6 +64,10 @@ class AndroidContactActivity : ComponentActivity() {
|
|||||||
|
|
||||||
private var color = 0
|
private var color = 0
|
||||||
|
|
||||||
|
private val backInvokedCallback = OnBackInvokedCallback {
|
||||||
|
goBack()
|
||||||
|
}
|
||||||
|
|
||||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||||
override fun handleOnBackPressed() {
|
override fun handleOnBackPressed() {
|
||||||
goBack()
|
goBack()
|
||||||
@ -73,6 +80,14 @@ class AndroidContactActivity : ComponentActivity() {
|
|||||||
|
|
||||||
enableEdgeToEdge()
|
enableEdgeToEdge()
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 33)
|
||||||
|
onBackInvokedDispatcher.registerOnBackInvokedCallback(
|
||||||
|
OnBackInvokedDispatcher.PRIORITY_DEFAULT,
|
||||||
|
backInvokedCallback
|
||||||
|
)
|
||||||
|
else
|
||||||
|
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||||
|
|
||||||
aor = intent.getStringExtra("aor")!!
|
aor = intent.getStringExtra("aor")!!
|
||||||
name = intent.getStringExtra("name")!!
|
name = intent.getStringExtra("name")!!
|
||||||
|
|
||||||
@ -84,6 +99,8 @@ class AndroidContactActivity : ComponentActivity() {
|
|||||||
goBack()
|
goBack()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Utils.addActivity("android contact, $name")
|
||||||
|
|
||||||
setContent {
|
setContent {
|
||||||
AppTheme {
|
AppTheme {
|
||||||
Surface(
|
Surface(
|
||||||
@ -94,10 +111,6 @@ class AndroidContactActivity : ComponentActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils.addActivity("android contact, $name")
|
|
||||||
|
|
||||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@ -268,6 +281,15 @@ class AndroidContactActivity : ComponentActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
if (Build.VERSION.SDK_INT >= 33) {
|
||||||
|
onBackInvokedDispatcher.unregisterOnBackInvokedCallback(backInvokedCallback)
|
||||||
|
} else {
|
||||||
|
onBackPressedCallback.remove()
|
||||||
|
}
|
||||||
|
super.onDestroy()
|
||||||
|
}
|
||||||
|
|
||||||
private fun goBack() {
|
private fun goBack() {
|
||||||
BaresipService.activities.remove("android contact,$name")
|
BaresipService.activities.remove("android contact,$name")
|
||||||
setResult(RESULT_CANCELED, Intent(this, MainActivity::class.java))
|
setResult(RESULT_CANCELED, Intent(this, MainActivity::class.java))
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
package com.tutpro.baresip
|
package com.tutpro.baresip
|
||||||
|
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.window.OnBackInvokedCallback
|
||||||
|
import android.window.OnBackInvokedDispatcher
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.OnBackPressedCallback
|
import androidx.activity.OnBackPressedCallback
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
@ -77,6 +80,10 @@ class AudioActivity : ComponentActivity() {
|
|||||||
private val alertMessage = mutableStateOf("")
|
private val alertMessage = mutableStateOf("")
|
||||||
private val showAlert = mutableStateOf(false)
|
private val showAlert = mutableStateOf(false)
|
||||||
|
|
||||||
|
private val backInvokedCallback = OnBackInvokedCallback {
|
||||||
|
goBack()
|
||||||
|
}
|
||||||
|
|
||||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||||
override fun handleOnBackPressed() {
|
override fun handleOnBackPressed() {
|
||||||
goBack()
|
goBack()
|
||||||
@ -89,6 +96,14 @@ class AudioActivity : ComponentActivity() {
|
|||||||
|
|
||||||
enableEdgeToEdge()
|
enableEdgeToEdge()
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 33)
|
||||||
|
onBackInvokedDispatcher.registerOnBackInvokedCallback(
|
||||||
|
OnBackInvokedDispatcher.PRIORITY_DEFAULT,
|
||||||
|
backInvokedCallback
|
||||||
|
)
|
||||||
|
else
|
||||||
|
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||||
|
|
||||||
val title = String.format(getString(R.string.configuration))
|
val title = String.format(getString(R.string.configuration))
|
||||||
|
|
||||||
Utils.addActivity("audio")
|
Utils.addActivity("audio")
|
||||||
@ -106,8 +121,6 @@ class AudioActivity : ComponentActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ -642,6 +655,15 @@ class AudioActivity : ComponentActivity() {
|
|||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
if (Build.VERSION.SDK_INT >= 33) {
|
||||||
|
onBackInvokedDispatcher.unregisterOnBackInvokedCallback(backInvokedCallback)
|
||||||
|
} else {
|
||||||
|
onBackPressedCallback.remove()
|
||||||
|
}
|
||||||
|
super.onDestroy()
|
||||||
|
}
|
||||||
|
|
||||||
private fun goBack() {
|
private fun goBack() {
|
||||||
BaresipService.activities.remove("audio")
|
BaresipService.activities.remove("audio")
|
||||||
finish()
|
finish()
|
||||||
|
|||||||
@ -9,10 +9,13 @@ import android.graphics.Bitmap
|
|||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
import android.graphics.Matrix
|
import android.graphics.Matrix
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.provider.ContactsContract
|
import android.provider.ContactsContract
|
||||||
import android.provider.ContactsContract.CommonDataKinds
|
import android.provider.ContactsContract.CommonDataKinds
|
||||||
import android.provider.ContactsContract.Contacts.Data
|
import android.provider.ContactsContract.Contacts.Data
|
||||||
|
import android.window.OnBackInvokedCallback
|
||||||
|
import android.window.OnBackInvokedDispatcher
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.OnBackPressedCallback
|
import androidx.activity.OnBackPressedCallback
|
||||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||||
@ -105,6 +108,10 @@ class BaresipContactActivity : ComponentActivity() {
|
|||||||
private val textAvatarColor = mutableIntStateOf(0)
|
private val textAvatarColor = mutableIntStateOf(0)
|
||||||
private val imageAvatarUri = mutableStateOf("")
|
private val imageAvatarUri = mutableStateOf("")
|
||||||
|
|
||||||
|
private val backInvokedCallback = OnBackInvokedCallback {
|
||||||
|
goBack()
|
||||||
|
}
|
||||||
|
|
||||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||||
override fun handleOnBackPressed() {
|
override fun handleOnBackPressed() {
|
||||||
goBack()
|
goBack()
|
||||||
@ -117,6 +124,14 @@ class BaresipContactActivity : ComponentActivity() {
|
|||||||
|
|
||||||
enableEdgeToEdge()
|
enableEdgeToEdge()
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 33)
|
||||||
|
onBackInvokedDispatcher.registerOnBackInvokedCallback(
|
||||||
|
OnBackInvokedDispatcher.PRIORITY_DEFAULT,
|
||||||
|
backInvokedCallback
|
||||||
|
)
|
||||||
|
else
|
||||||
|
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||||
|
|
||||||
val title: String
|
val title: String
|
||||||
|
|
||||||
new = intent.getBooleanExtra("new", false)
|
new = intent.getBooleanExtra("new", false)
|
||||||
@ -150,6 +165,8 @@ class BaresipContactActivity : ComponentActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Utils.addActivity("baresip contact,$new,$uriOrName")
|
||||||
|
|
||||||
setContent {
|
setContent {
|
||||||
AppTheme {
|
AppTheme {
|
||||||
Surface(
|
Surface(
|
||||||
@ -160,10 +177,6 @@ class BaresipContactActivity : ComponentActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils.addActivity("baresip contact,$new,$uriOrName")
|
|
||||||
|
|
||||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ -687,6 +700,15 @@ class BaresipContactActivity : ComponentActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
if (Build.VERSION.SDK_INT >= 33) {
|
||||||
|
onBackInvokedDispatcher.unregisterOnBackInvokedCallback(backInvokedCallback)
|
||||||
|
} else {
|
||||||
|
onBackPressedCallback.remove()
|
||||||
|
}
|
||||||
|
super.onDestroy()
|
||||||
|
}
|
||||||
|
|
||||||
private fun goBack() {
|
private fun goBack() {
|
||||||
BaresipService.activities.remove("baresip contact,$new,$uriOrName")
|
BaresipService.activities.remove("baresip contact,$new,$uriOrName")
|
||||||
setResult(RESULT_CANCELED, Intent(this, MainActivity::class.java))
|
setResult(RESULT_CANCELED, Intent(this, MainActivity::class.java))
|
||||||
|
|||||||
@ -3,8 +3,11 @@ package com.tutpro.baresip
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.media.AudioAttributes
|
import android.media.AudioAttributes
|
||||||
import android.media.MediaPlayer
|
import android.media.MediaPlayer
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.format.DateUtils
|
import android.text.format.DateUtils
|
||||||
|
import android.window.OnBackInvokedCallback
|
||||||
|
import android.window.OnBackInvokedDispatcher
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.OnBackPressedCallback
|
import androidx.activity.OnBackPressedCallback
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
@ -67,6 +70,10 @@ class CallDetailsActivity : ComponentActivity() {
|
|||||||
private val encPlayer = MediaPlayer()
|
private val encPlayer = MediaPlayer()
|
||||||
private var position = 0
|
private var position = 0
|
||||||
|
|
||||||
|
private val backInvokedCallback = OnBackInvokedCallback {
|
||||||
|
goBack()
|
||||||
|
}
|
||||||
|
|
||||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||||
override fun handleOnBackPressed() {
|
override fun handleOnBackPressed() {
|
||||||
goBack()
|
goBack()
|
||||||
@ -79,6 +86,14 @@ class CallDetailsActivity : ComponentActivity() {
|
|||||||
|
|
||||||
enableEdgeToEdge()
|
enableEdgeToEdge()
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 33)
|
||||||
|
onBackInvokedDispatcher.registerOnBackInvokedCallback(
|
||||||
|
OnBackInvokedDispatcher.PRIORITY_DEFAULT,
|
||||||
|
backInvokedCallback
|
||||||
|
)
|
||||||
|
else
|
||||||
|
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||||
|
|
||||||
aor = intent.getStringExtra("aor")!!
|
aor = intent.getStringExtra("aor")!!
|
||||||
account = Account.ofAor(aor)!!
|
account = Account.ofAor(aor)!!
|
||||||
peer = intent.getStringExtra("peer")!!
|
peer = intent.getStringExtra("peer")!!
|
||||||
@ -98,8 +113,6 @@ class CallDetailsActivity : ComponentActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@ -362,6 +375,15 @@ class CallDetailsActivity : ComponentActivity() {
|
|||||||
super.onPause()
|
super.onPause()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
if (Build.VERSION.SDK_INT >= 33) {
|
||||||
|
onBackInvokedDispatcher.unregisterOnBackInvokedCallback(backInvokedCallback)
|
||||||
|
} else {
|
||||||
|
onBackPressedCallback.remove()
|
||||||
|
}
|
||||||
|
super.onDestroy()
|
||||||
|
}
|
||||||
|
|
||||||
private fun goBack() {
|
private fun goBack() {
|
||||||
BaresipService.activities.remove("call_details,$aor,$peer,$position")
|
BaresipService.activities.remove("call_details,$aor,$peer,$position")
|
||||||
decPlayer.stop()
|
decPlayer.stop()
|
||||||
|
|||||||
@ -4,7 +4,10 @@ import android.annotation.SuppressLint
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.window.OnBackInvokedCallback
|
||||||
|
import android.window.OnBackInvokedDispatcher
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.OnBackPressedCallback
|
import androidx.activity.OnBackPressedCallback
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
@ -70,6 +73,10 @@ class CallsActivity : ComponentActivity() {
|
|||||||
|
|
||||||
private var aor = ""
|
private var aor = ""
|
||||||
|
|
||||||
|
private val backInvokedCallback = OnBackInvokedCallback {
|
||||||
|
goBack()
|
||||||
|
}
|
||||||
|
|
||||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||||
override fun handleOnBackPressed() {
|
override fun handleOnBackPressed() {
|
||||||
goBack()
|
goBack()
|
||||||
@ -82,6 +89,14 @@ class CallsActivity : ComponentActivity() {
|
|||||||
|
|
||||||
enableEdgeToEdge()
|
enableEdgeToEdge()
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 33)
|
||||||
|
onBackInvokedDispatcher.registerOnBackInvokedCallback(
|
||||||
|
OnBackInvokedDispatcher.PRIORITY_DEFAULT,
|
||||||
|
backInvokedCallback
|
||||||
|
)
|
||||||
|
else
|
||||||
|
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||||
|
|
||||||
val title = String.format(getString(R.string.call_history))
|
val title = String.format(getString(R.string.call_history))
|
||||||
|
|
||||||
aor = intent.getStringExtra("aor")!!
|
aor = intent.getStringExtra("aor")!!
|
||||||
@ -103,9 +118,6 @@ class CallsActivity : ComponentActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
account.missedCalls = false
|
account.missedCalls = false
|
||||||
invalidateOptionsMenu()
|
|
||||||
|
|
||||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ -439,14 +451,23 @@ class CallsActivity : ComponentActivity() {
|
|||||||
returnResult()
|
returnResult()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun returnResult() {
|
||||||
|
setResult(RESULT_CANCELED, Intent())
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
MainActivity.activityAor = aor
|
MainActivity.activityAor = aor
|
||||||
super.onPause()
|
super.onPause()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun returnResult() {
|
override fun onDestroy() {
|
||||||
setResult(RESULT_CANCELED, Intent())
|
if (Build.VERSION.SDK_INT >= 33) {
|
||||||
finish()
|
onBackInvokedDispatcher.unregisterOnBackInvokedCallback(backInvokedCallback)
|
||||||
|
} else {
|
||||||
|
onBackPressedCallback.remove()
|
||||||
|
}
|
||||||
|
super.onDestroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun aorGenerateHistory(aor: String) {
|
private fun aorGenerateHistory(aor: String) {
|
||||||
|
|||||||
@ -2,11 +2,14 @@ package com.tutpro.baresip
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.SystemClock
|
import android.os.SystemClock
|
||||||
import android.text.format.DateUtils.isToday
|
import android.text.format.DateUtils.isToday
|
||||||
import android.view.inputmethod.InputMethodManager
|
import android.view.inputmethod.InputMethodManager
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import android.window.OnBackInvokedCallback
|
||||||
|
import android.window.OnBackInvokedDispatcher
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.OnBackPressedCallback
|
import androidx.activity.OnBackPressedCallback
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
@ -98,6 +101,10 @@ class ChatActivity : ComponentActivity() {
|
|||||||
private var unsentMessage = ""
|
private var unsentMessage = ""
|
||||||
private var keyboardController: SoftwareKeyboardController? = null
|
private var keyboardController: SoftwareKeyboardController? = null
|
||||||
|
|
||||||
|
private val backInvokedCallback = OnBackInvokedCallback {
|
||||||
|
goBack()
|
||||||
|
}
|
||||||
|
|
||||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||||
override fun handleOnBackPressed() {
|
override fun handleOnBackPressed() {
|
||||||
goBack()
|
goBack()
|
||||||
@ -110,6 +117,14 @@ class ChatActivity : ComponentActivity() {
|
|||||||
|
|
||||||
enableEdgeToEdge()
|
enableEdgeToEdge()
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 33)
|
||||||
|
onBackInvokedDispatcher.registerOnBackInvokedCallback(
|
||||||
|
OnBackInvokedDispatcher.PRIORITY_DEFAULT,
|
||||||
|
backInvokedCallback
|
||||||
|
)
|
||||||
|
else
|
||||||
|
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||||
|
|
||||||
aor = intent.getStringExtra("aor")!!
|
aor = intent.getStringExtra("aor")!!
|
||||||
peerUri = intent.getStringExtra("peer")!!
|
peerUri = intent.getStringExtra("peer")!!
|
||||||
account = UserAgent.ofAor(aor)!!.account
|
account = UserAgent.ofAor(aor)!!.account
|
||||||
@ -156,8 +171,6 @@ class ChatActivity : ComponentActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ -622,6 +635,15 @@ class ChatActivity : ComponentActivity() {
|
|||||||
MainActivity.activityAor = aor
|
MainActivity.activityAor = aor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
if (Build.VERSION.SDK_INT >= 33) {
|
||||||
|
onBackInvokedDispatcher.unregisterOnBackInvokedCallback(backInvokedCallback)
|
||||||
|
} else {
|
||||||
|
onBackPressedCallback.remove()
|
||||||
|
}
|
||||||
|
super.onDestroy()
|
||||||
|
}
|
||||||
|
|
||||||
private fun goBack() {
|
private fun goBack() {
|
||||||
var save = false
|
var save = false
|
||||||
for (m in chatMessages) {
|
for (m in chatMessages) {
|
||||||
|
|||||||
@ -3,8 +3,11 @@ package com.tutpro.baresip
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.format.DateUtils.isToday
|
import android.text.format.DateUtils.isToday
|
||||||
|
import android.window.OnBackInvokedCallback
|
||||||
|
import android.window.OnBackInvokedDispatcher
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.OnBackPressedCallback
|
import androidx.activity.OnBackPressedCallback
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
@ -99,6 +102,10 @@ class ChatsActivity: ComponentActivity() {
|
|||||||
private val alertMessage = mutableStateOf("")
|
private val alertMessage = mutableStateOf("")
|
||||||
private val showAlert = mutableStateOf(false)
|
private val showAlert = mutableStateOf(false)
|
||||||
|
|
||||||
|
private val backInvokedCallback = OnBackInvokedCallback {
|
||||||
|
goBack()
|
||||||
|
}
|
||||||
|
|
||||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||||
override fun handleOnBackPressed() {
|
override fun handleOnBackPressed() {
|
||||||
goBack()
|
goBack()
|
||||||
@ -111,6 +118,14 @@ class ChatsActivity: ComponentActivity() {
|
|||||||
|
|
||||||
enableEdgeToEdge()
|
enableEdgeToEdge()
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 33)
|
||||||
|
onBackInvokedDispatcher.registerOnBackInvokedCallback(
|
||||||
|
OnBackInvokedDispatcher.PRIORITY_DEFAULT,
|
||||||
|
backInvokedCallback
|
||||||
|
)
|
||||||
|
else
|
||||||
|
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||||
|
|
||||||
aor = intent.extras!!.getString("aor")!!
|
aor = intent.extras!!.getString("aor")!!
|
||||||
Utils.addActivity("chats,$aor")
|
Utils.addActivity("chats,$aor")
|
||||||
account = UserAgent.ofAor(aor)!!.account
|
account = UserAgent.ofAor(aor)!!.account
|
||||||
@ -135,9 +150,6 @@ class ChatsActivity: ComponentActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ -670,6 +682,15 @@ class ChatsActivity: ComponentActivity() {
|
|||||||
_uaMessages.value = uaMessages(aor)
|
_uaMessages.value = uaMessages(aor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
if (Build.VERSION.SDK_INT >= 33) {
|
||||||
|
onBackInvokedDispatcher.unregisterOnBackInvokedCallback(backInvokedCallback)
|
||||||
|
} else {
|
||||||
|
onBackPressedCallback.remove()
|
||||||
|
}
|
||||||
|
super.onDestroy()
|
||||||
|
}
|
||||||
|
|
||||||
private fun goBack() {
|
private fun goBack() {
|
||||||
BaresipService.activities.remove("chats,$aor")
|
BaresipService.activities.remove("chats,$aor")
|
||||||
returnResult()
|
returnResult()
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
package com.tutpro.baresip
|
package com.tutpro.baresip
|
||||||
|
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.window.OnBackInvokedCallback
|
||||||
|
import android.window.OnBackInvokedDispatcher
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.OnBackPressedCallback
|
import androidx.activity.OnBackPressedCallback
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
@ -65,6 +68,10 @@ class CodecsActivity : ComponentActivity() {
|
|||||||
private val alertMessage = mutableStateOf("")
|
private val alertMessage = mutableStateOf("")
|
||||||
private val showAlert = mutableStateOf(false)
|
private val showAlert = mutableStateOf(false)
|
||||||
|
|
||||||
|
private val backInvokedCallback = OnBackInvokedCallback {
|
||||||
|
goBack()
|
||||||
|
}
|
||||||
|
|
||||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||||
override fun handleOnBackPressed() {
|
override fun handleOnBackPressed() {
|
||||||
goBack()
|
goBack()
|
||||||
@ -77,6 +84,14 @@ class CodecsActivity : ComponentActivity() {
|
|||||||
|
|
||||||
enableEdgeToEdge()
|
enableEdgeToEdge()
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 33)
|
||||||
|
onBackInvokedDispatcher.registerOnBackInvokedCallback(
|
||||||
|
OnBackInvokedDispatcher.PRIORITY_DEFAULT,
|
||||||
|
backInvokedCallback
|
||||||
|
)
|
||||||
|
else
|
||||||
|
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||||
|
|
||||||
aor = intent.getStringExtra("aor")!!
|
aor = intent.getStringExtra("aor")!!
|
||||||
media = intent.getStringExtra("media")!!
|
media = intent.getStringExtra("media")!!
|
||||||
|
|
||||||
@ -114,8 +129,6 @@ class CodecsActivity : ComponentActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@ -353,4 +366,12 @@ class CodecsActivity : ComponentActivity() {
|
|||||||
super.onPause()
|
super.onPause()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
if (Build.VERSION.SDK_INT >= 33) {
|
||||||
|
onBackInvokedDispatcher.unregisterOnBackInvokedCallback(backInvokedCallback)
|
||||||
|
} else {
|
||||||
|
onBackPressedCallback.remove()
|
||||||
|
}
|
||||||
|
super.onDestroy()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import android.os.Build
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
|
import android.window.OnBackInvokedCallback
|
||||||
|
import android.window.OnBackInvokedDispatcher
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.OnBackPressedCallback
|
import androidx.activity.OnBackPressedCallback
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
@ -129,6 +131,10 @@ class ConfigActivity : ComponentActivity() {
|
|||||||
private val onNegativeClicked = mutableStateOf({})
|
private val onNegativeClicked = mutableStateOf({})
|
||||||
private val showDialog = mutableStateOf(false)
|
private val showDialog = mutableStateOf(false)
|
||||||
|
|
||||||
|
private val backInvokedCallback = OnBackInvokedCallback {
|
||||||
|
goBack()
|
||||||
|
}
|
||||||
|
|
||||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||||
override fun handleOnBackPressed() {
|
override fun handleOnBackPressed() {
|
||||||
goBack()
|
goBack()
|
||||||
@ -201,6 +207,14 @@ class ConfigActivity : ComponentActivity() {
|
|||||||
|
|
||||||
enableEdgeToEdge()
|
enableEdgeToEdge()
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 33)
|
||||||
|
onBackInvokedDispatcher.registerOnBackInvokedCallback(
|
||||||
|
OnBackInvokedDispatcher.PRIORITY_DEFAULT,
|
||||||
|
backInvokedCallback
|
||||||
|
)
|
||||||
|
else
|
||||||
|
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||||
|
|
||||||
val title = String.format(getString(R.string.configuration))
|
val title = String.format(getString(R.string.configuration))
|
||||||
|
|
||||||
Utils.addActivity("config")
|
Utils.addActivity("config")
|
||||||
@ -291,8 +305,6 @@ class ConfigActivity : ComponentActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ -1279,6 +1291,12 @@ class ConfigActivity : ComponentActivity() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onStart() {
|
||||||
|
super.onStart()
|
||||||
|
requestPermissionLauncher =
|
||||||
|
registerForActivityResult(ActivityResultContracts.RequestPermission()) {}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
if (managingOverlayPermission) {
|
if (managingOverlayPermission) {
|
||||||
@ -1287,10 +1305,13 @@ class ConfigActivity : ComponentActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onDestroy() {
|
||||||
super.onStart()
|
if (Build.VERSION.SDK_INT >= 33) {
|
||||||
requestPermissionLauncher =
|
onBackInvokedDispatcher.unregisterOnBackInvokedCallback(backInvokedCallback)
|
||||||
registerForActivityResult(ActivityResultContracts.RequestPermission()) {}
|
} else {
|
||||||
|
onBackPressedCallback.remove()
|
||||||
|
}
|
||||||
|
super.onDestroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isAppearOnTopPermissionGranted(ctx: Context): Boolean {
|
private fun isAppearOnTopPermissionGranted(ctx: Context): Boolean {
|
||||||
|
|||||||
@ -4,9 +4,12 @@ import android.app.Activity
|
|||||||
import android.content.ContentValues
|
import android.content.ContentValues
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.SystemClock
|
import android.os.SystemClock
|
||||||
import android.provider.ContactsContract
|
import android.provider.ContactsContract
|
||||||
|
import android.window.OnBackInvokedCallback
|
||||||
|
import android.window.OnBackInvokedDispatcher
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.OnBackPressedCallback
|
import androidx.activity.OnBackPressedCallback
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
@ -71,6 +74,10 @@ class ContactsActivity : ComponentActivity() {
|
|||||||
private var newAndroidName: String? = null
|
private var newAndroidName: String? = null
|
||||||
private var lastClick: Long = 0
|
private var lastClick: Long = 0
|
||||||
|
|
||||||
|
private val backInvokedCallback = OnBackInvokedCallback {
|
||||||
|
goBack()
|
||||||
|
}
|
||||||
|
|
||||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||||
override fun handleOnBackPressed() {
|
override fun handleOnBackPressed() {
|
||||||
goBack()
|
goBack()
|
||||||
@ -91,6 +98,14 @@ class ContactsActivity : ComponentActivity() {
|
|||||||
|
|
||||||
enableEdgeToEdge()
|
enableEdgeToEdge()
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 33)
|
||||||
|
onBackInvokedDispatcher.registerOnBackInvokedCallback(
|
||||||
|
OnBackInvokedDispatcher.PRIORITY_DEFAULT,
|
||||||
|
backInvokedCallback
|
||||||
|
)
|
||||||
|
else
|
||||||
|
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||||
|
|
||||||
val title = String.format(getString(R.string.contacts))
|
val title = String.format(getString(R.string.contacts))
|
||||||
|
|
||||||
aor = intent.getStringExtra("aor")!!
|
aor = intent.getStringExtra("aor")!!
|
||||||
@ -126,8 +141,6 @@ class ContactsActivity : ComponentActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@ -419,6 +432,15 @@ class ContactsActivity : ComponentActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
if (Build.VERSION.SDK_INT >= 33) {
|
||||||
|
onBackInvokedDispatcher.unregisterOnBackInvokedCallback(backInvokedCallback)
|
||||||
|
} else {
|
||||||
|
onBackPressedCallback.remove()
|
||||||
|
}
|
||||||
|
super.onDestroy()
|
||||||
|
}
|
||||||
|
|
||||||
private fun goBack() {
|
private fun goBack() {
|
||||||
BaresipService.activities.remove("contacts,$aor")
|
BaresipService.activities.remove("contacts,$aor")
|
||||||
setResult(RESULT_OK, Intent())
|
setResult(RESULT_OK, Intent())
|
||||||
|
|||||||
Reference in New Issue
Block a user