Various fixes with audio and video calls
This commit is contained in:
parent
b331a16e1b
commit
186d7918d6
2 changed files with 27 additions and 14 deletions
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/switchCamera"
|
android:id="@+id/switchCamera"
|
||||||
|
android:visibility="gone"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
|
@ -62,6 +63,7 @@
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/transfer"
|
android:id="@+id/transfer"
|
||||||
|
android:visibility="gone"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="75dp"
|
android:layout_height="75dp"
|
||||||
android:src="@drawable/options_transfer"
|
android:src="@drawable/options_transfer"
|
||||||
|
@ -96,6 +98,7 @@
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/addCall"
|
android:id="@+id/addCall"
|
||||||
|
android:visibility="gone"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="75dp"
|
android:layout_height="75dp"
|
||||||
android:src="@drawable/options_add_call"
|
android:src="@drawable/options_add_call"
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.linphone.core.LinphoneCall;
|
||||||
import org.linphone.core.LinphoneCall.State;
|
import org.linphone.core.LinphoneCall.State;
|
||||||
import org.linphone.core.LinphoneCallParams;
|
import org.linphone.core.LinphoneCallParams;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
|
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
@ -61,7 +62,7 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
private StatusFragment status;
|
private StatusFragment status;
|
||||||
private AudioCallFragment audioCallFragment;
|
private AudioCallFragment audioCallFragment;
|
||||||
private VideoCallFragment videoCallFragment;
|
private VideoCallFragment videoCallFragment;
|
||||||
private boolean isSpeakerEnabled = false, isMicMuted = false, isVideoEnabled = false;
|
private boolean isSpeakerEnabled = false, isMicMuted = false, isVideoEnabled;
|
||||||
private LinearLayout mControlsLayout;
|
private LinearLayout mControlsLayout;
|
||||||
|
|
||||||
static final boolean isInstanciated() {
|
static final boolean isInstanciated() {
|
||||||
|
@ -78,6 +79,8 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
setContentView(R.layout.incall);
|
setContentView(R.layout.incall);
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
|
isVideoEnabled = getIntent().getExtras() != null && getIntent().getExtras().getBoolean("VideoEnabled");
|
||||||
|
|
||||||
if (findViewById(R.id.fragmentContainer) != null) {
|
if (findViewById(R.id.fragmentContainer) != null) {
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
return;
|
return;
|
||||||
|
@ -97,7 +100,10 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
if (isVideoEnabled) {
|
if (isVideoEnabled) {
|
||||||
callFragment = new VideoCallFragment();
|
callFragment = new VideoCallFragment();
|
||||||
videoCallFragment = (VideoCallFragment) callFragment;
|
videoCallFragment = (VideoCallFragment) callFragment;
|
||||||
|
|
||||||
|
if (AndroidCameraConfiguration.retrieveCameras().length > 1) {
|
||||||
switchCamera.setVisibility(View.VISIBLE);
|
switchCamera.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
callFragment = new AudioCallFragment();
|
callFragment = new AudioCallFragment();
|
||||||
audioCallFragment = (AudioCallFragment) callFragment;
|
audioCallFragment = (AudioCallFragment) callFragment;
|
||||||
|
@ -188,7 +194,7 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
|
|
||||||
private boolean isVideoActivatedInSettings() {
|
private boolean isVideoActivatedInSettings() {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
boolean settingsVideoEnabled = prefs.getBoolean(getString(R.string.pref_video), false);
|
boolean settingsVideoEnabled = prefs.getBoolean(getString(R.string.pref_video_enable_key), false);
|
||||||
return settingsVideoEnabled;
|
return settingsVideoEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,10 +258,6 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
LinphoneManager.getLc().updateCall(call, params);
|
LinphoneManager.getLc().updateCall(call, params);
|
||||||
replaceFragmentVideoByAudio();
|
replaceFragmentVideoByAudio();
|
||||||
|
|
||||||
isSpeakerEnabled = false;
|
|
||||||
LinphoneManager.getInstance().routeAudioToReceiver();
|
|
||||||
speaker.setImageResource(R.drawable.speaker_off);
|
|
||||||
|
|
||||||
video.setImageResource(R.drawable.video_on);
|
video.setImageResource(R.drawable.video_on);
|
||||||
setCallControlsVisibleAndRemoveCallbacks();
|
setCallControlsVisibleAndRemoveCallbacks();
|
||||||
|
|
||||||
|
@ -272,7 +274,6 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
video.setImageResource(R.drawable.video_off);
|
video.setImageResource(R.drawable.video_off);
|
||||||
displayVideoCallControlsIfHidden();
|
displayVideoCallControlsIfHidden();
|
||||||
}
|
}
|
||||||
LinphoneManager.getLc().enableSpeaker(true);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -289,7 +290,6 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private void replaceFragmentAudioByVideo() {
|
private void replaceFragmentAudioByVideo() {
|
||||||
switchCamera.setVisibility(View.VISIBLE);
|
|
||||||
videoCallFragment = new VideoCallFragment();
|
videoCallFragment = new VideoCallFragment();
|
||||||
|
|
||||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||||
|
@ -298,6 +298,10 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
transaction.commitAllowingStateLoss();
|
transaction.commitAllowingStateLoss();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (AndroidCameraConfiguration.retrieveCameras().length > 1) {
|
||||||
|
switchCamera.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toogleMicro() {
|
private void toogleMicro() {
|
||||||
|
@ -380,13 +384,15 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mControls != null) {
|
if (controlsHandler != null && mControls != null) {
|
||||||
controlsHandler.removeCallbacks(mControls);
|
controlsHandler.removeCallbacks(mControls);
|
||||||
}
|
}
|
||||||
|
|
||||||
controlsHandler.postDelayed(mControls = new Runnable() {
|
controlsHandler.postDelayed(mControls = new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (InCallActivity.this.getResources().getBoolean(R.bool.disable_animations)) {
|
if (InCallActivity.this.getResources().getBoolean(R.bool.disable_animations)) {
|
||||||
|
transfer.setVisibility(View.GONE);
|
||||||
|
addCall.setVisibility(View.GONE);
|
||||||
mControlsLayout.setVisibility(View.GONE);
|
mControlsLayout.setVisibility(View.GONE);
|
||||||
switchCamera.setVisibility(View.GONE);
|
switchCamera.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
|
@ -394,6 +400,7 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
animation.setAnimationListener(new AnimationListener() {
|
animation.setAnimationListener(new AnimationListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationStart(Animation animation) {
|
public void onAnimationStart(Animation animation) {
|
||||||
|
video.setEnabled(false); // HACK: Used to avoid controls from being hided if video is switched while controls are hiding
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -402,6 +409,9 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationEnd(Animation animation) {
|
public void onAnimationEnd(Animation animation) {
|
||||||
|
video.setEnabled(true); // HACK: Used to avoid controls from being hided if video is switched while controls are hiding
|
||||||
|
transfer.setVisibility(View.GONE);
|
||||||
|
addCall.setVisibility(View.GONE);
|
||||||
mControlsLayout.setVisibility(View.GONE);
|
mControlsLayout.setVisibility(View.GONE);
|
||||||
switchCamera.setVisibility(View.GONE);
|
switchCamera.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
@ -427,8 +437,8 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
private void hideOrDisplayCallOptions() {
|
private void hideOrDisplayCallOptions() {
|
||||||
if (addCall.getVisibility() == View.VISIBLE) {
|
if (addCall.getVisibility() == View.VISIBLE) {
|
||||||
if (getResources().getBoolean(R.bool.disable_animations)) {
|
if (getResources().getBoolean(R.bool.disable_animations)) {
|
||||||
transfer.setVisibility(View.INVISIBLE);
|
transfer.setVisibility(View.GONE);
|
||||||
addCall.setVisibility(View.INVISIBLE);
|
addCall.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
final Animation animAddCall = AnimationUtils.loadAnimation(this, R.anim.slide_out_top_to_bottom);
|
final Animation animAddCall = AnimationUtils.loadAnimation(this, R.anim.slide_out_top_to_bottom);
|
||||||
animAddCall.setAnimationListener(new AnimationListener() {
|
animAddCall.setAnimationListener(new AnimationListener() {
|
||||||
|
@ -444,7 +454,7 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationEnd(Animation animation) {
|
public void onAnimationEnd(Animation animation) {
|
||||||
addCall.setVisibility(View.INVISIBLE);
|
addCall.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -462,7 +472,7 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationEnd(Animation animation) {
|
public void onAnimationEnd(Animation animation) {
|
||||||
transfer.setVisibility(View.INVISIBLE);
|
transfer.setVisibility(View.GONE);
|
||||||
addCall.startAnimation(animAddCall);
|
addCall.startAnimation(animAddCall);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue