diff --git a/res/layout-land/video.xml b/res/layout-land/video.xml
index 46a71800f..207405d19 100644
--- a/res/layout-land/video.xml
+++ b/res/layout-land/video.xml
@@ -6,8 +6,8 @@
1) {
+ if (cameraNumber > 1) {
switchCamera.setVisibility(View.VISIBLE);
}
} else {
@@ -121,7 +129,6 @@ public class InCallActivity extends FragmentActivity implements
callFragment.setArguments(getIntent().getExtras());
getSupportFragmentManager().beginTransaction().add(R.id.fragmentContainer, callFragment).commitAllowingStateLoss();
}
-
}
private void initUI() {
@@ -161,6 +168,15 @@ public class InCallActivity extends FragmentActivity implements
if (!isTransferAllowed) {
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() {
@@ -302,7 +318,7 @@ public class InCallActivity extends FragmentActivity implements
}
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);
switchCamera.setVisibility(View.INVISIBLE);
@@ -371,18 +387,18 @@ public class InCallActivity extends FragmentActivity implements
public void displayVideoCallControlsIfHidden() {
if (mControlsLayout != null) {
if (mControlsLayout.getVisibility() == View.GONE) {
- if (getResources().getBoolean(R.bool.disable_animations)) {
+ if (isAnimationDisabled) {
mControlsLayout.setVisibility(View.VISIBLE);
- if (AndroidCameraConfiguration.retrieveCameras().length > 1) {
+ if (cameraNumber > 1) {
switchCamera.setVisibility(View.VISIBLE);
}
} else {
- Animation animation = AnimationUtils.loadAnimation(this, R.anim.slide_in_bottom_to_top);
+ Animation animation = slideInBottomToTop;
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
mControlsLayout.setVisibility(View.VISIBLE);
- if (AndroidCameraConfiguration.retrieveCameras().length > 1) {
+ if (cameraNumber > 1) {
switchCamera.setVisibility(View.VISIBLE);
}
}
@@ -393,11 +409,12 @@ public class InCallActivity extends FragmentActivity implements
@Override
public void onAnimationEnd(Animation animation) {
+ animation.setAnimationListener(null);
}
});
mControlsLayout.startAnimation(animation);
- if (AndroidCameraConfiguration.retrieveCameras().length > 1) {
- switchCamera.startAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_in_top_to_bottom));
+ if (cameraNumber > 1) {
+ switchCamera.startAnimation(slideInTopToBottom);
}
}
@@ -407,24 +424,24 @@ public class InCallActivity extends FragmentActivity implements
}
public void resetControlsHidingCallBack() {
- if (controlsHandler != null && mControls != null) {
- controlsHandler.removeCallbacks(mControls);
+ if (mControlsHandler != null && mControls != null) {
+ mControlsHandler.removeCallbacks(mControls);
}
mControls = null;
if (isVideoEnabled) {
- controlsHandler.postDelayed(mControls = new Runnable() {
+ mControlsHandler.postDelayed(mControls = new Runnable() {
public void run() {
hideNumpad();
- if (getResources().getBoolean(R.bool.disable_animations)) {
+ if (isAnimationDisabled) {
transfer.setVisibility(View.INVISIBLE);
addCall.setVisibility(View.INVISIBLE);
mControlsLayout.setVisibility(View.GONE);
switchCamera.setVisibility(View.INVISIBLE);
options.setImageResource(R.drawable.options);
} else {
- Animation animation = AnimationUtils.loadAnimation(instance, R.anim.slide_out_top_to_bottom);
+ Animation animation = slideOutTopToBottom;
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
@@ -443,11 +460,13 @@ public class InCallActivity extends FragmentActivity implements
mControlsLayout.setVisibility(View.GONE);
switchCamera.setVisibility(View.INVISIBLE);
options.setImageResource(R.drawable.options);
+
+ animation.setAnimationListener(null);
}
});
mControlsLayout.startAnimation(animation);
- if (AndroidCameraConfiguration.retrieveCameras().length > 1) {
- switchCamera.startAnimation(AnimationUtils.loadAnimation(instance, R.anim.slide_out_bottom_to_top));
+ if (cameraNumber > 1) {
+ switchCamera.startAnimation(slideOutBottomToTop);
}
}
}
@@ -456,8 +475,8 @@ public class InCallActivity extends FragmentActivity implements
}
public void setCallControlsVisibleAndRemoveCallbacks() {
- if (controlsHandler != null && mControls != null) {
- controlsHandler.removeCallbacks(mControls);
+ if (mControlsHandler != null && mControls != null) {
+ mControlsHandler.removeCallbacks(mControls);
}
mControls = null;
@@ -471,11 +490,11 @@ public class InCallActivity extends FragmentActivity implements
}
dialer.setImageResource(R.drawable.dialer_alt);
- if (getResources().getBoolean(R.bool.disable_animations)) {
+ if (isAnimationDisabled) {
numpad.setVisibility(View.GONE);
} else {
- Animation anim = AnimationUtils.loadAnimation(this, R.anim.slide_out_top_to_bottom);
- anim.setAnimationListener(new AnimationListener() {
+ Animation animation = slideOutTopToBottom;
+ animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
@@ -489,9 +508,10 @@ public class InCallActivity extends FragmentActivity implements
@Override
public void onAnimationEnd(Animation animation) {
numpad.setVisibility(View.GONE);
+ animation.setAnimationListener(null);
}
});
- numpad.startAnimation(anim);
+ numpad.startAnimation(animation);
}
}
@@ -504,11 +524,11 @@ public class InCallActivity extends FragmentActivity implements
hideNumpad();
} else {
dialer.setImageResource(R.drawable.dialer_alt_back);
- if (getResources().getBoolean(R.bool.disable_animations)) {
+ if (isAnimationDisabled) {
numpad.setVisibility(View.VISIBLE);
} else {
- Animation anim = AnimationUtils.loadAnimation(this, R.anim.slide_in_bottom_to_top);
- anim.setAnimationListener(new AnimationListener() {
+ Animation animation = slideInBottomToTop;
+ animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
@@ -522,9 +542,10 @@ public class InCallActivity extends FragmentActivity implements
@Override
public void onAnimationEnd(Animation animation) {
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() {
if (addCall.getVisibility() == View.VISIBLE) {
options.setImageResource(R.drawable.options);
- if (getResources().getBoolean(R.bool.disable_animations)) {
+ if (isAnimationDisabled) {
if (isTransferAllowed) {
transfer.setVisibility(View.INVISIBLE);
}
addCall.setVisibility(View.INVISIBLE);
} else {
- Animation anim = AnimationUtils.loadAnimation(this, R.anim.slide_out_left_to_right);
- anim.setAnimationListener(new AnimationListener() {
+ Animation animation = slideOutLeftToRight;
+ animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
@@ -556,12 +577,13 @@ public class InCallActivity extends FragmentActivity implements
transfer.setVisibility(View.INVISIBLE);
}
addCall.setVisibility(View.INVISIBLE);
+ animation.setAnimationListener(null);
}
});
if (isTransferAllowed) {
- transfer.startAnimation(anim);
+ transfer.startAnimation(animation);
}
- addCall.startAnimation(anim);
+ addCall.startAnimation(animation);
}
} else {
if (getResources().getBoolean(R.bool.disable_animations)) {
@@ -571,8 +593,8 @@ public class InCallActivity extends FragmentActivity implements
addCall.setVisibility(View.VISIBLE);
options.setImageResource(R.drawable.options_alt);
} else {
- Animation anim = AnimationUtils.loadAnimation(this, R.anim.slide_in_right_to_left);
- anim.setAnimationListener(new AnimationListener() {
+ Animation animation = slideInRightToLeft;
+ animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
@@ -590,12 +612,13 @@ public class InCallActivity extends FragmentActivity implements
transfer.setVisibility(View.VISIBLE);
}
addCall.setVisibility(View.VISIBLE);
+ animation.setAnimationListener(null);
}
});
if (isTransferAllowed) {
- transfer.startAnimation(anim);
+ transfer.startAnimation(animation);
}
- addCall.startAnimation(anim);
+ addCall.startAnimation(animation);
}
transfer.setEnabled(LinphoneManager.getLc().getCurrentCall() != null);
}
@@ -670,8 +693,8 @@ public class InCallActivity extends FragmentActivity implements
protected void onPause() {
super.onPause();
- if (controlsHandler != null && mControls != null) {
- controlsHandler.removeCallbacks(mControls);
+ if (mControlsHandler != null && mControls != null) {
+ mControlsHandler.removeCallbacks(mControls);
}
mControls = null;
@@ -681,10 +704,16 @@ public class InCallActivity extends FragmentActivity implements
@Override
protected void onDestroy() {
- super.onDestroy();
+ if (mControlsHandler != null && mControls != null) {
+ mControlsHandler.removeCallbacks(mControls);
+ }
+ mControls = null;
+ mControlsHandler = null;
+ mHandler = null;
unbindDrawables(findViewById(R.id.topLayout));
instance = null;
+ super.onDestroy();
System.gc();
}
@@ -692,6 +721,9 @@ public class InCallActivity extends FragmentActivity implements
if (view.getBackground() != null) {
view.getBackground().setCallback(null);
}
+ if (view instanceof ImageView) {
+ view.setOnClickListener(null);
+ }
if (view instanceof ViewGroup && !(view instanceof AdapterView)) {
for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
unbindDrawables(((ViewGroup) view).getChildAt(i));
@@ -710,4 +742,8 @@ public class InCallActivity extends FragmentActivity implements
public void bindAudioFragment(AudioCallFragment fragment) {
audioCallFragment = fragment;
}
+
+ public void bindVideoFragment(VideoCallFragment fragment) {
+ videoCallFragment = fragment;
+ }
}
diff --git a/src/org/linphone/IncomingCallActivity.java b/src/org/linphone/IncomingCallActivity.java
index 53201b899..0f244dca1 100644
--- a/src/org/linphone/IncomingCallActivity.java
+++ b/src/org/linphone/IncomingCallActivity.java
@@ -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;
getWindow().addFlags(flags);
-
// "Dial-to-answer" widget for incoming calls.
mIncomingCallWidget = (LinphoneSliders) findViewById(R.id.sliding_widget);
mIncomingCallWidget.setOnTriggerListener(this);
diff --git a/src/org/linphone/VideoCallFragment.java b/src/org/linphone/VideoCallFragment.java
index ecf0d169c..d39f66a8d 100644
--- a/src/org/linphone/VideoCallFragment.java
+++ b/src/org/linphone/VideoCallFragment.java
@@ -25,6 +25,7 @@ import org.linphone.core.Log;
import org.linphone.mediastream.video.AndroidVideoWindowImpl;
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
+import android.app.Activity;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.support.v4.app.Fragment;
@@ -38,7 +39,6 @@ import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
-import android.view.WindowManager;
/**
* @author Sylvain Berfini
@@ -51,18 +51,14 @@ public class VideoCallFragment extends Fragment implements OnGestureListener, On
private float mZoomFactor = 1.f;
private float mZoomCenterX, mZoomCenterY;
private CompatibilityScaleGestureDetector mScaleDetector;
+ private InCallActivity inCallActivity;
@SuppressWarnings("deprecation") // Warning useless because value is ignored and automatically set by new APIs.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
-
+ Bundle savedInstanceState) {
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);
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.
@@ -77,8 +73,7 @@ public class VideoCallFragment extends Fragment implements OnGestureListener, On
}
public void onVideoRenderingSurfaceDestroyed(AndroidVideoWindowImpl vw) {
- Log.d("VIDEO WINDOW destroyed!\n");
- LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
+ LinphoneCore lc = LinphoneManager.getLc();
if (lc != null) {
lc.setVideoWindow(null);
}
@@ -103,7 +98,9 @@ public class VideoCallFragment extends Fragment implements OnGestureListener, On
}
mGestureDetector.onTouchEvent(event);
- InCallActivity.instance().displayVideoCallControlsIfHidden();
+ if (inCallActivity != null) {
+ inCallActivity.displayVideoCallControlsIfHidden();
+ }
return true;
}
});
@@ -138,28 +135,35 @@ public class VideoCallFragment extends Fragment implements OnGestureListener, On
public void onResume() {
super.onResume();
- if (mVideoView != null)
+ if (mVideoView != null) {
((GLSurfaceView) mVideoView).onResume();
+ }
if (androidVideoWindowImpl != null) {
synchronized (androidVideoWindowImpl) {
LinphoneManager.getLc().setVideoWindow(androidVideoWindowImpl);
}
}
+
+ mGestureDetector = new GestureDetector(inCallActivity, this);
+ mScaleDetector = Compatibility.getScaleGestureDetector(inCallActivity, this);
}
@Override
- public void onPause() {
- synchronized (androidVideoWindowImpl) {
- /*
- * this call will destroy native opengl renderer which is used by
- * androidVideoWindowImpl
- */
- LinphoneManager.getLc().setVideoWindow(null);
+ public void onPause() {
+ if (androidVideoWindowImpl != null) {
+ synchronized (androidVideoWindowImpl) {
+ /*
+ * this call will destroy native opengl renderer which is used by
+ * androidVideoWindowImpl
+ */
+ LinphoneManager.getLc().setVideoWindow(null);
+ }
}
- if (mVideoView != null)
+ if (mVideoView != null) {
((GLSurfaceView) mVideoView).onPause();
+ }
super.onPause();
}
@@ -222,14 +226,17 @@ public class VideoCallFragment extends Fragment implements OnGestureListener, On
@Override
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) {
// Prevent linphone from crashing if correspondent hang up while you are rotating
androidVideoWindowImpl.release();
androidVideoWindowImpl = null;
- mCaptureView = null;
- mVideoView = null;
}
if (mGestureDetector != null) {
mGestureDetector.setOnDoubleTapListener(null);
@@ -242,6 +249,16 @@ public class VideoCallFragment extends Fragment implements OnGestureListener, On
super.onDestroy();
}
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+
+ inCallActivity = (InCallActivity) activity;
+ if (inCallActivity != null) {
+ inCallActivity.bindVideoFragment(this);
+ }
+ }
@Override
public boolean onDown(MotionEvent e) {