diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b3305793..be0ded5d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -12,6 +12,7 @@ + { val state = intent.getIntExtra(BluetoothHeadset.EXTRA_STATE, - BluetoothHeadset.STATE_AUDIO_DISCONNECTED) + BluetoothHeadset.STATE_AUDIO_DISCONNECTED) when (state) { BluetoothHeadset.STATE_AUDIO_CONNECTED -> { Log.d(LOG_TAG, "Bluetooth headset audio is connected") @@ -255,8 +261,9 @@ class BaresipService: Service() { val dnsServers = Utils.findDnsServers(BaresipService.dnsServers) if ((ipV4Addr == "") && (ipV6Addr == "")) Log.w(LOG_TAG, "Starting baresip without IP addresses") - Thread(Runnable { baresipStart(filesPath, ipV4Addr, ipV6Addr, "", - dnsServers, Api.AF_UNSPEC, logLevel) + Thread(Runnable { + baresipStart(filesPath, ipV4Addr, ipV6Addr, "", + dnsServers, Api.AF_UNSPEC, logLevel) }).start() isServiceRunning = true @@ -564,6 +571,8 @@ class BaresipService: Service() { .setOngoing(true) .setContentTitle(getString(R.string.incoming_call_from)) .setContentText(caller) + .setShowWhen(true) + .setFullScreenIntent(pi, true) if (Build.VERSION.SDK_INT < 26) { nb.setVibrate(LongArray(0)) .setVisibility(NotificationCompat.VISIBILITY_PRIVATE) @@ -579,8 +588,12 @@ class BaresipService: Service() { rejectIntent.putExtra("callp", callp) val rejectPendingIntent = PendingIntent.getService(this, REJECT_REQ_CODE, rejectIntent, PendingIntent.FLAG_UPDATE_CURRENT) - nb.addAction(R.drawable.ic_stat, getString(R.string.answer), answerPendingIntent) - nb.addAction(R.drawable.ic_stat, getString(R.string.reject), rejectPendingIntent) + nb.addAction(R.drawable.ic_stat, + getActionText(R.string.answer, R.color.colorGreen), + answerPendingIntent) + nb.addAction(R.drawable.ic_stat, + getActionText(R.string.reject, R.color.colorRed), + rejectPendingIntent) nm.notify(CALL_NOTIFICATION_ID, nb.build()) return } @@ -904,7 +917,15 @@ class BaresipService: Service() { nm.notify(STATUS_NOTIFICATION_ID, snb.build()) } - + private fun getActionText(@StringRes stringRes: Int, @ColorRes colorRes: Int): Spannable? { + val spannable: Spannable = SpannableString(applicationContext.getText(stringRes)) + if (VERSION.SDK_INT >= VERSION_CODES.N_MR1) { + spannable.setSpan( + ForegroundColorSpan(applicationContext.getColor(colorRes)), + 0, spannable.length, 0) + } + return spannable + } private fun requestAudioFocus(usage: Int) { if (audioFocusUsage != -1) { diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index aaf8bfd0..6a44c9fa 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -12,4 +12,5 @@ #0ca1fd #ffffff #01df01 + #df0101 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0f23a9f9..17336a91 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -186,7 +186,7 @@ Answer Reject - Call from + Incoming call from Missed call from Call transfer request to Message from