mirror of
				https://github.com/pierre42100/ComunicAndroid
				synced 2025-10-31 09:34:47 +00:00 
			
		
		
		
	Can hide hang up button
This commit is contained in:
		| @@ -49,6 +49,8 @@ import org.webrtc.VideoSink; | ||||
|  | ||||
| import java.util.Objects; | ||||
|  | ||||
| import static org.webrtc.RendererCommon.ScalingType.SCALE_ASPECT_FILL; | ||||
|  | ||||
| /** | ||||
|  * Call activity | ||||
|  * | ||||
| @@ -116,6 +118,7 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac | ||||
|     private ImageButton mHangUpButton; | ||||
|     private LinearLayout mRemoteVideosLayout; | ||||
|     private SurfaceViewRenderer mLocalVideoView; | ||||
|     private View mButtonsView; | ||||
|  | ||||
|  | ||||
|     @Override | ||||
| @@ -202,6 +205,7 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac | ||||
|         mHangUpButton.setOnClickListener(v -> hangUp()); | ||||
|         mRemoteVideosLayout = findViewById(R.id.remoteVideosLayout); | ||||
|         mLocalVideoView = findViewById(R.id.local_video); | ||||
|         mButtonsView = findViewById(R.id.buttonsLayout); | ||||
|     } | ||||
|  | ||||
|  | ||||
| @@ -383,15 +387,16 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac | ||||
|         SurfaceViewRenderer remoteView = new SurfaceViewRenderer(this); | ||||
|         remoteView.init(eglBase.getEglBaseContext(), null); | ||||
|         remoteView.setZOrderMediaOverlay(false); | ||||
|         remoteView.setScalingType(SCALE_ASPECT_FILL); | ||||
|         remoteView.setEnableHardwareScaler(false); | ||||
|         callPeer.setRemoteViewView(remoteView); | ||||
|         remoteView.setOnClickListener(v -> switchButtonsVisibility()); | ||||
|  | ||||
|         mRemoteVideosLayout.addView(remoteView, new LinearLayout.LayoutParams( | ||||
|                 ViewGroup.LayoutParams.MATCH_PARENT, 0, 1)); | ||||
|  | ||||
|  | ||||
|  | ||||
|         //callPeer.setLocalProxyVideoSink(mLocalProxyVideoSink); | ||||
|  | ||||
|         ProxyVideoSink remoteProxyRenderer = new ProxyVideoSink(); | ||||
|         remoteProxyRenderer.setTarget(callPeer.getRemoteViewView()); | ||||
|         callPeer.getRemoteSinks().add(remoteProxyRenderer); | ||||
| @@ -453,6 +458,20 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac | ||||
|         mList.remove(callPeer); | ||||
|     } | ||||
|  | ||||
|  | ||||
|     private void switchButtonsVisibility(){ | ||||
|  | ||||
|         boolean show = !getSupportActionBar().isShowing(); | ||||
|  | ||||
|         if(show) | ||||
|             getSupportActionBar().show(); | ||||
|         else | ||||
|             getSupportActionBar().hide(); | ||||
|  | ||||
|         mButtonsView.setVisibility(show ? View.VISIBLE : View.GONE); | ||||
|     } | ||||
|  | ||||
|  | ||||
|     //Based on https://github.com/vivek1794/webrtc-android-codelab | ||||
|     @Nullable | ||||
|     private VideoCapturer createCameraCapturer(CameraEnumerator enumerator){ | ||||
|   | ||||
| @@ -22,8 +22,8 @@ | ||||
|  | ||||
|     <LinearLayout | ||||
|         android:id="@+id/remoteVideosLayout" | ||||
|         android:layout_width="0dp" | ||||
|         android:layout_height="0dp" | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="match_parent" | ||||
|         android:orientation="vertical" | ||||
|         app:layout_constraintBottom_toBottomOf="parent" | ||||
|         app:layout_constraintEnd_toEndOf="parent" | ||||
| @@ -31,29 +31,40 @@ | ||||
|         app:layout_constraintTop_toTopOf="parent" /> | ||||
|  | ||||
|  | ||||
|     <ImageButton | ||||
|         android:id="@+id/hangUp" | ||||
|     <org.webrtc.SurfaceViewRenderer | ||||
|         android:id="@+id/local_video" | ||||
|         android:layout_width="@dimen/account_image_default_width" | ||||
|         android:layout_height="@dimen/account_image_default_height" | ||||
|  | ||||
|         android:layout_marginEnd="8dp" | ||||
|         android:layout_marginBottom="8dp" | ||||
|         app:layout_constraintBottom_toTopOf="@+id/buttonsLayout" | ||||
|         app:layout_constraintEnd_toEndOf="parent" /> | ||||
|  | ||||
|     <android.support.constraint.ConstraintLayout | ||||
|         android:id="@+id/buttonsLayout" | ||||
|         android:layout_width="wrap_content" | ||||
|         android:layout_height="wrap_content" | ||||
|         android:layout_marginStart="8dp" | ||||
|         android:layout_marginEnd="8dp" | ||||
|         android:layout_marginBottom="8dp" | ||||
|         android:backgroundTint="@color/holo_red_dark" | ||||
|         android:src="@drawable/ic_call" | ||||
|         android:tint="@android:color/white" | ||||
|         app:layout_constraintBottom_toBottomOf="parent" | ||||
|         app:layout_constraintEnd_toEndOf="parent" | ||||
|         app:layout_constraintStart_toStartOf="parent" | ||||
|         android:contentDescription="@string/action_hang_up"/> | ||||
|         app:layout_constraintStart_toStartOf="parent"> | ||||
|  | ||||
|     <org.webrtc.SurfaceViewRenderer | ||||
|         android:id="@+id/local_video" | ||||
|         android:layout_width="@dimen/account_image_default_width" | ||||
|         android:layout_height="@dimen/account_image_default_height" | ||||
|         android:layout_marginEnd="8dp" | ||||
|         android:layout_marginBottom="8dp" | ||||
|         app:layout_constraintBottom_toTopOf="@+id/hangUp" | ||||
|         app:layout_constraintEnd_toEndOf="parent" /> | ||||
|         <ImageButton | ||||
|             android:id="@+id/hangUp" | ||||
|             android:layout_width="51dp" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:backgroundTint="@color/holo_red_dark" | ||||
|             android:contentDescription="@string/action_hang_up" | ||||
|             android:src="@drawable/ic_call" | ||||
|             android:tint="@android:color/white" | ||||
|             app:layout_constraintBottom_toBottomOf="parent" | ||||
|             app:layout_constraintEnd_toEndOf="parent" | ||||
|             app:layout_constraintStart_toStartOf="parent" /> | ||||
|  | ||||
|     </android.support.constraint.ConstraintLayout> | ||||
|  | ||||
|  | ||||
| </android.support.constraint.ConstraintLayout> | ||||
		Reference in New Issue
	
	Block a user