Numpad added to incall controls to be able to send dtmfs
This commit is contained in:
parent
e2589c8535
commit
6384a8b287
8 changed files with 139 additions and 103 deletions
8
res/drawable/dialer_alt_back.xml
Normal file
8
res/drawable/dialer_alt_back.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true"
|
||||
android:drawable="@drawable/dialer_alt_back_over" />
|
||||
<item
|
||||
android:drawable="@drawable/dialer_alt_back_default" />
|
||||
</selector>
|
||||
|
BIN
res/drawable/dialer_alt_back_default.png
Normal file
BIN
res/drawable/dialer_alt_back_default.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.5 KiB |
BIN
res/drawable/dialer_alt_back_over.png
Normal file
BIN
res/drawable/dialer_alt_back_over.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.1 KiB |
BIN
res/drawable/dialer_alt_background.png
Normal file
BIN
res/drawable/dialer_alt_background.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
|
@ -3,7 +3,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/topLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -34,7 +34,16 @@
|
|||
android:contentDescription="@string/content_description_switch_camera"
|
||||
android:paddingTop="20dp"
|
||||
android:src="@drawable/switch_camera"
|
||||
android:visibility="gone" />
|
||||
android:visibility="invisible" />
|
||||
|
||||
<org.linphone.ui.Numpad
|
||||
android:id="@+id/numpad"
|
||||
android:background="@drawable/dialer_alt_background"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="invisible"
|
||||
android:layout_below="@id/switchCamera"
|
||||
android:layout_marginBottom="150dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/menu"
|
||||
|
@ -187,6 +196,7 @@
|
|||
android:scaleType="fitXY"
|
||||
android:src="@drawable/dialer_alt" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1">
|
||||
android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1">
|
||||
|
||||
<TableRow android:layout_weight="1">
|
||||
<org.linphone.ui.Digit android:id="@+id/Digit1" android:text="1" style="@style/DialerDigit" android:background="@drawable/numpad_one" android:soundEffectsEnabled="true" />
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.linphone.core.LinphoneCall.State;
|
|||
import org.linphone.core.LinphoneCallParams;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
||||
import org.linphone.ui.Numpad;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
|
@ -48,6 +49,7 @@ import android.widget.LinearLayout;
|
|||
/**
|
||||
* @author Sylvain Berfini
|
||||
*/
|
||||
//TODO Prevent controls from being hidden while user is using numpad
|
||||
public class InCallActivity extends FragmentActivity implements
|
||||
LinphoneOnCallStateChangedListener,
|
||||
LinphoneOnCallEncryptionChangedListener,
|
||||
|
@ -63,6 +65,7 @@ public class InCallActivity extends FragmentActivity implements
|
|||
private VideoCallFragment videoCallFragment;
|
||||
private boolean isSpeakerEnabled = false, isMicMuted = false, isVideoEnabled, isTransferAllowed;
|
||||
private LinearLayout mControlsLayout;
|
||||
private Numpad numpad;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -95,7 +98,7 @@ public class InCallActivity extends FragmentActivity implements
|
|||
} else {
|
||||
callFragment = new AudioCallFragment();
|
||||
audioCallFragment = (AudioCallFragment) callFragment;
|
||||
switchCamera.setVisibility(View.GONE);
|
||||
switchCamera.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
callFragment.setArguments(getIntent().getExtras());
|
||||
getSupportFragmentManager().beginTransaction().add(R.id.fragmentContainer, callFragment).commitAllowingStateLoss();
|
||||
|
@ -131,6 +134,7 @@ public class InCallActivity extends FragmentActivity implements
|
|||
dialer = (ImageView) findViewById(R.id.dialer);
|
||||
dialer.setOnClickListener(this);
|
||||
dialer.setEnabled(false);
|
||||
numpad = (Numpad) findViewById(R.id.numpad);
|
||||
|
||||
switchCamera = (ImageView) findViewById(R.id.switchCamera);
|
||||
switchCamera.setOnClickListener(this);
|
||||
|
@ -218,7 +222,7 @@ public class InCallActivity extends FragmentActivity implements
|
|||
hangUp();
|
||||
}
|
||||
else if (id == R.id.dialer) {
|
||||
|
||||
hideOrDisplayNumpad();
|
||||
}
|
||||
else if (id == R.id.switchCamera) {
|
||||
if (videoCallFragment != null) {
|
||||
|
@ -226,7 +230,7 @@ public class InCallActivity extends FragmentActivity implements
|
|||
}
|
||||
}
|
||||
else if (id == R.id.transfer) {
|
||||
|
||||
//TODO Call Transfer
|
||||
}
|
||||
else if (id == R.id.options) {
|
||||
hideOrDisplayCallOptions();
|
||||
|
@ -381,11 +385,13 @@ public class InCallActivity extends FragmentActivity implements
|
|||
|
||||
controlsHandler.postDelayed(mControls = new Runnable() {
|
||||
public void run() {
|
||||
hideNumpad();
|
||||
|
||||
if (InCallActivity.this.getResources().getBoolean(R.bool.disable_animations)) {
|
||||
transfer.setVisibility(View.GONE);
|
||||
addCall.setVisibility(View.GONE);
|
||||
mControlsLayout.setVisibility(View.GONE);
|
||||
switchCamera.setVisibility(View.GONE);
|
||||
switchCamera.setVisibility(View.INVISIBLE);
|
||||
options.setImageResource(R.drawable.options);
|
||||
} else {
|
||||
Animation animation = AnimationUtils.loadAnimation(InCallActivity.this, R.anim.slide_out_top_to_bottom);
|
||||
|
@ -405,7 +411,7 @@ public class InCallActivity extends FragmentActivity implements
|
|||
transfer.setVisibility(View.GONE);
|
||||
addCall.setVisibility(View.GONE);
|
||||
mControlsLayout.setVisibility(View.GONE);
|
||||
switchCamera.setVisibility(View.GONE);
|
||||
switchCamera.setVisibility(View.INVISIBLE);
|
||||
options.setImageResource(R.drawable.options);
|
||||
}
|
||||
});
|
||||
|
@ -424,7 +430,67 @@ public class InCallActivity extends FragmentActivity implements
|
|||
}
|
||||
|
||||
mControlsLayout.setVisibility(View.VISIBLE);
|
||||
switchCamera.setVisibility(View.GONE);
|
||||
switchCamera.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
private void hideNumpad() {
|
||||
if (numpad.getVisibility() != View.VISIBLE) {
|
||||
return;
|
||||
}
|
||||
|
||||
dialer.setImageResource(R.drawable.dialer_alt);
|
||||
if (getResources().getBoolean(R.bool.disable_animations)) {
|
||||
numpad.setVisibility(View.GONE);
|
||||
} else {
|
||||
Animation anim = AnimationUtils.loadAnimation(this, R.anim.slide_out_top_to_bottom);
|
||||
anim.setAnimationListener(new AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
numpad.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
numpad.startAnimation(anim);
|
||||
}
|
||||
}
|
||||
|
||||
private void hideOrDisplayNumpad() {
|
||||
if (numpad.getVisibility() == View.VISIBLE) {
|
||||
hideNumpad();
|
||||
} else {
|
||||
dialer.setImageResource(R.drawable.dialer_alt_back);
|
||||
if (getResources().getBoolean(R.bool.disable_animations)) {
|
||||
numpad.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
Animation anim = AnimationUtils.loadAnimation(this, R.anim.slide_in_bottom_to_top);
|
||||
anim.setAnimationListener(new AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
numpad.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
numpad.startAnimation(anim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void hideOrDisplayCallOptions() {
|
||||
|
|
|
@ -564,6 +564,46 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
manageTunnelServer(info);
|
||||
}
|
||||
|
||||
public void initAccount(String key, boolean cleanBefore, boolean defaultAccount) throws LinphoneCoreException {
|
||||
if (cleanBefore) {
|
||||
mLc.clearAuthInfos();
|
||||
mLc.clearProxyConfigs();
|
||||
}
|
||||
|
||||
String username = getPrefString(getString(R.string.pref_username_key) + key, null);
|
||||
String password = getPrefString(getString(R.string.pref_passwd_key) + key, null);
|
||||
if (username != null && username.length() > 0) {
|
||||
LinphoneAuthInfo lAuthInfo = LinphoneCoreFactory.instance().createAuthInfo(username, password, null);
|
||||
mLc.addAuthInfo(lAuthInfo);
|
||||
|
||||
String domain = getPrefString(getString(R.string.pref_domain_key) + key, null);
|
||||
if (domain != null && domain.length() > 0) {
|
||||
String identity = "sip:" + username +"@" + domain;
|
||||
String proxy = getPrefString(getString(R.string.pref_proxy_key) + key, null);
|
||||
if (proxy == null || proxy.length() == 0) {
|
||||
proxy = "sip:" + domain;
|
||||
}
|
||||
if (!proxy.startsWith("sip:")) {
|
||||
proxy = "sip:" + proxy;
|
||||
}
|
||||
LinphoneProxyConfig defaultProxyConfig = LinphoneCoreFactory.instance().createProxyConfig(identity, proxy, null, true);
|
||||
mLc.addProxyConfig(defaultProxyConfig);
|
||||
|
||||
//outbound proxy
|
||||
if (getPrefBoolean(getString(R.string.pref_enable_outbound_proxy_key) + key, false)) {
|
||||
defaultProxyConfig.setRoute(proxy);
|
||||
} else {
|
||||
defaultProxyConfig.setRoute(null);
|
||||
}
|
||||
defaultProxyConfig.done();
|
||||
|
||||
if (defaultAccount) {
|
||||
mLc.setDefaultProxyConfig(defaultProxyConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void initFromConf() throws LinphoneConfigException {
|
||||
|
||||
|
||||
|
@ -609,110 +649,22 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
}
|
||||
boolean isVideoEnabled = isVideoEnabled();
|
||||
mLc.enableVideo(isVideoEnabled, isVideoEnabled);
|
||||
//1 read proxy config from preferences
|
||||
String lUserName = getPrefString(R.string.pref_username_key, null);
|
||||
if (lUserName == null || lUserName.length()==0) {
|
||||
throw new LinphoneConfigException(getString(R.string.wrong_username));
|
||||
}
|
||||
|
||||
String lPasswd = getPrefString(R.string.pref_passwd_key, null);
|
||||
// we have the right of having no password
|
||||
//if (lPasswd == null || lPasswd.length()==0) {
|
||||
// throw new LinphoneConfigException(getString(R.string.wrong_passwd));
|
||||
//}
|
||||
|
||||
String lDomain = getPrefString(R.string.pref_domain_key, null);
|
||||
if (lDomain == null || lDomain.length()==0) {
|
||||
throw new LinphoneConfigException(getString(R.string.wrong_domain));
|
||||
}
|
||||
|
||||
String lStun = getPrefString(R.string.pref_stun_server_key, null);
|
||||
|
||||
//stun server
|
||||
String lStun = getPrefString(R.string.pref_stun_server_key, null);
|
||||
mLc.setStunServer(lStun);
|
||||
mLc.setFirewallPolicy((lStun!=null && lStun.length()>0) ? FirewallPolicy.UseStun : FirewallPolicy.NoFirewall);
|
||||
|
||||
//auth
|
||||
mLc.clearAuthInfos();
|
||||
if (lPasswd!=null && lPasswd.length()>0){
|
||||
LinphoneAuthInfo lAuthInfo = LinphoneCoreFactory.instance().createAuthInfo(lUserName, lPasswd,null);
|
||||
mLc.addAuthInfo(lAuthInfo);
|
||||
}
|
||||
|
||||
//proxy
|
||||
mLc.clearProxyConfigs();
|
||||
String lProxy = getPrefString(R.string.pref_proxy_key,null);
|
||||
if (lProxy == null || lProxy.length() == 0) {
|
||||
lProxy = "sip:"+lDomain;
|
||||
}
|
||||
if (!lProxy.startsWith("sip:")) {
|
||||
lProxy = "sip:"+lProxy;
|
||||
}
|
||||
//get Default proxy if any
|
||||
LinphoneProxyConfig lDefaultProxyConfig = mLc.getDefaultProxyConfig();
|
||||
String lIdentity = "sip:"+lUserName+"@"+lDomain;
|
||||
//accounts
|
||||
try {
|
||||
if (lDefaultProxyConfig == null) {
|
||||
lDefaultProxyConfig = LinphoneCoreFactory.instance().createProxyConfig(lIdentity, lProxy, null,true);
|
||||
mLc.addProxyConfig(lDefaultProxyConfig);
|
||||
int defaultAccount = getPrefInt(R.string.pref_default_account, 0);
|
||||
if (defaultAccount == 0 || defaultAccount >= getPrefInt(R.string.pref_extra_accounts, 0)) {
|
||||
//outbound proxy
|
||||
if (getPrefBoolean(R.string.pref_enable_outbound_proxy_key, false)) {
|
||||
lDefaultProxyConfig.setRoute(lProxy);
|
||||
} else {
|
||||
lDefaultProxyConfig.setRoute(null);
|
||||
}
|
||||
mLc.setDefaultProxyConfig(lDefaultProxyConfig);
|
||||
}
|
||||
|
||||
} else {
|
||||
lDefaultProxyConfig.edit();
|
||||
lDefaultProxyConfig.setIdentity(lIdentity);
|
||||
lDefaultProxyConfig.setProxy(lProxy);
|
||||
lDefaultProxyConfig.enableRegister(true);
|
||||
lDefaultProxyConfig.done();
|
||||
}
|
||||
|
||||
// Extra accounts
|
||||
for (int i = 1; i < getPrefExtraAccountsNumber(); i++) {
|
||||
for (int i = 0; i < getPrefExtraAccountsNumber(); i++) {
|
||||
if (getPrefBoolean(getString(R.string.pref_disable_account_key) + i, false)) {
|
||||
continue;
|
||||
}
|
||||
lUserName = getPrefString(getString(R.string.pref_username_key) + i, null);
|
||||
lPasswd = getPrefString(getString(R.string.pref_passwd_key) + i, null);
|
||||
if (lUserName != null && lUserName.length() > 0) {
|
||||
LinphoneAuthInfo lAuthInfo = LinphoneCoreFactory.instance().createAuthInfo(lUserName, lPasswd, null);
|
||||
mLc.addAuthInfo(lAuthInfo);
|
||||
|
||||
lDomain = getPrefString(getString(R.string.pref_domain_key) + i, null);
|
||||
if (lDomain != null && lDomain.length() > 0) {
|
||||
lIdentity = "sip:"+lUserName+"@"+lDomain;
|
||||
lProxy = getPrefString(getString(R.string.pref_proxy_key) + i, null);
|
||||
if (lProxy == null || lProxy.length() == 0) {
|
||||
lProxy = "sip:" + lDomain;
|
||||
}
|
||||
if (!lProxy.startsWith("sip:")) {
|
||||
lProxy = "sip:" + lProxy;
|
||||
}
|
||||
lDefaultProxyConfig = LinphoneCoreFactory.instance().createProxyConfig(lIdentity, lProxy, null, true);
|
||||
mLc.addProxyConfig(lDefaultProxyConfig);
|
||||
|
||||
//outbound proxy
|
||||
if (getPrefBoolean(getString(R.string.pref_enable_outbound_proxy_key) + i, false)) {
|
||||
lDefaultProxyConfig.setRoute(lProxy);
|
||||
} else {
|
||||
lDefaultProxyConfig.setRoute(null);
|
||||
}
|
||||
|
||||
if (i == getPrefInt(R.string.pref_default_account, 0)) {
|
||||
mLc.setDefaultProxyConfig(lDefaultProxyConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
initAccount(i == 0 ? "" : String.valueOf(i), i == 0, i == getPrefInt(R.string.pref_default_account, 0));
|
||||
}
|
||||
|
||||
lDefaultProxyConfig = mLc.getDefaultProxyConfig();
|
||||
LinphoneProxyConfig lDefaultProxyConfig = mLc.getDefaultProxyConfig();
|
||||
if (lDefaultProxyConfig !=null) {
|
||||
//prefix
|
||||
String lPrefix = getPrefString(R.string.pref_prefix_key, null);
|
||||
|
|
Loading…
Reference in a new issue