Finished accounts settings + added back colored led for registration status
This commit is contained in:
parent
81a2b89243
commit
18bd5b0185
3 changed files with 78 additions and 5 deletions
|
@ -40,6 +40,12 @@ public class AccountPreferencesFragment extends PreferencesListFragment {
|
|||
super(R.xml.account_preferences);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
LinphoneManager.getLc().refreshRegisters();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -69,7 +75,6 @@ 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;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -201,7 +201,16 @@ public class LinphonePreferences {
|
|||
}
|
||||
|
||||
public void setAccountDomain(int n, String domain) {
|
||||
//TODO
|
||||
String identity = "sip:" + getAccountUsername(n) + "@" + domain;
|
||||
String proxy = "sip:" + domain;
|
||||
|
||||
try {
|
||||
LinphoneProxyConfig prxCfg = getProxyConfig(n);
|
||||
prxCfg.setIdentity(identity);
|
||||
prxCfg.setProxy(proxy);
|
||||
} catch (LinphoneCoreException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String getAccountDomain(int n) {
|
||||
|
@ -213,7 +222,12 @@ public class LinphonePreferences {
|
|||
}
|
||||
|
||||
public void setAccountProxy(int n, String proxy) {
|
||||
//TODO
|
||||
try {
|
||||
LinphoneProxyConfig prxCfg = getProxyConfig(n);
|
||||
prxCfg.setProxy("sip:" + proxy);
|
||||
} catch (LinphoneCoreException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String getAccountProxy(int n) {
|
||||
|
@ -225,7 +239,15 @@ public class LinphonePreferences {
|
|||
}
|
||||
|
||||
public void setAccountOutboundProxyEnabled(int n, boolean enabled) {
|
||||
//TODO
|
||||
try {
|
||||
if (enabled) {
|
||||
getProxyConfig(n).setRoute(getAccountProxy(n));
|
||||
} else {
|
||||
getProxyConfig(n).setRoute(null);
|
||||
}
|
||||
} catch (LinphoneCoreException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setNewAccountContactParameters(String contactParams) {
|
||||
|
|
|
@ -4,18 +4,24 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.linphone.LinphoneManager.EcCalibrationListener;
|
||||
import org.linphone.core.LinphoneAddress;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
||||
import org.linphone.core.LinphoneCore.MediaEncryption;
|
||||
import org.linphone.core.LinphoneCoreException;
|
||||
import org.linphone.core.LinphoneCoreFactory;
|
||||
import org.linphone.core.LinphoneProxyConfig;
|
||||
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.LedPreference;
|
||||
import org.linphone.ui.PreferencesListFragment;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
|
@ -27,6 +33,7 @@ import android.preference.PreferenceScreen;
|
|||
public class SettingsFragment extends PreferencesListFragment implements EcCalibrationListener {
|
||||
private static final int WIZARD_INTENT = 1;
|
||||
private LinphonePreferences mPrefs;
|
||||
private Handler mHandler = new Handler();
|
||||
|
||||
public SettingsFragment() {
|
||||
super(R.xml.preferences);
|
||||
|
@ -219,7 +226,7 @@ public class SettingsFragment extends PreferencesListFragment implements EcCalib
|
|||
for (int i = 0; i < nbAccounts; i++) {
|
||||
final int accountId = i;
|
||||
// For each, add menus to configure it
|
||||
Preference account = new Preference(LinphoneService.instance());
|
||||
LedPreference account = new LedPreference(LinphoneService.instance());
|
||||
String username = mPrefs.getAccountUsername(accountId);
|
||||
String domain = mPrefs.getAccountDomain(accountId);
|
||||
|
||||
|
@ -240,10 +247,48 @@ public class SettingsFragment extends PreferencesListFragment implements EcCalib
|
|||
return false;
|
||||
}
|
||||
});
|
||||
updateAccountLed(account, username, domain, mPrefs.isAccountEnabled(i));
|
||||
accounts.addPreference(account);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAccountLed(final LedPreference me, final String username, final String domain, boolean enabled) {
|
||||
if (!enabled) {
|
||||
me.setLed(R.drawable.led_disconnected);
|
||||
return;
|
||||
}
|
||||
|
||||
if (LinphoneManager.getLcIfManagerNotDestroyedOrNull() != null) {
|
||||
for (LinphoneProxyConfig lpc : LinphoneManager.getLc().getProxyConfigList()) {
|
||||
LinphoneAddress addr = null;
|
||||
try {
|
||||
addr = LinphoneCoreFactory.instance().createLinphoneAddress(lpc.getIdentity());
|
||||
} catch (LinphoneCoreException e) {
|
||||
me.setLed(R.drawable.led_disconnected);
|
||||
return;
|
||||
}
|
||||
if (addr.getUserName().equals(username) && addr.getDomain().equals(domain)) {
|
||||
if (lpc.getState() == LinphoneCore.RegistrationState.RegistrationOk) {
|
||||
me.setLed(R.drawable.led_connected);
|
||||
} else if (lpc.getState() == LinphoneCore.RegistrationState.RegistrationFailed) {
|
||||
me.setLed(R.drawable.led_error);
|
||||
} else if (lpc.getState() == LinphoneCore.RegistrationState.RegistrationProgress) {
|
||||
me.setLed(R.drawable.led_inprogress);
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateAccountLed(me, username, domain, true);
|
||||
}
|
||||
}, 500);
|
||||
} else {
|
||||
me.setLed(R.drawable.led_disconnected);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initMediaEncryptionPreference(ListPreference pref) {
|
||||
List<CharSequence> entries = new ArrayList<CharSequence>();
|
||||
List<CharSequence> values = new ArrayList<CharSequence>();
|
||||
|
@ -568,6 +613,7 @@ public class SettingsFragment extends PreferencesListFragment implements EcCalib
|
|||
super.onResume();
|
||||
|
||||
initAccounts();
|
||||
|
||||
if (LinphoneActivity.isInstanciated()) {
|
||||
LinphoneActivity.instance().selectMenu(FragmentsAvailable.SETTINGS);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue