Rework incall activity
This commit is contained in:
parent
d5b71ff05b
commit
909d351670
2 changed files with 55 additions and 35 deletions
|
@ -89,7 +89,7 @@
|
||||||
<activity android:name="org.linphone.InCallActivity"
|
<activity android:name="org.linphone.InCallActivity"
|
||||||
android:theme="@style/FullScreen"
|
android:theme="@style/FullScreen"
|
||||||
android:noHistory="true"
|
android:noHistory="true"
|
||||||
android:launchMode="singleTop">
|
android:launchMode="singleInstance">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
|
@ -91,7 +91,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, isPaused = false, isTransferAllowed, isAnimationDisabled;
|
private boolean isSpeakerEnabled = false, isMicMuted = false, isVideoEnabled, isTransferAllowed, isAnimationDisabled;
|
||||||
private ViewGroup mControlsLayout;
|
private ViewGroup mControlsLayout;
|
||||||
private Numpad numpad;
|
private Numpad numpad;
|
||||||
private int cameraNumber;
|
private int cameraNumber;
|
||||||
|
@ -122,7 +122,6 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
|
||||||
setContentView(R.layout.incall);
|
setContentView(R.layout.incall);
|
||||||
|
|
||||||
isVideoEnabled = getIntent().getExtras() != null && getIntent().getExtras().getBoolean("VideoEnabled");
|
|
||||||
isTransferAllowed = getApplicationContext().getResources().getBoolean(R.bool.allow_transfers);
|
isTransferAllowed = getApplicationContext().getResources().getBoolean(R.bool.allow_transfers);
|
||||||
showCallListInVideo = getApplicationContext().getResources().getBoolean(R.bool.show_current_calls_above_video);
|
showCallListInVideo = getApplicationContext().getResources().getBoolean(R.bool.show_current_calls_above_video);
|
||||||
isSpeakerEnabled = LinphoneManager.getLcIfManagerNotDestroyedOrNull().isSpeakerEnabled();
|
isSpeakerEnabled = LinphoneManager.getLcIfManagerNotDestroyedOrNull().isSpeakerEnabled();
|
||||||
|
@ -137,7 +136,6 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
LinphoneCall call = LinphoneManager.getLc().getCalls()[0];
|
LinphoneCall call = LinphoneManager.getLc().getCalls()[0];
|
||||||
|
|
||||||
if (LinphoneUtils.isCallEstablished(call)) {
|
if (LinphoneUtils.isCallEstablished(call)) {
|
||||||
isVideoEnabled = call.getCurrentParamsCopy().getVideoEnabled() && !call.getRemoteParams().isLowBandwidthEnabled();
|
|
||||||
enableAndRefreshInCallActions();
|
enableAndRefreshInCallActions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,7 +150,7 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
Fragment callFragment;
|
Fragment callFragment;
|
||||||
if (isVideoEnabled) {
|
if (isVideoEnabled(LinphoneManager.getLc().getCurrentCall())) {
|
||||||
callFragment = new VideoCallFragment();
|
callFragment = new VideoCallFragment();
|
||||||
videoCallFragment = (VideoCallFragment) callFragment;
|
videoCallFragment = (VideoCallFragment) callFragment;
|
||||||
|
|
||||||
|
@ -169,6 +167,13 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isVideoEnabled(LinphoneCall call) {
|
||||||
|
if(call != null){
|
||||||
|
return call.getCurrentParamsCopy().getVideoEnabled();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
outState.putBoolean("Speaker", isSpeakerEnabled);
|
outState.putBoolean("Speaker", isSpeakerEnabled);
|
||||||
|
@ -277,7 +282,7 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
if (!LinphonePreferences.instance().isVideoEnabled()) {
|
if (!LinphonePreferences.instance().isVideoEnabled()) {
|
||||||
video.setEnabled(false);
|
video.setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
if (isVideoEnabled) {
|
if (isVideoEnabled(LinphoneManager.getLc().getCurrentCall())) {
|
||||||
video.setBackgroundResource(R.drawable.video_on);
|
video.setBackgroundResource(R.drawable.video_on);
|
||||||
} else {
|
} else {
|
||||||
video.setBackgroundResource(R.drawable.video_off);
|
video.setBackgroundResource(R.drawable.video_off);
|
||||||
|
@ -325,12 +330,6 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
pause.setBackgroundResource(R.drawable.pause_off);
|
pause.setBackgroundResource(R.drawable.pause_off);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isPaused){
|
|
||||||
video.setEnabled(false);
|
|
||||||
} else {
|
|
||||||
video.setEnabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -368,13 +367,12 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
int id = v.getId();
|
int id = v.getId();
|
||||||
|
|
||||||
if (isVideoEnabled) {
|
if (isVideoEnabled(LinphoneManager.getLc().getCurrentCall())) {
|
||||||
displayVideoCallControlsIfHidden();
|
displayVideoCallControlsIfHidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id == R.id.video) {
|
if (id == R.id.video) {
|
||||||
isVideoEnabled = !isVideoEnabled;
|
switchVideo(!isVideoEnabled(LinphoneManager.getLc().getCurrentCall()), true);
|
||||||
switchVideo(isVideoEnabled, true);
|
|
||||||
}
|
}
|
||||||
else if (id == R.id.micro) {
|
else if (id == R.id.micro) {
|
||||||
toggleMicro();
|
toggleMicro();
|
||||||
|
@ -495,7 +493,6 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
|
|
||||||
private void showAudioView() {
|
private void showAudioView() {
|
||||||
video.setBackgroundResource(R.drawable.video_on);
|
video.setBackgroundResource(R.drawable.video_on);
|
||||||
|
|
||||||
LinphoneManager.startProximitySensorForActivity(InCallActivity.this);
|
LinphoneManager.startProximitySensorForActivity(InCallActivity.this);
|
||||||
replaceFragmentVideoByAudio();
|
replaceFragmentVideoByAudio();
|
||||||
setCallControlsVisibleAndRemoveCallbacks();
|
setCallControlsVisibleAndRemoveCallbacks();
|
||||||
|
@ -581,7 +578,7 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
lc.pauseCall(call);
|
lc.pauseCall(call);
|
||||||
if (isVideoEnabled) {
|
if (isVideoEnabled(LinphoneManager.getLc().getCurrentCall())) {
|
||||||
isVideoCallPaused = true;
|
isVideoCallPaused = true;
|
||||||
showAudioView();
|
showAudioView();
|
||||||
}
|
}
|
||||||
|
@ -682,7 +679,7 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
}
|
}
|
||||||
mControls = null;
|
mControls = null;
|
||||||
|
|
||||||
if (isVideoEnabled && mControlsHandler != null) {
|
if (isVideoEnabled(LinphoneManager.getLc().getCurrentCall()) && mControlsHandler != null) {
|
||||||
mControlsHandler.postDelayed(mControls = new Runnable() {
|
mControlsHandler.postDelayed(mControls = new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
hideNumpad();
|
hideNumpad();
|
||||||
|
@ -1057,26 +1054,43 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!LinphonePreferences.instance().isVideoEnabled()){
|
||||||
|
video.setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
if (state == State.IncomingReceived) {
|
if (state == State.IncomingReceived) {
|
||||||
startIncomingCallActivity();
|
startIncomingCallActivity();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state == State.Paused || state == State.PausedByRemote || state == State.Pausing) {
|
if (state == State.Paused || state == State.PausedByRemote || state == State.Pausing) {
|
||||||
isPaused = true;
|
mHandler.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
video.setEnabled(false);
|
||||||
|
if(isVideoEnabled(call)){
|
||||||
|
showAudioView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state == State.Resuming) {
|
if (state == State.Resuming) {
|
||||||
isPaused = false;
|
if(LinphonePreferences.instance().isVideoEnabled()){
|
||||||
|
mHandler.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
status.refreshStatusItems(call, isVideoEnabled(call));
|
||||||
|
if(call.getCurrentParamsCopy().getVideoEnabled()){
|
||||||
|
showVideoView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state == State.StreamsRunning) {
|
if (state == State.StreamsRunning) {
|
||||||
isPaused = false;
|
switchVideo(isVideoEnabled(call), false);
|
||||||
boolean isVideoEnabledInCall = call.getCurrentParamsCopy().getVideoEnabled();
|
|
||||||
if (isVideoEnabledInCall != isVideoEnabled) {
|
|
||||||
isVideoEnabled = isVideoEnabledInCall;
|
|
||||||
switchVideo(isVideoEnabled, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
LinphoneManager.getLc().enableSpeaker(isSpeakerEnabled);
|
LinphoneManager.getLc().enableSpeaker(isSpeakerEnabled);
|
||||||
|
|
||||||
|
@ -1087,11 +1101,12 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
status.refreshStatusItems(call, isVideoEnabled);
|
status.refreshStatusItems(call, isVideoEnabled(call));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshInCallActions();
|
refreshInCallActions();
|
||||||
|
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
|
@ -1103,8 +1118,8 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
|
|
||||||
if (state == State.CallUpdatedByRemote) {
|
if (state == State.CallUpdatedByRemote) {
|
||||||
// If the correspondent proposes video while audio call
|
// If the correspondent proposes video while audio call
|
||||||
boolean isVideoEnabled = LinphonePreferences.instance().isVideoEnabled();
|
boolean videoEnabled = LinphonePreferences.instance().isVideoEnabled();
|
||||||
if (!isVideoEnabled) {
|
if (!videoEnabled) {
|
||||||
acceptCallUpdate(false);
|
acceptCallUpdate(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1164,8 +1179,7 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
instance = this;
|
instance = this;
|
||||||
|
if (isVideoEnabled(LinphoneManager.getLc().getCurrentCall())) {
|
||||||
if (isVideoEnabled) {
|
|
||||||
displayVideoCallControlsIfHidden();
|
displayVideoCallControlsIfHidden();
|
||||||
} else {
|
} else {
|
||||||
LinphoneManager.startProximitySensorForActivity(this);
|
LinphoneManager.startProximitySensorForActivity(this);
|
||||||
|
@ -1175,22 +1189,23 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
LinphoneManager.addListener(this);
|
LinphoneManager.addListener(this);
|
||||||
|
|
||||||
refreshCallList(getResources());
|
refreshCallList(getResources());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
||||||
if (mControlsHandler != null && mControls != null) {
|
if (mControlsHandler != null && mControls != null) {
|
||||||
mControlsHandler.removeCallbacks(mControls);
|
mControlsHandler.removeCallbacks(mControls);
|
||||||
}
|
}
|
||||||
mControls = null;
|
mControls = null;
|
||||||
|
|
||||||
if (!isVideoEnabled) {
|
if (!isVideoEnabled(LinphoneManager.getLc().getCurrentCall())) {
|
||||||
LinphoneManager.stopProximitySensorForActivity(this);
|
LinphoneManager.stopProximitySensorForActivity(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
LinphoneManager.removeListener(this);
|
LinphoneManager.removeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1438,10 +1453,15 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
for (LinphoneCall call : LinphoneManager.getLc().getCalls()) {
|
for (LinphoneCall call : LinphoneManager.getLc().getCalls()) {
|
||||||
displayCall(resources, call, index);
|
displayCall(resources, call, index);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(LinphoneManager.getLc().getCurrentCall() == null){
|
||||||
|
showAudioView();
|
||||||
|
video.setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
callsList.invalidate();
|
callsList.invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue