diff --git a/res/drawable-hdpi/ic_call_end_grey600_32dp.png b/res/drawable-hdpi/ic_call_end_grey600_32dp.png
new file mode 100644
index 0000000000..4aaf9cf732
Binary files /dev/null and b/res/drawable-hdpi/ic_call_end_grey600_32dp.png differ
diff --git a/res/drawable-hdpi/ic_close_grey600_32dp.png b/res/drawable-hdpi/ic_close_grey600_32dp.png
new file mode 100644
index 0000000000..7810e54fc5
Binary files /dev/null and b/res/drawable-hdpi/ic_close_grey600_32dp.png differ
diff --git a/res/drawable-hdpi/ic_phone_grey600_32dp.png b/res/drawable-hdpi/ic_phone_grey600_32dp.png
new file mode 100644
index 0000000000..6059ede3c6
Binary files /dev/null and b/res/drawable-hdpi/ic_phone_grey600_32dp.png differ
diff --git a/res/drawable-hdpi/redphone_stat_sys_phone_call.png b/res/drawable-hdpi/redphone_stat_sys_phone_call.png
deleted file mode 100644
index 955075ce99..0000000000
Binary files a/res/drawable-hdpi/redphone_stat_sys_phone_call.png and /dev/null differ
diff --git a/res/drawable-mdpi/ic_call_end_grey600_32dp.png b/res/drawable-mdpi/ic_call_end_grey600_32dp.png
new file mode 100644
index 0000000000..ce1b386c36
Binary files /dev/null and b/res/drawable-mdpi/ic_call_end_grey600_32dp.png differ
diff --git a/res/drawable-mdpi/ic_close_grey600_32dp.png b/res/drawable-mdpi/ic_close_grey600_32dp.png
new file mode 100644
index 0000000000..9148357609
Binary files /dev/null and b/res/drawable-mdpi/ic_close_grey600_32dp.png differ
diff --git a/res/drawable-mdpi/ic_phone_grey600_32dp.png b/res/drawable-mdpi/ic_phone_grey600_32dp.png
new file mode 100644
index 0000000000..73de3a8822
Binary files /dev/null and b/res/drawable-mdpi/ic_phone_grey600_32dp.png differ
diff --git a/res/drawable-mdpi/redphone_stat_sys_phone_call.png b/res/drawable-mdpi/redphone_stat_sys_phone_call.png
deleted file mode 100644
index bc0e4a3ab9..0000000000
Binary files a/res/drawable-mdpi/redphone_stat_sys_phone_call.png and /dev/null differ
diff --git a/res/drawable-xhdpi/ic_call_end_grey600_32dp.png b/res/drawable-xhdpi/ic_call_end_grey600_32dp.png
new file mode 100644
index 0000000000..fb35213050
Binary files /dev/null and b/res/drawable-xhdpi/ic_call_end_grey600_32dp.png differ
diff --git a/res/drawable-xhdpi/ic_close_grey600_32dp.png b/res/drawable-xhdpi/ic_close_grey600_32dp.png
new file mode 100644
index 0000000000..86edcc1a8a
Binary files /dev/null and b/res/drawable-xhdpi/ic_close_grey600_32dp.png differ
diff --git a/res/drawable-xhdpi/ic_phone_grey600_32dp.png b/res/drawable-xhdpi/ic_phone_grey600_32dp.png
new file mode 100644
index 0000000000..1a2aa8d680
Binary files /dev/null and b/res/drawable-xhdpi/ic_phone_grey600_32dp.png differ
diff --git a/res/drawable-xhdpi/redphone_stat_sys_phone_call.png b/res/drawable-xhdpi/redphone_stat_sys_phone_call.png
deleted file mode 100644
index cc0613bef7..0000000000
Binary files a/res/drawable-xhdpi/redphone_stat_sys_phone_call.png and /dev/null differ
diff --git a/res/drawable-xxhdpi/ic_call_end_grey600_32dp.png b/res/drawable-xxhdpi/ic_call_end_grey600_32dp.png
new file mode 100644
index 0000000000..8286d0d296
Binary files /dev/null and b/res/drawable-xxhdpi/ic_call_end_grey600_32dp.png differ
diff --git a/res/drawable-xxhdpi/ic_close_grey600_32dp.png b/res/drawable-xxhdpi/ic_close_grey600_32dp.png
new file mode 100644
index 0000000000..fc507f758e
Binary files /dev/null and b/res/drawable-xxhdpi/ic_close_grey600_32dp.png differ
diff --git a/res/drawable-xxhdpi/ic_phone_grey600_32dp.png b/res/drawable-xxhdpi/ic_phone_grey600_32dp.png
new file mode 100644
index 0000000000..f32384b7ee
Binary files /dev/null and b/res/drawable-xxhdpi/ic_phone_grey600_32dp.png differ
diff --git a/res/drawable-xxhdpi/redphone_stat_sys_phone_call.png b/res/drawable-xxhdpi/redphone_stat_sys_phone_call.png
deleted file mode 100644
index cc989f2519..0000000000
Binary files a/res/drawable-xxhdpi/redphone_stat_sys_phone_call.png and /dev/null differ
diff --git a/res/drawable-xxxhdpi/ic_call_end_grey600_32dp.png b/res/drawable-xxxhdpi/ic_call_end_grey600_32dp.png
new file mode 100644
index 0000000000..542871bdb5
Binary files /dev/null and b/res/drawable-xxxhdpi/ic_call_end_grey600_32dp.png differ
diff --git a/res/drawable-xxxhdpi/ic_close_grey600_32dp.png b/res/drawable-xxxhdpi/ic_close_grey600_32dp.png
new file mode 100644
index 0000000000..40e95b63a1
Binary files /dev/null and b/res/drawable-xxxhdpi/ic_close_grey600_32dp.png differ
diff --git a/res/drawable-xxxhdpi/ic_phone_grey600_32dp.png b/res/drawable-xxxhdpi/ic_phone_grey600_32dp.png
new file mode 100644
index 0000000000..630384d91a
Binary files /dev/null and b/res/drawable-xxxhdpi/ic_phone_grey600_32dp.png differ
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 716e81c2df..110e158f3b 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -313,6 +313,12 @@
Signal call in progress
Missed call from %s
Missed Signal call
+ Establishing Signal call
+ Incoming Signal call
+ Deny call
+ Answer call
+ End call
+ Cancel call
Multimedia message
diff --git a/src/org/thoughtcrime/redphone/RedPhone.java b/src/org/thoughtcrime/redphone/RedPhone.java
index e196cb5a2f..d5b9ecbd99 100644
--- a/src/org/thoughtcrime/redphone/RedPhone.java
+++ b/src/org/thoughtcrime/redphone/RedPhone.java
@@ -61,6 +61,10 @@ public class RedPhone extends Activity {
private static final int STANDARD_DELAY_FINISH = 1000;
public static final int BUSY_SIGNAL_DELAY_FINISH = 5500;
+ public static final String ANSWER_ACTION = RedPhone.class.getCanonicalName() + ".ANSWER_ACTION";
+ public static final String DENY_ACTION = RedPhone.class.getCanonicalName() + ".DENY_ACTION";
+ public static final String END_CALL_ACTION = RedPhone.class.getCanonicalName() + ".END_CALL_ACTION";
+
private CallScreen callScreen;
private BroadcastReceiver bluetoothStateReceiver;
@@ -87,6 +91,16 @@ public class RedPhone extends Activity {
registerBluetoothReceiver();
}
+ @Override
+ public void onNewIntent(Intent intent){
+ if (ANSWER_ACTION.equals(intent.getAction())) {
+ handleAnswerCall();
+ } else if (DENY_ACTION.equals(intent.getAction())) {
+ handleDenyCall();
+ } else if (END_CALL_ACTION.equals(intent.getAction())) {
+ handleEndCall();
+ }
+ }
@Override
public void onPause() {
@@ -151,6 +165,19 @@ public class RedPhone extends Activity {
}
}
+ private void handleEndCall() {
+ Log.w(TAG, "Hangup pressed, handling termination now...");
+ Intent intent = new Intent(RedPhone.this, RedPhoneService.class);
+ intent.setAction(RedPhoneService.ACTION_HANGUP_CALL);
+ startService(intent);
+
+ RedPhoneEvent event = EventBus.getDefault().getStickyEvent(RedPhoneEvent.class);
+
+ if (event != null) {
+ RedPhone.this.handleTerminate(event.getRecipient());
+ }
+ }
+
private void handleIncomingCall(@NonNull RedPhoneEvent event) {
callScreen.setIncomingCall(event.getRecipient());
}
@@ -303,16 +330,7 @@ public class RedPhone extends Activity {
private class HangupButtonListener implements CallControls.HangupButtonListener {
public void onClick() {
- Log.w(TAG, "Hangup pressed, handling termination now...");
- Intent intent = new Intent(RedPhone.this, RedPhoneService.class);
- intent.setAction(RedPhoneService.ACTION_HANGUP_CALL);
- startService(intent);
-
- RedPhoneEvent event = EventBus.getDefault().getStickyEvent(RedPhoneEvent.class);
-
- if (event != null) {
- RedPhone.this.handleTerminate(event.getRecipient());
- }
+ handleEndCall();
}
}
diff --git a/src/org/thoughtcrime/redphone/RedPhoneService.java b/src/org/thoughtcrime/redphone/RedPhoneService.java
index bd493c45b2..7027988163 100644
--- a/src/org/thoughtcrime/redphone/RedPhoneService.java
+++ b/src/org/thoughtcrime/redphone/RedPhoneService.java
@@ -204,7 +204,8 @@ public class RedPhoneService extends Service implements CallStateListener, CallS
if (remoteNumber == null || remoteNumber.length() == 0)
return;
- sendMessage(Type.OUTGOING_CALL, getRecipient(), null);
+ Recipient recipient = getRecipient();
+ sendMessage(Type.OUTGOING_CALL, recipient, null);
state = STATE_DIALING;
lockManager.updatePhoneState(LockManager.PhoneState.INTERACTIVE);
@@ -212,7 +213,7 @@ public class RedPhoneService extends Service implements CallStateListener, CallS
remoteNumber, zid);
this.currentCallManager.start();
- NotificationBarManager.setCallInProgress(this);
+ NotificationBarManager.setCallInProgress(this, NotificationBarManager.TYPE_OUTGOING_RINGING, recipient);
DatabaseFactory.getSmsDatabase(this).insertOutgoingCall(remoteNumber);
}
@@ -389,7 +390,7 @@ public class RedPhoneService extends Service implements CallStateListener, CallS
startCallCardActivity();
incomingRinger.start();
- NotificationBarManager.setCallInProgress(this);
+ NotificationBarManager.setCallInProgress(this, NotificationBarManager.TYPE_INCOMING_RINGING, getRecipient());
}
public void notifyBusy() {
@@ -414,7 +415,10 @@ public class RedPhoneService extends Service implements CallStateListener, CallS
outgoingRinger.playComplete();
lockManager.updatePhoneState(LockManager.PhoneState.IN_CALL);
state = STATE_CONNECTED;
- sendMessage(Type.CALL_CONNECTED, getRecipient(), sas.getSasText());
+ Recipient recipient = getRecipient();
+ sendMessage(Type.CALL_CONNECTED, recipient, sas.getSasText());
+
+ NotificationBarManager.setCallInProgress(this, NotificationBarManager.TYPE_ESTABLISHED, recipient);
}
public void notifyConnectingtoInitiator() {
diff --git a/src/org/thoughtcrime/redphone/ui/NotificationBarManager.java b/src/org/thoughtcrime/redphone/ui/NotificationBarManager.java
index 30c304c307..f89755eb09 100644
--- a/src/org/thoughtcrime/redphone/ui/NotificationBarManager.java
+++ b/src/org/thoughtcrime/redphone/ui/NotificationBarManager.java
@@ -17,20 +17,15 @@
package org.thoughtcrime.redphone.ui;
-import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
-import android.net.Uri;
import android.support.v4.app.NotificationCompat;
import org.thoughtcrime.redphone.RedPhone;
-import org.thoughtcrime.securesms.ConversationActivity;
import org.thoughtcrime.securesms.R;
-import org.thoughtcrime.securesms.database.DatabaseFactory;
-import org.thoughtcrime.securesms.recipients.RecipientFactory;
-import org.thoughtcrime.securesms.recipients.Recipients;
+import org.thoughtcrime.securesms.recipients.Recipient;
/**
* Manages the state of the RedPhone items in the Android notification bar.
@@ -44,6 +39,10 @@ public class NotificationBarManager {
private static final int RED_PHONE_NOTIFICATION = 313388;
private static final int MISSED_CALL_NOTIFICATION = 313389;
+ public static final int TYPE_INCOMING_RINGING = 1;
+ public static final int TYPE_OUTGOING_RINGING = 2;
+ public static final int TYPE_ESTABLISHED = 3;
+
public static void setCallEnded(Context context) {
NotificationManager notificationManager = (NotificationManager)context
.getSystemService(Context.NOTIFICATION_SERVICE);
@@ -51,20 +50,40 @@ public class NotificationBarManager {
notificationManager.cancel(RED_PHONE_NOTIFICATION);
}
- public static void setCallInProgress(Context context) {
+ public static void setCallInProgress(Context context, int type, Recipient recipient) {
NotificationManager notificationManager = (NotificationManager)context
.getSystemService(Context.NOTIFICATION_SERVICE);
Intent contentIntent = new Intent(context, RedPhone.class);
contentIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, contentIntent, 0);
- String notificationText = context.getString(R.string.NotificationBarManager_signal_call_in_progress);
- Notification notification = new Notification(R.drawable.redphone_stat_sys_phone_call, null,
- System.currentTimeMillis());
- notification.setLatestEventInfo(context, notificationText, notificationText, pendingIntent);
- notification.flags = Notification.FLAG_NO_CLEAR;
- notificationManager.notify(RED_PHONE_NOTIFICATION, notification);
+ NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
+ .setSmallIcon(R.drawable.ic_call_secure_white_24dp)
+ .setContentIntent(pendingIntent)
+ .setOngoing(true)
+ .setContentTitle(recipient.getName());
+
+ if (type == TYPE_INCOMING_RINGING) {
+ builder.setContentText(context.getString(R.string.NotificationBarManager__incoming_signal_call));
+ builder.addAction(getNotificationAction(context, RedPhone.DENY_ACTION, R.drawable.ic_close_grey600_32dp, R.string.NotificationBarManager__deny_call));
+ builder.addAction(getNotificationAction(context, RedPhone.ANSWER_ACTION, R.drawable.ic_phone_grey600_32dp, R.string.NotificationBarManager__answer_call));
+ } else if (type == TYPE_OUTGOING_RINGING) {
+ builder.setContentText(context.getString(R.string.NotificationBarManager__establishing_signal_call));
+ builder.addAction(getNotificationAction(context, RedPhone.END_CALL_ACTION, R.drawable.ic_call_end_grey600_32dp, R.string.NotificationBarManager__cancel_call));
+ } else {
+ builder.setContentText(context.getString(R.string.NotificationBarManager_signal_call_in_progress));
+ builder.addAction(getNotificationAction(context, RedPhone.END_CALL_ACTION, R.drawable.ic_call_end_grey600_32dp, R.string.NotificationBarManager__end_call));
+ }
+
+ notificationManager.notify(RED_PHONE_NOTIFICATION, builder.build());
+ }
+
+ private static NotificationCompat.Action getNotificationAction(Context context, String action, int iconResId, int titleResId) {
+ Intent intent = new Intent(context, RedPhone.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
+ intent.setAction(action);
+ PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
+ return new NotificationCompat.Action(iconResId, context.getString(titleResId), pendingIntent);
}
-
}