Bläddra i källkod

Fix #389

Signed-off-by: Mario Danic <mario@lovelyhq.com>
Mario Danic 6 år sedan
förälder
incheckning
67b590d9d0

+ 23 - 6
app/src/main/java/com/nextcloud/talk/controllers/CallController.java

@@ -35,10 +35,7 @@ import android.view.LayoutInflater;
 import android.view.MotionEvent;
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
+import android.widget.*;
 import androidx.annotation.NonNull;
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 import androidx.annotation.Nullable;
 import androidx.appcompat.app.AppCompatActivity;
 import androidx.appcompat.app.AppCompatActivity;
@@ -98,6 +95,7 @@ import pub.devrel.easypermissions.AfterPermissionGranted;
 
 
 import javax.inject.Inject;
 import javax.inject.Inject;
 import java.io.IOException;
 import java.io.IOException;
+import java.lang.reflect.Field;
 import java.util.*;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeUnit;
 
 
@@ -268,6 +266,8 @@ public class CallController extends BaseController {
                 .setRepeatCount(PulseAnimation.INFINITE)
                 .setRepeatCount(PulseAnimation.INFINITE)
                 .setRepeatMode(PulseAnimation.REVERSE);
                 .setRepeatMode(PulseAnimation.REVERSE);
 
 
+        setPipVideoViewDimensions();
+
         try {
         try {
             cache.evictAll();
             cache.evictAll();
         } catch (IOException e) {
         } catch (IOException e) {
@@ -540,7 +540,6 @@ public class CallController extends BaseController {
             if (enumerator.isFrontFacing(deviceName)) {
             if (enumerator.isFrontFacing(deviceName)) {
                 Logging.d(TAG, "Creating front facing camera capturer.");
                 Logging.d(TAG, "Creating front facing camera capturer.");
                 VideoCapturer videoCapturer = enumerator.createCapturer(deviceName, null);
                 VideoCapturer videoCapturer = enumerator.createCapturer(deviceName, null);
-
                 if (videoCapturer != null) {
                 if (videoCapturer != null) {
                     pipVideoView.setMirror(true);
                     pipVideoView.setMirror(true);
                     return videoCapturer;
                     return videoCapturer;
@@ -1431,7 +1430,7 @@ public class CallController extends BaseController {
             videoCapturer.startCapture(1280, 720, 30);
             videoCapturer.startCapture(1280, 720, 30);
         }
         }
     }
     }
-
+    
     private void processUsersInRoom(List<HashMap<String, Object>> users) {
     private void processUsersInRoom(List<HashMap<String, Object>> users) {
         List<String> newSessions = new ArrayList<>();
         List<String> newSessions = new ArrayList<>();
         Set<String> oldSesssions = new HashSet<>();
         Set<String> oldSesssions = new HashSet<>();
@@ -1608,13 +1607,31 @@ public class CallController extends BaseController {
     public void onMessageEvent(ConfigurationChangeEvent configurationChangeEvent) {
     public void onMessageEvent(ConfigurationChangeEvent configurationChangeEvent) {
         powerManagerUtils.setOrientation(Objects.requireNonNull(getResources()).getConfiguration().orientation);
         powerManagerUtils.setOrientation(Objects.requireNonNull(getResources()).getConfiguration().orientation);
 
 
+
         if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
         if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
             remoteRenderersLayout.setOrientation(LinearLayout.HORIZONTAL);
             remoteRenderersLayout.setOrientation(LinearLayout.HORIZONTAL);
         } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
         } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
             remoteRenderersLayout.setOrientation(LinearLayout.VERTICAL);
             remoteRenderersLayout.setOrientation(LinearLayout.VERTICAL);
         }
         }
+
+        setPipVideoViewDimensions();
     }
     }
 
 
+    private void setPipVideoViewDimensions() {
+        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) pipVideoView.getLayoutParams();
+
+        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
+            remoteRenderersLayout.setOrientation(LinearLayout.HORIZONTAL);
+            layoutParams.height = (int) getResources().getDimension(R.dimen.large_preview_dimension);
+            layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
+            pipVideoView.setLayoutParams(layoutParams);
+        } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
+            remoteRenderersLayout.setOrientation(LinearLayout.VERTICAL);
+            layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT;
+            layoutParams.width = (int) getResources().getDimension(R.dimen.large_preview_dimension);
+            pipVideoView.setLayoutParams(layoutParams);
+        }
+    }
     @Subscribe(threadMode = ThreadMode.MAIN)
     @Subscribe(threadMode = ThreadMode.MAIN)
     public void onMessageEvent(PeerConnectionEvent peerConnectionEvent) {
     public void onMessageEvent(PeerConnectionEvent peerConnectionEvent) {
         if (peerConnectionEvent.getPeerConnectionEventType().equals(PeerConnectionEvent.PeerConnectionEventType
         if (peerConnectionEvent.getPeerConnectionEventType().equals(PeerConnectionEvent.PeerConnectionEventType

+ 2 - 3
app/src/main/res/layout/controller_call.xml

@@ -82,8 +82,8 @@
 
 
             <org.webrtc.SurfaceViewRenderer
             <org.webrtc.SurfaceViewRenderer
                 android:id="@+id/pip_video_view"
                 android:id="@+id/pip_video_view"
-                android:layout_width="120dp"
-                android:layout_height="120dp"
+                android:layout_width="@dimen/large_preview_dimension"
+                android:layout_height="wrap_content"
                 android:layout_gravity="center"
                 android:layout_gravity="center"
                 android:layout_margin="16dp"
                 android:layout_margin="16dp"
                 android:visibility="invisible" />
                 android:visibility="invisible" />
@@ -94,7 +94,6 @@
                 android:layout_height="40dp"
                 android:layout_height="40dp"
                 android:layout_gravity="center_horizontal|bottom"
                 android:layout_gravity="center_horizontal|bottom"
                 android:layout_marginBottom="20dp"
                 android:layout_marginBottom="20dp"
-
                 app:checked="false"
                 app:checked="false"
                 app:enableInitialAnimation="false"
                 app:enableInitialAnimation="false"
                 app:frontBackgroundColor="@color/colorPrimary"
                 app:frontBackgroundColor="@color/colorPrimary"

+ 1 - 0
app/src/main/res/values/dimens.xml

@@ -16,4 +16,5 @@
     <dimen name="chat_text_size">14sp</dimen>
     <dimen name="chat_text_size">14sp</dimen>
     <dimen name="message_bubble_corners_radius">6dp</dimen>
     <dimen name="message_bubble_corners_radius">6dp</dimen>
     <dimen name="message_bubble_corners_padding">8dp</dimen>
     <dimen name="message_bubble_corners_padding">8dp</dimen>
+    <dimen name="large_preview_dimension">120dp</dimen>
 </resources>
 </resources>