Fix FC camera
This commit is contained in:
parent
1c1f42e722
commit
9a9cd5a54e
2 changed files with 97 additions and 55 deletions
|
@ -39,6 +39,7 @@
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@android:style/Theme.NoTitleBar"
|
android:theme="@android:style/Theme.NoTitleBar"
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
|
android:windowSoftInputMode="stateAlwaysHidden|adjustResize"
|
||||||
> <!-- android:alwaysRetainTaskState="true" clearTaskOnLaunch="false"-->
|
> <!-- android:alwaysRetainTaskState="true" clearTaskOnLaunch="false"-->
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
@ -94,7 +95,8 @@
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name="org.linphone.DialerActivity">
|
<activity android:name="org.linphone.DialerActivity"
|
||||||
|
android:configChanges="keyboardHidden|orientation">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
|
@ -40,16 +40,20 @@ import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.hardware.Camera;
|
import android.hardware.Camera;
|
||||||
import android.hardware.Camera.CameraInfo;
|
import android.hardware.Camera.CameraInfo;
|
||||||
|
import android.hardware.Camera.Parameters;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.view.Display;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Surface;
|
||||||
import android.view.SurfaceHolder;
|
import android.view.SurfaceHolder;
|
||||||
import android.view.SurfaceHolder.Callback;
|
import android.view.SurfaceHolder.Callback;
|
||||||
import android.view.SurfaceView;
|
import android.view.SurfaceView;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
|
import android.view.WindowManager;
|
||||||
import android.widget.Adapter;
|
import android.widget.Adapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ListAdapter;
|
import android.widget.ListAdapter;
|
||||||
|
@ -203,64 +207,16 @@ public class DialerActivity extends Activity implements LinphoneGuiListener {
|
||||||
setContentView(R.layout.dialer);
|
setContentView(R.layout.dialer);
|
||||||
|
|
||||||
mAddress = (AddressText) findViewById(R.id.SipUri);
|
mAddress = (AddressText) findViewById(R.id.SipUri);
|
||||||
((EraseButton) findViewById(R.id.Erase)).setAddressWidget(mAddress);
|
EraseButton erase = (EraseButton) findViewById(R.id.Erase);
|
||||||
|
erase.setAddressWidget(mAddress);
|
||||||
|
erase.requestFocus();
|
||||||
|
|
||||||
mCall = (CallButton) findViewById(R.id.Call);
|
mCall = (CallButton) findViewById(R.id.Call);
|
||||||
mCall.setAddressWidget(mAddress);
|
mCall.setAddressWidget(mAddress);
|
||||||
|
|
||||||
mStatus = (TextView) findViewById(R.id.status_label);
|
mStatus = (TextView) findViewById(R.id.status_label);
|
||||||
|
|
||||||
// For the tablet landscape
|
|
||||||
final int numberOfCameras = Camera.getNumberOfCameras();
|
|
||||||
CameraInfo cameraInfo = new CameraInfo();
|
|
||||||
for (int i = 0; i < numberOfCameras; i++) {
|
|
||||||
Camera.getCameraInfo(i, cameraInfo);
|
|
||||||
if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
|
|
||||||
mCurrentCameraId = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mCamera = Camera.open(mCurrentCameraId);
|
|
||||||
|
|
||||||
mVideoCaptureViewReady = (SurfaceView) findViewById(R.id.video_background);
|
tryToInitTablerUI();
|
||||||
if (mVideoCaptureViewReady != null)
|
|
||||||
{
|
|
||||||
mVideoCaptureViewReady.getHolder().addCallback(new Callback() {
|
|
||||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
|
||||||
if (mCamera != null) {
|
|
||||||
mCamera.stopPreview();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void surfaceCreated(SurfaceHolder holder) {
|
|
||||||
try {
|
|
||||||
if (mCamera != null) {
|
|
||||||
mCamera.setPreviewDisplay(holder);
|
|
||||||
}
|
|
||||||
} catch (IOException exception) {
|
|
||||||
Log.e("IOException caused by setPreviewDisplay()", exception);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void surfaceChanged(SurfaceHolder holder, int format, int width,
|
|
||||||
int height) {
|
|
||||||
Camera.Parameters parameters = mCamera.getParameters();
|
|
||||||
parameters.setPreviewSize(holder.getSurfaceFrame().width(), holder.getSurfaceFrame().height());
|
|
||||||
mVideoCaptureViewReady.requestLayout();
|
|
||||||
|
|
||||||
mCamera.setParameters(parameters);
|
|
||||||
mCamera.startPreview();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
mCamera.startPreview();
|
|
||||||
|
|
||||||
Button switchCamera = (Button) findViewById(R.id.switch_camera);
|
|
||||||
if (switchCamera != null)
|
|
||||||
{
|
|
||||||
switchCamera.setOnClickListener(new OnClickListener() {
|
|
||||||
public void onClick(View v) {
|
|
||||||
mCamera = Camera.open((mCurrentCameraId + 1) % numberOfCameras);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
SlidingDrawer drawer = (SlidingDrawer) findViewById(R.id.drawer);
|
SlidingDrawer drawer = (SlidingDrawer) findViewById(R.id.drawer);
|
||||||
if (drawer != null) {
|
if (drawer != null) {
|
||||||
|
@ -297,10 +253,89 @@ public class DialerActivity extends Activity implements LinphoneGuiListener {
|
||||||
verifiyAccountsActivated();
|
verifiyAccountsActivated();
|
||||||
|
|
||||||
displayRegisterStatus();
|
displayRegisterStatus();
|
||||||
|
mCall.requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void checkIfOutgoingCallIntentReceived() {
|
private synchronized void tryToInitTablerUI() {
|
||||||
|
final int numberOfCameras = Camera.getNumberOfCameras();
|
||||||
|
|
||||||
|
CameraInfo cameraInfo = new CameraInfo();
|
||||||
|
for (int i = 0; i < numberOfCameras; i++) {
|
||||||
|
Camera.getCameraInfo(i, cameraInfo);
|
||||||
|
if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
|
||||||
|
mCurrentCameraId = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mVideoCaptureViewReady = (SurfaceView) findViewById(R.id.video_background);
|
||||||
|
if (mVideoCaptureViewReady != null)
|
||||||
|
{
|
||||||
|
if (mCamera == null)
|
||||||
|
mCamera = Camera.open(mCurrentCameraId);
|
||||||
|
|
||||||
|
mVideoCaptureViewReady.getHolder().addCallback(new Callback() {
|
||||||
|
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||||
|
if (mCamera != null) {
|
||||||
|
mCamera.stopPreview();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void surfaceCreated(SurfaceHolder holder) {
|
||||||
|
try {
|
||||||
|
if (mCamera != null) {
|
||||||
|
mCamera.setPreviewDisplay(holder);
|
||||||
|
}
|
||||||
|
} catch (IOException exception) {
|
||||||
|
Log.e("IOException caused by setPreviewDisplay()", exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void surfaceChanged(SurfaceHolder holder, int format, int width,
|
||||||
|
int height) {
|
||||||
|
Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
|
||||||
|
|
||||||
|
if(display.getRotation() == Surface.ROTATION_90)
|
||||||
|
{
|
||||||
|
mCamera.setDisplayOrientation(270);
|
||||||
|
}
|
||||||
|
else if(display.getRotation() == Surface.ROTATION_270)
|
||||||
|
{
|
||||||
|
mCamera.setDisplayOrientation(90);
|
||||||
|
}
|
||||||
|
else if (display.getRotation() == Surface.ROTATION_180)
|
||||||
|
{
|
||||||
|
mCamera.setDisplayOrientation(180);
|
||||||
|
}
|
||||||
|
|
||||||
|
mVideoCaptureViewReady.requestLayout();
|
||||||
|
mCamera.startPreview();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
mCamera.startPreview();
|
||||||
|
}
|
||||||
|
|
||||||
|
Button switchCamera = (Button) findViewById(R.id.switch_camera);
|
||||||
|
if (switchCamera != null)
|
||||||
|
{
|
||||||
|
if (numberOfCameras == 1)
|
||||||
|
switchCamera.setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
|
switchCamera.setOnClickListener(new OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
try {
|
||||||
|
mCamera.setPreviewDisplay(mVideoCaptureViewReady.getHolder());
|
||||||
|
} catch (IOException exception) { }
|
||||||
|
mCurrentCameraId = (mCurrentCameraId + 1) % numberOfCameras;
|
||||||
|
mCamera.release();
|
||||||
|
mCamera = Camera.open(mCurrentCameraId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkIfOutgoingCallIntentReceived() {
|
||||||
if (getIntent().getData() == null) return;
|
if (getIntent().getData() == null) return;
|
||||||
|
|
||||||
if (!LinphoneService.isReady() || LinphoneManager.getLc().isIncall()) {
|
if (!LinphoneService.isReady() || LinphoneManager.getLc().isIncall()) {
|
||||||
|
@ -321,7 +356,7 @@ public class DialerActivity extends Activity implements LinphoneGuiListener {
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
||||||
if (mCamera != null) {
|
if (mCamera != null) {
|
||||||
mCamera.release();
|
mCamera.release();
|
||||||
mCamera = null;
|
mCamera = null;
|
||||||
|
@ -457,6 +492,11 @@ public class DialerActivity extends Activity implements LinphoneGuiListener {
|
||||||
{
|
{
|
||||||
mCamera = Camera.open(mCurrentCameraId);
|
mCamera = Camera.open(mCurrentCameraId);
|
||||||
mVideoCaptureViewReady.requestLayout();
|
mVideoCaptureViewReady.requestLayout();
|
||||||
|
try {
|
||||||
|
mCamera.setPreviewDisplay(mVideoCaptureViewReady.getHolder());
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
mCamera.startPreview();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue