Browse Source

hide pip button for android < 8

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Marcel Hibbe 3 năm trước cách đây
mục cha
commit
1ae5f51a81

+ 5 - 2
app/src/main/java/com/nextcloud/talk/activities/MagicCallActivity.kt

@@ -95,10 +95,13 @@ class MagicCallActivity : BaseActivity() {
         enterPictureInPictureMode(getPipParams())
     }
 
-    @RequiresApi(Build.VERSION_CODES.O)
     override fun onUserLeaveHint() {
         enableKeyguard()
-        enterPictureInPictureMode(getPipParams())
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+            enterPictureInPictureMode(getPipParams())
+        } else {
+            finish()
+        }
     }
 
     @RequiresApi(Build.VERSION_CODES.O)

+ 19 - 0
app/src/main/java/com/nextcloud/talk/adapters/ParticipantsAdapter.java

@@ -79,6 +79,8 @@ public class ParticipantsAdapter extends BaseAdapter {
 
             surfaceViewRenderer = convertView.findViewById(R.id.surface_view);
             try {
+                Log.d(TAG, "hasSurface: " + participantDisplayItem.getRootEglBase().hasSurface());
+
                 surfaceViewRenderer.setMirror(false);
                 surfaceViewRenderer.init(participantDisplayItem.getRootEglBase().getEglBaseContext(), null);
                 surfaceViewRenderer.setZOrderMediaOverlay(false);
@@ -127,7 +129,24 @@ public class ParticipantsAdapter extends BaseAdapter {
         } else {
             audioOffView.setVisibility(View.INVISIBLE);
         }
+
+
+        convertView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
+
+            @Override
+            public void onViewAttachedToWindow(View v) {
+                Log.d(TAG,"onViewAttachedToWindow");
+            }
+
+            @Override
+            public void onViewDetachedFromWindow(View v) {
+                Log.d(TAG,"onViewDetachedFromWindow");
+            }
+        });
+
+
         return convertView;
+
     }
 
     private boolean hasVideoStream(ParticipantDisplayItem participantDisplayItem, MediaStream mediaStream) {

+ 12 - 5
app/src/main/java/com/nextcloud/talk/controllers/CallController.java

@@ -141,7 +141,6 @@ import javax.inject.Inject;
 
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
-import androidx.annotation.RequiresApi;
 import androidx.appcompat.app.AppCompatActivity;
 import autodagger.AutoInjector;
 import butterknife.BindView;
@@ -208,8 +207,8 @@ public class CallController extends BaseController {
     TextView callVoiceOrVideoTextView;
     @BindView(R.id.callConversationNameTextView)
     TextView callConversationNameTextView;
-
-
+    @BindView(R.id.callControlEnterPip)
+    SimpleDraweeView callControlEnterPip;
 
     @BindView(R.id.callStateRelativeLayoutView)
     RelativeLayout callStateView;
@@ -484,6 +483,10 @@ public class CallController extends BaseController {
         callInfosLinearLayout.setVisibility(View.VISIBLE);
         selfVideoViewWrapper.setVisibility(View.VISIBLE);
 
+        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
+            callControlEnterPip.setVisibility(View.GONE);
+        }
+
         if (isVoiceOnlyCall) {
             callControlEnableSpeaker.setVisibility(View.VISIBLE);
             cameraSwitchButton.setVisibility(View.GONE);
@@ -858,10 +861,14 @@ public class CallController extends BaseController {
         }
     }
 
-    @RequiresApi(api = Build.VERSION_CODES.O)
     @OnClick(R.id.callControlEnterPip)
     void enterPipMode() {
-        ((MagicCallActivity) getActivity()).enterPipMode();
+        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O){
+            ((MagicCallActivity) getActivity()).enterPipMode();
+        } else{
+            Log.w(TAG, "tried to enterPipMode with an android api level below 26 (Android 8). This scenario should " +
+                "have been avoided by hiding the PIP button!");
+        }
     }
 
     @OnClick(R.id.callControlHangupView)

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

@@ -139,13 +139,14 @@
         android:animateLayoutChanges="true"
         android:background="@android:color/transparent"
         android:gravity="center"
-        android:orientation="horizontal">
+        android:orientation="horizontal"
+        android:layout_marginStart="40dp"
+        android:layout_marginEnd="40dp">
 
         <com.facebook.drawee.view.SimpleDraweeView
             android:id="@+id/callControlEnterPip"
             android:layout_width="60dp"
             android:layout_height="match_parent"
-            android:layout_marginStart="40dp"
             android:layout_marginEnd="10dp"
             android:elevation="10dp"
             app:backgroundImage="@color/call_buttons_background"
@@ -189,7 +190,7 @@
             android:layout_width="60dp"
             android:layout_height="match_parent"
             android:layout_marginStart="10dp"
-            android:layout_marginEnd="40dp"
+            android:layout_marginEnd="10dp"
             app:backgroundImage="@color/nc_darkRed"
             app:placeholderImage="@drawable/ic_call_end_white_24px"
             app:roundAsCircle="true" />