From ed726ffe6ab4e1ff30e38883f153e338f7cf0a0d Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Tue, 19 May 2026 18:56:51 +0300 Subject: [PATCH] Coding style changes --- .../com/tutpro/baresip/BaresipService.kt | 32 +++++----- .../com/tutpro/baresip/ContactScreen.kt | 61 +++++++++---------- .../kotlin/com/tutpro/baresip/MainScreen.kt | 4 +- .../kotlin/com/tutpro/baresip/MmsReceiver.kt | 7 --- 4 files changed, 46 insertions(+), 58 deletions(-) diff --git a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt index 90b5c5a4..d5070c2c 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt @@ -404,11 +404,7 @@ class BaresipService: Service() { cleanService() isServiceRunning = false postServiceEvent( - ServiceEvent( - "stopped", - arrayListOf(""), - System.nanoTime() - ) + ServiceEvent("stopped", arrayListOf(""), System.nanoTime()) ) stopSelf() // exitProcess(0) @@ -461,12 +457,10 @@ class BaresipService: Service() { if (!file.exists() && a != "config") { Log.i(TAG, "Copying asset '$a'") Utils.copyAssetToFile(this, a, "$filesPath/$a") - } else { + else Log.i(TAG, "Asset '$a' already copied") - } - if (a == "config") { + if (a == "config") Config.initialize(this) - } } if (contactsMode != "android") @@ -920,8 +914,10 @@ class BaresipService: Service() { Utils.friendlyUri(this, peerUri, ua.account) ) else if (ua.account.blockUnknown && Contact.contactName(peerUri) == peerUri) - String.format(getString(R.string.call_blocked), - Utils.friendlyUri(this, peerUri, ua.account)) + String.format( + getString(R.string.call_blocked), + Utils.friendlyUri(this, peerUri, ua.account) + ) else if (!Utils.checkPermissions(this, arrayOf(RECORD_AUDIO))) getString(R.string.no_calls) else @@ -1222,12 +1218,16 @@ class BaresipService: Service() { rxFile.delete() txFile.delete() } catch (e: Exception) { - Log.w(TAG, "Could not delete temporary raw files " + - "after merge: ${e.message}") + Log.w( + TAG, + "Could not delete temporary raw files after merge: ${e.message}" + ) } - } else { - Log.e(TAG, "Automatic merge failed. " + - "Storing raw file paths as fallback.") + else { + Log.e( + TAG, + "Automatic merge failed. Storing raw file paths as fallback." + ) history.recording = call.dumpfiles } } diff --git a/app/src/main/kotlin/com/tutpro/baresip/ContactScreen.kt b/app/src/main/kotlin/com/tutpro/baresip/ContactScreen.kt index 061fa95d..20f77b6d 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/ContactScreen.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/ContactScreen.kt @@ -46,6 +46,7 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.automirrored.filled.Chat import androidx.compose.material.icons.filled.Add +import androidx.compose.material.icons.filled.Call import androidx.compose.material.icons.filled.Check import androidx.compose.material.icons.filled.Edit import androidx.compose.material.icons.filled.Remove @@ -680,21 +681,19 @@ private fun UrisSection( color = MaterialTheme.colorScheme.onBackground, ) + val ua = UserAgent.ofAor(selectedAor) + // Chat Button - IconButton( - onClick = { - val aor = viewModel.selectedAor.value - val ua = UserAgent.ofAor(aor) - if (ua == null) - Log.w(TAG, "Message clickable did not find AoR $aor") - else { - if (ua.account.isMobile && Utils.isAirplaneModeOn(ctx)) { + if (ua != null) + IconButton( + onClick = { + if (ua.account.isMobile && Utils.isAirplaneModeOn(ctx)) handleDialog(ctx, ctx.getString(R.string.notice), ctx.getString(R.string.airplane_mode)) - } else if (ua.account.isMobile && !Utils.isDefaultSmsApp(ctx)) { + else if (ua.account.isMobile && !Utils.isDefaultSmsApp(ctx)) handleDialog(ctx, ctx.getString(R.string.notice), ctx.getString(R.string.enable_default_messaging)) - } else { + else { val intent = Intent(ctx, MainActivity::class.java) intent.putExtra("uap", ua.uap) intent.putExtra("peer", uri) @@ -705,27 +704,23 @@ private fun UrisSection( } } } + ) { + Icon( + imageVector = Icons.AutoMirrored.Filled.Chat, + contentDescription = "Send Message", + modifier = Modifier.size(24.dp), + tint = MaterialTheme.colorScheme.onBackground + ) } - ) { - Icon( - imageVector = Icons.AutoMirrored.Filled.Chat, - contentDescription = "Send Message", - tint = MaterialTheme.colorScheme.onBackground - ) - } // Call Button - IconButton( - onClick = { - val aor = viewModel.selectedAor.value - val ua = UserAgent.ofAor(aor) - if (ua == null) - Log.w(TAG, "Call clickable did not find AoR $aor") - else { - if (ua.account.isMobile && Utils.isAirplaneModeOn(ctx)) { + if (ua != null) + IconButton( + onClick = { + if (ua.account.isMobile && Utils.isAirplaneModeOn(ctx)) handleDialog(ctx, ctx.getString(R.string.notice), ctx.getString(R.string.airplane_mode)) - } else { + else { val intent = Intent(ctx, MainActivity::class.java) intent.putExtra("uap", ua.uap) intent.putExtra("peer", uri) @@ -736,14 +731,14 @@ private fun UrisSection( } } } + ) { + Icon( + imageVector = Icons.Filled.Call, + contentDescription = "Call", + modifier = Modifier.size(24.dp), + tint = MaterialTheme.colorScheme.onBackground + ) } - ) { - Icon( - imageVector = Icons.Outlined.Call, - contentDescription = "Call", - tint = MaterialTheme.colorScheme.onBackground - ) - } } } } diff --git a/app/src/main/kotlin/com/tutpro/baresip/MainScreen.kt b/app/src/main/kotlin/com/tutpro/baresip/MainScreen.kt index 62b526c5..595b24e7 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/MainScreen.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/MainScreen.kt @@ -2057,14 +2057,14 @@ private fun callClick(ctx: Context, viewModel: ViewModel, dialerState: ViewModel else String.format(ctx.getString(R.string.contact_no_sip_or_tel_uri), uriText) showAlert.value = true - } else { + } + else makeCall( ctx, viewModel, uriText, dialerState ) - } } else if (uris.size == 1) makeCall( diff --git a/app/src/main/kotlin/com/tutpro/baresip/MmsReceiver.kt b/app/src/main/kotlin/com/tutpro/baresip/MmsReceiver.kt index 93ca700f..05c8b887 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/MmsReceiver.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/MmsReceiver.kt @@ -16,13 +16,6 @@ class MmsReceiver : BroadcastReceiver() { val contentType = intent.type if (contentType == "application/vnd.wap.mms-message") { Log.d(TAG, "Received MMS WAP Push Deliver") - - // For a robust implementation, we'd need to parse the PDU. - // However, since we are the default SMS app, the OS will also - // save the MMS to the system provider. We can query it. - // Note: WAP_PUSH_DELIVER usually triggers before or during the save. - // We might need a small delay or use a ContentObserver if the query fails. - extractTextFromProvider(context) } }