Refresh account status led when needed
This commit is contained in:
parent
011517b6fb
commit
b01a4d19de
2 changed files with 35 additions and 22 deletions
|
@ -564,7 +564,27 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
manageTunnelServer(info);
|
manageTunnelServer(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initAccount(String key, boolean cleanBefore, boolean defaultAccount) throws LinphoneCoreException {
|
public void initAccounts() throws LinphoneCoreException {
|
||||||
|
for (int i = 0; i < getPrefExtraAccountsNumber(); i++) {
|
||||||
|
if (getPrefBoolean(getString(R.string.pref_disable_account_key) + i, false)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
initAccount(i == 0 ? "" : String.valueOf(i), i == 0, i == getPrefInt(R.string.pref_default_account, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
LinphoneProxyConfig lDefaultProxyConfig = mLc.getDefaultProxyConfig();
|
||||||
|
if (lDefaultProxyConfig !=null) {
|
||||||
|
//prefix
|
||||||
|
String lPrefix = getPrefString(R.string.pref_prefix_key, null);
|
||||||
|
if (lPrefix != null) {
|
||||||
|
lDefaultProxyConfig.setDialPrefix(lPrefix);
|
||||||
|
}
|
||||||
|
//escape +
|
||||||
|
lDefaultProxyConfig.setDialEscapePlus(getPrefBoolean(R.string.pref_escape_plus_key,false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initAccount(String key, boolean cleanBefore, boolean defaultAccount) throws LinphoneCoreException {
|
||||||
if (cleanBefore) {
|
if (cleanBefore) {
|
||||||
mLc.clearAuthInfos();
|
mLc.clearAuthInfos();
|
||||||
mLc.clearProxyConfigs();
|
mLc.clearProxyConfigs();
|
||||||
|
@ -657,23 +677,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
|
|
||||||
//accounts
|
//accounts
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < getPrefExtraAccountsNumber(); i++) {
|
initAccounts();
|
||||||
if (getPrefBoolean(getString(R.string.pref_disable_account_key) + i, false)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
initAccount(i == 0 ? "" : String.valueOf(i), i == 0, i == getPrefInt(R.string.pref_default_account, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
LinphoneProxyConfig lDefaultProxyConfig = mLc.getDefaultProxyConfig();
|
|
||||||
if (lDefaultProxyConfig !=null) {
|
|
||||||
//prefix
|
|
||||||
String lPrefix = getPrefString(R.string.pref_prefix_key, null);
|
|
||||||
if (lPrefix != null) {
|
|
||||||
lDefaultProxyConfig.setDialPrefix(lPrefix);
|
|
||||||
}
|
|
||||||
//escape +
|
|
||||||
lDefaultProxyConfig.setDialEscapePlus(getPrefBoolean(R.string.pref_escape_plus_key,false));
|
|
||||||
}
|
|
||||||
|
|
||||||
//init network state
|
//init network state
|
||||||
NetworkInfo networkInfo = mConnectivityManager.getActiveNetworkInfo();
|
NetworkInfo networkInfo = mConnectivityManager.getActiveNetworkInfo();
|
||||||
|
|
|
@ -39,6 +39,7 @@ import org.linphone.LinphoneManager.LinphoneConfigException;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
||||||
import org.linphone.core.LinphoneCore.MediaEncryption;
|
import org.linphone.core.LinphoneCore.MediaEncryption;
|
||||||
|
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||||
import org.linphone.core.LinphoneCoreException;
|
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;
|
||||||
|
@ -162,10 +163,14 @@ public class PreferencesActivity extends LinphonePreferencesActivity implements
|
||||||
|
|
||||||
for (LinphoneProxyConfig lpc : LinphoneManager.getLc().getProxyConfigList()) {
|
for (LinphoneProxyConfig lpc : LinphoneManager.getLc().getProxyConfigList()) {
|
||||||
if (lpc.getIdentity().contains(prefs.getString(keyUsername, "")) && lpc.getIdentity().contains(prefs.getString(keyDomain, ""))) {
|
if (lpc.getIdentity().contains(prefs.getString(keyUsername, "")) && lpc.getIdentity().contains(prefs.getString(keyDomain, ""))) {
|
||||||
if (lpc.getState() == LinphoneCore.RegistrationState.RegistrationOk)
|
while (lpc.getState() == RegistrationState.RegistrationProgress || lpc.getState() == RegistrationState.RegistrationNone)
|
||||||
|
{};
|
||||||
|
|
||||||
|
if (lpc.getState() == LinphoneCore.RegistrationState.RegistrationOk) {
|
||||||
me.setWidgetLayoutResource(R.layout.preference_led_connected);
|
me.setWidgetLayoutResource(R.layout.preference_led_connected);
|
||||||
else
|
} else {
|
||||||
me.setWidgetLayoutResource(R.layout.preference_led_not_connected);
|
me.setWidgetLayoutResource(R.layout.preference_led_not_connected);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,6 +191,11 @@ public class PreferencesActivity extends LinphonePreferencesActivity implements
|
||||||
editor.commit();
|
editor.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
LinphoneManager.getInstance().initAccounts();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
createDynamicAccountsPreferences();
|
createDynamicAccountsPreferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,5 +509,4 @@ public class PreferencesActivity extends LinphonePreferencesActivity implements
|
||||||
LinphoneActivity.instance().showPreferenceErrorDialog(e.getMessage());
|
LinphoneActivity.instance().showPreferenceErrorDialog(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue