use of com.waz.zclient.core.controllers.tracking.events.settings.ChangedContactsPermissionEvent in project wire-android by wireapp.
the class OptionsPreferences method handlePreferenceChanged.
@Override
public Event handlePreferenceChanged(SharedPreferences sharedPreferences, String key) {
Event event = null;
if (key.equals(getString(R.string.pref_options_sounds_key))) {
String stringValue = sharedPreferences.getString(key, "");
TrackingUtils.tagChangedSoundNotificationLevelEvent(((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class), stringValue, getContext());
} else if (key.equals(ringtonePreference.getKey()) || key.equals(textTonePreference.getKey()) || key.equals(pingPreference.getKey())) {
SoundController ctrl = inject(SoundController.class);
if (ctrl != null) {
ctrl.setCustomSoundUrisFromPreferences(sharedPreferences);
}
} else if (key.equals(getString(R.string.pref_options_image_download_key))) {
String stringValue = sharedPreferences.getString(key, "");
boolean wifiOnly = stringValue.equals(getContext().getString(R.string.zms_image_download_value_wifi));
event = new ChangedImageDownloadPreferenceEvent(wifiOnly);
} else if (key.equals(getString(R.string.pref_options_contacts_key))) {
boolean shareContacts = sharedPreferences.getBoolean(key, false);
event = new ChangedContactsPermissionEvent(shareContacts, true);
boolean hasContactsReadPermission = PermissionUtils.hasSelfPermissions(getContext(), Manifest.permission.READ_CONTACTS);
if (shareContacts && !hasContactsReadPermission) {
ActivityCompat.requestPermissions(getActivity(), new String[] { Manifest.permission.READ_CONTACTS }, PermissionUtils.REQUEST_READ_CONTACTS);
}
} else if (key.equals(getString(R.string.pref_options_theme_switch_key))) {
getControllerFactory().getThemeController().toggleThemePending(true);
event = new ChangedThemeEvent(getControllerFactory().getThemeController().isDarkTheme());
} else if (key.equals(getString(R.string.pref_options_cursor_send_button_key))) {
boolean sendButtonIsOn = sharedPreferences.getBoolean(key, false);
event = new ChangedSendButtonSettingEvent(sendButtonIsOn);
}
return event;
}
use of com.waz.zclient.core.controllers.tracking.events.settings.ChangedContactsPermissionEvent in project wire-android by wireapp.
the class TrackingUtils method tagChangedContactsPermissionEvent.
public static void tagChangedContactsPermissionEvent(GlobalTrackingController trackingController, String[] permissions, int[] grantResults) {
for (int i = 0; i < permissions.length; i++) {
String permission = permissions[i];
if (!permission.contains(Permission.READ_CONTACTS.toString())) {
continue;
}
boolean grantedContactsPermission = grantResults[i] == PackageManager.PERMISSION_GRANTED ? true : false;
trackingController.tagEvent(new ChangedContactsPermissionEvent(grantedContactsPermission, false));
}
}
Aggregations