Can stop camera

This commit is contained in:
Pierre HUBERT 2019-02-27 10:34:34 +01:00
parent db3f22e058
commit f17909886d
6 changed files with 77 additions and 28 deletions

View File

@ -31,6 +31,7 @@ import org.communiquons.android.comunic.client.ui.asynctasks.HangUpCallTask;
import org.communiquons.android.comunic.client.ui.asynctasks.RespondToCallTask; import org.communiquons.android.comunic.client.ui.asynctasks.RespondToCallTask;
import org.communiquons.android.comunic.client.ui.models.CallPeerConnection; import org.communiquons.android.comunic.client.ui.models.CallPeerConnection;
import org.communiquons.android.comunic.client.ui.receivers.PendingCallsBroadcastReceiver; import org.communiquons.android.comunic.client.ui.receivers.PendingCallsBroadcastReceiver;
import org.communiquons.android.comunic.client.ui.utils.UiUtils;
import org.communiquons.signalexchangerclient.SignalExchangerCallback; import org.communiquons.signalexchangerclient.SignalExchangerCallback;
import org.communiquons.signalexchangerclient.SignalExchangerClient; import org.communiquons.signalexchangerclient.SignalExchangerClient;
import org.communiquons.signalexchangerclient.SignalExchangerInitConfig; import org.communiquons.signalexchangerclient.SignalExchangerInitConfig;
@ -96,7 +97,7 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac
* Specify whether call was stopped or not * Specify whether call was stopped or not
*/ */
private boolean mStopped = false; private boolean mStopped = false;
private boolean mIsCameraStopped = false;
/** /**
* Connections list * Connections list
@ -119,7 +120,7 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac
private LinearLayout mRemoteVideosLayout; private LinearLayout mRemoteVideosLayout;
private SurfaceViewRenderer mLocalVideoView; private SurfaceViewRenderer mLocalVideoView;
private View mButtonsView; private View mButtonsView;
private ImageButton mSwitchCameraButton; private ImageButton mStopCameraButton;
@Override @Override
@ -202,13 +203,19 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac
private void initViews(){ private void initViews(){
mProgressBar = findViewById(R.id.progressBar); mProgressBar = findViewById(R.id.progressBar);
mHangUpButton = findViewById(R.id.hangUp);
mHangUpButton.setOnClickListener(v -> hangUp());
mRemoteVideosLayout = findViewById(R.id.remoteVideosLayout); mRemoteVideosLayout = findViewById(R.id.remoteVideosLayout);
mLocalVideoView = findViewById(R.id.local_video); mLocalVideoView = findViewById(R.id.local_video);
mButtonsView = findViewById(R.id.buttonsLayout); mButtonsView = findViewById(R.id.buttonsLayout);
mSwitchCameraButton = findViewById(R.id.switchCameraButton);
mSwitchCameraButton.setOnClickListener(v -> switchCamera()); mHangUpButton = findViewById(R.id.hangUp);
mHangUpButton.setOnClickListener(v -> hangUp());
ImageButton switchCameraButton = findViewById(R.id.switchCameraButton);
switchCameraButton.setOnClickListener(v -> switchCamera());
mStopCameraButton = findViewById(R.id.stopCameraButton);
mStopCameraButton.setOnClickListener(v -> toggleStopCamera());
} }
@ -467,6 +474,19 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac
c.getPeerConnectionClient().switchCamera(); c.getPeerConnectionClient().switchCamera();
} }
private void toggleStopCamera(){
mIsCameraStopped = !mIsCameraStopped;
for(CallPeerConnection c : mList) {
if(mIsCameraStopped)
c.getPeerConnectionClient().stopVideoSource();
else
c.getPeerConnectionClient().startVideoSource();
}
mStopCameraButton.setImageDrawable(UiUtils.getDrawable(this,
mIsCameraStopped ? R.drawable.ic_videocam_off : R.drawable.ic_videocam));
}
private void switchButtonsVisibility(){ private void switchButtonsVisibility(){
boolean show = !getSupportActionBar().isShowing(); boolean show = !getSupportActionBar().isShowing();

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M17,10.5V7c0,-0.55 -0.45,-1 -1,-1H4c-0.55,0 -1,0.45 -1,1v10c0,0.55 0.45,1 1,1h12c0.55,0 1,-0.45 1,-1v-3.5l4,4v-11l-4,4z"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M21,6.5l-4,4V7c0,-0.55 -0.45,-1 -1,-1H9.82L21,17.18V6.5zM3.27,2L2,3.27 4.73,6H4c-0.55,0 -1,0.45 -1,1v10c0,0.55 0.45,1 1,1h12c0.21,0 0.39,-0.08 0.54,-0.18L19.73,21 21,19.73 3.27,2z"/>
</vector>

View File

@ -41,7 +41,7 @@
app:layout_constraintBottom_toTopOf="@+id/buttonsLayout" app:layout_constraintBottom_toTopOf="@+id/buttonsLayout"
app:layout_constraintEnd_toEndOf="parent" /> app:layout_constraintEnd_toEndOf="parent" />
<android.support.constraint.ConstraintLayout <LinearLayout
android:id="@+id/buttonsLayout" android:id="@+id/buttonsLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -50,37 +50,46 @@
android:background="@android:color/black" android:background="@android:color/black"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"> app:layout_constraintStart_toStartOf="parent"
android:orientation="horizontal">
<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"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton <ImageButton
android:id="@+id/switchCameraButton" android:id="@+id/switchCameraButton"
style="@style/Widget.AppCompat.Button.Borderless" style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:contentDescription="@string/action_switch_camera" android:contentDescription="@string/action_switch_camera"
android:src="@drawable/ic_camera_switch" android:src="@drawable/ic_camera_switch"
android:tint="@android:color/white" android:tint="@android:color/white" />
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/hangUp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout> <ImageButton
android:id="@+id/stopCameraButton"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:contentDescription="@string/action_stop_camera"
android:src="@drawable/ic_videocam"
android:tint="@android:color/white" />
<ImageButton
android:id="@+id/hangUp"
android:layout_width="0dp"
android:layout_weight="1"
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" />
</LinearLayout>
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>

View File

@ -334,4 +334,5 @@
<string name="notice_call_terminated">Appel terminé.</string> <string name="notice_call_terminated">Appel terminé.</string>
<string name="action_hang_up">Raccrocher</string> <string name="action_hang_up">Raccrocher</string>
<string name="action_switch_camera">Changer de caméra</string> <string name="action_switch_camera">Changer de caméra</string>
<string name="action_stop_camera">Arrêter la caméra</string>
</resources> </resources>

View File

@ -333,4 +333,5 @@
<string name="notice_call_terminated">Call terminated</string> <string name="notice_call_terminated">Call terminated</string>
<string name="action_hang_up">Hang up</string> <string name="action_hang_up">Hang up</string>
<string name="action_switch_camera">Switch camera</string> <string name="action_switch_camera">Switch camera</string>
<string name="action_stop_camera">Stop camera</string>
</resources> </resources>