Search in sources :

Example 1 with Settings

use of cx.ring.model.Settings in project ring-client-android by savoirfairelinux.

the class SharedPreferencesServiceImpl method loadSettings.

@Override
public Settings loadSettings() {
    SharedPreferences appPrefs = mContext.getSharedPreferences(RING_SETTINGS, Context.MODE_PRIVATE);
    if (null == mUserSettings) {
        mUserSettings = new Settings();
    }
    mUserSettings.setAllowMobileData(appPrefs.getBoolean(RING_MOBILE_DATA, false));
    mUserSettings.setAllowSystemContacts(appPrefs.getBoolean(RING_SYSTEM_CONTACTS, false));
    mUserSettings.setAllowPlaceSystemCalls(appPrefs.getBoolean(RING_PLACE_CALLS, false));
    mUserSettings.setAllowRingOnStartup(appPrefs.getBoolean(RING_ON_STARTUP, true));
    mUserSettings.setAllowPushNotifications(appPrefs.getBoolean(RING_PUSH_NOTIFICATIONS, false));
    return mUserSettings;
}
Also used : SharedPreferences(android.content.SharedPreferences) Settings(cx.ring.model.Settings)

Example 2 with Settings

use of cx.ring.model.Settings in project ring-client-android by savoirfairelinux.

the class SettingsFragment method saveSettings.

private void saveSettings() {
    Settings newSettings = new Settings();
    newSettings.setAllowMobileData(mViewMobileData.isChecked());
    newSettings.setAllowSystemContacts(mViewContacts.isChecked());
    newSettings.setAllowPlaceSystemCalls(mViewPlaceCall.isChecked());
    newSettings.setAllowRingOnStartup(mViewStartup.isChecked());
    newSettings.setAllowPushNotifications(mViewPushNotifications.isChecked());
    // save settings according to UI inputs
    presenter.saveSettings(newSettings);
}
Also used : Settings(cx.ring.model.Settings)

Example 3 with Settings

use of cx.ring.model.Settings in project ring-client-android by savoirfairelinux.

the class ContactService method loadContacts.

/**
 * Load contacts from system and generate a local contact cache
 *
 * @param loadRingContacts if true, ring contacts will be taken care of
 * @param loadSipContacts  if true, sip contacts will be taken care of
 */
public void loadContacts(final boolean loadRingContacts, final boolean loadSipContacts, final Account account) {
    mApplicationExecutor.submit(() -> {
        Settings settings = mPreferencesService.loadSettings();
        if (settings.isAllowSystemContacts() && mDeviceRuntimeService.hasContactPermission()) {
            mContactList = loadContactsFromSystem(loadRingContacts, loadSipContacts);
        }
        mContactsRing.clear();
        mAccountId = account.getAccountID();
        Map<String, CallContact> ringContacts = account.getContacts();
        for (CallContact contact : ringContacts.values()) {
            mContactsRing.put(contact.getPhones().get(0).getNumber().getRawUriString(), contact);
        }
        setChanged();
        ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.CONTACTS_CHANGED);
        notifyObservers(event);
    });
}
Also used : ServiceEvent(cx.ring.model.ServiceEvent) Settings(cx.ring.model.Settings) CallContact(cx.ring.model.CallContact)

Example 4 with Settings

use of cx.ring.model.Settings in project ring-client-android by savoirfairelinux.

the class ContactService method findContact.

public CallContact findContact(Uri uri) {
    if (uri == null) {
        return null;
    }
    String searchedCanonicalNumber = uri.getRawUriString();
    // Look for Ring contact by ID
    boolean isRingId = uri.isRingId();
    if (isRingId) {
        CallContact contact = mContactsRing.get(searchedCanonicalNumber);
        if (contact != null) {
            return contact;
        }
    }
    // Look for other contact
    for (CallContact c : mContactsRing.values()) {
        if (c.hasNumber(searchedCanonicalNumber)) {
            return c;
        }
    }
    Settings settings = mPreferencesService.loadSettings();
    if (settings.isAllowSystemContacts() && mDeviceRuntimeService.hasContactPermission()) {
        CallContact contact = findContactByNumberFromSystem(searchedCanonicalNumber);
        if (contact != null) {
            mContactList.put(contact.getId(), contact);
            return contact;
        }
    }
    CallContact contact = CallContact.buildUnknown(uri);
    mContactsRing.put(searchedCanonicalNumber, contact);
    return contact;
}
Also used : CallContact(cx.ring.model.CallContact) Settings(cx.ring.model.Settings)

Example 5 with Settings

use of cx.ring.model.Settings in project ring-client-android by savoirfairelinux.

the class LaunchPresenter method buildPermissionsToAsk.

private String[] buildPermissionsToAsk() {
    ArrayList<String> perms = new ArrayList<>();
    if (!mDeviceRuntimeService.hasAudioPermission()) {
        perms.add(Manifest.permission.RECORD_AUDIO);
    }
    Settings settings = mPreferencesService.loadSettings();
    if (settings.isAllowSystemContacts() && !mDeviceRuntimeService.hasContactPermission()) {
        perms.add(Manifest.permission.READ_CONTACTS);
    }
    if (!mDeviceRuntimeService.hasVideoPermission()) {
        perms.add(Manifest.permission.CAMERA);
    }
    if (settings.isAllowPlaceSystemCalls() && !mDeviceRuntimeService.hasCallLogPermission()) {
        perms.add(Manifest.permission.WRITE_CALL_LOG);
    }
    return perms.toArray(new String[perms.size()]);
}
Also used : ArrayList(java.util.ArrayList) Settings(cx.ring.model.Settings)

Aggregations

Settings (cx.ring.model.Settings)7 CallContact (cx.ring.model.CallContact)3 SharedPreferences (android.content.SharedPreferences)1 ServiceEvent (cx.ring.model.ServiceEvent)1 ArrayList (java.util.ArrayList)1