Code optimizations

This commit is contained in:
Sylvain Berfini 2012-08-06 17:30:40 +02:00
parent 5ecf57aa9e
commit 9df1170172
5 changed files with 123 additions and 71 deletions

View file

@ -6,8 +6,8 @@
<org.linphone.mediastream.video.display.GL2JNIView <org.linphone.mediastream.video.display.GL2JNIView
android:visibility="visible" android:visibility="visible"
android:layout_height="fill_parent" android:layout_height="match_parent"
android:layout_width="fill_parent" android:layout_width="match_parent"
android:id="@+id/videoSurface" /> android:id="@+id/videoSurface" />
<SurfaceView <SurfaceView

View file

@ -6,8 +6,8 @@
<org.linphone.mediastream.video.display.GL2JNIView <org.linphone.mediastream.video.display.GL2JNIView
android:visibility="visible" android:visibility="visible"
android:layout_height="fill_parent" android:layout_height="match_parent"
android:layout_width="fill_parent" android:layout_width="match_parent"
android:id="@+id/videoSurface" /> android:id="@+id/videoSurface" />
<SurfaceView <SurfaceView

View file

@ -41,6 +41,7 @@ import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.View; import android.view.View;
import android.view.WindowManager;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.animation.Animation; import android.view.animation.Animation;
@ -58,18 +59,20 @@ public class InCallActivity extends FragmentActivity implements
LinphoneOnCallEncryptionChangedListener, LinphoneOnCallEncryptionChangedListener,
OnClickListener { OnClickListener {
private final static int SECONDS_BEFORE_HIDING_CONTROLS = 3000; private final static int SECONDS_BEFORE_HIDING_CONTROLS = 3000;
private static InCallActivity instance;
private static InCallActivity instance = null;
private Handler mHandler = new Handler(); private Handler mHandler = new Handler();
private Handler controlsHandler = new Handler(); private Handler mControlsHandler = new Handler();
private Runnable mControls; private Runnable mControls;
private ImageView video, micro, speaker, addCall, pause, hangUp, dialer, switchCamera, options, transfer; private ImageView video, micro, speaker, addCall, pause, hangUp, dialer, switchCamera, options, transfer;
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, isTransferAllowed; private boolean isSpeakerEnabled = false, isMicMuted = false, isVideoEnabled, isTransferAllowed, isAnimationDisabled;
private LinearLayout mControlsLayout; private LinearLayout mControlsLayout;
private Numpad numpad; private Numpad numpad;
private int cameraNumber;
private Animation slideOutLeftToRight, slideInRightToLeft, slideInBottomToTop, slideInTopToBottom, slideOutBottomToTop, slideOutTopToBottom;
public static InCallActivity instance() { public static InCallActivity instance() {
return instance; return instance;
@ -83,11 +86,15 @@ public class InCallActivity extends FragmentActivity implements
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
instance = this; instance = this;
Compatibility.setFullScreen(getWindow()); Compatibility.setFullScreen(getWindow());
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.incall); setContentView(R.layout.incall);
isVideoEnabled = getIntent().getExtras() != null && getIntent().getExtras().getBoolean("VideoEnabled"); isVideoEnabled = getIntent().getExtras() != null && getIntent().getExtras().getBoolean("VideoEnabled");
isTransferAllowed = getResources().getBoolean(R.bool.allow_transfers); isTransferAllowed = getApplicationContext().getResources().getBoolean(R.bool.allow_transfers);
isAnimationDisabled = getApplicationContext().getResources().getBoolean(R.bool.disable_animations);
cameraNumber = AndroidCameraConfiguration.retrieveCameras().length;
if (findViewById(R.id.fragmentContainer) != null) { if (findViewById(R.id.fragmentContainer) != null) {
initUI(); initUI();
@ -96,12 +103,13 @@ 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)) {
enableAndRefreshInCallActions();
isVideoEnabled = call.getCurrentParamsCopy().getVideoEnabled(); isVideoEnabled = call.getCurrentParamsCopy().getVideoEnabled();
enableAndRefreshInCallActions();
} }
} }
if (savedInstanceState != null) { if (savedInstanceState != null) {
// Fragment already created, no need to create it again (else it will generate a memory leak with duplicated fragments)
return; return;
} }
@ -110,7 +118,7 @@ public class InCallActivity extends FragmentActivity implements
callFragment = new VideoCallFragment(); callFragment = new VideoCallFragment();
videoCallFragment = (VideoCallFragment) callFragment; videoCallFragment = (VideoCallFragment) callFragment;
if (AndroidCameraConfiguration.retrieveCameras().length > 1) { if (cameraNumber > 1) {
switchCamera.setVisibility(View.VISIBLE); switchCamera.setVisibility(View.VISIBLE);
} }
} else { } else {
@ -121,7 +129,6 @@ public class InCallActivity extends FragmentActivity implements
callFragment.setArguments(getIntent().getExtras()); callFragment.setArguments(getIntent().getExtras());
getSupportFragmentManager().beginTransaction().add(R.id.fragmentContainer, callFragment).commitAllowingStateLoss(); getSupportFragmentManager().beginTransaction().add(R.id.fragmentContainer, callFragment).commitAllowingStateLoss();
} }
} }
private void initUI() { private void initUI() {
@ -161,6 +168,15 @@ public class InCallActivity extends FragmentActivity implements
if (!isTransferAllowed) { if (!isTransferAllowed) {
addCall.setImageResource(R.drawable.options_add_call); addCall.setImageResource(R.drawable.options_add_call);
} }
if (!isAnimationDisabled) {
slideInRightToLeft = AnimationUtils.loadAnimation(this, R.anim.slide_in_right_to_left);
slideOutLeftToRight = AnimationUtils.loadAnimation(this, R.anim.slide_out_left_to_right);
slideInBottomToTop = AnimationUtils.loadAnimation(this, R.anim.slide_in_bottom_to_top);
slideInTopToBottom = AnimationUtils.loadAnimation(this, R.anim.slide_in_top_to_bottom);
slideOutBottomToTop = AnimationUtils.loadAnimation(this, R.anim.slide_out_bottom_to_top);
slideOutTopToBottom = AnimationUtils.loadAnimation(this, R.anim.slide_out_top_to_bottom);
}
} }
private void enableAndRefreshInCallActions() { private void enableAndRefreshInCallActions() {
@ -302,7 +318,7 @@ public class InCallActivity extends FragmentActivity implements
} }
private void replaceFragmentAudioByVideo() { private void replaceFragmentAudioByVideo() {
//Hiding controls to let displayVideoCallControlsIfHidden add them plus the callback // Hiding controls to let displayVideoCallControlsIfHidden add them plus the callback
mControlsLayout.setVisibility(View.GONE); mControlsLayout.setVisibility(View.GONE);
switchCamera.setVisibility(View.INVISIBLE); switchCamera.setVisibility(View.INVISIBLE);
@ -371,18 +387,18 @@ public class InCallActivity extends FragmentActivity implements
public void displayVideoCallControlsIfHidden() { public void displayVideoCallControlsIfHidden() {
if (mControlsLayout != null) { if (mControlsLayout != null) {
if (mControlsLayout.getVisibility() == View.GONE) { if (mControlsLayout.getVisibility() == View.GONE) {
if (getResources().getBoolean(R.bool.disable_animations)) { if (isAnimationDisabled) {
mControlsLayout.setVisibility(View.VISIBLE); mControlsLayout.setVisibility(View.VISIBLE);
if (AndroidCameraConfiguration.retrieveCameras().length > 1) { if (cameraNumber > 1) {
switchCamera.setVisibility(View.VISIBLE); switchCamera.setVisibility(View.VISIBLE);
} }
} else { } else {
Animation animation = AnimationUtils.loadAnimation(this, R.anim.slide_in_bottom_to_top); Animation animation = slideInBottomToTop;
animation.setAnimationListener(new AnimationListener() { animation.setAnimationListener(new AnimationListener() {
@Override @Override
public void onAnimationStart(Animation animation) { public void onAnimationStart(Animation animation) {
mControlsLayout.setVisibility(View.VISIBLE); mControlsLayout.setVisibility(View.VISIBLE);
if (AndroidCameraConfiguration.retrieveCameras().length > 1) { if (cameraNumber > 1) {
switchCamera.setVisibility(View.VISIBLE); switchCamera.setVisibility(View.VISIBLE);
} }
} }
@ -393,11 +409,12 @@ public class InCallActivity extends FragmentActivity implements
@Override @Override
public void onAnimationEnd(Animation animation) { public void onAnimationEnd(Animation animation) {
animation.setAnimationListener(null);
} }
}); });
mControlsLayout.startAnimation(animation); mControlsLayout.startAnimation(animation);
if (AndroidCameraConfiguration.retrieveCameras().length > 1) { if (cameraNumber > 1) {
switchCamera.startAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_in_top_to_bottom)); switchCamera.startAnimation(slideInTopToBottom);
} }
} }
@ -407,24 +424,24 @@ public class InCallActivity extends FragmentActivity implements
} }
public void resetControlsHidingCallBack() { public void resetControlsHidingCallBack() {
if (controlsHandler != null && mControls != null) { if (mControlsHandler != null && mControls != null) {
controlsHandler.removeCallbacks(mControls); mControlsHandler.removeCallbacks(mControls);
} }
mControls = null; mControls = null;
if (isVideoEnabled) { if (isVideoEnabled) {
controlsHandler.postDelayed(mControls = new Runnable() { mControlsHandler.postDelayed(mControls = new Runnable() {
public void run() { public void run() {
hideNumpad(); hideNumpad();
if (getResources().getBoolean(R.bool.disable_animations)) { if (isAnimationDisabled) {
transfer.setVisibility(View.INVISIBLE); transfer.setVisibility(View.INVISIBLE);
addCall.setVisibility(View.INVISIBLE); addCall.setVisibility(View.INVISIBLE);
mControlsLayout.setVisibility(View.GONE); mControlsLayout.setVisibility(View.GONE);
switchCamera.setVisibility(View.INVISIBLE); switchCamera.setVisibility(View.INVISIBLE);
options.setImageResource(R.drawable.options); options.setImageResource(R.drawable.options);
} else { } else {
Animation animation = AnimationUtils.loadAnimation(instance, R.anim.slide_out_top_to_bottom); Animation animation = slideOutTopToBottom;
animation.setAnimationListener(new AnimationListener() { animation.setAnimationListener(new AnimationListener() {
@Override @Override
public void onAnimationStart(Animation animation) { public void onAnimationStart(Animation animation) {
@ -443,11 +460,13 @@ public class InCallActivity extends FragmentActivity implements
mControlsLayout.setVisibility(View.GONE); mControlsLayout.setVisibility(View.GONE);
switchCamera.setVisibility(View.INVISIBLE); switchCamera.setVisibility(View.INVISIBLE);
options.setImageResource(R.drawable.options); options.setImageResource(R.drawable.options);
animation.setAnimationListener(null);
} }
}); });
mControlsLayout.startAnimation(animation); mControlsLayout.startAnimation(animation);
if (AndroidCameraConfiguration.retrieveCameras().length > 1) { if (cameraNumber > 1) {
switchCamera.startAnimation(AnimationUtils.loadAnimation(instance, R.anim.slide_out_bottom_to_top)); switchCamera.startAnimation(slideOutBottomToTop);
} }
} }
} }
@ -456,8 +475,8 @@ public class InCallActivity extends FragmentActivity implements
} }
public void setCallControlsVisibleAndRemoveCallbacks() { public void setCallControlsVisibleAndRemoveCallbacks() {
if (controlsHandler != null && mControls != null) { if (mControlsHandler != null && mControls != null) {
controlsHandler.removeCallbacks(mControls); mControlsHandler.removeCallbacks(mControls);
} }
mControls = null; mControls = null;
@ -471,11 +490,11 @@ public class InCallActivity extends FragmentActivity implements
} }
dialer.setImageResource(R.drawable.dialer_alt); dialer.setImageResource(R.drawable.dialer_alt);
if (getResources().getBoolean(R.bool.disable_animations)) { if (isAnimationDisabled) {
numpad.setVisibility(View.GONE); numpad.setVisibility(View.GONE);
} else { } else {
Animation anim = AnimationUtils.loadAnimation(this, R.anim.slide_out_top_to_bottom); Animation animation = slideOutTopToBottom;
anim.setAnimationListener(new AnimationListener() { animation.setAnimationListener(new AnimationListener() {
@Override @Override
public void onAnimationStart(Animation animation) { public void onAnimationStart(Animation animation) {
@ -489,9 +508,10 @@ public class InCallActivity extends FragmentActivity implements
@Override @Override
public void onAnimationEnd(Animation animation) { public void onAnimationEnd(Animation animation) {
numpad.setVisibility(View.GONE); numpad.setVisibility(View.GONE);
animation.setAnimationListener(null);
} }
}); });
numpad.startAnimation(anim); numpad.startAnimation(animation);
} }
} }
@ -504,11 +524,11 @@ public class InCallActivity extends FragmentActivity implements
hideNumpad(); hideNumpad();
} else { } else {
dialer.setImageResource(R.drawable.dialer_alt_back); dialer.setImageResource(R.drawable.dialer_alt_back);
if (getResources().getBoolean(R.bool.disable_animations)) { if (isAnimationDisabled) {
numpad.setVisibility(View.VISIBLE); numpad.setVisibility(View.VISIBLE);
} else { } else {
Animation anim = AnimationUtils.loadAnimation(this, R.anim.slide_in_bottom_to_top); Animation animation = slideInBottomToTop;
anim.setAnimationListener(new AnimationListener() { animation.setAnimationListener(new AnimationListener() {
@Override @Override
public void onAnimationStart(Animation animation) { public void onAnimationStart(Animation animation) {
@ -522,9 +542,10 @@ public class InCallActivity extends FragmentActivity implements
@Override @Override
public void onAnimationEnd(Animation animation) { public void onAnimationEnd(Animation animation) {
numpad.setVisibility(View.VISIBLE); numpad.setVisibility(View.VISIBLE);
animation.setAnimationListener(null);
} }
}); });
numpad.startAnimation(anim); numpad.startAnimation(animation);
} }
} }
} }
@ -532,14 +553,14 @@ public class InCallActivity extends FragmentActivity implements
private void hideOrDisplayCallOptions() { private void hideOrDisplayCallOptions() {
if (addCall.getVisibility() == View.VISIBLE) { if (addCall.getVisibility() == View.VISIBLE) {
options.setImageResource(R.drawable.options); options.setImageResource(R.drawable.options);
if (getResources().getBoolean(R.bool.disable_animations)) { if (isAnimationDisabled) {
if (isTransferAllowed) { if (isTransferAllowed) {
transfer.setVisibility(View.INVISIBLE); transfer.setVisibility(View.INVISIBLE);
} }
addCall.setVisibility(View.INVISIBLE); addCall.setVisibility(View.INVISIBLE);
} else { } else {
Animation anim = AnimationUtils.loadAnimation(this, R.anim.slide_out_left_to_right); Animation animation = slideOutLeftToRight;
anim.setAnimationListener(new AnimationListener() { animation.setAnimationListener(new AnimationListener() {
@Override @Override
public void onAnimationStart(Animation animation) { public void onAnimationStart(Animation animation) {
@ -556,12 +577,13 @@ public class InCallActivity extends FragmentActivity implements
transfer.setVisibility(View.INVISIBLE); transfer.setVisibility(View.INVISIBLE);
} }
addCall.setVisibility(View.INVISIBLE); addCall.setVisibility(View.INVISIBLE);
animation.setAnimationListener(null);
} }
}); });
if (isTransferAllowed) { if (isTransferAllowed) {
transfer.startAnimation(anim); transfer.startAnimation(animation);
} }
addCall.startAnimation(anim); addCall.startAnimation(animation);
} }
} else { } else {
if (getResources().getBoolean(R.bool.disable_animations)) { if (getResources().getBoolean(R.bool.disable_animations)) {
@ -571,8 +593,8 @@ public class InCallActivity extends FragmentActivity implements
addCall.setVisibility(View.VISIBLE); addCall.setVisibility(View.VISIBLE);
options.setImageResource(R.drawable.options_alt); options.setImageResource(R.drawable.options_alt);
} else { } else {
Animation anim = AnimationUtils.loadAnimation(this, R.anim.slide_in_right_to_left); Animation animation = slideInRightToLeft;
anim.setAnimationListener(new AnimationListener() { animation.setAnimationListener(new AnimationListener() {
@Override @Override
public void onAnimationStart(Animation animation) { public void onAnimationStart(Animation animation) {
@ -590,12 +612,13 @@ public class InCallActivity extends FragmentActivity implements
transfer.setVisibility(View.VISIBLE); transfer.setVisibility(View.VISIBLE);
} }
addCall.setVisibility(View.VISIBLE); addCall.setVisibility(View.VISIBLE);
animation.setAnimationListener(null);
} }
}); });
if (isTransferAllowed) { if (isTransferAllowed) {
transfer.startAnimation(anim); transfer.startAnimation(animation);
} }
addCall.startAnimation(anim); addCall.startAnimation(animation);
} }
transfer.setEnabled(LinphoneManager.getLc().getCurrentCall() != null); transfer.setEnabled(LinphoneManager.getLc().getCurrentCall() != null);
} }
@ -670,8 +693,8 @@ public class InCallActivity extends FragmentActivity implements
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();
if (controlsHandler != null && mControls != null) { if (mControlsHandler != null && mControls != null) {
controlsHandler.removeCallbacks(mControls); mControlsHandler.removeCallbacks(mControls);
} }
mControls = null; mControls = null;
@ -681,10 +704,16 @@ public class InCallActivity extends FragmentActivity implements
@Override @Override
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); if (mControlsHandler != null && mControls != null) {
mControlsHandler.removeCallbacks(mControls);
}
mControls = null;
mControlsHandler = null;
mHandler = null;
unbindDrawables(findViewById(R.id.topLayout)); unbindDrawables(findViewById(R.id.topLayout));
instance = null; instance = null;
super.onDestroy();
System.gc(); System.gc();
} }
@ -692,6 +721,9 @@ public class InCallActivity extends FragmentActivity implements
if (view.getBackground() != null) { if (view.getBackground() != null) {
view.getBackground().setCallback(null); view.getBackground().setCallback(null);
} }
if (view instanceof ImageView) {
view.setOnClickListener(null);
}
if (view instanceof ViewGroup && !(view instanceof AdapterView)) { if (view instanceof ViewGroup && !(view instanceof AdapterView)) {
for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) { for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
unbindDrawables(((ViewGroup) view).getChildAt(i)); unbindDrawables(((ViewGroup) view).getChildAt(i));
@ -710,4 +742,8 @@ public class InCallActivity extends FragmentActivity implements
public void bindAudioFragment(AudioCallFragment fragment) { public void bindAudioFragment(AudioCallFragment fragment) {
audioCallFragment = fragment; audioCallFragment = fragment;
} }
public void bindVideoFragment(VideoCallFragment fragment) {
videoCallFragment = fragment;
}
} }

View file

@ -64,7 +64,6 @@ public class IncomingCallActivity extends Activity implements LinphoneOnCallStat
int flags = WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON; int flags = WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
getWindow().addFlags(flags); getWindow().addFlags(flags);
// "Dial-to-answer" widget for incoming calls. // "Dial-to-answer" widget for incoming calls.
mIncomingCallWidget = (LinphoneSliders) findViewById(R.id.sliding_widget); mIncomingCallWidget = (LinphoneSliders) findViewById(R.id.sliding_widget);
mIncomingCallWidget.setOnTriggerListener(this); mIncomingCallWidget.setOnTriggerListener(this);

View file

@ -25,6 +25,7 @@ import org.linphone.core.Log;
import org.linphone.mediastream.video.AndroidVideoWindowImpl; import org.linphone.mediastream.video.AndroidVideoWindowImpl;
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration; import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
import android.app.Activity;
import android.opengl.GLSurfaceView; import android.opengl.GLSurfaceView;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
@ -38,7 +39,6 @@ import android.view.SurfaceView;
import android.view.View; import android.view.View;
import android.view.View.OnTouchListener; import android.view.View.OnTouchListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.WindowManager;
/** /**
* @author Sylvain Berfini * @author Sylvain Berfini
@ -51,18 +51,14 @@ public class VideoCallFragment extends Fragment implements OnGestureListener, On
private float mZoomFactor = 1.f; private float mZoomFactor = 1.f;
private float mZoomCenterX, mZoomCenterY; private float mZoomCenterX, mZoomCenterY;
private CompatibilityScaleGestureDetector mScaleDetector; private CompatibilityScaleGestureDetector mScaleDetector;
private InCallActivity inCallActivity;
@SuppressWarnings("deprecation") // Warning useless because value is ignored and automatically set by new APIs. @SuppressWarnings("deprecation") // Warning useless because value is ignored and automatically set by new APIs.
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
View view = inflater.inflate(R.layout.video, container, false); View view = inflater.inflate(R.layout.video, container, false);
mGestureDetector = new GestureDetector(getActivity(), this);
mScaleDetector = Compatibility.getScaleGestureDetector(getActivity(), this);
mVideoView = (SurfaceView) view.findViewById(R.id.videoSurface); mVideoView = (SurfaceView) view.findViewById(R.id.videoSurface);
mCaptureView = (SurfaceView) view.findViewById(R.id.videoCaptureSurface); mCaptureView = (SurfaceView) view.findViewById(R.id.videoCaptureSurface);
mCaptureView.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); // Warning useless because value is ignored and automatically set by new APIs. mCaptureView.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); // Warning useless because value is ignored and automatically set by new APIs.
@ -77,8 +73,7 @@ public class VideoCallFragment extends Fragment implements OnGestureListener, On
} }
public void onVideoRenderingSurfaceDestroyed(AndroidVideoWindowImpl vw) { public void onVideoRenderingSurfaceDestroyed(AndroidVideoWindowImpl vw) {
Log.d("VIDEO WINDOW destroyed!\n"); LinphoneCore lc = LinphoneManager.getLc();
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (lc != null) { if (lc != null) {
lc.setVideoWindow(null); lc.setVideoWindow(null);
} }
@ -103,7 +98,9 @@ public class VideoCallFragment extends Fragment implements OnGestureListener, On
} }
mGestureDetector.onTouchEvent(event); mGestureDetector.onTouchEvent(event);
InCallActivity.instance().displayVideoCallControlsIfHidden(); if (inCallActivity != null) {
inCallActivity.displayVideoCallControlsIfHidden();
}
return true; return true;
} }
}); });
@ -138,28 +135,35 @@ public class VideoCallFragment extends Fragment implements OnGestureListener, On
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
if (mVideoView != null) if (mVideoView != null) {
((GLSurfaceView) mVideoView).onResume(); ((GLSurfaceView) mVideoView).onResume();
}
if (androidVideoWindowImpl != null) { if (androidVideoWindowImpl != null) {
synchronized (androidVideoWindowImpl) { synchronized (androidVideoWindowImpl) {
LinphoneManager.getLc().setVideoWindow(androidVideoWindowImpl); LinphoneManager.getLc().setVideoWindow(androidVideoWindowImpl);
} }
} }
mGestureDetector = new GestureDetector(inCallActivity, this);
mScaleDetector = Compatibility.getScaleGestureDetector(inCallActivity, this);
} }
@Override @Override
public void onPause() { public void onPause() {
synchronized (androidVideoWindowImpl) { if (androidVideoWindowImpl != null) {
/* synchronized (androidVideoWindowImpl) {
* this call will destroy native opengl renderer which is used by /*
* androidVideoWindowImpl * this call will destroy native opengl renderer which is used by
*/ * androidVideoWindowImpl
LinphoneManager.getLc().setVideoWindow(null); */
LinphoneManager.getLc().setVideoWindow(null);
}
} }
if (mVideoView != null) if (mVideoView != null) {
((GLSurfaceView) mVideoView).onPause(); ((GLSurfaceView) mVideoView).onPause();
}
super.onPause(); super.onPause();
} }
@ -222,14 +226,17 @@ public class VideoCallFragment extends Fragment implements OnGestureListener, On
@Override @Override
public void onDestroy() { public void onDestroy() {
getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); inCallActivity = null;
mCaptureView = null;
if (mVideoView != null) {
mVideoView.setOnTouchListener(null);
mVideoView = null;
}
if (androidVideoWindowImpl != null) { if (androidVideoWindowImpl != null) {
// Prevent linphone from crashing if correspondent hang up while you are rotating // Prevent linphone from crashing if correspondent hang up while you are rotating
androidVideoWindowImpl.release(); androidVideoWindowImpl.release();
androidVideoWindowImpl = null; androidVideoWindowImpl = null;
mCaptureView = null;
mVideoView = null;
} }
if (mGestureDetector != null) { if (mGestureDetector != null) {
mGestureDetector.setOnDoubleTapListener(null); mGestureDetector.setOnDoubleTapListener(null);
@ -243,6 +250,16 @@ public class VideoCallFragment extends Fragment implements OnGestureListener, On
super.onDestroy(); super.onDestroy();
} }
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
inCallActivity = (InCallActivity) activity;
if (inCallActivity != null) {
inCallActivity.bindVideoFragment(this);
}
}
@Override @Override
public boolean onDown(MotionEvent e) { public boolean onDown(MotionEvent e) {
return true; // Needed to make the GestureDetector working return true; // Needed to make the GestureDetector working