Эх сурвалжийг харах

Fix #242

Signed-off-by: Mario Danic <mario@lovelyhq.com>
Mario Danic 6 жил өмнө
parent
commit
2664528660

+ 35 - 11
app/src/main/java/com/nextcloud/talk/controllers/CallController.java

@@ -225,7 +225,8 @@ public class CallController extends BaseController {
 
     private boolean isVoiceOnlyCall;
     private boolean isFromNotification;
-    private Handler handler = new Handler();
+    private Handler callControlHandler = new Handler();
+    private Handler cameraSwitchHandler = new Handler();
 
     private boolean isPTTActive = false;
     private PulseAnimation pulseAnimation;
@@ -587,9 +588,11 @@ public class CallController extends BaseController {
     @OnLongClick(R.id.call_control_microphone)
     public boolean onMicrophoneLongClick() {
         if (!audioOn) {
-            handler.removeCallbacksAndMessages(null);
+            callControlHandler.removeCallbacksAndMessages(null);
+            cameraSwitchHandler.removeCallbacksAndMessages(null);
             isPTTActive = true;
             callControls.setVisibility(View.VISIBLE);
+            cameraSwitchButton.setVisibility(View.VISIBLE);
         }
 
         onMicrophoneClick();
@@ -791,20 +794,18 @@ public class CallController extends BaseController {
             long duration;
 
             if (show) {
-                handler.removeCallbacksAndMessages(null);
+                callControlHandler.removeCallbacksAndMessages(null);
+                cameraSwitchHandler.removeCallbacksAndMessages(null);
                 alpha = 1.0f;
                 duration = 1000;
                 if (callControls.getVisibility() != View.VISIBLE) {
                     callControls.setAlpha(0.0f);
                     callControls.setVisibility(View.VISIBLE);
-                } else {
-                    handler.postDelayed(new Runnable() {
-                        @Override
-                        public void run() {
-                            animateCallControls(false, 0);
 
-                        }
-                    }, 5000);
+                    cameraSwitchButton.setAlpha(0.0f);
+                    cameraSwitchButton.setVisibility(View.VISIBLE);
+                } else {
+                    callControlHandler.postDelayed(() -> animateCallControls(false, 0), 5000);
                     return;
                 }
             } else {
@@ -830,7 +831,7 @@ public class CallController extends BaseController {
                                             spotlightView.setVisibility(View.GONE);
                                         }
                                     } else {
-                                        handler.postDelayed(new Runnable() {
+                                        callControlHandler.postDelayed(new Runnable() {
                                             @Override
                                             public void run() {
                                                 if (!isPTTActive) {
@@ -845,6 +846,29 @@ public class CallController extends BaseController {
                             }
                         });
             }
+
+            if (cameraSwitchButton != null) {
+                cameraSwitchButton.setEnabled(false);
+                cameraSwitchButton.animate()
+                        .translationY(0)
+                        .alpha(alpha)
+                        .setDuration(duration)
+                        .setStartDelay(startDelay)
+                        .setListener(new AnimatorListenerAdapter() {
+                            @Override
+                            public void onAnimationEnd(Animator animation) {
+                                super.onAnimationEnd(animation);
+                                if (cameraSwitchButton != null) {
+                                    if (!show) {
+                                        cameraSwitchButton.setVisibility(View.GONE);
+                                    }
+
+                                    cameraSwitchButton.setEnabled(true);
+                                }
+                            }
+                        });
+            }
+
         }
     }
 

+ 32 - 26
app/src/main/res/layout/controller_call.xml

@@ -74,14 +74,33 @@
             android:orientation="vertical">
         </LinearLayout>
 
-        <org.webrtc.SurfaceViewRenderer
-            android:id="@+id/pip_video_view"
-            android:layout_width="120dp"
-            android:layout_height="120dp"
-            android:layout_alignParentEnd="true"
+        <FrameLayout
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
             android:layout_alignParentTop="true"
-            android:layout_margin="16dp"
-            android:visibility="invisible"/>
+            android:layout_alignParentEnd="true">
+
+            <org.webrtc.SurfaceViewRenderer
+                android:id="@+id/pip_video_view"
+                android:layout_width="120dp"
+                android:layout_height="120dp"
+                android:layout_gravity="center"
+                android:layout_margin="16dp"
+                android:visibility="invisible"/>
+
+            <com.nextcloud.talk.utils.MagicFlipView
+                xmlns:app="http://schemas.android.com/apk/res-auto"
+                android:id="@+id/call_control_switch_camera"
+                android:layout_width="40dp"
+                android:layout_height="40dp"
+                android:layout_marginBottom="20dp"
+                android:layout_gravity="center_horizontal|bottom"
+
+                app:checked="false"
+                app:enableInitialAnimation="false"
+                app:frontBackgroundColor="@color/colorPrimary"
+                app:frontImage="@drawable/ic_switch_video_white_24px"/>
+        </FrameLayout>
     </RelativeLayout>
 
     <LinearLayout
@@ -109,44 +128,31 @@
 
         <com.nextcloud.talk.utils.MagicFlipView
             xmlns:app="http://schemas.android.com/apk/res-auto"
-            android:id="@+id/call_control_camera"
+            android:id="@+id/callControlHangupView"
             android:layout_width="60dp"
             android:layout_height="60dp"
             android:layout_marginEnd="20dp"
-            android:alpha="0.7"
             app:checked="false"
             app:enableInitialAnimation="false"
-            app:frontBackgroundColor="@color/colorPrimary"
-            app:frontImage="@drawable/ic_videocam_off_white_24px"/>
+            app:frontBackgroundColor="@color/nc_darkRed"
+            app:frontImage="@drawable/ic_call_end_white_24px"/>
 
         <com.nextcloud.talk.utils.MagicFlipView
             xmlns:app="http://schemas.android.com/apk/res-auto"
-            android:id="@+id/call_control_switch_camera"
+            android:id="@+id/call_control_camera"
             android:layout_width="60dp"
             android:layout_height="60dp"
-            android:layout_marginEnd="20dp"
-            android:visibility="gone"
+            android:alpha="0.7"
             app:checked="false"
             app:enableInitialAnimation="false"
             app:frontBackgroundColor="@color/colorPrimary"
-            app:frontImage="@drawable/ic_switch_video_white_24px"/>
-
-        <com.nextcloud.talk.utils.MagicFlipView
-            xmlns:app="http://schemas.android.com/apk/res-auto"
-            android:id="@+id/callControlHangupView"
-            android:layout_width="60dp"
-            android:layout_height="60dp"
-            app:checked="false"
-            app:enableInitialAnimation="false"
-            app:frontBackgroundColor="@color/nc_darkRed"
-            app:frontImage="@drawable/ic_call_end_white_24px"/>
+            app:frontImage="@drawable/ic_videocam_off_white_24px"/>
 
         <com.nextcloud.talk.utils.MagicFlipView
             xmlns:app="http://schemas.android.com/apk/res-auto"
             android:id="@+id/callControlEnableSpeaker"
             android:layout_width="60dp"
             android:layout_height="60dp"
-            android:layout_marginStart="20dp"
             app:checked="false"
             android:visibility="gone"
             app:enableInitialAnimation="false"

+ 7 - 7
app/src/main/res/layout/controller_call_notification.xml

@@ -89,25 +89,25 @@
             app:frontImage="@drawable/ic_mic_white_24px"/>
 
         <com.nextcloud.talk.utils.MagicFlipView
-            android:id="@+id/callAnswerCameraView"
+            android:id="@+id/callControlHangupView"
             android:layout_width="60dp"
             android:layout_height="60dp"
             android:layout_margin="24dp"
-            android:visibility="gone"
             app:checked="false"
             app:enableInitialAnimation="false"
-            app:frontBackgroundColor="@color/colorPrimary"
-            app:frontImage="@drawable/ic_videocam_white_24px"/>
+            app:frontBackgroundColor="@color/nc_darkRed"
+            app:frontImage="@drawable/ic_call_end_white_24px"/>
 
         <com.nextcloud.talk.utils.MagicFlipView
-            android:id="@+id/callControlHangupView"
+            android:id="@+id/callAnswerCameraView"
             android:layout_width="60dp"
             android:layout_height="60dp"
             android:layout_margin="24dp"
+            android:visibility="gone"
             app:checked="false"
             app:enableInitialAnimation="false"
-            app:frontBackgroundColor="@color/nc_darkRed"
-            app:frontImage="@drawable/ic_call_end_white_24px"/>
+            app:frontBackgroundColor="@color/colorPrimary"
+            app:frontImage="@drawable/ic_videocam_white_24px"/>
     </LinearLayout>
 
 </android.support.constraint.ConstraintLayout>