Fix delete/disable account
This commit is contained in:
parent
9f37ac8251
commit
6797a1e2c2
3 changed files with 57 additions and 36 deletions
|
@ -291,6 +291,11 @@ public class LinphonePreferences {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAccountDeleted(int n){
|
||||||
|
LinphoneProxyConfig proxyConfig = getProxyConfig(n);
|
||||||
|
return proxyConfig.getIsDeleted();
|
||||||
|
}
|
||||||
|
|
||||||
public void setAccountTransport(int n, String transport) {
|
public void setAccountTransport(int n, String transport) {
|
||||||
LinphoneProxyConfig proxyConfig = getProxyConfig(n);
|
LinphoneProxyConfig proxyConfig = getProxyConfig(n);
|
||||||
|
|
||||||
|
@ -586,6 +591,7 @@ public class LinphonePreferences {
|
||||||
|
|
||||||
public void setAccountEnabled(int n, boolean enabled) {
|
public void setAccountEnabled(int n, boolean enabled) {
|
||||||
LinphoneProxyConfig prxCfg = getProxyConfig(n);
|
LinphoneProxyConfig prxCfg = getProxyConfig(n);
|
||||||
|
prxCfg.edit();
|
||||||
prxCfg.enableRegister(enabled);
|
prxCfg.enableRegister(enabled);
|
||||||
prxCfg.done();
|
prxCfg.done();
|
||||||
|
|
||||||
|
@ -608,19 +614,31 @@ public class LinphonePreferences {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteAccount(int n) {
|
public void deleteAccount(int n) {
|
||||||
LinphoneAuthInfo authInfo = getAuthInfo(n);
|
final LinphoneAuthInfo authInfo = getAuthInfo(n);
|
||||||
if (authInfo != null)
|
final LinphoneProxyConfig proxyCfg = getProxyConfig(n);
|
||||||
getLc().removeAuthInfo(authInfo);
|
|
||||||
LinphoneProxyConfig proxyCfg = getProxyConfig(n);
|
proxyCfg.edit();
|
||||||
if (proxyCfg != null)
|
proxyCfg.enableRegister(false);
|
||||||
getLc().removeProxyConfig(proxyCfg);
|
proxyCfg.done();
|
||||||
|
|
||||||
if (getLc().getProxyConfigList().length == 0) {
|
proxyCfg.setIsDeleted(true);
|
||||||
// TODO: remove once issue http://bugs.linphone.org/view.php?id=984 will be fixed
|
new Thread(new Runnable() {
|
||||||
LinphoneActivity.instance().getStatusFragment().registrationStateChanged(RegistrationState.RegistrationNone);
|
|
||||||
} else {
|
@Override
|
||||||
getLc().refreshRegisters();
|
public void run() {
|
||||||
}
|
while(proxyCfg.getState() != RegistrationState.RegistrationCleared && proxyCfg.getState() != RegistrationState.RegistrationFailed){}
|
||||||
|
if (authInfo != null)
|
||||||
|
getLc().removeAuthInfo(authInfo);
|
||||||
|
if (proxyCfg != null)
|
||||||
|
getLc().removeProxyConfig(proxyCfg);
|
||||||
|
if (getLc().getProxyConfigList().length == 0) {
|
||||||
|
// TODO: remove once issue http://bugs.linphone.org/view.php?id=984 will be fixed
|
||||||
|
LinphoneActivity.instance().getStatusFragment().registrationStateChanged(RegistrationState.RegistrationNone);
|
||||||
|
} else {
|
||||||
|
getLc().refreshRegisters();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
// End of accounts settings
|
// End of accounts settings
|
||||||
|
|
||||||
|
|
|
@ -276,29 +276,31 @@ public class SettingsFragment extends PreferencesListFragment implements EcCalib
|
||||||
for (int i = 0; i < nbAccounts; i++) {
|
for (int i = 0; i < nbAccounts; i++) {
|
||||||
final int accountId = i;
|
final int accountId = i;
|
||||||
// For each, add menus to configure it
|
// For each, add menus to configure it
|
||||||
LedPreference account = new LedPreference(LinphoneService.instance());
|
if(!mPrefs.isAccountDeleted(accountId)){
|
||||||
String username = mPrefs.getAccountUsername(accountId);
|
String username = mPrefs.getAccountUsername(accountId);
|
||||||
String domain = mPrefs.getAccountDomain(accountId);
|
String domain = mPrefs.getAccountDomain(accountId);
|
||||||
|
LedPreference account = new LedPreference(LinphoneService.instance());
|
||||||
if (username == null) {
|
|
||||||
account.setTitle(getString(R.string.pref_sipaccount));
|
if (username == null) {
|
||||||
} else {
|
account.setTitle(getString(R.string.pref_sipaccount));
|
||||||
account.setTitle(username + "@" + domain);
|
} else {
|
||||||
}
|
account.setTitle(username + "@" + domain);
|
||||||
|
|
||||||
if (defaultAccountID == i) {
|
|
||||||
account.setSummary(R.string.default_account_flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
account.setOnPreferenceClickListener(new OnPreferenceClickListener()
|
|
||||||
{
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
|
||||||
LinphoneActivity.instance().displayAccountSettings(accountId);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
updateAccountLed(account, username, domain, mPrefs.isAccountEnabled(i));
|
if (defaultAccountID == i) {
|
||||||
accounts.addPreference(account);
|
account.setSummary(R.string.default_account_flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
account.setOnPreferenceClickListener(new OnPreferenceClickListener()
|
||||||
|
{
|
||||||
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
LinphoneActivity.instance().displayAccountSettings(accountId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
updateAccountLed(account, username, domain, mPrefs.isAccountEnabled(i));
|
||||||
|
accounts.addPreference(account);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -225,7 +225,8 @@ public class StatusFragment extends Fragment {
|
||||||
|
|
||||||
private int getStatusIconResource(LinphoneCore.RegistrationState state, boolean isDefaultAccount) {
|
private int getStatusIconResource(LinphoneCore.RegistrationState state, boolean isDefaultAccount) {
|
||||||
try {
|
try {
|
||||||
boolean defaultAccountConnected = (isDefaultAccount && LinphoneManager.getLcIfManagerNotDestroyedOrNull().getDefaultProxyConfig().isRegistered()) || !isDefaultAccount;
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
boolean defaultAccountConnected = (isDefaultAccount && lc != null && lc.getDefaultProxyConfig() != null && lc.getDefaultProxyConfig().isRegistered()) || !isDefaultAccount;
|
||||||
if (state == RegistrationState.RegistrationOk && defaultAccountConnected) {
|
if (state == RegistrationState.RegistrationOk && defaultAccountConnected) {
|
||||||
return R.drawable.led_connected;
|
return R.drawable.led_connected;
|
||||||
} else if (state == RegistrationState.RegistrationProgress) {
|
} else if (state == RegistrationState.RegistrationProgress) {
|
||||||
|
|
Loading…
Reference in a new issue