From 4ba29bccd2a5cf601cb0446f04f09d7bc47ea5b7 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Wed, 27 Feb 2019 10:46:31 +0100 Subject: [PATCH] Can stop microphone --- .../client/ui/activities/CallActivity.java | 14 ++++++++++++ app/src/main/res/drawable/ic_mic.xml | 9 ++++++++ app/src/main/res/drawable/ic_mic_off.xml | 9 ++++++++ app/src/main/res/layout/activity_call.xml | 22 +++++++++++++++---- 4 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 app/src/main/res/drawable/ic_mic.xml create mode 100644 app/src/main/res/drawable/ic_mic_off.xml diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/CallActivity.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/CallActivity.java index 651ca22..87dc843 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/CallActivity.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/CallActivity.java @@ -98,6 +98,7 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac */ private boolean mStopped = false; private boolean mIsCameraStopped = false; + private boolean mIsMicrophoneStopped = false; /** * Connections list @@ -121,6 +122,7 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac private SurfaceViewRenderer mLocalVideoView; private View mButtonsView; private ImageButton mStopCameraButton; + private ImageButton mStopMicrophoneButton; @Override @@ -216,6 +218,8 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac mStopCameraButton = findViewById(R.id.stopCameraButton); mStopCameraButton.setOnClickListener(v -> toggleStopCamera()); + mStopMicrophoneButton = findViewById(R.id.stopMicrophoneButton); + mStopMicrophoneButton.setOnClickListener(v -> toggleStopMicrophone()); } @@ -487,6 +491,16 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac mIsCameraStopped ? R.drawable.ic_videocam_off : R.drawable.ic_videocam)); } + private void toggleStopMicrophone(){ + mIsMicrophoneStopped = !mIsMicrophoneStopped; + + for(CallPeerConnection c : mList) + c.getPeerConnectionClient().setAudioEnabled(!mIsMicrophoneStopped); + + mStopMicrophoneButton.setImageDrawable(UiUtils.getDrawable(this, + mIsMicrophoneStopped ? R.drawable.ic_mic_off : R.drawable.ic_mic)); + } + private void switchButtonsVisibility(){ boolean show = !getSupportActionBar().isShowing(); diff --git a/app/src/main/res/drawable/ic_mic.xml b/app/src/main/res/drawable/ic_mic.xml new file mode 100644 index 0000000..29bdc0d --- /dev/null +++ b/app/src/main/res/drawable/ic_mic.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_mic_off.xml b/app/src/main/res/drawable/ic_mic_off.xml new file mode 100644 index 0000000..89bb76a --- /dev/null +++ b/app/src/main/res/drawable/ic_mic_off.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_call.xml b/app/src/main/res/layout/activity_call.xml index e13d783..9bbdba6 100644 --- a/app/src/main/res/layout/activity_call.xml +++ b/app/src/main/res/layout/activity_call.xml @@ -59,8 +59,8 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" - android:layout_marginStart="8dp" - android:layout_marginEnd="8dp" + android:layout_marginStart="0dp" + android:layout_marginEnd="0dp" android:contentDescription="@string/action_switch_camera" android:src="@drawable/ic_camera_switch" android:tint="@android:color/white" /> @@ -71,8 +71,8 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" - android:layout_marginStart="8dp" - android:layout_marginEnd="8dp" + android:layout_marginStart="0dp" + android:layout_marginEnd="0dp" android:contentDescription="@string/action_stop_camera" android:src="@drawable/ic_videocam" android:tint="@android:color/white" /> @@ -82,11 +82,25 @@ android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginEnd="8dp" android:backgroundTint="@color/holo_red_dark" android:contentDescription="@string/action_hang_up" android:src="@drawable/ic_call" android:tint="@android:color/white" /> + +