display status information in ui
This commit is contained in:
parent
a9a35fb74b
commit
0e88b56eb4
|
@ -32,6 +32,7 @@
|
|||
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
||||
|
||||
<uses-permission
|
||||
android:name="android.permission.READ_PHONE_STATE"
|
||||
|
|
|
@ -37,8 +37,13 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
|
|||
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
|
||||
super.onCreate(savedInstanceState);
|
||||
this.binding = DataBindingUtil.setContentView(this, R.layout.activity_rtp_session);
|
||||
this.binding.acceptCall.setOnClickListener(this::acceptCall);
|
||||
this.binding.rejectCall.setOnClickListener(this::rejectCall);
|
||||
this.binding.endCall.setOnClickListener(this::endCall);
|
||||
this.binding.acceptCall.setOnClickListener(this::acceptCall);
|
||||
}
|
||||
|
||||
private void endCall(View view) {
|
||||
requireRtpConnection().endCall();
|
||||
}
|
||||
|
||||
private void rejectCall(View view) {
|
||||
|
@ -70,11 +75,13 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
|
|||
}
|
||||
this.rtpConnectionReference = reference;
|
||||
binding.with.setText(getWith().getDisplayName());
|
||||
showState(requireRtpConnection().getEndUserState());
|
||||
final RtpEndUserState currentState = requireRtpConnection().getEndUserState();
|
||||
updateStateDisplay(currentState);
|
||||
updateButtonConfiguration(currentState);
|
||||
}
|
||||
}
|
||||
|
||||
private void showState(final RtpEndUserState state) {
|
||||
private void updateStateDisplay(final RtpEndUserState state) {
|
||||
switch (state) {
|
||||
case INCOMING_CALL:
|
||||
binding.status.setText(R.string.rtp_state_incoming_call);
|
||||
|
@ -88,6 +95,25 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
|
|||
case ACCEPTING_CALL:
|
||||
binding.status.setText(R.string.rtp_state_accepting_call);
|
||||
break;
|
||||
case ENDING_CALL:
|
||||
binding.status.setText(R.string.rtp_state_ending_call);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateButtonConfiguration(final RtpEndUserState state) {
|
||||
if (state == RtpEndUserState.INCOMING_CALL) {
|
||||
this.binding.rejectCall.show();
|
||||
this.binding.endCall.hide();
|
||||
this.binding.acceptCall.show();
|
||||
} else if (state == RtpEndUserState.ENDING_CALL) {
|
||||
this.binding.rejectCall.hide();
|
||||
this.binding.endCall.hide();
|
||||
this.binding.acceptCall.hide();
|
||||
} else {
|
||||
this.binding.rejectCall.hide();
|
||||
this.binding.endCall.show();
|
||||
this.binding.acceptCall.hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,7 +136,8 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
|
|||
final AbstractJingleConnection.Id id = requireRtpConnection().getId();
|
||||
if (account == id.account && id.with.equals(with)) {
|
||||
runOnUiThread(()->{
|
||||
showState(state);
|
||||
updateStateDisplay(state);
|
||||
updateButtonConfiguration(state);
|
||||
});
|
||||
} else {
|
||||
Log.d(Config.LOGTAG,"received update for other rtp session");
|
||||
|
|
|
@ -317,6 +317,8 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
|
|||
return RtpEndUserState.CONNECTED;
|
||||
} else if (state == PeerConnection.PeerConnectionState.NEW || state == PeerConnection.PeerConnectionState.CONNECTING) {
|
||||
return RtpEndUserState.CONNECTING;
|
||||
} else if (state == PeerConnection.PeerConnectionState.CLOSED) {
|
||||
return RtpEndUserState.ENDING_CALL;
|
||||
} else {
|
||||
return RtpEndUserState.FAILED;
|
||||
}
|
||||
|
@ -342,6 +344,14 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
|
|||
Log.d(Config.LOGTAG, "todo rejecting call");
|
||||
}
|
||||
|
||||
public void endCall() {
|
||||
if (isInState(State.SESSION_INITIALIZED, State.SESSION_ACCEPTED)) {
|
||||
webRTCWrapper.close();
|
||||
} else {
|
||||
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": called 'endCall' while in state " + this.state);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupWebRTC() {
|
||||
this.webRTCWrapper.setup(this.xmppConnectionService);
|
||||
this.webRTCWrapper.initializePeerConnection();
|
||||
|
@ -392,6 +402,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
|
|||
|
||||
@Override
|
||||
public void onConnectionChange(PeerConnection.PeerConnectionState newState) {
|
||||
Log.d(Config.LOGTAG,id.account.getJid().asBareJid()+": PeerConnectionState changed to "+newState);
|
||||
updateEndUserState();
|
||||
}
|
||||
|
||||
|
|
|
@ -8,5 +8,6 @@ public enum RtpEndUserState {
|
|||
RINGING, //'propose' has been sent out and it has been 184 acked
|
||||
ACCEPTED_ON_OTHER_DEVICE, //received 'accept' from one of our own devices
|
||||
ACCEPTING_CALL, //'proceed' message has been sent; but no session-initiate has been received
|
||||
ENDING_CALL, //libwebrt says 'closed' but session-terminate hasnt gone through
|
||||
FAILED //something went wrong. TODO needs more concrete error states
|
||||
}
|
||||
|
|
|
@ -200,6 +200,9 @@ public class WebRTCWrapper {
|
|||
this.peerConnection = peerConnection;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
requirePeerConnection().close();
|
||||
}
|
||||
|
||||
|
||||
public ListenableFuture<SessionDescription> createOffer() {
|
||||
|
@ -287,15 +290,19 @@ public class WebRTCWrapper {
|
|||
}
|
||||
|
||||
public void addIceCandidate(IceCandidate iceCandidate) {
|
||||
requirePeerConnection().addIceCandidate(iceCandidate);
|
||||
}
|
||||
|
||||
public PeerConnection.PeerConnectionState getState() {
|
||||
return requirePeerConnection().connectionState();
|
||||
}
|
||||
|
||||
private PeerConnection requirePeerConnection() {
|
||||
final PeerConnection peerConnection = this.peerConnection;
|
||||
if (peerConnection == null) {
|
||||
throw new IllegalStateException("initialize PeerConnection first");
|
||||
}
|
||||
peerConnection.addIceCandidate(iceCandidate);
|
||||
}
|
||||
|
||||
public PeerConnection.PeerConnectionState getState() {
|
||||
return this.peerConnection.connectionState();
|
||||
return peerConnection;
|
||||
}
|
||||
|
||||
private static abstract class SetSdpObserver implements SdpObserver {
|
||||
|
@ -329,6 +336,7 @@ public class WebRTCWrapper {
|
|||
|
||||
public interface EventCallback {
|
||||
void onIceCandidate(IceCandidate iceCandidate);
|
||||
|
||||
void onConnectionChange(PeerConnection.PeerConnectionState newState);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,22 @@
|
|||
app:backgroundTint="@color/red700"
|
||||
app:elevation="4dp"
|
||||
app:fabCustomSize="72dp"
|
||||
app:maxImageSize="36dp" />
|
||||
app:maxImageSize="36dp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/end_call"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:src="@drawable/ic_call_end_white_48dp"
|
||||
app:backgroundTint="@color/red700"
|
||||
app:elevation="4dp"
|
||||
app:fabCustomSize="72dp"
|
||||
app:maxImageSize="36dp"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/accept_call"
|
||||
|
@ -68,7 +83,9 @@
|
|||
app:backgroundTint="@color/green700"
|
||||
app:elevation="4dp"
|
||||
app:fabCustomSize="72dp"
|
||||
app:maxImageSize="36dp" />
|
||||
app:maxImageSize="36dp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"/>
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -889,6 +889,7 @@
|
|||
<string name="rtp_state_connecting">Connecting</string>
|
||||
<string name="rtp_state_connected">Connected</string>
|
||||
<string name="rtp_state_accepting_call">Accepting call</string>
|
||||
<string name="rtp_state_ending_call">Ending call</string>
|
||||
<plurals name="view_users">
|
||||
<item quantity="one">View %1$d Participant</item>
|
||||
<item quantity="other">View %1$d Participants</item>
|
||||
|
|
Loading…
Reference in New Issue