Search in sources :

Example 1 with PreferencesService

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;
        }
    }
}
Also used : SipCall(cx.ring.model.SipCall) SharedPreferences(android.content.SharedPreferences) Bundle(android.os.Bundle) Intent(android.content.Intent) CallActivity(cx.ring.client.CallActivity) TVCallActivity(cx.ring.tv.call.TVCallActivity) AccountService(cx.ring.services.AccountService) TVCallActivity(cx.ring.tv.call.TVCallActivity) PreferencesService(cx.ring.services.PreferencesService) CallService(cx.ring.services.CallService)

Aggregations

Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 Bundle (android.os.Bundle)1 CallActivity (cx.ring.client.CallActivity)1 SipCall (cx.ring.model.SipCall)1 AccountService (cx.ring.services.AccountService)1 CallService (cx.ring.services.CallService)1 PreferencesService (cx.ring.services.PreferencesService)1 TVCallActivity (cx.ring.tv.call.TVCallActivity)1