fix switch camera issue + add call button
This commit is contained in:
parent
6ddc0d8f0c
commit
1eadb5bc81
5 changed files with 106 additions and 16 deletions
|
@ -67,12 +67,38 @@
|
||||||
android:background="@drawable/clavier_bg"
|
android:background="@drawable/clavier_bg"
|
||||||
android:src="@drawable/startcall_green" />
|
android:src="@drawable/startcall_green" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/InCallControls"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_weight="3" >
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/AddCall"
|
||||||
|
style="@style/DialerDigit"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/AddCallButtonText" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/Back"
|
||||||
|
style="@style/DialerDigit"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/CancelButtonText" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
style="@style/DialerDigit"
|
|
||||||
android:id="@+id/switch_camera"
|
android:id="@+id/switch_camera"
|
||||||
|
style="@style/DialerDigit"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_weight="5"
|
android:layout_weight="5"
|
||||||
|
android:visibility="invisible"
|
||||||
android:text="@string/menu_videocall_switch_camera_title" />
|
android:text="@string/menu_videocall_switch_camera_title" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
|
|
|
@ -57,7 +57,8 @@
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
style="@style/incall_control"
|
style="@style/incall_control"
|
||||||
|
android:background="@drawable/clavier_bg"
|
||||||
android:id="@+id/switch_camera"
|
android:id="@+id/switch_camera"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
|
|
@ -25,8 +25,10 @@ import org.linphone.LinphoneService.LinphoneGuiListener;
|
||||||
import org.linphone.core.LinphoneCall;
|
import org.linphone.core.LinphoneCall;
|
||||||
import org.linphone.core.LinphoneCall.State;
|
import org.linphone.core.LinphoneCall.State;
|
||||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||||
|
import org.linphone.core.LinphoneCoreException;
|
||||||
import org.linphone.core.LinphoneProxyConfig;
|
import org.linphone.core.LinphoneProxyConfig;
|
||||||
import org.linphone.core.Log;
|
import org.linphone.core.Log;
|
||||||
|
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
||||||
import org.linphone.ui.AddressAware;
|
import org.linphone.ui.AddressAware;
|
||||||
import org.linphone.ui.AddressText;
|
import org.linphone.ui.AddressText;
|
||||||
import org.linphone.ui.CallButton;
|
import org.linphone.ui.CallButton;
|
||||||
|
@ -49,6 +51,7 @@ import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.widget.Adapter;
|
import android.widget.Adapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ListAdapter;
|
import android.widget.ListAdapter;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.SimpleAdapter;
|
import android.widget.SimpleAdapter;
|
||||||
|
@ -75,6 +78,8 @@ public class DialerActivity extends Activity implements LinphoneGuiListener {
|
||||||
|
|
||||||
private AddressText mAddress;
|
private AddressText mAddress;
|
||||||
private CallButton mCall;
|
private CallButton mCall;
|
||||||
|
private Button mBack, mAddCall, mSwitchCamera;
|
||||||
|
private LinearLayout mInCallControls;
|
||||||
|
|
||||||
private static DialerActivity instance;
|
private static DialerActivity instance;
|
||||||
private boolean mPreventDoubleCallOnRotation;
|
private boolean mPreventDoubleCallOnRotation;
|
||||||
|
@ -88,6 +93,7 @@ public class DialerActivity extends Activity implements LinphoneGuiListener {
|
||||||
|
|
||||||
private Camera mCamera;
|
private Camera mCamera;
|
||||||
|
|
||||||
|
|
||||||
private static final String CURRENT_ADDRESS = "org.linphone.current-address";
|
private static final String CURRENT_ADDRESS = "org.linphone.current-address";
|
||||||
private static final String CURRENT_DISPLAYNAME = "org.linphone.current-displayname";
|
private static final String CURRENT_DISPLAYNAME = "org.linphone.current-displayname";
|
||||||
private static final String PREVENT_DOUBLE_CALL = "prevent_call_on_phone_rotation";
|
private static final String PREVENT_DOUBLE_CALL = "prevent_call_on_phone_rotation";
|
||||||
|
@ -206,10 +212,12 @@ public class DialerActivity extends Activity implements LinphoneGuiListener {
|
||||||
|
|
||||||
mCall = (CallButton) findViewById(R.id.Call);
|
mCall = (CallButton) findViewById(R.id.Call);
|
||||||
mCall.setAddressWidget(mAddress);
|
mCall.setAddressWidget(mAddress);
|
||||||
|
mBack = (Button) findViewById(R.id.Back);
|
||||||
|
mAddCall = (Button) findViewById(R.id.AddCall);
|
||||||
|
mInCallControls = (LinearLayout) findViewById(R.id.InCallControls);
|
||||||
mStatus = (TextView) findViewById(R.id.status_label);
|
mStatus = (TextView) findViewById(R.id.status_label);
|
||||||
|
|
||||||
tryToInitTablerUI();
|
tryToInitTabletUI();
|
||||||
|
|
||||||
SlidingDrawer drawer = (SlidingDrawer) findViewById(R.id.drawer);
|
SlidingDrawer drawer = (SlidingDrawer) findViewById(R.id.drawer);
|
||||||
if (drawer != null) {
|
if (drawer != null) {
|
||||||
|
@ -250,7 +258,7 @@ public class DialerActivity extends Activity implements LinphoneGuiListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private synchronized void tryToInitTablerUI() {
|
private synchronized void tryToInitTabletUI() {
|
||||||
final int numberOfCameras = Camera.getNumberOfCameras();
|
final int numberOfCameras = Camera.getNumberOfCameras();
|
||||||
|
|
||||||
CameraInfo cameraInfo = new CameraInfo();
|
CameraInfo cameraInfo = new CameraInfo();
|
||||||
|
@ -271,13 +279,13 @@ public class DialerActivity extends Activity implements LinphoneGuiListener {
|
||||||
mCamera.startPreview();
|
mCamera.startPreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
Button switchCamera = (Button) findViewById(R.id.switch_camera);
|
mSwitchCamera = (Button) findViewById(R.id.switch_camera);
|
||||||
if (switchCamera != null)
|
if (mSwitchCamera != null)
|
||||||
{
|
{
|
||||||
if (numberOfCameras == 1)
|
if (AndroidCameraConfiguration.hasSeveralCameras())
|
||||||
switchCamera.setVisibility(View.INVISIBLE);
|
mSwitchCamera.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
switchCamera.setOnClickListener(new OnClickListener() {
|
mSwitchCamera.setOnClickListener(new OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
mCurrentCameraId = (mCurrentCameraId + 1) % numberOfCameras;
|
mCurrentCameraId = (mCurrentCameraId + 1) % numberOfCameras;
|
||||||
mCamera.release();
|
mCamera.release();
|
||||||
|
@ -289,6 +297,34 @@ public class DialerActivity extends Activity implements LinphoneGuiListener {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mBack.setOnClickListener(new OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
LinphoneCall call = LinphoneManager.getLc().getCurrentCall();
|
||||||
|
if (call.getCurrentParamsCopy().getVideoEnabled())
|
||||||
|
LinphoneActivity.instance().startVideoActivity(call, 0);
|
||||||
|
else
|
||||||
|
LinphoneActivity.instance().startIncallActivity();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mAddCall.setOnClickListener(new OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
LinphoneCall call = LinphoneManager.getLc().getCurrentCall();
|
||||||
|
if (call != null && !call.isInConference()) {
|
||||||
|
LinphoneManager.getLc().pauseCall(call);
|
||||||
|
} else {
|
||||||
|
LinphoneManager.getLc().leaveConference();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
LinphoneManager.getLc().invite(mAddress.getText().toString());
|
||||||
|
} catch (LinphoneCoreException e) {
|
||||||
|
Log.e(e);
|
||||||
|
Toast.makeText(DialerActivity.this, R.string.error_adding_new_call, Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkIfOutgoingCallIntentReceived() {
|
private void checkIfOutgoingCallIntentReceived() {
|
||||||
|
@ -423,7 +459,20 @@ public class DialerActivity extends Activity implements LinphoneGuiListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCallStateChanged(LinphoneCall call, State s, String m) {}
|
public void onCallStateChanged(LinphoneCall call, State s, String m) {
|
||||||
|
if (mVideoCaptureView != null && mCamera == null && !LinphoneManager.getLc().isIncall())
|
||||||
|
{
|
||||||
|
mInCallControls.setVisibility(View.GONE);
|
||||||
|
mCall.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
if (AndroidCameraConfiguration.hasSeveralCameras())
|
||||||
|
mSwitchCamera.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
mCamera = Camera.open(mCurrentCameraId);
|
||||||
|
mVideoCaptureView.switchCamera(mCamera, mCurrentCameraId);
|
||||||
|
mCamera.startPreview();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void onGlobalStateChangedToOn(String message) {
|
public void onGlobalStateChangedToOn(String message) {
|
||||||
mCall.setEnabled(!LinphoneManager.getLc().isIncall());
|
mCall.setEnabled(!LinphoneManager.getLc().isIncall());
|
||||||
|
@ -445,11 +494,21 @@ public class DialerActivity extends Activity implements LinphoneGuiListener {
|
||||||
|
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
|
mInCallControls.setVisibility(View.GONE);
|
||||||
|
mCall.setVisibility(View.VISIBLE);
|
||||||
|
if (AndroidCameraConfiguration.hasSeveralCameras())
|
||||||
|
mSwitchCamera.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
if (mVideoCaptureView != null && mCamera == null && !LinphoneManager.getLc().isIncall())
|
if (mVideoCaptureView != null && mCamera == null && !LinphoneManager.getLc().isIncall())
|
||||||
{
|
{
|
||||||
mCamera = Camera.open(mCurrentCameraId);
|
mCamera = Camera.open(mCurrentCameraId);
|
||||||
mVideoCaptureView.switchCamera(mCamera, mCurrentCameraId);
|
mVideoCaptureView.switchCamera(mCamera, mCurrentCameraId);
|
||||||
mCamera.startPreview();
|
mCamera.startPreview();
|
||||||
|
} else if (LinphoneManager.getLc().isIncall())
|
||||||
|
{
|
||||||
|
mInCallControls.setVisibility(View.VISIBLE);
|
||||||
|
mCall.setVisibility(View.GONE);
|
||||||
|
mSwitchCamera.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -324,7 +324,7 @@ public class IncallActivity extends AbstractCalleesActivity implements
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
switch (v.getId()) {
|
switch (v.getId()) {
|
||||||
case R.id.addCall:
|
case R.id.addCall:
|
||||||
openUriPicker(UriPickerActivity.EXTRA_PICKER_TYPE_ADD, addCallId);
|
finish();
|
||||||
break;
|
break;
|
||||||
case R.id.incallHang:
|
case R.id.incallHang:
|
||||||
terminateCurrentCallOrConferenceOrAll();
|
terminateCurrentCallOrConferenceOrAll();
|
||||||
|
|
|
@ -166,6 +166,7 @@ public class VideoCallActivity extends Activity implements LinphoneOnCallStateCh
|
||||||
findViewById(R.id.toggleMuteMic).setOnClickListener(this);
|
findViewById(R.id.toggleMuteMic).setOnClickListener(this);
|
||||||
findViewById(R.id.toggleSpeaker).setOnClickListener(this);
|
findViewById(R.id.toggleSpeaker).setOnClickListener(this);
|
||||||
findViewById(R.id.incallNumpadShow).setOnClickListener(this);
|
findViewById(R.id.incallNumpadShow).setOnClickListener(this);
|
||||||
|
findViewById(R.id.addCall).setOnClickListener(this);
|
||||||
findViewById(R.id.incallHang).setOnClickListener(this);
|
findViewById(R.id.incallHang).setOnClickListener(this);
|
||||||
findViewById(R.id.switch_camera).setOnClickListener(this);
|
findViewById(R.id.switch_camera).setOnClickListener(this);
|
||||||
findViewById(R.id.conf_simple_pause).setOnClickListener(this);
|
findViewById(R.id.conf_simple_pause).setOnClickListener(this);
|
||||||
|
@ -257,9 +258,9 @@ public class VideoCallActivity extends Activity implements LinphoneOnCallStateCh
|
||||||
mControlsLayout.setVisibility(View.GONE);
|
mControlsLayout.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
if (LinphoneUtils.onKeyVolumeSoftAdjust(keyCode)) return true;
|
if (LinphoneUtils.onKeyVolumeSoftAdjust(keyCode)) return true;
|
||||||
|
if (LinphoneUtils.onKeyBackGoHome(this, keyCode, event)) return true;
|
||||||
return super.onKeyDown(keyCode, event);
|
return super.onKeyDown(keyCode, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,7 +373,7 @@ public class VideoCallActivity extends Activity implements LinphoneOnCallStateCh
|
||||||
case R.id.toggleMuteMic:
|
case R.id.toggleMuteMic:
|
||||||
LinphoneManager.getLc().muteMic(((Checkable) v).isChecked());
|
LinphoneManager.getLc().muteMic(((Checkable) v).isChecked());
|
||||||
break;
|
break;
|
||||||
case R.id.videocall_menu_switch_camera:
|
case R.id.switch_camera:
|
||||||
int id = LinphoneManager.getLc().getVideoDevice();
|
int id = LinphoneManager.getLc().getVideoDevice();
|
||||||
id = (id + 1) % AndroidCameraConfiguration.retrieveCameras().length;
|
id = (id + 1) % AndroidCameraConfiguration.retrieveCameras().length;
|
||||||
LinphoneManager.getLc().setVideoDevice(id);
|
LinphoneManager.getLc().setVideoDevice(id);
|
||||||
|
@ -392,6 +393,9 @@ public class VideoCallActivity extends Activity implements LinphoneOnCallStateCh
|
||||||
params.setVideoEnabled(false);
|
params.setVideoEnabled(false);
|
||||||
LinphoneManager.getLc().updateCall(videoCall, params);
|
LinphoneManager.getLc().updateCall(videoCall, params);
|
||||||
break;
|
break;
|
||||||
|
case R.id.addCall:
|
||||||
|
finish();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue