Use a default .linphonerc if not existing yet (moved some values from factory to linphonerc) + can create account using wizard
This commit is contained in:
parent
0d61f337d3
commit
6eb333bcf6
12 changed files with 297 additions and 171 deletions
|
@ -1,21 +1,11 @@
|
|||
[net]
|
||||
download_bw=512
|
||||
upload_bw=512
|
||||
firewall_policy=0
|
||||
mtu=1300
|
||||
|
||||
[sip]
|
||||
sip_port=5060
|
||||
sip_random_port=1
|
||||
guess_hostname=1
|
||||
contact=sip:unknown@unknown-host
|
||||
inc_timeout=15
|
||||
use_info=0
|
||||
use_ipv6=0
|
||||
register_only_when_network_is_up=1
|
||||
default_proxy=0
|
||||
auto_net_state_mon=0
|
||||
keepalive_period=30000
|
||||
auto_answer_replacing_calls=1
|
||||
media_encryption_mandatory=0
|
||||
|
||||
|
@ -34,8 +24,5 @@ remote_ring=/data/data/org.linphone/files/ringback.wav
|
|||
local_ring=/data/data/org.linphone/files/oldphone_mono.wav
|
||||
dtmf_player_amp=0.1
|
||||
|
||||
[video]
|
||||
size=vga
|
||||
|
||||
[misc]
|
||||
max_calls=10
|
||||
|
|
14
res/raw-sw600dp/linphonerc_default
Normal file
14
res/raw-sw600dp/linphonerc_default
Normal file
|
@ -0,0 +1,14 @@
|
|||
[net]
|
||||
download_bw=512
|
||||
upload_bw=512
|
||||
firewall_policy=0
|
||||
|
||||
[sip]
|
||||
sip_random_port=1
|
||||
contact=sip:unknown@unknown-host
|
||||
use_info=0
|
||||
use_ipv6=0
|
||||
keepalive_period=30000
|
||||
|
||||
[video]
|
||||
size=qvga
|
|
@ -1,20 +1,11 @@
|
|||
[net]
|
||||
download_bw=380
|
||||
upload_bw=380
|
||||
mtu=1300
|
||||
|
||||
[sip]
|
||||
sip_port=5060
|
||||
sip_random_port=1
|
||||
guess_hostname=1
|
||||
contact=sip:unknown@unknown-host
|
||||
inc_timeout=15
|
||||
use_info=0
|
||||
use_ipv6=0
|
||||
register_only_when_network_is_up=1
|
||||
default_proxy=0
|
||||
auto_net_state_mon=0
|
||||
keepalive_period=30000
|
||||
auto_answer_replacing_calls=1
|
||||
media_encryption_mandatory=0
|
||||
ping_with_options=0
|
||||
|
@ -38,8 +29,5 @@ remote_ring=/data/data/org.linphone/files/ringback.wav
|
|||
local_ring=/data/data/org.linphone/files/oldphone_mono.wav
|
||||
dtmf_player_amp=0.1
|
||||
|
||||
[video]
|
||||
size=qvga
|
||||
|
||||
[misc]
|
||||
max_calls=10
|
||||
|
|
13
res/raw/linphonerc_default
Normal file
13
res/raw/linphonerc_default
Normal file
|
@ -0,0 +1,13 @@
|
|||
[net]
|
||||
download_bw=380
|
||||
upload_bw=380
|
||||
|
||||
[sip]
|
||||
sip_random_port=1
|
||||
contact=sip:unknown@unknown-host
|
||||
use_info=0
|
||||
use_ipv6=0
|
||||
keepalive_period=30000
|
||||
|
||||
[video]
|
||||
size=qvga
|
|
@ -426,7 +426,7 @@
|
|||
<string name="download_image">Download</string>
|
||||
<string name="download_image_failed">Download failed. Please check your internet access or try again later.</string>
|
||||
|
||||
<string name="pref_auth_userid">Auth userid*</string>
|
||||
<string name="pref_auth_userid">Auth userid</string>
|
||||
|
||||
<string name="pref_help_auth_userid">Enter authentication userid (optionnal)</string>
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ public class AccountPreferencesFragment extends PreferencesListFragment {
|
|||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
LinphonePreferences.instance().setAccountUsername(n, newValue.toString());
|
||||
preference.setSummary(newValue.toString());
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
@ -60,6 +61,7 @@ public class AccountPreferencesFragment extends PreferencesListFragment {
|
|||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
LinphonePreferences.instance().setAccountUserId(n, newValue.toString());
|
||||
preference.setSummary(newValue.toString());
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
@ -67,6 +69,7 @@ public class AccountPreferencesFragment extends PreferencesListFragment {
|
|||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
LinphonePreferences.instance().setAccountPassword(n, newValue.toString());
|
||||
preference.setSummary(newValue.toString());
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
@ -74,6 +77,7 @@ public class AccountPreferencesFragment extends PreferencesListFragment {
|
|||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
LinphonePreferences.instance().setAccountDomain(n, newValue.toString());
|
||||
preference.setSummary(newValue.toString());
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
@ -81,6 +85,7 @@ public class AccountPreferencesFragment extends PreferencesListFragment {
|
|||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
LinphonePreferences.instance().setAccountProxy(n, newValue.toString());
|
||||
preference.setSummary(newValue.toString());
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
@ -163,15 +168,4 @@ public class AccountPreferencesFragment extends PreferencesListFragment {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
|
||||
int n = LinphonePreferences.instance().getAccountCount();
|
||||
if (LinphonePreferences.instance().getAccountUsername(n).equals("")) {
|
||||
//If not, we suppress it to not display a blank field
|
||||
LinphonePreferences.instance().setAccountCount(n-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -525,7 +525,6 @@ public class LinphoneManager implements LinphoneCoreListener {
|
|||
try {
|
||||
copyAssetsFromPackage();
|
||||
//traces alway start with traces enable to not missed first initialization
|
||||
|
||||
boolean isDebugLogEnabled = !(mR.getBoolean(R.bool.disable_every_log));
|
||||
LinphoneCoreFactory.instance().setDebugMode(isDebugLogEnabled, getString(R.string.app_name));
|
||||
|
||||
|
@ -593,13 +592,15 @@ public class LinphoneManager implements LinphoneCoreListener {
|
|||
copyIfNotExist(R.raw.oldphone_mono,mRingSoundFile);
|
||||
copyIfNotExist(R.raw.ringback,mRingbackSoundFile);
|
||||
copyIfNotExist(R.raw.toy_mono,mPauseSoundFile);
|
||||
copyIfNotExist(R.raw.linphonerc_default, mLinphoneConfigFile);
|
||||
copyFromPackage(R.raw.linphonerc, new File(mLinphoneInitialConfigFile).getName());
|
||||
copyIfNotExist(R.raw.lpconfig, new File(mLPConfigXsd).getName());
|
||||
copyIfNotExist(R.raw.rootca, new File(mLinphoneRootCaFile).getName());
|
||||
copyIfNotExist(R.raw.lpconfig, mLPConfigXsd);
|
||||
copyIfNotExist(R.raw.rootca, mLinphoneRootCaFile);
|
||||
}
|
||||
|
||||
private void copyIfNotExist(int ressourceId,String target) throws IOException {
|
||||
File lFileToCopy = new File(target);
|
||||
Log.w("File " + target + " exists ? " + lFileToCopy.exists());
|
||||
if (!lFileToCopy.exists()) {
|
||||
copyFromPackage(ressourceId,lFileToCopy.getName());
|
||||
}
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
package org.linphone;
|
||||
|
||||
import org.linphone.core.LinphoneAuthInfo;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneCore.MediaEncryption;
|
||||
import org.linphone.core.LinphoneCore.Transports;
|
||||
import org.linphone.core.LinphoneCoreException;
|
||||
import org.linphone.core.LinphoneCoreFactory;
|
||||
import org.linphone.core.LinphoneProxyConfig;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
|
@ -51,6 +55,10 @@ public class LinphonePreferences {
|
|||
return mContext.getString(key);
|
||||
}
|
||||
|
||||
private LinphoneCore getLc() {
|
||||
return LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
}
|
||||
|
||||
public boolean isFirstLaunch() {
|
||||
return false;
|
||||
}
|
||||
|
@ -59,11 +67,11 @@ public class LinphonePreferences {
|
|||
}
|
||||
|
||||
public boolean isDebugEnabled() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setRemoteProvisioningUrl(String url) {
|
||||
LinphoneManager.getLcIfManagerNotDestroyedOrNull().getConfig().setString("app", "remote_provisioning", url);
|
||||
getLc().getConfig().setString("app", "remote_provisioning", url);
|
||||
}
|
||||
|
||||
public String getRemoteProvisioningUrl() {
|
||||
|
@ -99,19 +107,19 @@ public class LinphonePreferences {
|
|||
}
|
||||
|
||||
public boolean isAutoStartEnabled() {
|
||||
return LinphoneManager.getLcIfManagerNotDestroyedOrNull().getConfig().getBool("app", "auto_start", false);
|
||||
return getLc().getConfig().getBool("app", "auto_start", false);
|
||||
}
|
||||
|
||||
public void setAutoStart(boolean autoStartEnabled) {
|
||||
LinphoneManager.getLcIfManagerNotDestroyedOrNull().getConfig().setBool("app", "auto_start", autoStartEnabled);
|
||||
getLc().getConfig().setBool("app", "auto_start", autoStartEnabled);
|
||||
}
|
||||
|
||||
public String getSharingPictureServerUrl() {
|
||||
return LinphoneManager.getLcIfManagerNotDestroyedOrNull().getConfig().getString("app", "sharing_server", null);
|
||||
return getLc().getConfig().getString("app", "sharing_server", null);
|
||||
}
|
||||
|
||||
public void setSharingPictureServerUrl(String url) {
|
||||
LinphoneManager.getLcIfManagerNotDestroyedOrNull().getConfig().setString("app", "sharing_server", url);
|
||||
getLc().getConfig().setString("app", "sharing_server", url);
|
||||
}
|
||||
|
||||
public boolean shouldUseLinphoneToStoreChatHistory() {
|
||||
|
@ -147,72 +155,149 @@ public class LinphonePreferences {
|
|||
}
|
||||
|
||||
// Accounts
|
||||
public void setAccountUsername(int n, String string) {
|
||||
|
||||
}
|
||||
|
||||
public String getAccountUsername(int i) {
|
||||
private LinphoneProxyConfig getProxyConfig(int n) {
|
||||
LinphoneProxyConfig[] prxCfgs = getLc().getProxyConfigList();
|
||||
if (n < 0 || n >= prxCfgs.length)
|
||||
return null;
|
||||
return prxCfgs[n];
|
||||
}
|
||||
|
||||
public void setAccountUserId(int n, String string) {
|
||||
private LinphoneAuthInfo getAuthInfo(int n) {
|
||||
LinphoneAuthInfo[] authsInfos = getLc().getAuthInfosList();
|
||||
if (n < 0 || n >= authsInfos.length)
|
||||
return null;
|
||||
return authsInfos[n];
|
||||
}
|
||||
|
||||
private String tempUsername;
|
||||
private String tempUserId;
|
||||
private String tempPassword;
|
||||
private String tempDomain;
|
||||
private String tempProxy;
|
||||
private boolean tempOutboundProxy;
|
||||
|
||||
/**
|
||||
* Saves a created account or an edited account
|
||||
* @throws LinphoneCoreException
|
||||
*/
|
||||
public void saveNewAccount() throws LinphoneCoreException {
|
||||
String identity = "sip:" + tempUsername + "@" + tempDomain;
|
||||
String proxy = "sip:";
|
||||
proxy += tempProxy == null ? tempDomain : tempProxy;
|
||||
String route = tempOutboundProxy ? tempProxy : null;
|
||||
|
||||
LinphoneProxyConfig prxCfg = LinphoneCoreFactory.instance().createProxyConfig(identity, proxy, route, true);
|
||||
LinphoneAuthInfo authInfo = LinphoneCoreFactory.instance().createAuthInfo(tempUsername, tempUserId, tempPassword, null, null);
|
||||
|
||||
getLc().addProxyConfig(prxCfg);
|
||||
getLc().addAuthInfo(authInfo);
|
||||
|
||||
if (getAccountCount() == 1)
|
||||
getLc().setDefaultProxyConfig(prxCfg);
|
||||
|
||||
tempUsername = null;
|
||||
tempUserId = null;
|
||||
tempPassword = null;
|
||||
tempDomain = null;
|
||||
tempProxy = null;
|
||||
tempOutboundProxy = false;
|
||||
}
|
||||
|
||||
public void setNewAccountUsername(String username) {
|
||||
tempUsername = username;
|
||||
}
|
||||
|
||||
public void setAccountUsername(int n, String username) {
|
||||
|
||||
}
|
||||
|
||||
public String getAccountUsername(int n) {
|
||||
return getAuthInfo(n).getUsername();
|
||||
}
|
||||
|
||||
public void setNewAccountUserId(String userId) {
|
||||
tempUserId = userId;
|
||||
}
|
||||
|
||||
public void setAccountUserId(int n, String userId) {
|
||||
|
||||
}
|
||||
|
||||
public String getAccountUserId(int n) {
|
||||
return null;
|
||||
return getAuthInfo(n).getUserId();
|
||||
}
|
||||
|
||||
public void setAccountPassword(int n, String string) {
|
||||
public void setNewAccountPassword(String password) {
|
||||
tempPassword = password;
|
||||
}
|
||||
|
||||
public void setAccountPassword(int n, String password) {
|
||||
|
||||
}
|
||||
|
||||
public String getAccountPassword(int n) {
|
||||
return null;
|
||||
return getAuthInfo(n).getPassword();
|
||||
}
|
||||
|
||||
public void setAccountDomain(int n, String string) {
|
||||
public void setNewAccountDomain(String domain) {
|
||||
tempDomain = domain;
|
||||
}
|
||||
|
||||
public void setAccountDomain(int n, String domain) {
|
||||
|
||||
}
|
||||
|
||||
public String getAccountDomain(int i) {
|
||||
return null;
|
||||
public String getAccountDomain(int n) {
|
||||
return getProxyConfig(n).getDomain();
|
||||
}
|
||||
|
||||
public void setAccountProxy(int n, String string) {
|
||||
public void setNewAccountProxy(String proxy) {
|
||||
tempProxy = proxy;
|
||||
}
|
||||
|
||||
public void setAccountProxy(int n, String proxy) {
|
||||
|
||||
}
|
||||
|
||||
public String getAccountProxy(int n) {
|
||||
return null;
|
||||
return getProxyConfig(n).getProxy();
|
||||
}
|
||||
|
||||
public void setAccountOutboundProxyEnabled(int n, Boolean newValue) {
|
||||
public void setNewAccountOutboundProxyEnabled(boolean enabled) {
|
||||
tempOutboundProxy = enabled;
|
||||
}
|
||||
|
||||
public void setAccountOutboundProxyEnabled(int n, boolean enabled) {
|
||||
|
||||
}
|
||||
|
||||
public boolean isAccountOutboundProxySet(int n) {
|
||||
return false;
|
||||
return getProxyConfig(n).getRoute() != null;
|
||||
}
|
||||
|
||||
public void setAccountEnabled(int n, Boolean newValue) {
|
||||
public void setAccountEnabled(int n, Boolean enabled) {
|
||||
|
||||
}
|
||||
|
||||
public void setDefaultAccount(int accountIndex) {
|
||||
|
||||
LinphoneProxyConfig[] prxCfgs = getLc().getProxyConfigList();
|
||||
if (accountIndex >= 0 && accountIndex < prxCfgs.length)
|
||||
getLc().setDefaultProxyConfig(prxCfgs[accountIndex]);
|
||||
}
|
||||
|
||||
public int getDefaultAccountIndex() {
|
||||
return 0;
|
||||
LinphoneProxyConfig defaultPrxCfg = getLc().getDefaultProxyConfig();
|
||||
LinphoneProxyConfig[] prxCfgs = getLc().getProxyConfigList();
|
||||
for (int i = 0; i < prxCfgs.length; i++) {
|
||||
if (defaultPrxCfg.equals(prxCfgs[i])) {
|
||||
return i;
|
||||
}
|
||||
|
||||
public void setAccountCount(int i) {
|
||||
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int getAccountCount() {
|
||||
return 0;
|
||||
return getLc().getProxyConfigList().length;
|
||||
}
|
||||
|
||||
public boolean isAccountEnabled(int n) {
|
||||
|
@ -225,23 +310,23 @@ public class LinphonePreferences {
|
|||
// End of Accounts
|
||||
|
||||
public MediaEncryption getMediaEncryption() {
|
||||
return LinphoneManager.getLcIfManagerNotDestroyedOrNull().getMediaEncryption();
|
||||
return getLc().getMediaEncryption();
|
||||
}
|
||||
|
||||
public void setMediaEncryption(MediaEncryption menc) {
|
||||
if (menc == null)
|
||||
return;
|
||||
|
||||
LinphoneManager.getLcIfManagerNotDestroyedOrNull().setMediaEncryption(menc);
|
||||
getLc().setMediaEncryption(menc);
|
||||
}
|
||||
|
||||
public String getTransport() {
|
||||
Transports transports = LinphoneManager.getLcIfManagerNotDestroyedOrNull().getSignalingTransportPorts();
|
||||
Transports transports = getLc().getSignalingTransportPorts();
|
||||
String transport = getString(R.string.pref_transport_udp);
|
||||
if (transports.tcp > 0)
|
||||
transport = getString(R.string.pref_transport_tcp_key);
|
||||
transport = getString(R.string.pref_transport_tcp);
|
||||
else if (transports.tls > 0)
|
||||
transport = getString(R.string.pref_transport_tls_key);
|
||||
transport = getString(R.string.pref_transport_tls);
|
||||
return transport;
|
||||
}
|
||||
|
||||
|
@ -249,7 +334,7 @@ public class LinphonePreferences {
|
|||
if (transportKey == null)
|
||||
return;
|
||||
|
||||
Transports transports = LinphoneManager.getLcIfManagerNotDestroyedOrNull().getSignalingTransportPorts();
|
||||
Transports transports = getLc().getSignalingTransportPorts();
|
||||
if (transports.udp > 0) {
|
||||
if (transportKey.equals(getString(R.string.pref_transport_tcp_key))) {
|
||||
transports.tcp = transports.udp;
|
||||
|
@ -275,15 +360,15 @@ public class LinphonePreferences {
|
|||
transports.tls = transports.udp;
|
||||
}
|
||||
}
|
||||
LinphoneManager.getLcIfManagerNotDestroyedOrNull().setSignalingTransportPorts(transports);
|
||||
getLc().setSignalingTransportPorts(transports);
|
||||
}
|
||||
|
||||
public String getStunServer() {
|
||||
return LinphoneManager.getLcIfManagerNotDestroyedOrNull().getStunServer();
|
||||
return getLc().getStunServer();
|
||||
}
|
||||
|
||||
public void setStunServer(String stun) {
|
||||
LinphoneManager.getLcIfManagerNotDestroyedOrNull().setStunServer(stun);
|
||||
getLc().setStunServer(stun);
|
||||
}
|
||||
|
||||
public String getExpire() {
|
||||
|
@ -295,7 +380,7 @@ public class LinphonePreferences {
|
|||
}
|
||||
|
||||
public String getSipPortIfNotRandom() {
|
||||
Transports transports = LinphoneManager.getLcIfManagerNotDestroyedOrNull().getSignalingTransportPorts();
|
||||
Transports transports = getLc().getSignalingTransportPorts();
|
||||
int port;
|
||||
if (transports.udp > 0)
|
||||
port = transports.udp;
|
||||
|
@ -310,13 +395,21 @@ public class LinphonePreferences {
|
|||
if (port <= 0)
|
||||
return;
|
||||
|
||||
Transports transports = LinphoneManager.getLcIfManagerNotDestroyedOrNull().getSignalingTransportPorts();
|
||||
Transports transports = getLc().getSignalingTransportPorts();
|
||||
if (transports.udp > 0)
|
||||
transports.udp = port;
|
||||
else if (transports.tcp > 0)
|
||||
transports.tcp = port;
|
||||
else
|
||||
transports.udp = port;
|
||||
LinphoneManager.getLcIfManagerNotDestroyedOrNull().setSignalingTransportPorts(transports);
|
||||
getLc().setSignalingTransportPorts(transports);
|
||||
}
|
||||
|
||||
public void setIceEnabled(boolean b) {
|
||||
|
||||
}
|
||||
|
||||
public void setPushNotificationEnabled(boolean b) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -272,7 +272,7 @@ public class PreferencesFragment extends PreferencesListFragment implements EcCa
|
|||
addAccount.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
nbAccounts = LinphonePreferences.instance().getAccountCount();
|
||||
LinphonePreferences.instance().setAccountCount(nbAccounts + 1);
|
||||
//LinphonePreferences.instance().setAccountCount(nbAccounts + 1);
|
||||
|
||||
addExtraAccountPreferencesButton(accounts, nbAccounts, true);
|
||||
LinphoneActivity.instance().displayAccountSettings(nbAccounts);
|
||||
|
@ -367,7 +367,7 @@ public class PreferencesFragment extends PreferencesListFragment implements EcCa
|
|||
|
||||
private void addExtraAccountPreferencesButton(PreferenceCategory parent, final int n, boolean isNewAccount) {
|
||||
if (isNewAccount) {
|
||||
LinphonePreferences.instance().setAccountCount(n+1);
|
||||
//LinphonePreferences.instance().setAccountCount(n+1);
|
||||
}
|
||||
|
||||
final LedPreference led = new LedPreference(mContext);
|
||||
|
|
|
@ -11,8 +11,10 @@ import org.linphone.mediastream.Log;
|
|||
import org.linphone.mediastream.Version;
|
||||
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
||||
import org.linphone.mediastream.video.capture.hwconf.Hacks;
|
||||
import org.linphone.setup.SetupActivity;
|
||||
import org.linphone.ui.PreferencesListFragment;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.ListPreference;
|
||||
|
@ -23,6 +25,7 @@ import android.preference.PreferenceCategory;
|
|||
import android.preference.PreferenceScreen;
|
||||
|
||||
public class SettingsFragment extends PreferencesListFragment implements EcCalibrationListener {
|
||||
private static final int WIZARD_INTENT = 1;
|
||||
private LinphonePreferences mPrefs;
|
||||
|
||||
public SettingsFragment() {
|
||||
|
@ -42,8 +45,10 @@ public class SettingsFragment extends PreferencesListFragment implements EcCalib
|
|||
|
||||
// Inits the values or the listener on some settings
|
||||
private void initSettings() {
|
||||
//initAccounts(); Init accounts on Resume instead of on Create to update the account list when coming back from wizard
|
||||
initMediaEncryptionPreference((ListPreference) findPreference(getString(R.string.pref_media_encryption_key)));
|
||||
initializeTransportPreferences((ListPreference) findPreference(getString(R.string.pref_transport_key)));
|
||||
initializePreferredVideoSizePreferences((ListPreference) findPreference(getString(R.string.pref_preferred_video_size_key)));
|
||||
|
||||
findPreference(getString(R.string.pref_stun_server_key)).setSummary(mPrefs.getStunServer());
|
||||
findPreference(getString(R.string.pref_image_sharing_server_key)).setSummary(mPrefs.getSharingPictureServerUrl());
|
||||
|
@ -61,6 +66,14 @@ public class SettingsFragment extends PreferencesListFragment implements EcCalib
|
|||
return false;
|
||||
}
|
||||
});
|
||||
findPreference(getString(R.string.setup_key)).setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Intent intent = new Intent(LinphoneService.instance(), SetupActivity.class);
|
||||
startActivityForResult(intent, WIZARD_INTENT);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// Disable sip port choice if port is random
|
||||
Preference sipPort = findPreference(getString(R.string.pref_sip_port_key));
|
||||
|
@ -96,6 +109,14 @@ public class SettingsFragment extends PreferencesListFragment implements EcCalib
|
|||
return true;
|
||||
}
|
||||
});
|
||||
findPreference(getString(R.string.pref_transport_key)).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
mPrefs.setTransport(newValue.toString());
|
||||
preference.setSummary(mPrefs.getTransport());
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Read the values set in resources and hides the settings accordingly
|
||||
|
@ -205,15 +226,45 @@ public class SettingsFragment extends PreferencesListFragment implements EcCalib
|
|||
preference.setLayoutResource(R.layout.hidden);
|
||||
}
|
||||
|
||||
private void initAccounts() {
|
||||
PreferenceCategory accounts = (PreferenceCategory) findPreference(getString(R.string.pref_sipaccounts_key));
|
||||
accounts.removeAll();
|
||||
|
||||
// Get already configured extra accounts
|
||||
int nbAccounts = mPrefs.getAccountCount();
|
||||
for (int i = 0; i < nbAccounts; i++) {
|
||||
final int accountId = i;
|
||||
// For each, add menus to configure it
|
||||
Preference account = new Preference(LinphoneService.instance());
|
||||
String username = mPrefs.getAccountUsername(accountId);
|
||||
String domain = mPrefs.getAccountDomain(accountId);
|
||||
|
||||
if (username == null) {
|
||||
account.setTitle(getString(R.string.pref_sipaccount));
|
||||
} else {
|
||||
account.setTitle(username + "@" + domain);
|
||||
}
|
||||
|
||||
account.setOnPreferenceClickListener(new OnPreferenceClickListener()
|
||||
{
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
LinphoneActivity.instance().displayAccountSettings(accountId);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
accounts.addPreference(account);
|
||||
}
|
||||
}
|
||||
|
||||
private void initMediaEncryptionPreference(ListPreference pref) {
|
||||
List<CharSequence> mencEntries = new ArrayList<CharSequence>();
|
||||
List<CharSequence> mencEntryValues = new ArrayList<CharSequence>();
|
||||
mencEntries.add(getString(R.string.media_encryption_none));
|
||||
mencEntryValues.add(getString(R.string.pref_media_encryption_key_none));
|
||||
List<CharSequence> entries = new ArrayList<CharSequence>();
|
||||
List<CharSequence> values = new ArrayList<CharSequence>();
|
||||
entries.add(getString(R.string.media_encryption_none));
|
||||
values.add(getString(R.string.pref_media_encryption_key_none));
|
||||
|
||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
if (lc == null || getResources().getBoolean(R.bool.disable_all_security_features_for_markets)) {
|
||||
setListPreferenceValues(pref, mencEntries, mencEntryValues);
|
||||
setListPreferenceValues(pref, entries, values);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -223,35 +274,50 @@ public class SettingsFragment extends PreferencesListFragment implements EcCalib
|
|||
pref.setEnabled(false);
|
||||
} else {
|
||||
if (hasSrtp){
|
||||
mencEntries.add(getString(R.string.media_encryption_srtp));
|
||||
mencEntryValues.add(getString(R.string.pref_media_encryption_key_srtp));
|
||||
entries.add(getString(R.string.media_encryption_srtp));
|
||||
values.add(getString(R.string.pref_media_encryption_key_srtp));
|
||||
}
|
||||
if (hasZrtp){
|
||||
mencEntries.add(getString(R.string.media_encryption_zrtp));
|
||||
mencEntryValues.add(getString(R.string.pref_media_encryption_key_zrtp));
|
||||
entries.add(getString(R.string.media_encryption_zrtp));
|
||||
values.add(getString(R.string.pref_media_encryption_key_zrtp));
|
||||
}
|
||||
setListPreferenceValues(pref, mencEntries, mencEntryValues);
|
||||
setListPreferenceValues(pref, entries, values);
|
||||
}
|
||||
|
||||
pref.setSummary(mPrefs.getMediaEncryption().toString());
|
||||
}
|
||||
|
||||
private void initializeTransportPreferences(ListPreference pref) {
|
||||
List<CharSequence> mencEntries = new ArrayList<CharSequence>();
|
||||
List<CharSequence> mencEntryValues = new ArrayList<CharSequence>();
|
||||
mencEntries.add(getString(R.string.pref_transport_udp));
|
||||
mencEntryValues.add(getString(R.string.pref_transport_udp_key));
|
||||
mencEntries.add(getString(R.string.pref_transport_tcp));
|
||||
mencEntryValues.add(getString(R.string.pref_transport_tcp_key));
|
||||
List<CharSequence> entries = new ArrayList<CharSequence>();
|
||||
List<CharSequence> values = new ArrayList<CharSequence>();
|
||||
entries.add(getString(R.string.pref_transport_udp));
|
||||
values.add(getString(R.string.pref_transport_udp_key));
|
||||
entries.add(getString(R.string.pref_transport_tcp));
|
||||
values.add(getString(R.string.pref_transport_tcp_key));
|
||||
|
||||
if (!getResources().getBoolean(R.bool.disable_all_security_features_for_markets)) {
|
||||
mencEntries.add(getString(R.string.pref_transport_tls));
|
||||
mencEntryValues.add(getString(R.string.pref_transport_tls_key));
|
||||
entries.add(getString(R.string.pref_transport_tls));
|
||||
values.add(getString(R.string.pref_transport_tls_key));
|
||||
}
|
||||
setListPreferenceValues(pref, mencEntries, mencEntryValues);
|
||||
setListPreferenceValues(pref, entries, values);
|
||||
pref.setSummary(mPrefs.getTransport());
|
||||
}
|
||||
|
||||
private void initializePreferredVideoSizePreferences(ListPreference pref) {
|
||||
List<CharSequence> entries = new ArrayList<CharSequence>();
|
||||
List<CharSequence> values = new ArrayList<CharSequence>();
|
||||
if (Version.isHDVideoCapable()) {
|
||||
entries.add(getString(R.string.pref_preferred_video_size_hd));
|
||||
values.add(getString(R.string.pref_preferred_video_size_hd_key));
|
||||
}
|
||||
entries.add(getString(R.string.pref_preferred_video_size_vga));
|
||||
values.add(getString(R.string.pref_preferred_video_size_vga_key));
|
||||
entries.add(getString(R.string.pref_preferred_video_size_qvga));
|
||||
values.add(getString(R.string.pref_preferred_video_size_qvga_key));
|
||||
|
||||
setListPreferenceValues(pref, entries, values);
|
||||
}
|
||||
|
||||
private static void setListPreferenceValues(ListPreference pref, List<CharSequence> entries, List<CharSequence> values) {
|
||||
CharSequence[] contents = new CharSequence[entries.size()];
|
||||
entries.toArray(contents);
|
||||
|
@ -270,6 +336,7 @@ public class SettingsFragment extends PreferencesListFragment implements EcCalib
|
|||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
initAccounts();
|
||||
if (LinphoneActivity.isInstanciated()) {
|
||||
LinphoneActivity.instance().selectMenu(FragmentsAvailable.SETTINGS);
|
||||
}
|
||||
|
|
|
@ -22,14 +22,13 @@ import org.linphone.LinphonePreferences;
|
|||
import org.linphone.LinphoneSimpleListener.LinphoneOnRegistrationStateChangedListener;
|
||||
import org.linphone.R;
|
||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||
import org.linphone.core.LinphoneCoreException;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
|
@ -46,9 +45,9 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
|||
private static SetupActivity instance;
|
||||
private RelativeLayout back, next, cancel;
|
||||
private SetupFragmentsEnum currentFragment;
|
||||
private SharedPreferences mPref;
|
||||
private SetupFragmentsEnum firstFragment;
|
||||
private Fragment fragment;
|
||||
private LinphonePreferences mPrefs;
|
||||
private boolean accountCreated = false;
|
||||
private Handler mHandler = new Handler();
|
||||
|
||||
|
@ -69,8 +68,7 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
|||
currentFragment = (SetupFragmentsEnum) savedInstanceState.getSerializable("CurrentFragment");
|
||||
}
|
||||
}
|
||||
|
||||
mPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
mPrefs = LinphonePreferences.instance();
|
||||
|
||||
initUI();
|
||||
instance = this;
|
||||
|
@ -165,7 +163,7 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
|||
}
|
||||
|
||||
private void launchEchoCancellerCalibration(boolean sendEcCalibrationResult) {
|
||||
if (LinphoneManager.getLc().needsEchoCalibration() && !mPref.getBoolean(getString(R.string.first_launch_suceeded_once_key), false)) {
|
||||
if (LinphoneManager.getLc().needsEchoCalibration() && mPrefs.isFirstLaunch()) {
|
||||
EchoCancellerCalibrationFragment fragment = new EchoCancellerCalibrationFragment();
|
||||
fragment.enableEcCalibrationResultSending(sendEcCalibrationResult);
|
||||
changeFragment(fragment);
|
||||
|
@ -207,7 +205,6 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
|||
}
|
||||
} else if (state == RegistrationState.RegistrationFailed) {
|
||||
LinphoneManager.removeListener(registrationListener);
|
||||
deleteCreatedAccount();
|
||||
mHandler.post(new Runnable () {
|
||||
public void run() {
|
||||
Toast.makeText(SetupActivity.this, getString(R.string.first_launch_bad_login_password), Toast.LENGTH_LONG).show();
|
||||
|
@ -235,22 +232,6 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
|||
logIn(username, password, domain, false);
|
||||
}
|
||||
|
||||
private void writePreference(int key, String value) {
|
||||
mPref.edit().putString(getString(key), value).commit();
|
||||
}
|
||||
|
||||
private void writePreference(String key, String value) {
|
||||
mPref.edit().putString(key, value).commit();
|
||||
}
|
||||
|
||||
private void writePreference(int key, int value) {
|
||||
mPref.edit().putInt(getString(key), value).commit();
|
||||
}
|
||||
|
||||
private void writePreference(int key, boolean value) {
|
||||
mPref.edit().putBoolean(getString(key), value).commit();
|
||||
}
|
||||
|
||||
private void display(SetupFragmentsEnum fragment) {
|
||||
switch (fragment) {
|
||||
case WELCOME:
|
||||
|
@ -288,57 +269,45 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
|||
currentFragment = SetupFragmentsEnum.WIZARD;
|
||||
}
|
||||
|
||||
public void deleteCreatedAccount() {
|
||||
if (!accountCreated)
|
||||
return;
|
||||
|
||||
writePreference(R.string.pref_extra_accounts, 0);
|
||||
accountCreated = false;
|
||||
}
|
||||
|
||||
public void saveCreatedAccount(String username, String password, String domain) {
|
||||
if (accountCreated)
|
||||
return;
|
||||
|
||||
int newAccountId = mPref.getInt(getString(R.string.pref_extra_accounts), 0);
|
||||
if (newAccountId == -1)
|
||||
newAccountId = 0;
|
||||
writePreference(R.string.pref_extra_accounts, newAccountId+1);
|
||||
|
||||
if (newAccountId == 0) {
|
||||
writePreference(R.string.pref_username_key, username);
|
||||
writePreference(R.string.pref_passwd_key, password);
|
||||
writePreference(R.string.pref_domain_key, domain);
|
||||
|
||||
boolean isMainAccountLinphoneDotOrg = domain.equals(getString(R.string.default_domain));
|
||||
boolean useLinphoneDotOrgCustomPorts = getResources().getBoolean(R.bool.use_linphone_server_ports);
|
||||
mPrefs.setNewAccountUsername(username);
|
||||
mPrefs.setNewAccountDomain(domain);
|
||||
mPrefs.setNewAccountPassword(password);
|
||||
|
||||
if (isMainAccountLinphoneDotOrg && useLinphoneDotOrgCustomPorts) {
|
||||
if (getResources().getBoolean(R.bool.disable_all_security_features_for_markets)) {
|
||||
writePreference(R.string.pref_proxy_key, domain + ":5228");
|
||||
writePreference(R.string.pref_transport_key, getString(R.string.pref_transport_tcp_key));
|
||||
mPrefs.setNewAccountProxy(domain + ":5228");
|
||||
mPrefs.setTransport(getString(R.string.pref_transport_tcp_key));
|
||||
}
|
||||
else {
|
||||
writePreference(R.string.pref_proxy_key, domain + ":5223");
|
||||
writePreference(R.string.pref_transport_key, getString(R.string.pref_transport_tls_key));
|
||||
mPrefs.setNewAccountProxy(domain + ":5223");
|
||||
mPrefs.setTransport(getString(R.string.pref_transport_tls_key));
|
||||
}
|
||||
|
||||
writePreference(R.string.pref_expire_key, "604800"); // 3600*24*7
|
||||
writePreference(R.string.pref_enable_outbound_proxy_key, true);
|
||||
writePreference(R.string.pref_stun_server_key, getString(R.string.default_stun));
|
||||
writePreference(R.string.pref_ice_enable_key, true);
|
||||
writePreference(R.string.pref_push_notification_key, true);
|
||||
}
|
||||
mPrefs.setExpire("604800");
|
||||
mPrefs.setNewAccountOutboundProxyEnabled(true);
|
||||
mPrefs.setStunServer(getString(R.string.default_stun));
|
||||
mPrefs.setIceEnabled(true);
|
||||
mPrefs.setPushNotificationEnabled(true);
|
||||
} else {
|
||||
writePreference(getString(R.string.pref_username_key) + newAccountId, username);
|
||||
writePreference(getString(R.string.pref_passwd_key) + newAccountId, password);
|
||||
writePreference(getString(R.string.pref_domain_key) + newAccountId, domain);
|
||||
}
|
||||
String forcedProxy=getResources().getString(R.string.setup_forced_proxy);
|
||||
String forcedProxy = getResources().getString(R.string.setup_forced_proxy);
|
||||
if (!TextUtils.isEmpty(forcedProxy)) {
|
||||
writePreference(R.string.pref_enable_outbound_proxy_key, true);
|
||||
writePreference(R.string.pref_proxy_key, forcedProxy);
|
||||
mPrefs.setNewAccountProxy(forcedProxy);
|
||||
mPrefs.setNewAccountOutboundProxyEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
mPrefs.saveNewAccount();
|
||||
accountCreated = true;
|
||||
} catch (LinphoneCoreException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void displayWizardConfirm(String username) {
|
||||
|
@ -366,7 +335,7 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
|||
}
|
||||
|
||||
public void success() {
|
||||
writePreference(R.string.first_launch_suceeded_once_key, true);
|
||||
mPrefs.firstLaunchSuccessful();
|
||||
setResult(Activity.RESULT_OK);
|
||||
finish();
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 863770bebb7193963df5af36d30c968bb053d50e
|
||||
Subproject commit c344f32c1e0db5da3d596f741a330dea28fc5639
|
Loading…
Reference in a new issue