mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
show the Acccept Call notification button only at incoming ringing status
This commit is contained in:
parent
d64546e059
commit
4058fc3a4e
@ -231,6 +231,7 @@ class CallActivity : SimpleActivity() {
|
|||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
private fun setupNotification() {
|
private fun setupNotification() {
|
||||||
|
val callState = CallManager.getState()
|
||||||
val channelId = "simple_contacts_call"
|
val channelId = "simple_contacts_call"
|
||||||
if (isOreoPlus()) {
|
if (isOreoPlus()) {
|
||||||
val importance = NotificationManager.IMPORTANCE_DEFAULT
|
val importance = NotificationManager.IMPORTANCE_DEFAULT
|
||||||
@ -254,7 +255,7 @@ class CallActivity : SimpleActivity() {
|
|||||||
val declinePendingIntent = PendingIntent.getBroadcast(this, 1, declineCallIntent, PendingIntent.FLAG_CANCEL_CURRENT)
|
val declinePendingIntent = PendingIntent.getBroadcast(this, 1, declineCallIntent, PendingIntent.FLAG_CANCEL_CURRENT)
|
||||||
|
|
||||||
val callerName = if (callContact != null && callContact!!.name.isNotEmpty()) callContact!!.name else getString(R.string.unknown_caller)
|
val callerName = if (callContact != null && callContact!!.name.isNotEmpty()) callContact!!.name else getString(R.string.unknown_caller)
|
||||||
val contentTextId = when (CallManager.getState()) {
|
val contentTextId = when (callState) {
|
||||||
Call.STATE_RINGING -> R.string.is_calling
|
Call.STATE_RINGING -> R.string.is_calling
|
||||||
Call.STATE_DIALING -> R.string.dialing
|
Call.STATE_DIALING -> R.string.dialing
|
||||||
Call.STATE_DISCONNECTED -> R.string.call_ended
|
Call.STATE_DISCONNECTED -> R.string.call_ended
|
||||||
@ -264,7 +265,8 @@ class CallActivity : SimpleActivity() {
|
|||||||
|
|
||||||
val collapsedView = RemoteViews(packageName, R.layout.call_notification).apply {
|
val collapsedView = RemoteViews(packageName, R.layout.call_notification).apply {
|
||||||
setText(R.id.notification_caller_name, callerName)
|
setText(R.id.notification_caller_name, callerName)
|
||||||
setText(R.id.notification_caller_number, getString(contentTextId))
|
setText(R.id.notification_call_status, getString(contentTextId))
|
||||||
|
setVisibleIf(R.id.notification_accept_call, callState == Call.STATE_RINGING)
|
||||||
|
|
||||||
setOnClickPendingIntent(R.id.notification_decline_call, declinePendingIntent)
|
setOnClickPendingIntent(R.id.notification_decline_call, declinePendingIntent)
|
||||||
setOnClickPendingIntent(R.id.notification_accept_call, acceptPendingIntent)
|
setOnClickPendingIntent(R.id.notification_accept_call, acceptPendingIntent)
|
||||||
@ -281,7 +283,7 @@ class CallActivity : SimpleActivity() {
|
|||||||
.setCategory(Notification.CATEGORY_CALL)
|
.setCategory(Notification.CATEGORY_CALL)
|
||||||
.setCustomContentView(collapsedView)
|
.setCustomContentView(collapsedView)
|
||||||
.setOngoing(true)
|
.setOngoing(true)
|
||||||
.setUsesChronometer(CallManager.getState() == Call.STATE_ACTIVE)
|
.setUsesChronometer(callState == Call.STATE_ACTIVE)
|
||||||
.setChannelId(channelId)
|
.setChannelId(channelId)
|
||||||
.setStyle(NotificationCompat.DecoratedCustomViewStyle())
|
.setStyle(NotificationCompat.DecoratedCustomViewStyle())
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
tools:text="Caller name" />
|
tools:text="Caller name" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/notification_caller_number"
|
android:id="@+id/notification_call_status"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/notification_caller_name"
|
android:layout_below="@+id/notification_caller_name"
|
||||||
@ -34,7 +34,7 @@
|
|||||||
android:id="@+id/notification_actions_holder"
|
android:id="@+id/notification_actions_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/notification_caller_number"
|
android:layout_below="@+id/notification_call_status"
|
||||||
android:layout_marginTop="@dimen/activity_margin"
|
android:layout_marginTop="@dimen/activity_margin"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user