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;
}
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);
}
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);
});
}
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;
}
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()]);
}
Aggregations