Migration to API 33
This commit is contained in:
@ -3,12 +3,12 @@ apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
|
||||
android {
|
||||
compileSdkVersion = 32
|
||||
compileSdkVersion = 33
|
||||
ndkVersion = '23.1.7779620'
|
||||
defaultConfig {
|
||||
applicationId = 'com.tutpro.baresip'
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 32
|
||||
targetSdkVersion 33
|
||||
versionCode = 231
|
||||
versionName = '48.2.0'
|
||||
externalNativeBuild {
|
||||
|
||||
@ -7,12 +7,19 @@ import androidx.core.text.HtmlCompat
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.text.method.LinkMovementMethod
|
||||
import android.view.MenuItem
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import com.tutpro.baresip.databinding.ActivityAboutBinding
|
||||
|
||||
class AboutActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var binding: ActivityAboutBinding
|
||||
|
||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -26,26 +33,24 @@ class AboutActivity : AppCompatActivity() {
|
||||
binding.aboutText.text = HtmlCompat.fromHtml(text, HtmlCompat.FROM_HTML_MODE_LEGACY)
|
||||
binding.aboutText.movementMethod = LinkMovementMethod.getInstance()
|
||||
|
||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
|
||||
when (item.itemId) {
|
||||
android.R.id.home -> {
|
||||
BaresipService.activities.remove("about")
|
||||
setResult(Activity.RESULT_CANCELED, Intent())
|
||||
finish()
|
||||
}
|
||||
android.R.id.home ->
|
||||
goBack()
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
||||
private fun goBack() {
|
||||
BaresipService.activities.remove("about")
|
||||
super.onBackPressed()
|
||||
|
||||
setResult(Activity.RESULT_CANCELED, Intent())
|
||||
finish()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import android.view.View
|
||||
import android.view.View.GONE
|
||||
import android.view.View.VISIBLE
|
||||
import android.widget.*
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.tutpro.baresip.databinding.ActivityAccountBinding
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@ -61,6 +62,12 @@ class AccountActivity : AppCompatActivity() {
|
||||
|
||||
private val scope = CoroutineScope(Job() + Dispatchers.Main)
|
||||
|
||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -108,6 +115,8 @@ class AccountActivity : AppCompatActivity() {
|
||||
|
||||
bindTitles()
|
||||
|
||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||
|
||||
}
|
||||
|
||||
private fun initAccountFromConfig(ctx: AccountActivity) {
|
||||
@ -650,7 +659,7 @@ class AccountActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
android.R.id.home -> {
|
||||
onBackPressed()
|
||||
goBack()
|
||||
return true
|
||||
}
|
||||
|
||||
@ -660,7 +669,7 @@ class AccountActivity : AppCompatActivity() {
|
||||
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
private fun goBack() {
|
||||
BaresipService.activities.remove("account,$aor")
|
||||
returnResult(Activity.RESULT_CANCELED)
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.widget.EditText
|
||||
import android.widget.TextView
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
@ -19,6 +20,12 @@ class AccountsActivity : AppCompatActivity() {
|
||||
private lateinit var alAdapter: AccountListAdapter
|
||||
internal lateinit var aor: String
|
||||
|
||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -84,6 +91,8 @@ class AccountsActivity : AppCompatActivity() {
|
||||
accountRequest.launch(i)
|
||||
}
|
||||
|
||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||
|
||||
}
|
||||
|
||||
private fun askPassword(ua: UserAgent) {
|
||||
@ -129,7 +138,7 @@ class AccountsActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
android.R.id.home -> {
|
||||
onBackPressed()
|
||||
goBack()
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -143,7 +152,7 @@ class AccountsActivity : AppCompatActivity() {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
private fun goBack() {
|
||||
BaresipService.activities.remove("accounts,$aor")
|
||||
setResult(Activity.RESULT_CANCELED, Intent())
|
||||
finish()
|
||||
|
||||
@ -9,6 +9,7 @@ import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.cardview.widget.CardView
|
||||
import com.tutpro.baresip.databinding.ActivityAndroidContactBinding
|
||||
@ -27,6 +28,12 @@ class AndroidContactActivity : AppCompatActivity() {
|
||||
private var index = 0
|
||||
private var color = 0
|
||||
|
||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -59,34 +66,28 @@ class AndroidContactActivity : AppCompatActivity() {
|
||||
|
||||
Utils.addActivity("android contact,$aor,$index")
|
||||
|
||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
|
||||
if (BaresipService.activities.indexOf("android contact,$aor,$index") == -1) return true
|
||||
if (BaresipService.activities.indexOf("android contact,$aor,$index") == -1)
|
||||
return true
|
||||
|
||||
when (item.itemId) {
|
||||
|
||||
android.R.id.home -> {
|
||||
|
||||
BaresipService.activities.remove("android contact,$aor,$index")
|
||||
setResult(Activity.RESULT_CANCELED, Intent(this, MainActivity::class.java))
|
||||
finish()
|
||||
}
|
||||
|
||||
android.R.id.home ->
|
||||
goBack()
|
||||
}
|
||||
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
||||
private fun goBack() {
|
||||
BaresipService.activities.remove("android contact,$index")
|
||||
setResult(Activity.RESULT_CANCELED, Intent(this, MainActivity::class.java))
|
||||
finish()
|
||||
super.onBackPressed()
|
||||
|
||||
}
|
||||
|
||||
private fun showTextAvatar(name: String, color: Int) {
|
||||
|
||||
@ -7,6 +7,7 @@ import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.tutpro.baresip.databinding.ActivityAudioBinding
|
||||
@ -27,6 +28,12 @@ class AudioActivity : AppCompatActivity() {
|
||||
private var oldAec = false
|
||||
private val audioModules = listOf("opus", "amr", "g722", "g7221", "g726", "g729", "g711")
|
||||
|
||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -116,6 +123,8 @@ class AudioActivity : AppCompatActivity() {
|
||||
|
||||
bindTitles()
|
||||
|
||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
@ -220,7 +229,7 @@ class AudioActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
android.R.id.home -> {
|
||||
onBackPressed()
|
||||
goBack()
|
||||
return true
|
||||
}
|
||||
|
||||
@ -230,10 +239,9 @@ class AudioActivity : AppCompatActivity() {
|
||||
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
private fun goBack() {
|
||||
BaresipService.activities.remove("audio")
|
||||
finish()
|
||||
super.onBackPressed()
|
||||
}
|
||||
|
||||
private fun bindTitles() {
|
||||
|
||||
@ -325,7 +325,11 @@ class BaresipService: Service() {
|
||||
"force" -> {
|
||||
cleanService()
|
||||
isServiceRunning = false
|
||||
stopForeground(true)
|
||||
if (VERSION.SDK_INT < 33)
|
||||
@Suppress("DEPRECATION")
|
||||
stopForeground(true)
|
||||
else
|
||||
stopForeground(STOP_FOREGROUND_REMOVE)
|
||||
stopSelf()
|
||||
exitProcess(0)
|
||||
}
|
||||
@ -1093,7 +1097,11 @@ class BaresipService: Service() {
|
||||
quitTimer.cancel()
|
||||
isServiceRunning = false
|
||||
postServiceEvent(ServiceEvent("stopped", arrayListOf(error), System.nanoTime()))
|
||||
stopForeground(true)
|
||||
if (VERSION.SDK_INT < 33)
|
||||
@Suppress("DEPRECATION")
|
||||
stopForeground(true)
|
||||
else
|
||||
stopForeground(STOP_FOREGROUND_REMOVE)
|
||||
stopSelf()
|
||||
}
|
||||
|
||||
@ -1131,13 +1139,18 @@ class BaresipService: Service() {
|
||||
|
||||
private fun updateStatusNotification() {
|
||||
val contentView = RemoteViews(packageName, R.layout.status_notification)
|
||||
for (i: Int in 0..5) {
|
||||
val resID = resources.getIdentifier("status$i", "id", packageName)
|
||||
for (i: Int in 0..3) {
|
||||
val resId = when (i) {
|
||||
0-> R.id.status0
|
||||
1-> R.id.status1
|
||||
2-> R.id.status2
|
||||
else -> R.id.status3
|
||||
}
|
||||
if (i < uas.size) {
|
||||
contentView.setImageViewResource(resID, uas[i].status)
|
||||
contentView.setViewVisibility(resID, View.VISIBLE)
|
||||
contentView.setImageViewResource(resId, uas[i].status)
|
||||
contentView.setViewVisibility(resId, View.VISIBLE)
|
||||
} else {
|
||||
contentView.setViewVisibility(resID, View.INVISIBLE)
|
||||
contentView.setViewVisibility(resId, View.INVISIBLE)
|
||||
}
|
||||
}
|
||||
if (uas.size > 4)
|
||||
@ -1172,7 +1185,7 @@ class BaresipService: Service() {
|
||||
private fun isBluetoothHeadsetConnected(): Boolean {
|
||||
return if (VERSION.SDK_INT < 31)
|
||||
btAdapter != null && btAdapter!!.isEnabled &&
|
||||
btAdapter!!.getProfileConnectionState(BluetoothHeadset.HEADSET) == BluetoothHeadset.STATE_CONNECTED
|
||||
btAdapter!!.getProfileConnectionState(BluetoothHeadset.HEADSET) == BluetoothAdapter.STATE_CONNECTED
|
||||
else
|
||||
// getProfileConnectionState requires asking fot BLUETOOTH_CONNECT permission
|
||||
true
|
||||
|
||||
@ -3,6 +3,7 @@ package com.tutpro.baresip
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import android.view.MenuItem
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import com.tutpro.baresip.databinding.ActivityCallDetailsBinding
|
||||
|
||||
class CallDetailsActivity : AppCompatActivity() {
|
||||
@ -12,6 +13,12 @@ class CallDetailsActivity : AppCompatActivity() {
|
||||
private lateinit var peer: String
|
||||
private var position = 0
|
||||
|
||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -33,6 +40,7 @@ class CallDetailsActivity : AppCompatActivity() {
|
||||
val listView = binding.calls
|
||||
listView.adapter = CallDetailsAdapter(this, CallsActivity.uaHistory[position].details)
|
||||
|
||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
@ -47,7 +55,7 @@ class CallDetailsActivity : AppCompatActivity() {
|
||||
|
||||
when (item.itemId) {
|
||||
android.R.id.home -> {
|
||||
onBackPressed()
|
||||
goBack()
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -55,10 +63,9 @@ class CallDetailsActivity : AppCompatActivity() {
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
private fun goBack() {
|
||||
BaresipService.activities.remove("call_details,$aor,$peer,$position")
|
||||
finish()
|
||||
super.onBackPressed()
|
||||
}
|
||||
|
||||
}
|
||||
@ -8,6 +8,7 @@ import android.os.SystemClock
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.widget.AdapterView
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
@ -22,6 +23,12 @@ class CallsActivity : AppCompatActivity() {
|
||||
private var aor = ""
|
||||
private var lastClick: Long = 0
|
||||
|
||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -143,6 +150,9 @@ class CallsActivity : AppCompatActivity() {
|
||||
|
||||
ua.account.missedCalls = false
|
||||
invalidateOptionsMenu()
|
||||
|
||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
@ -180,7 +190,7 @@ class CallsActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
android.R.id.home -> {
|
||||
onBackPressed()
|
||||
goBack()
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -188,7 +198,7 @@ class CallsActivity : AppCompatActivity() {
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
private fun goBack() {
|
||||
BaresipService.activities.remove("calls,$aor")
|
||||
returnResult()
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ import android.widget.EditText
|
||||
import android.widget.ImageButton
|
||||
import android.widget.ListView
|
||||
import android.widget.Toast
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.Observer
|
||||
import com.tutpro.baresip.databinding.ActivityChatBinding
|
||||
@ -34,6 +35,12 @@ class ChatActivity : AppCompatActivity() {
|
||||
private var focus = false
|
||||
private var lastCall: Long = 0
|
||||
|
||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -130,6 +137,8 @@ class ChatActivity : AppCompatActivity() {
|
||||
|
||||
ua.account.unreadMessages = false
|
||||
|
||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
@ -184,7 +193,7 @@ class ChatActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
android.R.id.home -> {
|
||||
onBackPressed()
|
||||
goBack()
|
||||
return true
|
||||
}
|
||||
|
||||
@ -194,7 +203,7 @@ class ChatActivity : AppCompatActivity() {
|
||||
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
private fun goBack() {
|
||||
|
||||
var save = false
|
||||
for (m in chatMessages) {
|
||||
@ -210,7 +219,6 @@ class ChatActivity : AppCompatActivity() {
|
||||
BaresipService.activities.remove("chat,$aor,$peerUri,false")
|
||||
BaresipService.activities.remove("chat,$aor,$peerUri,true")
|
||||
returnResult(Activity.RESULT_OK)
|
||||
super.onBackPressed()
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.widget.*
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
@ -24,6 +25,12 @@ class ChatsActivity: AppCompatActivity() {
|
||||
internal lateinit var account: Account
|
||||
private var scrollPosition = -1
|
||||
|
||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -152,6 +159,8 @@ class ChatsActivity: AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
@ -165,7 +174,7 @@ class ChatsActivity: AppCompatActivity() {
|
||||
uaMessages = uaMessages(aor)
|
||||
clAdapter = ChatListAdapter(this, account, uaMessages)
|
||||
listView.adapter = clAdapter
|
||||
if (uaMessages.count() > 0) {
|
||||
if (uaMessages.isNotEmpty()) {
|
||||
if (scrollPosition >= 0) {
|
||||
listView.setSelection(scrollPosition)
|
||||
scrollPosition = -1
|
||||
@ -206,7 +215,7 @@ class ChatsActivity: AppCompatActivity() {
|
||||
}
|
||||
|
||||
android.R.id.home -> {
|
||||
onBackPressed()
|
||||
goBack()
|
||||
return true
|
||||
}
|
||||
|
||||
@ -215,7 +224,7 @@ class ChatsActivity: AppCompatActivity() {
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
private fun goBack() {
|
||||
BaresipService.activities.remove("chats,$aor")
|
||||
returnResult()
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.recyclerview.widget.ItemTouchHelper
|
||||
import androidx.recyclerview.widget.ItemTouchHelper.*
|
||||
@ -23,6 +24,12 @@ class CodecsActivity : AppCompatActivity() {
|
||||
private var newCodecs = ArrayList<Codec>()
|
||||
private var media = ""
|
||||
|
||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -79,6 +86,8 @@ class CodecsActivity : AppCompatActivity() {
|
||||
getString(R.string.video_codecs_help))
|
||||
}
|
||||
|
||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||
|
||||
}
|
||||
|
||||
private val itemTouchHelper by lazy {
|
||||
@ -177,7 +186,7 @@ class CodecsActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
android.R.id.home -> {
|
||||
onBackPressed()
|
||||
goBack()
|
||||
return true
|
||||
}
|
||||
|
||||
@ -187,10 +196,9 @@ class CodecsActivity : AppCompatActivity() {
|
||||
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
private fun goBack() {
|
||||
BaresipService.activities.remove("codecs,$aor,$media")
|
||||
finish()
|
||||
super.onBackPressed()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
|
||||
@ -14,6 +14,7 @@ import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.activity.result.ActivityResultLauncher
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
@ -64,6 +65,11 @@ class ConfigActivity : AppCompatActivity() {
|
||||
private var restart = false
|
||||
private var menu: Menu? = null
|
||||
|
||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -379,6 +385,8 @@ class ConfigActivity : AppCompatActivity() {
|
||||
|
||||
bindTitles()
|
||||
|
||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
@ -567,11 +575,7 @@ class ConfigActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
android.R.id.home -> {
|
||||
|
||||
BaresipService.activities.remove("config")
|
||||
setResult(Activity.RESULT_CANCELED, Intent(this, MainActivity::class.java))
|
||||
finish()
|
||||
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
|
||||
@ -592,12 +596,11 @@ class ConfigActivity : AppCompatActivity() {
|
||||
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
private fun goBack() {
|
||||
|
||||
BaresipService.activities.remove("config")
|
||||
setResult(Activity.RESULT_CANCELED, Intent(this, MainActivity::class.java))
|
||||
finish()
|
||||
super.onBackPressed()
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -18,6 +18,7 @@ import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.cardview.widget.CardView
|
||||
@ -46,6 +47,12 @@ class ContactActivity : AppCompatActivity() {
|
||||
private var color = 0
|
||||
private var id: Long = 0
|
||||
|
||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -176,6 +183,8 @@ class ContactActivity : AppCompatActivity() {
|
||||
|
||||
Utils.addActivity("contact,$newContact,$uOrI")
|
||||
|
||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(optionsMenu: Menu): Boolean {
|
||||
@ -283,10 +292,7 @@ class ContactActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
android.R.id.home -> {
|
||||
|
||||
BaresipService.activities.remove("contact,$newContact,$uOrI")
|
||||
setResult(Activity.RESULT_CANCELED, Intent(this, MainActivity::class.java))
|
||||
finish()
|
||||
goBack()
|
||||
}
|
||||
|
||||
}
|
||||
@ -295,13 +301,10 @@ class ContactActivity : AppCompatActivity() {
|
||||
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
||||
private fun goBack() {
|
||||
BaresipService.activities.remove("contact,$newContact,$uOrI")
|
||||
setResult(Activity.RESULT_CANCELED, Intent(this, MainActivity::class.java))
|
||||
finish()
|
||||
super.onBackPressed()
|
||||
|
||||
}
|
||||
|
||||
private fun showTextAvatar(name: String, color: Int) {
|
||||
|
||||
@ -6,6 +6,7 @@ import android.os.Bundle
|
||||
import android.os.SystemClock
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.view.MenuItem
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.lifecycle.Observer
|
||||
import com.tutpro.baresip.databinding.ActivityContactsBinding
|
||||
@ -17,6 +18,12 @@ class ContactsActivity : AppCompatActivity() {
|
||||
private lateinit var aor: String
|
||||
private var lastClick: Long = 0
|
||||
|
||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -61,6 +68,8 @@ class ContactsActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
@ -71,18 +80,15 @@ class ContactsActivity : AppCompatActivity() {
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
|
||||
when (item.itemId) {
|
||||
android.R.id.home -> {
|
||||
BaresipService.activities.remove("contacts,$aor")
|
||||
setResult(Activity.RESULT_OK, Intent())
|
||||
finish()
|
||||
}
|
||||
android.R.id.home ->
|
||||
goBack()
|
||||
}
|
||||
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
private fun goBack() {
|
||||
|
||||
BaresipService.activities.remove("contacts,$aor")
|
||||
setResult(Activity.RESULT_OK, Intent())
|
||||
|
||||
@ -20,6 +20,7 @@ import android.text.TextWatcher
|
||||
import android.view.*
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.*
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.activity.result.ActivityResultLauncher
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.annotation.RequiresApi
|
||||
@ -100,6 +101,12 @@ class MainActivity : AppCompatActivity() {
|
||||
private var resumeAction = ""
|
||||
private var firstRun = false
|
||||
|
||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
moveTaskToBack(true)
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
@ -107,6 +114,8 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
|
||||
|
||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||
|
||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||
|
||||
val extraAction = intent.getStringExtra("action")
|
||||
@ -351,15 +360,14 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
answerButton.setOnClickListener {
|
||||
val ua = BaresipService.uas[aorSpinner.selectedItemPosition]
|
||||
val aor = ua.account.aor
|
||||
val callp = ua.currentCall()!!.callp
|
||||
Log.d(TAG, "AoR $aor answering call $callp from ${callUri.text}")
|
||||
val call = ua.currentCall() ?: return@setOnClickListener
|
||||
Log.d(TAG, "AoR ${ua.account.aor} answering call from ${callUri.text}")
|
||||
answerButton.isEnabled = false
|
||||
rejectButton.isEnabled = false
|
||||
val intent = Intent(this@MainActivity, BaresipService::class.java)
|
||||
intent.action = "Call Answer"
|
||||
intent.putExtra("uap", ua.uap)
|
||||
intent.putExtra("callp", callp)
|
||||
intent.putExtra("callp", call.callp)
|
||||
intent.putExtra("video", Api.VIDMODE_OFF)
|
||||
startService(intent)
|
||||
}
|
||||
@ -1184,10 +1192,6 @@ class MainActivity : AppCompatActivity() {
|
||||
exitProcess(0)
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
moveTaskToBack(true)
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
|
||||
menuInflater.inflate(R.menu.main_menu, menu)
|
||||
|
||||
@ -21,7 +21,7 @@ open class OnSwipeTouchListener(ctx: Context) : View.OnTouchListener {
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
override fun onTouch(view: View?, event: MotionEvent?): Boolean {
|
||||
override fun onTouch(view: View?, event: MotionEvent): Boolean {
|
||||
return gestureDetector.onTouchEvent(event)
|
||||
}
|
||||
|
||||
@ -31,34 +31,32 @@ open class OnSwipeTouchListener(ctx: Context) : View.OnTouchListener {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onFling(e1: MotionEvent?, e2: MotionEvent?, velX: Float, velY: Float): Boolean {
|
||||
override fun onFling(e1: MotionEvent, e2: MotionEvent, velX: Float, velY: Float): Boolean {
|
||||
var result = false
|
||||
if (e1 != null && e2 != null) {
|
||||
try {
|
||||
val diffY = e2.y - e1.y
|
||||
val diffX = e2.x - e1.x
|
||||
if (abs(diffX) > abs(diffY)) {
|
||||
if (abs(diffX) > SWIPE_THRESHOLD && abs(velX) > SWIPE_VELOCITY_THRESHOLD) {
|
||||
if (diffX > 0) {
|
||||
onSwipeRight()
|
||||
} else {
|
||||
onSwipeLeft()
|
||||
}
|
||||
result = true
|
||||
}
|
||||
} else if (abs(diffY) > SWIPE_THRESHOLD && abs(velY) > SWIPE_VELOCITY_THRESHOLD) {
|
||||
result = if (diffY > 0) {
|
||||
onSwipeBottom()
|
||||
false
|
||||
try {
|
||||
val diffY = e2.y - e1.y
|
||||
val diffX = e2.x - e1.x
|
||||
if (abs(diffX) > abs(diffY)) {
|
||||
if (abs(diffX) > SWIPE_THRESHOLD && abs(velX) > SWIPE_VELOCITY_THRESHOLD) {
|
||||
if (diffX > 0) {
|
||||
onSwipeRight()
|
||||
} else {
|
||||
onSwipeTop()
|
||||
true
|
||||
onSwipeLeft()
|
||||
}
|
||||
result = true
|
||||
}
|
||||
} else if (abs(diffY) > SWIPE_THRESHOLD && abs(velY) > SWIPE_VELOCITY_THRESHOLD) {
|
||||
result = if (diffY > 0) {
|
||||
onSwipeBottom()
|
||||
false
|
||||
} else {
|
||||
onSwipeTop()
|
||||
true
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "onFling exception $e")
|
||||
e.printStackTrace()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "onFling exception $e")
|
||||
e.printStackTrace()
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@ -818,7 +818,7 @@ object Utils {
|
||||
Log.d(TAG, "Dumping intent start")
|
||||
while (it.hasNext()) {
|
||||
val key = it.next()
|
||||
Log.d(TAG, "[" + key + "=" + bundle.get(key) + "]")
|
||||
Log.d(TAG, "[" + key + "=" + bundle.getBundle(key) + "]")
|
||||
}
|
||||
Log.d(TAG, "Dumping intent finish")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user