use of com.waz.zclient.core.controllers.tracking.events.settings.ChangedImageDownloadPreferenceEvent in project wire-android by wireapp.
the class AdvancedPreferences method handlePreferenceChanged.
@Override
public Event handlePreferenceChanged(SharedPreferences sharedPreferences, String key) {
Event event = null;
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_advanced_analytics_enabled_key))) {
boolean enableTracking = sharedPreferences.getBoolean(key, false);
if (enableTracking) {
event = new OptIn();
Localytics.setOptedOut(false);
} else {
try {
(((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class)).tagEvent(new OptOut());
} catch (Exception e) {
Timber.e("Unable to tag event OptOut");
e.printStackTrace();
}
Localytics.setOptedOut(true);
}
}
return event;
}
use of com.waz.zclient.core.controllers.tracking.events.settings.ChangedImageDownloadPreferenceEvent 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;
}
Aggregations