back button should not end call if call is connected. fixes #3975
This commit is contained in:
		
							parent
							
								
									bc97d0b0bb
								
							
						
					
					
						commit
						619af9c6c5
					
				| 
						 | 
					@ -537,6 +537,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected void onNewIntent(final Intent intent) {
 | 
					    protected void onNewIntent(final Intent intent) {
 | 
				
			||||||
 | 
					        super.onNewIntent(intent);
 | 
				
			||||||
        if (isViewOrShareIntent(intent)) {
 | 
					        if (isViewOrShareIntent(intent)) {
 | 
				
			||||||
            if (xmppConnectionService != null) {
 | 
					            if (xmppConnectionService != null) {
 | 
				
			||||||
                clearPendingViewIntent();
 | 
					                clearPendingViewIntent();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -458,19 +458,22 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void onBackPressed() {
 | 
					    public void onBackPressed() {
 | 
				
			||||||
        super.onBackPressed();
 | 
					        if (isConnected()) {
 | 
				
			||||||
 | 
					            if (switchToPictureInPicture()) {
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
            endCall();
 | 
					            endCall();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        super.onBackPressed();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void onUserLeaveHint() {
 | 
					    public void onUserLeaveHint() {
 | 
				
			||||||
        super.onUserLeaveHint();
 | 
					        super.onUserLeaveHint();
 | 
				
			||||||
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && deviceSupportsPictureInPicture()) {
 | 
					        if (switchToPictureInPicture()) {
 | 
				
			||||||
            if (shouldBePictureInPicture()) {
 | 
					 | 
				
			||||||
                startPictureInPicture();
 | 
					 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        //TODO apparently this method is not getting called on Android 10 when using the task switcher
 | 
					        //TODO apparently this method is not getting called on Android 10 when using the task switcher
 | 
				
			||||||
        final boolean emptyReference = rtpConnectionReference == null || rtpConnectionReference.get() == null;
 | 
					        final boolean emptyReference = rtpConnectionReference == null || rtpConnectionReference.get() == null;
 | 
				
			||||||
        if (emptyReference && xmppConnectionService != null) {
 | 
					        if (emptyReference && xmppConnectionService != null) {
 | 
				
			||||||
| 
						 | 
					@ -478,6 +481,21 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private boolean isConnected() {
 | 
				
			||||||
 | 
					        final JingleRtpConnection connection = this.rtpConnectionReference != null ? this.rtpConnectionReference.get() : null;
 | 
				
			||||||
 | 
					        return connection != null && connection.getEndUserState() == RtpEndUserState.CONNECTED;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private boolean switchToPictureInPicture() {
 | 
				
			||||||
 | 
					        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && deviceSupportsPictureInPicture()) {
 | 
				
			||||||
 | 
					            if (shouldBePictureInPicture()) {
 | 
				
			||||||
 | 
					                startPictureInPicture();
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @RequiresApi(api = Build.VERSION_CODES.O)
 | 
					    @RequiresApi(api = Build.VERSION_CODES.O)
 | 
				
			||||||
    private void startPictureInPicture() {
 | 
					    private void startPictureInPicture() {
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue