Incoming call Dialog. Fix standard ports in Manager.
This commit is contained in:
parent
e71b7a5c97
commit
244cae9246
9 changed files with 116 additions and 41 deletions
|
@ -40,7 +40,7 @@
|
|||
<LinearLayout android:layout_height="wrap_content" android:orientation="vertical" android:layout_width="fill_parent">
|
||||
<LinearLayout android:id="@+id/CallControlRow" android:layout_height="fill_parent" android:layout_width="fill_parent">
|
||||
<org.linphone.ui.CallButton android:id="@+id/Call" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="0.25" android:src="@drawable/startcall_green" android:background="@drawable/clavier_bg"/>
|
||||
<org.linphone.ui.HangCallButton android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="0.25" android:id="@+id/Decline" android:src="@drawable/stopcall_red" android:background="@drawable/clavier_bg"/>
|
||||
<org.linphone.ui.HangCallButton android:id="@+id/Decline" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="0.25" android:src="@drawable/stopcall_red" android:background="@drawable/clavier_bg"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout android:id="@+id/IncallControlRow" android:layout_height="fill_parent" android:layout_width="fill_parent">
|
||||
|
|
19
res/layout/incoming_call.xml
Normal file
19
res/layout/incoming_call.xml
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:linphone="http://schemas.android.com/apk/res/linphone"
|
||||
android:orientation="vertical" android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<!-- <View android:layout_height="0px" android:layout_width="0px" android:layout_weight="1" />-->
|
||||
|
||||
<LinearLayout android:layout_height="fill_parent" android:layout_width="fill_parent"
|
||||
android:gravity="bottom">
|
||||
<org.linphone.ui.CallButton android:id="@+id/Call"
|
||||
android:layout_height="wrap_content" android:layout_width="fill_parent"
|
||||
android:layout_weight="0.25" android:src="@drawable/startcall_green" android:background="@drawable/clavier_bg"/>
|
||||
<org.linphone.ui.HangCallButton android:id="@+id/Decline"
|
||||
android:layout_height="wrap_content" android:layout_width="fill_parent"
|
||||
android:layout_weight="0.25" android:src="@drawable/stopcall_red" android:background="@drawable/clavier_bg"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
|
@ -13,6 +13,7 @@
|
|||
<bool name="useMenuAbout">true</bool>
|
||||
<bool name="use_incall_activity">true</bool>
|
||||
<bool name="use_video_activity">false</bool>
|
||||
<bool name="show_full_remote_address_on_incoming_call">true</bool>
|
||||
|
||||
<string name="notification_title">Linphone</string>
|
||||
<bool name="allow_edit_in_dialer">true</bool>
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
|
||||
<string name="error_while_accepting_pending_call">Error while accepting pending call</string>
|
||||
<string name="incoming_call_dialog_title">%s is calling you</string>
|
||||
<string name="accept">Accept</string>
|
||||
<string name="decline">Decline</string>
|
||||
<string name="unknown_incoming_call_name">Unknown</string>
|
||||
|
||||
<string name="pref_network_title">Network</string>
|
||||
<string name="pref_transport_udp">UDP</string>
|
||||
|
|
|
@ -30,10 +30,13 @@ import org.linphone.ui.AddressAware;
|
|||
import org.linphone.ui.AddressText;
|
||||
import org.linphone.ui.CallButton;
|
||||
import org.linphone.ui.EraseButton;
|
||||
import org.linphone.ui.HangCallButton;
|
||||
import org.linphone.ui.MuteMicButton;
|
||||
import org.linphone.ui.SpeakerButton;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
|
@ -43,6 +46,7 @@ import android.os.PowerManager;
|
|||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -288,16 +292,36 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, New
|
|||
mCall.setEnabled(true);
|
||||
}
|
||||
|
||||
private void callPending(LinphoneCall call) {
|
||||
mDecline.setEnabled(true);
|
||||
|
||||
// Privacy setting to not share the user camera by default
|
||||
boolean prefVideoEnable = LinphoneManager.getInstance().isVideoEnabled();
|
||||
boolean prefAutoShareMyCamera = mPref.getBoolean(getString(R.string.pref_video_automatically_share_my_video_key), false);
|
||||
boolean videoMuted = !(prefVideoEnable && prefAutoShareMyCamera);
|
||||
AndroidCameraRecordManager.getInstance().setMuted(videoMuted);
|
||||
private void callPending(final LinphoneCall call) {
|
||||
String from = LinphoneManager.getInstance().extractIncomingRemoteName();
|
||||
View incomingCallView = getLayoutInflater().inflate(R.layout.incoming_call, null);
|
||||
|
||||
call.enableCamera(prefAutoShareMyCamera);
|
||||
final Dialog dialog = new AlertDialog.Builder(this)
|
||||
.setMessage(String.format(getString(R.string.incoming_call_dialog_title), from))
|
||||
.setCancelable(false)
|
||||
.setView(incomingCallView).create();
|
||||
|
||||
|
||||
((CallButton) incomingCallView.findViewById(R.id.Call)).setExternalClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
dialog.dismiss();
|
||||
LinphoneManager.getInstance().resetCameraFromPreferences();
|
||||
|
||||
// Privacy setting to not share the user camera by default
|
||||
boolean prefVideoEnable = LinphoneManager.getInstance().isVideoEnabled();
|
||||
boolean prefAutoShareMyCamera = mPref.getBoolean(getString(R.string.pref_video_automatically_share_my_video_key), false);
|
||||
boolean videoMuted = !(prefVideoEnable && prefAutoShareMyCamera);
|
||||
AndroidCameraRecordManager.getInstance().setMuted(videoMuted);
|
||||
|
||||
call.enableCamera(prefAutoShareMyCamera);
|
||||
}
|
||||
});
|
||||
((HangCallButton) incomingCallView.findViewById(R.id.Decline)).setExternalClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {dialog.dismiss();}
|
||||
});
|
||||
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
|
||||
|
@ -354,7 +378,6 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, New
|
|||
if (state == LinphoneCall.State.OutgoingInit) {
|
||||
enterIncallMode(lc);
|
||||
} else if (state == LinphoneCall.State.IncomingReceived) {
|
||||
LinphoneManager.getInstance().resetCameraFromPreferences();
|
||||
callPending(call);
|
||||
} else if (state == LinphoneCall.State.Connected) {
|
||||
if (call.getDirection() == CallDirection.Incoming) {
|
||||
|
|
|
@ -65,7 +65,8 @@ public class LinphoneActivity extends TabActivity {
|
|||
public static final String PREF_FIRST_LAUNCH = "pref_first_launch";
|
||||
static final int VIDEO_VIEW_ACTIVITY = 100;
|
||||
static final int FIRST_LOGIN_ACTIVITY = 101;
|
||||
static final int INCALL_ACTIVITY = 102;
|
||||
static final int INCALL_ACTIVITY = 102;
|
||||
static final int INCOMING_CALL_ACTIVITY = 103;
|
||||
private static final String PREF_CHECK_CONFIG = "pref_check_config";
|
||||
|
||||
private static LinphoneActivity instance;
|
||||
|
@ -203,9 +204,7 @@ public class LinphoneActivity extends TabActivity {
|
|||
}
|
||||
}*/
|
||||
|
||||
getTabHost().setCurrentTabByTag(DIALER_TAB);
|
||||
|
||||
|
||||
gotToDialer();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -216,8 +215,7 @@ public class LinphoneActivity extends TabActivity {
|
|||
if (!LinphoneService.isReady() || !LinphoneManager.getLc().isIncall()) return;
|
||||
LinphoneCore lc = LinphoneManager.getLc();
|
||||
if(lc.isInComingInvitePending()) {
|
||||
// TODO
|
||||
Log.e(TAG, "Not handled case: recreation while incoming invite pending");
|
||||
gotToDialer();
|
||||
} else {
|
||||
if (getResources().getBoolean(R.bool.use_incall_activity)) {
|
||||
startIncallActivity(LinphoneManager.getInstance().extractADisplayName());
|
||||
|
@ -436,9 +434,12 @@ public class LinphoneActivity extends TabActivity {
|
|||
|
||||
static void setAddressAndGoToDialer(String number, String name) {
|
||||
DialerActivity.instance().setContactAddress(number, name);
|
||||
instance.getTabHost().setCurrentTabByTag(DIALER_TAB);
|
||||
instance.gotToDialer();
|
||||
}
|
||||
|
||||
private void gotToDialer() {
|
||||
getTabHost().setCurrentTabByTag(DIALER_TAB);
|
||||
}
|
||||
|
||||
|
||||
private void startActivityInTab(String tag, Intent intent, int indicatorId, int drawableId) {
|
||||
|
|
|
@ -506,19 +506,19 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
if (!getBool(R.string.pref_transport_udp_key, false)) {
|
||||
ports.udp = 0;
|
||||
} else if (useStandardPort) {
|
||||
ports.udp = 5600;
|
||||
ports.udp = 5060;
|
||||
}
|
||||
|
||||
if (!getBool(R.string.pref_transport_tcp_key, false)) {
|
||||
ports.tcp = 0;
|
||||
} else if (useStandardPort) {
|
||||
ports.tcp = 5600;
|
||||
ports.tcp = 5060;
|
||||
}
|
||||
|
||||
if (!getBool(R.string.pref_transport_tls_key, false)) {
|
||||
ports.tls = 0;
|
||||
} else if (useStandardPort) {
|
||||
ports.tls = 5600;
|
||||
ports.tls = 5060;
|
||||
}
|
||||
|
||||
mLc.setSignalingTransportPorts(ports);
|
||||
|
@ -749,9 +749,10 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public String extractADisplayName() {
|
||||
final LinphoneAddress remote = mLc.getRemoteAddress();
|
||||
if (remote == null) return null;
|
||||
if (remote == null) return mR.getString(R.string.unknown_incoming_call_name);
|
||||
|
||||
final String displayName = remote.getDisplayName();
|
||||
if (displayName!=null) {
|
||||
|
@ -759,7 +760,11 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
} else if (remote.getUserName() != null){
|
||||
return remote.getUserName();
|
||||
} else {
|
||||
return remote.toString();
|
||||
String rms = remote.toString();
|
||||
if (rms != null && rms.length() > 1)
|
||||
return rms;
|
||||
|
||||
return mR.getString(R.string.unknown_incoming_call_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -811,4 +816,24 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
serviceListener.onAlreadyInVideoCall();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean acceptCallIfIncomingPending() throws LinphoneCoreException {
|
||||
setAudioModeIncallForGalaxyS();
|
||||
if (mLc.isInComingInvitePending()) {
|
||||
mLc.acceptCall(mLc.getCurrentCall());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String extractIncomingRemoteName() {
|
||||
if (!mR.getBoolean(R.bool.show_full_remote_address_on_incoming_call))
|
||||
return extractADisplayName();
|
||||
|
||||
LinphoneAddress remote = mLc.getRemoteAddress();
|
||||
if (remote != null)
|
||||
return remote.toString();
|
||||
|
||||
return mR.getString(R.string.unknown_incoming_call_name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.linphone.ui;
|
|||
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneCoreException;
|
||||
|
||||
import android.content.Context;
|
||||
|
@ -37,6 +36,10 @@ import android.widget.Toast;
|
|||
public class CallButton extends ImageButton implements OnClickListener, AddressAware {
|
||||
|
||||
private AddressText mAddress;
|
||||
public void setAddressWidget(AddressText a) {mAddress = a;}
|
||||
|
||||
private OnClickListener externalClickListener;
|
||||
public void setExternalClickListener(OnClickListener e) {externalClickListener = e;}
|
||||
|
||||
public CallButton(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
@ -44,20 +47,18 @@ public class CallButton extends ImageButton implements OnClickListener, AddressA
|
|||
}
|
||||
|
||||
public void onClick(View v) {
|
||||
LinphoneManager.getInstance().setAudioModeIncallForGalaxyS();
|
||||
LinphoneCore lc = LinphoneManager.getLc();
|
||||
if (lc.isInComingInvitePending()) {
|
||||
try {
|
||||
lc.acceptCall(lc.getCurrentCall());
|
||||
} catch (LinphoneCoreException e) {
|
||||
lc.terminateCall(lc.getCurrentCall());
|
||||
onWrongDestinationAddress();
|
||||
try {
|
||||
if (!LinphoneManager.getInstance().acceptCallIfIncomingPending()) {
|
||||
if (mAddress.getText().length() >0) {
|
||||
LinphoneManager.getInstance().newOutgoingCall(mAddress);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (mAddress.getText().length() >0) {
|
||||
LinphoneManager.getInstance().newOutgoingCall(mAddress);
|
||||
}
|
||||
} catch (LinphoneCoreException e) {
|
||||
LinphoneManager.getInstance().terminateCall();
|
||||
onWrongDestinationAddress();
|
||||
};
|
||||
|
||||
if (externalClickListener != null) externalClickListener.onClick(v);
|
||||
}
|
||||
|
||||
|
||||
|
@ -69,8 +70,4 @@ public class CallButton extends ImageButton implements OnClickListener, AddressA
|
|||
}
|
||||
|
||||
|
||||
public void setAddressWidget(AddressText address) {
|
||||
mAddress = address;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,6 +29,9 @@ import android.widget.ImageButton;
|
|||
|
||||
public class HangCallButton extends ImageButton implements OnClickListener {
|
||||
|
||||
private OnClickListener externalClickListener;
|
||||
public void setExternalClickListener(OnClickListener e) {externalClickListener = e;}
|
||||
|
||||
public HangCallButton(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setOnClickListener(this);
|
||||
|
@ -37,5 +40,7 @@ public class HangCallButton extends ImageButton implements OnClickListener {
|
|||
public void onClick(View v) {
|
||||
LinphoneCore lc = LinphoneManager.getLc();
|
||||
lc.terminateCall(lc.getCurrentCall());
|
||||
|
||||
if (externalClickListener != null) externalClickListener.onClick(v);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue