Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2018-07-19 09:46:11 +02:00
parent 754cdf7fd5
commit 2664528660
3 changed files with 82 additions and 52 deletions

View file

@ -225,7 +225,8 @@ public class CallController extends BaseController {
private boolean isVoiceOnlyCall;
private boolean isFromNotification;
private Handler handler = new Handler();
private Handler callControlHandler = new Handler();
private Handler cameraSwitchHandler = new Handler();
private boolean isPTTActive = false;
private PulseAnimation pulseAnimation;
@ -587,9 +588,11 @@ public class CallController extends BaseController {
@OnLongClick(R.id.call_control_microphone)
public boolean onMicrophoneLongClick() {
if (!audioOn) {
handler.removeCallbacksAndMessages(null);
callControlHandler.removeCallbacksAndMessages(null);
cameraSwitchHandler.removeCallbacksAndMessages(null);
isPTTActive = true;
callControls.setVisibility(View.VISIBLE);
cameraSwitchButton.setVisibility(View.VISIBLE);
}
onMicrophoneClick();
@ -791,20 +794,18 @@ public class CallController extends BaseController {
long duration;
if (show) {
handler.removeCallbacksAndMessages(null);
callControlHandler.removeCallbacksAndMessages(null);
cameraSwitchHandler.removeCallbacksAndMessages(null);
alpha = 1.0f;
duration = 1000;
if (callControls.getVisibility() != View.VISIBLE) {
callControls.setAlpha(0.0f);
callControls.setVisibility(View.VISIBLE);
} else {
handler.postDelayed(new Runnable() {
@Override
public void run() {
animateCallControls(false, 0);
}
}, 5000);
cameraSwitchButton.setAlpha(0.0f);
cameraSwitchButton.setVisibility(View.VISIBLE);
} else {
callControlHandler.postDelayed(() -> animateCallControls(false, 0), 5000);
return;
}
} else {
@ -830,7 +831,7 @@ public class CallController extends BaseController {
spotlightView.setVisibility(View.GONE);
}
} else {
handler.postDelayed(new Runnable() {
callControlHandler.postDelayed(new Runnable() {
@Override
public void run() {
if (!isPTTActive) {
@ -845,6 +846,29 @@ public class CallController extends BaseController {
}
});
}
if (cameraSwitchButton != null) {
cameraSwitchButton.setEnabled(false);
cameraSwitchButton.animate()
.translationY(0)
.alpha(alpha)
.setDuration(duration)
.setStartDelay(startDelay)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
if (cameraSwitchButton != null) {
if (!show) {
cameraSwitchButton.setVisibility(View.GONE);
}
cameraSwitchButton.setEnabled(true);
}
}
});
}
}
}

View file

@ -74,14 +74,33 @@
android:orientation="vertical">
</LinearLayout>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true">
<org.webrtc.SurfaceViewRenderer
android:id="@+id/pip_video_view"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_gravity="center"
android:layout_margin="16dp"
android:visibility="invisible"/>
<com.nextcloud.talk.utils.MagicFlipView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/call_control_switch_camera"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="20dp"
android:layout_gravity="center_horizontal|bottom"
app:checked="false"
app:enableInitialAnimation="false"
app:frontBackgroundColor="@color/colorPrimary"
app:frontImage="@drawable/ic_switch_video_white_24px"/>
</FrameLayout>
</RelativeLayout>
<LinearLayout
@ -109,44 +128,31 @@
<com.nextcloud.talk.utils.MagicFlipView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/call_control_camera"
android:id="@+id/callControlHangupView"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginEnd="20dp"
app:checked="false"
app:enableInitialAnimation="false"
app:frontBackgroundColor="@color/nc_darkRed"
app:frontImage="@drawable/ic_call_end_white_24px"/>
<com.nextcloud.talk.utils.MagicFlipView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/call_control_camera"
android:layout_width="60dp"
android:layout_height="60dp"
android:alpha="0.7"
app:checked="false"
app:enableInitialAnimation="false"
app:frontBackgroundColor="@color/colorPrimary"
app:frontImage="@drawable/ic_videocam_off_white_24px"/>
<com.nextcloud.talk.utils.MagicFlipView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/call_control_switch_camera"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginEnd="20dp"
android:visibility="gone"
app:checked="false"
app:enableInitialAnimation="false"
app:frontBackgroundColor="@color/colorPrimary"
app:frontImage="@drawable/ic_switch_video_white_24px"/>
<com.nextcloud.talk.utils.MagicFlipView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/callControlHangupView"
android:layout_width="60dp"
android:layout_height="60dp"
app:checked="false"
app:enableInitialAnimation="false"
app:frontBackgroundColor="@color/nc_darkRed"
app:frontImage="@drawable/ic_call_end_white_24px"/>
<com.nextcloud.talk.utils.MagicFlipView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/callControlEnableSpeaker"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginStart="20dp"
app:checked="false"
android:visibility="gone"
app:enableInitialAnimation="false"

View file

@ -88,6 +88,16 @@
app:frontBackgroundColor="@color/colorPrimary"
app:frontImage="@drawable/ic_mic_white_24px"/>
<com.nextcloud.talk.utils.MagicFlipView
android:id="@+id/callControlHangupView"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_margin="24dp"
app:checked="false"
app:enableInitialAnimation="false"
app:frontBackgroundColor="@color/nc_darkRed"
app:frontImage="@drawable/ic_call_end_white_24px"/>
<com.nextcloud.talk.utils.MagicFlipView
android:id="@+id/callAnswerCameraView"
android:layout_width="60dp"
@ -98,16 +108,6 @@
app:enableInitialAnimation="false"
app:frontBackgroundColor="@color/colorPrimary"
app:frontImage="@drawable/ic_videocam_white_24px"/>
<com.nextcloud.talk.utils.MagicFlipView
android:id="@+id/callControlHangupView"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_margin="24dp"
app:checked="false"
app:enableInitialAnimation="false"
app:frontBackgroundColor="@color/nc_darkRed"
app:frontImage="@drawable/ic_call_end_white_24px"/>
</LinearLayout>
</android.support.constraint.ConstraintLayout>