Fix status fragment registration state
This commit is contained in:
parent
96bb1db397
commit
c3da8a9fe6
3 changed files with 26 additions and 34 deletions
|
@ -683,11 +683,6 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
|
|
||||||
public void updateStatusFragment(StatusFragment fragment) {
|
public void updateStatusFragment(StatusFragment fragment) {
|
||||||
statusFragment = fragment;
|
statusFragment = fragment;
|
||||||
|
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
|
||||||
if (lc != null && lc.getDefaultProxyConfig() != null) {
|
|
||||||
statusFragment.registrationStateChanged(LinphoneManager.getLc().getDefaultProxyConfig().getState());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displaySettings() {
|
public void displaySettings() {
|
||||||
|
@ -768,21 +763,12 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
getChatStorage().updateMessageStatus(to, id, newState);
|
getChatStorage().updateMessageStatus(to, id, newState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void registrationState(LinphoneCore lc, LinphoneProxyConfig proxy, LinphoneCore.RegistrationState state, String smessage) {
|
public void registrationState(LinphoneCore lc, LinphoneProxyConfig proxy, LinphoneCore.RegistrationState state, String smessage) {
|
||||||
if (statusFragment != null) {
|
if (state.equals(RegistrationState.RegistrationCleared)) {
|
||||||
if (lc != null)
|
if (lc != null) {
|
||||||
if(lc.getDefaultProxyConfig() == null)
|
|
||||||
statusFragment.registrationStateChanged(proxy.getState());
|
|
||||||
else
|
|
||||||
statusFragment.registrationStateChanged(lc.getDefaultProxyConfig().getState());
|
|
||||||
else
|
|
||||||
statusFragment.registrationStateChanged(RegistrationState.RegistrationNone);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(state.equals(RegistrationState.RegistrationCleared)){
|
|
||||||
if(lc != null){
|
|
||||||
LinphoneAuthInfo authInfo = lc.findAuthInfo(proxy.getIdentity(), proxy.getRealm(), proxy.getDomain());
|
LinphoneAuthInfo authInfo = lc.findAuthInfo(proxy.getIdentity(), proxy.getRealm(), proxy.getDomain());
|
||||||
if(authInfo != null)
|
if (authInfo != null)
|
||||||
lc.removeAuthInfo(authInfo);
|
lc.removeAuthInfo(authInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,13 +20,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.linphone.core.LinphoneAddress;
|
import org.linphone.core.LinphoneAddress;
|
||||||
|
import org.linphone.core.LinphoneAddress.TransportType;
|
||||||
import org.linphone.core.LinphoneAuthInfo;
|
import org.linphone.core.LinphoneAuthInfo;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneAddress.TransportType;
|
|
||||||
import org.linphone.core.LinphoneCore.AdaptiveRateAlgorithm;
|
import org.linphone.core.LinphoneCore.AdaptiveRateAlgorithm;
|
||||||
import org.linphone.core.LinphoneCore.FirewallPolicy;
|
import org.linphone.core.LinphoneCore.FirewallPolicy;
|
||||||
import org.linphone.core.LinphoneCore.MediaEncryption;
|
import org.linphone.core.LinphoneCore.MediaEncryption;
|
||||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
|
||||||
import org.linphone.core.LinphoneCore.Transports;
|
import org.linphone.core.LinphoneCore.Transports;
|
||||||
import org.linphone.core.LinphoneCoreException;
|
import org.linphone.core.LinphoneCoreException;
|
||||||
import org.linphone.core.LinphoneCoreFactory;
|
import org.linphone.core.LinphoneCoreFactory;
|
||||||
|
@ -690,9 +689,7 @@ public class LinphonePreferences {
|
||||||
|
|
||||||
if (proxyCfg != null)
|
if (proxyCfg != null)
|
||||||
getLc().removeProxyConfig(proxyCfg);
|
getLc().removeProxyConfig(proxyCfg);
|
||||||
if (getLc().getProxyConfigList().length == 0) {
|
if (getLc().getProxyConfigList().length != 0) {
|
||||||
LinphoneActivity.instance().getStatusFragment().registrationStateChanged(RegistrationState.RegistrationNone);
|
|
||||||
} else {
|
|
||||||
resetDefaultProxyConfig();
|
resetDefaultProxyConfig();
|
||||||
getLc().refreshRegisters();
|
getLc().refreshRegisters();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCore.MediaEncryption;
|
import org.linphone.core.LinphoneCore.MediaEncryption;
|
||||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||||
import org.linphone.core.LinphoneCoreListener.LinphoneNotifyListener;
|
import org.linphone.core.LinphoneCoreListener.LinphoneNotifyListener;
|
||||||
|
import org.linphone.core.LinphoneCoreListener.LinphoneRegistrationStateListener;
|
||||||
import org.linphone.core.LinphoneEvent;
|
import org.linphone.core.LinphoneEvent;
|
||||||
import org.linphone.core.LinphoneProxyConfig;
|
import org.linphone.core.LinphoneProxyConfig;
|
||||||
import org.linphone.core.PayloadType;
|
import org.linphone.core.PayloadType;
|
||||||
|
@ -58,7 +59,7 @@ import android.widget.TextView;
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
public class StatusFragment extends Fragment implements LinphoneNotifyListener {
|
public class StatusFragment extends Fragment implements LinphoneNotifyListener, LinphoneRegistrationStateListener {
|
||||||
private Handler mHandler = new Handler();
|
private Handler mHandler = new Handler();
|
||||||
private Handler refreshHandler = new Handler();
|
private Handler refreshHandler = new Handler();
|
||||||
private TextView statusText, exit, voicemailCount;
|
private TextView statusText, exit, voicemailCount;
|
||||||
|
@ -111,6 +112,11 @@ public class StatusFragment extends Fragment implements LinphoneNotifyListener {
|
||||||
|
|
||||||
// We create it once to not delay the first display
|
// We create it once to not delay the first display
|
||||||
populateSliderContent();
|
populateSliderContent();
|
||||||
|
|
||||||
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
if (lc != null) {
|
||||||
|
lc.addListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
@ -182,7 +188,8 @@ public class StatusFragment extends Fragment implements LinphoneNotifyListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registrationStateChanged(final RegistrationState state) {
|
@Override
|
||||||
|
public void registrationState(LinphoneCore lc, LinphoneProxyConfig proxy, final LinphoneCore.RegistrationState state, String smessage) {
|
||||||
if (!isAttached || !LinphoneService.isReady()) {
|
if (!isAttached || !LinphoneService.isReady()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -325,11 +332,8 @@ public class StatusFragment extends Fragment implements LinphoneNotifyListener {
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
if (lc != null) {
|
|
||||||
lc.addListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
LinphoneCall call = lc.getCurrentCall();
|
LinphoneCall call = lc.getCurrentCall();
|
||||||
if (isInCall && (call != null || lc.getConferenceSize() > 1 || lc.getCallsNb() > 0)) {
|
if (isInCall && (call != null || lc.getConferenceSize() > 1 || lc.getCallsNb() > 0)) {
|
||||||
if (call != null) {
|
if (call != null) {
|
||||||
|
@ -361,11 +365,6 @@ public class StatusFragment extends Fragment implements LinphoneNotifyListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
|
||||||
if (lc != null) {
|
|
||||||
lc.removeListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
||||||
if (mCallQualityUpdater != null) {
|
if (mCallQualityUpdater != null) {
|
||||||
|
@ -374,6 +373,16 @@ public class StatusFragment extends Fragment implements LinphoneNotifyListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
if (lc != null) {
|
||||||
|
lc.removeListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
public void refreshStatusItems(final LinphoneCall call, boolean isVideoEnabled) {
|
public void refreshStatusItems(final LinphoneCall call, boolean isVideoEnabled) {
|
||||||
if (call != null) {
|
if (call != null) {
|
||||||
voicemailCount.setVisibility(View.GONE);
|
voicemailCount.setVisibility(View.GONE);
|
||||||
|
|
Loading…
Reference in a new issue