use of cx.ring.services.PreferencesService in project ring-client-android by savoirfairelinux.
the class DRingService method update.
@Override
public void update(Observable observable, ServiceEvent arg) {
if (observable instanceof PreferencesService) {
refreshContacts();
updateConnectivityState();
} else if (observable instanceof AccountService && arg != null) {
switch(arg.getEventType()) {
case ACCOUNTS_CHANGED:
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(DRingService.this);
sharedPreferences.edit().putBoolean(OutgoingCallHandler.KEY_CACHE_HAVE_RINGACCOUNT, mAccountService.hasRingAccount()).putBoolean(OutgoingCallHandler.KEY_CACHE_HAVE_SIPACCOUNT, mAccountService.hasSipAccount()).apply();
refreshContacts();
break;
case CONTACT_ADDED:
case CONTACT_REMOVED:
refreshContacts();
break;
}
} else if (observable instanceof CallService && arg != null) {
switch(arg.getEventType()) {
case INCOMING_CALL:
SipCall call = arg.getEventInput(ServiceEvent.EventInput.CALL, SipCall.class);
if (call != null) {
Log.d(TAG, "call id : " + call.getCallId());
Bundle extras = new Bundle();
extras.putString("account", mAccountService.getCurrentAccount().getAccountID());
extras.putString("callId", call.getCallId());
startActivity(new Intent(Intent.ACTION_VIEW).putExtras(extras).setClass(getApplicationContext(), DeviceUtils.isTv(this) ? TVCallActivity.class : CallActivity.class).setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
}
break;
}
}
}
Aggregations