Browse Source

Refactor intent creation

Signed-off-by: Mario Danic <mario@lovelyhq.com>
Mario Danic 7 năm trước cách đây
mục cha
commit
719c81d4a6

+ 18 - 9
app/src/main/java/com/nextcloud/talk/controllers/ChatController.java

@@ -441,17 +441,10 @@ public class ChatController extends BaseController implements MessagesListAdapte
                 return true;
                 return true;
 
 
             case R.id.conversation_video_call:
             case R.id.conversation_video_call:
-                Bundle bundle = new Bundle();
-                bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomToken);
-                bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, Parcels.wrap(currentUser));
-                bundle.putString(BundleKeys.KEY_CALL_SESSION, currentCall.getSessionId());
-
-                Intent callIntent = new Intent(getActivity(), CallActivity.class);
-                callIntent.putExtras(bundle);
-
-                startActivity(callIntent);
+                startActivity(getIntentForCall(false));
                 return true;
                 return true;
             case R.id.conversation_voice_call:
             case R.id.conversation_voice_call:
+                startActivity(getIntentForCall(true));
                 return true;
                 return true;
 
 
             default:
             default:
@@ -459,6 +452,22 @@ public class ChatController extends BaseController implements MessagesListAdapte
         }
         }
     }
     }
 
 
+    private Intent getIntentForCall(boolean isVoiceOnlyCall) {
+        Bundle bundle = new Bundle();
+        bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomToken);
+        bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, Parcels.wrap(currentUser));
+        bundle.putString(BundleKeys.KEY_CALL_SESSION, currentCall.getSessionId());
+
+        if (isVoiceOnlyCall) {
+            bundle.putBoolean(BundleKeys.KEY_CALL_VOICE_ONLY, true);
+        }
+
+        Intent callIntent = new Intent(getActivity(), CallActivity.class);
+        callIntent.putExtras(bundle);
+
+        return callIntent;
+    }
+
     @Override
     @Override
     public void onSelectionChanged(int count) {
     public void onSelectionChanged(int count) {
         //globalMenu.findItem(R.id.action_delete).setVisible(count > 0);
         //globalMenu.findItem(R.id.action_delete).setVisible(count > 0);

+ 1 - 0
app/src/main/java/com/nextcloud/talk/utils/bundle/BundleKeys.java

@@ -47,4 +47,5 @@ public class BundleKeys {
     public static final String KEY_INVITED_PARTICIPANTS = "KEY_INVITED_PARTICIPANTS";
     public static final String KEY_INVITED_PARTICIPANTS = "KEY_INVITED_PARTICIPANTS";
     public static final String KEY_CONVERSATION_NAME = "KEY_CONVERSATION_NAME";
     public static final String KEY_CONVERSATION_NAME = "KEY_CONVERSATION_NAME";
     public static final String KEY_ROOM_PASSWORD = "KEY_ROOM_PASSWORD";
     public static final String KEY_ROOM_PASSWORD = "KEY_ROOM_PASSWORD";
+    public static final String KEY_CALL_VOICE_ONLY = "KEY_CALL_VOICE_ONLY";
 }
 }