Refresh account status led when needed
This commit is contained in:
parent
011517b6fb
commit
b01a4d19de
2 changed files with 35 additions and 22 deletions
|
@ -563,8 +563,28 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
mLc.tunnelAddServerAndMirror(host, port, 12345,500);
|
||||
manageTunnelServer(info);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
public void initAccount(String key, boolean cleanBefore, boolean defaultAccount) throws LinphoneCoreException {
|
||||
private void initAccount(String key, boolean cleanBefore, boolean defaultAccount) throws LinphoneCoreException {
|
||||
if (cleanBefore) {
|
||||
mLc.clearAuthInfos();
|
||||
mLc.clearProxyConfigs();
|
||||
|
@ -657,23 +677,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
|
||||
//accounts
|
||||
try {
|
||||
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));
|
||||
}
|
||||
initAccounts();
|
||||
|
||||
//init network state
|
||||
NetworkInfo networkInfo = mConnectivityManager.getActiveNetworkInfo();
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.linphone.LinphoneManager.LinphoneConfigException;
|
|||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
||||
import org.linphone.core.LinphoneCore.MediaEncryption;
|
||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||
import org.linphone.core.LinphoneCoreException;
|
||||
import org.linphone.core.LinphoneProxyConfig;
|
||||
import org.linphone.core.Log;
|
||||
|
@ -162,10 +163,14 @@ public class PreferencesActivity extends LinphonePreferencesActivity implements
|
|||
|
||||
for (LinphoneProxyConfig lpc : LinphoneManager.getLc().getProxyConfigList()) {
|
||||
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);
|
||||
else
|
||||
} else {
|
||||
me.setWidgetLayoutResource(R.layout.preference_led_not_connected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,6 +191,11 @@ public class PreferencesActivity extends LinphonePreferencesActivity implements
|
|||
editor.commit();
|
||||
}
|
||||
|
||||
try {
|
||||
LinphoneManager.getInstance().initAccounts();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
createDynamicAccountsPreferences();
|
||||
}
|
||||
|
||||
|
@ -473,7 +483,7 @@ public class PreferencesActivity extends LinphonePreferencesActivity implements
|
|||
private void writeBoolean(int key, boolean value) {
|
||||
prefs().edit().putBoolean(getString(key), value).commit();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
|
@ -499,5 +509,4 @@ public class PreferencesActivity extends LinphonePreferencesActivity implements
|
|||
LinphoneActivity.instance().showPreferenceErrorDialog(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue