Search in sources :

Example 1 with ChangedContactsPermissionEvent

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;
}
Also used : SoundController(com.waz.zclient.media.SoundController) ChangedContactsPermissionEvent(com.waz.zclient.core.controllers.tracking.events.settings.ChangedContactsPermissionEvent) GlobalTrackingController(com.waz.zclient.tracking.GlobalTrackingController) ChangedSendButtonSettingEvent(com.waz.zclient.core.controllers.tracking.events.settings.ChangedSendButtonSettingEvent) ChangedImageDownloadPreferenceEvent(com.waz.zclient.core.controllers.tracking.events.settings.ChangedImageDownloadPreferenceEvent) ChangedThemeEvent(com.waz.zclient.core.controllers.tracking.events.settings.ChangedThemeEvent) Event(com.waz.zclient.core.controllers.tracking.events.Event) ChangedSendButtonSettingEvent(com.waz.zclient.core.controllers.tracking.events.settings.ChangedSendButtonSettingEvent) ChangedImageDownloadPreferenceEvent(com.waz.zclient.core.controllers.tracking.events.settings.ChangedImageDownloadPreferenceEvent) ChangedContactsPermissionEvent(com.waz.zclient.core.controllers.tracking.events.settings.ChangedContactsPermissionEvent) ChangedThemeEvent(com.waz.zclient.core.controllers.tracking.events.settings.ChangedThemeEvent)

Example 2 with ChangedContactsPermissionEvent

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));
    }
}
Also used : ChangedContactsPermissionEvent(com.waz.zclient.core.controllers.tracking.events.settings.ChangedContactsPermissionEvent)

Aggregations

ChangedContactsPermissionEvent (com.waz.zclient.core.controllers.tracking.events.settings.ChangedContactsPermissionEvent)2 Event (com.waz.zclient.core.controllers.tracking.events.Event)1 ChangedImageDownloadPreferenceEvent (com.waz.zclient.core.controllers.tracking.events.settings.ChangedImageDownloadPreferenceEvent)1 ChangedSendButtonSettingEvent (com.waz.zclient.core.controllers.tracking.events.settings.ChangedSendButtonSettingEvent)1 ChangedThemeEvent (com.waz.zclient.core.controllers.tracking.events.settings.ChangedThemeEvent)1 SoundController (com.waz.zclient.media.SoundController)1 GlobalTrackingController (com.waz.zclient.tracking.GlobalTrackingController)1