show toast after failure to disable video

Daniel Gultsch created

Change summary

src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java | 11 ++
src/main/res/values/strings.xml                                 |  1 
2 files changed, 9 insertions(+), 3 deletions(-)

Detailed changes

src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java 🔗

@@ -1126,7 +1126,7 @@ public class RtpSessionActivity extends XmppActivity
                 MainThreadExecutor.getInstance());
     }
 
-    private void enableVideo(View view) {
+    private void enableVideo(final View view) {
         try {
             requireRtpConnection().setVideoEnabled(true);
         } catch (final IllegalStateException e) {
@@ -1136,14 +1136,19 @@ public class RtpSessionActivity extends XmppActivity
         updateInCallButtonConfigurationVideo(true, requireRtpConnection().isCameraSwitchable());
     }
 
-    private void disableVideo(View view) {
+    private void disableVideo(final View view) {
         final JingleRtpConnection rtpConnection = requireRtpConnection();
         final ContentAddition pending = rtpConnection.getPendingContentAddition();
         if (pending != null && pending.direction == ContentAddition.Direction.OUTGOING) {
             rtpConnection.retractContentAdd();
             return;
         }
-        requireRtpConnection().setVideoEnabled(false);
+        try {
+            requireRtpConnection().setVideoEnabled(false);
+        } catch (final IllegalStateException e) {
+            Toast.makeText(this, R.string.could_not_disable_video, Toast.LENGTH_SHORT).show();
+            return;
+        }
         updateInCallButtonConfigurationVideo(false, requireRtpConnection().isCameraSwitchable());
     }
 

src/main/res/values/strings.xml 🔗

@@ -992,6 +992,7 @@
     <string name="no_active_accounts_support_this">No active accounts support this feature</string>
     <string name="backup_started_message">The backup has been started. You’ll get a notification once it has been completed.</string>
     <string name="unable_to_enable_video">Unable to enable video.</string>
+    <string name="could_not_disable_video">Could not disable video.</string>
     <string name="plain_text_document">Plain text document</string>
     <string name="account_registrations_are_not_supported">Account registrations are not supported</string>
     <string name="no_xmpp_adddress_found">No XMPP address found</string>