BIN
res/drawable-hdpi/ic_call_end_grey600_32dp.png
Normal file
After Width: | Height: | Size: 425 B |
BIN
res/drawable-hdpi/ic_close_grey600_32dp.png
Normal file
After Width: | Height: | Size: 256 B |
BIN
res/drawable-hdpi/ic_phone_grey600_32dp.png
Normal file
After Width: | Height: | Size: 457 B |
Before Width: | Height: | Size: 444 B |
BIN
res/drawable-mdpi/ic_call_end_grey600_32dp.png
Normal file
After Width: | Height: | Size: 313 B |
BIN
res/drawable-mdpi/ic_close_grey600_32dp.png
Normal file
After Width: | Height: | Size: 197 B |
BIN
res/drawable-mdpi/ic_phone_grey600_32dp.png
Normal file
After Width: | Height: | Size: 350 B |
Before Width: | Height: | Size: 346 B |
BIN
res/drawable-xhdpi/ic_call_end_grey600_32dp.png
Normal file
After Width: | Height: | Size: 557 B |
BIN
res/drawable-xhdpi/ic_close_grey600_32dp.png
Normal file
After Width: | Height: | Size: 307 B |
BIN
res/drawable-xhdpi/ic_phone_grey600_32dp.png
Normal file
After Width: | Height: | Size: 612 B |
Before Width: | Height: | Size: 536 B |
BIN
res/drawable-xxhdpi/ic_call_end_grey600_32dp.png
Normal file
After Width: | Height: | Size: 773 B |
BIN
res/drawable-xxhdpi/ic_close_grey600_32dp.png
Normal file
After Width: | Height: | Size: 411 B |
BIN
res/drawable-xxhdpi/ic_phone_grey600_32dp.png
Normal file
After Width: | Height: | Size: 863 B |
Before Width: | Height: | Size: 739 B |
BIN
res/drawable-xxxhdpi/ic_call_end_grey600_32dp.png
Normal file
After Width: | Height: | Size: 996 B |
BIN
res/drawable-xxxhdpi/ic_close_grey600_32dp.png
Normal file
After Width: | Height: | Size: 460 B |
BIN
res/drawable-xxxhdpi/ic_phone_grey600_32dp.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
@ -313,6 +313,12 @@
|
||||
<string name="NotificationBarManager_signal_call_in_progress">Signal call in progress</string>
|
||||
<string name="NotificationBarManager_missed_call_from_s">Missed call from %s</string>
|
||||
<string name="NotificationBarManager_missed_signal_call">Missed Signal call</string>
|
||||
<string name="NotificationBarManager__establishing_signal_call">Establishing Signal call</string>
|
||||
<string name="NotificationBarManager__incoming_signal_call">Incoming Signal call</string>
|
||||
<string name="NotificationBarManager__deny_call">Deny call</string>
|
||||
<string name="NotificationBarManager__answer_call">Answer call</string>
|
||||
<string name="NotificationBarManager__end_call">End call</string>
|
||||
<string name="NotificationBarManager__cancel_call">Cancel call</string>
|
||||
|
||||
<!-- NotificationMmsMessageRecord -->
|
||||
<string name="NotificationMmsMessageRecord_multimedia_message">Multimedia message</string>
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|