浏览代码

fix to hide selfVideo when pip-view is tapped

on some devices (reproduced with Pixel2 on api level30) the own video became visible when the pip view was tapped. This fix should hide the own video.

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Marcel Hibbe 3 年之前
父节点
当前提交
f9a28cb0aa
共有 1 个文件被更改,包括 34 次插入24 次删除
  1. 34 24
      app/src/main/java/com/nextcloud/talk/activities/CallActivity.java

+ 34 - 24
app/src/main/java/com/nextcloud/talk/activities/CallActivity.java

@@ -269,6 +269,7 @@ public class CallActivity extends BaseActivity {
     @Override
     @Override
     public void onCreate(Bundle savedInstanceState) {
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         super.onCreate(savedInstanceState);
+        Log.d(TAG, "onCreate");
 
 
         NextcloudTalkApplication.Companion.getSharedApplication().getComponentApplication().inject(this);
         NextcloudTalkApplication.Companion.getSharedApplication().getComponentApplication().inject(this);
 
 
@@ -511,6 +512,7 @@ public class CallActivity extends BaseActivity {
 
 
     @SuppressLint("ClickableViewAccessibility")
     @SuppressLint("ClickableViewAccessibility")
     private void initViews() {
     private void initViews() {
+        Log.d(TAG, "initViews");
         binding.callInfosLinearLayout.setVisibility(View.VISIBLE);
         binding.callInfosLinearLayout.setVisibility(View.VISIBLE);
         binding.selfVideoViewWrapper.setVisibility(View.VISIBLE);
         binding.selfVideoViewWrapper.setVisibility(View.VISIBLE);
 
 
@@ -574,6 +576,7 @@ public class CallActivity extends BaseActivity {
     }
     }
 
 
     private void initGridAdapter() {
     private void initGridAdapter() {
+        Log.d(TAG, "initGridAdapter");
         int columns;
         int columns;
         int participantsInGrid = participantDisplayItems.size();
         int participantsInGrid = participantDisplayItems.size();
         if (getResources() != null && getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
         if (getResources() != null && getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
@@ -1894,36 +1897,39 @@ public class CallActivity extends BaseActivity {
     }
     }
 
 
     private void updateSelfVideoViewPosition() {
     private void updateSelfVideoViewPosition() {
-        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) binding.selfVideoRenderer.getLayoutParams();
+        Log.d(TAG, "updateSelfVideoViewPosition");
+        if (!isInPipMode) {
+            FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) binding.selfVideoRenderer.getLayoutParams();
 
 
-        DisplayMetrics displayMetrics = getApplicationContext().getResources().getDisplayMetrics();
-        int screenWidthPx = displayMetrics.widthPixels;
+            DisplayMetrics displayMetrics = getApplicationContext().getResources().getDisplayMetrics();
+            int screenWidthPx = displayMetrics.widthPixels;
 
 
-        int screenWidthDp = (int) DisplayUtils.convertPixelToDp(screenWidthPx, getApplicationContext());
+            int screenWidthDp = (int) DisplayUtils.convertPixelToDp(screenWidthPx, getApplicationContext());
 
 
-        float newXafterRotate = 0;
-        float newYafterRotate;
-        if (binding.callInfosLinearLayout.getVisibility() == View.VISIBLE) {
-            newYafterRotate = 250;
-        } else {
-            newYafterRotate = 20;
-        }
+            float newXafterRotate = 0;
+            float newYafterRotate;
+            if (binding.callInfosLinearLayout.getVisibility() == View.VISIBLE) {
+                newYafterRotate = 250;
+            } else {
+                newYafterRotate = 20;
+            }
 
 
-        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
-            layoutParams.height = (int) getResources().getDimension(R.dimen.large_preview_dimension);
-            layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
-            newXafterRotate = (float) (screenWidthDp - getResources().getDimension(R.dimen.large_preview_dimension) * 0.8);
+            if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
+                layoutParams.height = (int) getResources().getDimension(R.dimen.large_preview_dimension);
+                layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
+                newXafterRotate = (float) (screenWidthDp - getResources().getDimension(R.dimen.large_preview_dimension) * 0.8);
 
 
-        } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
-            layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT;
-            layoutParams.width = (int) getResources().getDimension(R.dimen.large_preview_dimension);
-            newXafterRotate = (float) (screenWidthDp - getResources().getDimension(R.dimen.large_preview_dimension) * 0.5);
-        }
-        binding.selfVideoRenderer.setLayoutParams(layoutParams);
+            } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
+                layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT;
+                layoutParams.width = (int) getResources().getDimension(R.dimen.large_preview_dimension);
+                newXafterRotate = (float) (screenWidthDp - getResources().getDimension(R.dimen.large_preview_dimension) * 0.5);
+            }
+            binding.selfVideoRenderer.setLayoutParams(layoutParams);
 
 
-        int newXafterRotatePx = (int) DisplayUtils.convertDpToPixel(newXafterRotate, getApplicationContext());
-        binding.selfVideoViewWrapper.setY(newYafterRotate);
-        binding.selfVideoViewWrapper.setX(newXafterRotatePx);
+            int newXafterRotatePx = (int) DisplayUtils.convertDpToPixel(newXafterRotate, getApplicationContext());
+            binding.selfVideoViewWrapper.setY(newYafterRotate);
+            binding.selfVideoViewWrapper.setX(newXafterRotatePx);
+        }
     }
     }
 
 
     @Subscribe(threadMode = ThreadMode.MAIN)
     @Subscribe(threadMode = ThreadMode.MAIN)
@@ -2474,6 +2480,8 @@ public class CallActivity extends BaseActivity {
     @Override
     @Override
     public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, Configuration newConfig) {
     public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, Configuration newConfig) {
         super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig);
         super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig);
+        Log.d(TAG, "onPictureInPictureModeChanged");
+        Log.d(TAG, "isInPictureInPictureMode= " + isInPictureInPictureMode);
         isInPipMode = isInPictureInPictureMode;
         isInPipMode = isInPictureInPictureMode;
         if (isInPictureInPictureMode) {
         if (isInPictureInPictureMode) {
             mReceiver =
             mReceiver =
@@ -2528,6 +2536,7 @@ public class CallActivity extends BaseActivity {
     }
     }
 
 
     public void updateUiForPipMode() {
     public void updateUiForPipMode() {
+        Log.d(TAG, "updateUiForPipMode");
         RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
         RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                                                                              ViewGroup.LayoutParams.WRAP_CONTENT);
                                                                              ViewGroup.LayoutParams.WRAP_CONTENT);
         params.setMargins(0, 0, 0, 0);
         params.setMargins(0, 0, 0, 0);
@@ -2550,6 +2559,7 @@ public class CallActivity extends BaseActivity {
     }
     }
 
 
     public void updateUiForNormalMode() {
     public void updateUiForNormalMode() {
+        Log.d(TAG, "updateUiForNormalMode");
         if (isVoiceOnlyCall) {
         if (isVoiceOnlyCall) {
             binding.callControls.setVisibility(View.VISIBLE);
             binding.callControls.setVisibility(View.VISIBLE);
         } else {
         } else {