Search in sources :

Example 6 with SoundController

use of com.waz.zclient.media.SoundController in project wire-android by wireapp.

the class ParticipantFragment method showBlockUserConfirmation.

private void showBlockUserConfirmation(final User user) {
    ConfirmationCallback callback = new TwoButtonConfirmationCallback() {

        @Override
        public void positiveButtonClicked(boolean checkboxIsSelected) {
            getStoreFactory().getConversationStore().setCurrentConversationToNext(ConversationChangeRequester.BLOCK_USER);
            getStoreFactory().getConnectStore().blockUser(user);
            getControllerFactory().getConversationScreenController().hideUser();
            if (LayoutSpec.isTablet(getActivity())) {
                getControllerFactory().getConversationScreenController().hideParticipants(false, true);
            }
            ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new BlockingEvent(BlockingEvent.ConformationResponse.BLOCK));
        }

        @Override
        public void negativeButtonClicked() {
            ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new BlockingEvent(BlockingEvent.ConformationResponse.CANCEL));
        }

        @Override
        public void onHideAnimationEnd(boolean confirmed, boolean canceled, boolean checkboxIsSelected) {
        }
    };
    String header = getString(R.string.confirmation_menu__block_header);
    String text = getString(R.string.confirmation_menu__block_text_with_name, user.getDisplayName());
    String confirm = getString(R.string.confirmation_menu__confirm_block);
    String cancel = getString(R.string.confirmation_menu__cancel);
    OptionsTheme optionsTheme = getControllerFactory().getThemeController().getThemeDependentOptionsTheme();
    ConfirmationRequest request = new ConfirmationRequest.Builder().withHeader(header).withMessage(text).withPositiveButton(confirm).withNegativeButton(cancel).withConfirmationCallback(callback).withWireTheme(optionsTheme).build();
    getControllerFactory().getConfirmationController().requestConfirmation(request, IConfirmationController.PARTICIPANTS);
    SoundController ctrl = inject(SoundController.class);
    if (ctrl != null) {
        ctrl.playAlert();
    }
}
Also used : SoundController(com.waz.zclient.media.SoundController) ConfirmationCallback(com.waz.zclient.controllers.confirmation.ConfirmationCallback) TwoButtonConfirmationCallback(com.waz.zclient.controllers.confirmation.TwoButtonConfirmationCallback) GlobalTrackingController(com.waz.zclient.tracking.GlobalTrackingController) BlockingEvent(com.waz.zclient.controllers.tracking.events.connect.BlockingEvent) TwoButtonConfirmationCallback(com.waz.zclient.controllers.confirmation.TwoButtonConfirmationCallback) OptionsTheme(com.waz.zclient.ui.theme.OptionsTheme) ConfirmationRequest(com.waz.zclient.controllers.confirmation.ConfirmationRequest)

Example 7 with SoundController

use of com.waz.zclient.media.SoundController in project wire-android by wireapp.

the class ParticipantFragment method showLeaveConfirmation.

//////////////////////////////////////////////////////////////////////////////////////////
//
//  Confirmation overlays
//
//////////////////////////////////////////////////////////////////////////////////////////
private void showLeaveConfirmation(final IConversation conversation) {
    ConfirmationCallback callback = new TwoButtonConfirmationCallback() {

        @Override
        public void positiveButtonClicked(boolean checkboxIsSelected) {
            ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new LeaveGroupConversationEvent(true, getStoreFactory().getConversationStore().getCurrentConversation().getUsers().size()));
            getStoreFactory().getConversationStore().leave(conversation);
            getStoreFactory().getConversationStore().setCurrentConversationToNext(ConversationChangeRequester.LEAVE_CONVERSATION);
            if (LayoutSpec.isTablet(getActivity())) {
                getControllerFactory().getConversationScreenController().hideParticipants(false, true);
            }
        }

        @Override
        public void negativeButtonClicked() {
            ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new LeaveGroupConversationEvent(false, getStoreFactory().getConversationStore().getCurrentConversation().getUsers().size()));
        }

        @Override
        public void onHideAnimationEnd(boolean confirmed, boolean canceled, boolean checkboxIsSelected) {
        }
    };
    String header = getString(R.string.confirmation_menu__meta_remove);
    String text = getString(R.string.confirmation_menu__meta_remove_text);
    String confirm = getString(R.string.confirmation_menu__confirm_leave);
    String cancel = getString(R.string.confirmation_menu__cancel);
    ConfirmationRequest request = new ConfirmationRequest.Builder().withHeader(header).withMessage(text).withPositiveButton(confirm).withNegativeButton(cancel).withConfirmationCallback(callback).withWireTheme(getControllerFactory().getThemeController().getThemeDependentOptionsTheme()).build();
    getControllerFactory().getConfirmationController().requestConfirmation(request, IConfirmationController.PARTICIPANTS);
    SoundController ctrl = inject(SoundController.class);
    if (ctrl != null) {
        ctrl.playAlert();
    }
}
Also used : SoundController(com.waz.zclient.media.SoundController) ConfirmationCallback(com.waz.zclient.controllers.confirmation.ConfirmationCallback) TwoButtonConfirmationCallback(com.waz.zclient.controllers.confirmation.TwoButtonConfirmationCallback) GlobalTrackingController(com.waz.zclient.tracking.GlobalTrackingController) TwoButtonConfirmationCallback(com.waz.zclient.controllers.confirmation.TwoButtonConfirmationCallback) LeaveGroupConversationEvent(com.waz.zclient.controllers.tracking.events.group.LeaveGroupConversationEvent) ConfirmationRequest(com.waz.zclient.controllers.confirmation.ConfirmationRequest)

Example 8 with SoundController

use of com.waz.zclient.media.SoundController in project wire-android by wireapp.

the class ParticipantBodyFragment method showLeaveConfirmation.

private void showLeaveConfirmation(final IConversation conversation) {
    ConfirmationCallback callback = new TwoButtonConfirmationCallback() {

        @Override
        public void positiveButtonClicked(boolean checkboxIsSelected) {
            if (getStoreFactory() == null || getControllerFactory() == null || getStoreFactory().isTornDown() || getControllerFactory().isTornDown()) {
                return;
            }
            ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new LeaveGroupConversationEvent(true, getStoreFactory().getConversationStore().getCurrentConversation().getUsers().size()));
            getStoreFactory().getConversationStore().leave(conversation);
            getStoreFactory().getConversationStore().setCurrentConversationToNext(ConversationChangeRequester.LEAVE_CONVERSATION);
            if (LayoutSpec.isTablet(getActivity())) {
                getControllerFactory().getConversationScreenController().hideParticipants(false, true);
            }
        }

        @Override
        public void negativeButtonClicked() {
            if (getControllerFactory() == null || getControllerFactory().isTornDown()) {
                return;
            }
            ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new LeaveGroupConversationEvent(false, getStoreFactory().getConversationStore().getCurrentConversation().getUsers().size()));
        }

        @Override
        public void onHideAnimationEnd(boolean confirmed, boolean canceled, boolean checkboxIsSelected) {
        }
    };
    String header = getString(R.string.confirmation_menu__meta_remove);
    String text = getString(R.string.confirmation_menu__meta_remove_text);
    String confirm = getString(R.string.confirmation_menu__confirm_leave);
    String cancel = getString(R.string.confirmation_menu__cancel);
    String checkboxLabel = getString(R.string.confirmation_menu__delete_conversation__checkbox__label);
    ConfirmationRequest request = new ConfirmationRequest.Builder().withHeader(header).withMessage(text).withPositiveButton(confirm).withNegativeButton(cancel).withConfirmationCallback(callback).withCheckboxLabel(checkboxLabel).withWireTheme(getControllerFactory().getThemeController().getThemeDependentOptionsTheme()).withCheckboxSelectedByDefault().build();
    getControllerFactory().getConfirmationController().requestConfirmation(request, IConfirmationController.PARTICIPANTS);
    SoundController ctrl = inject(SoundController.class);
    if (ctrl != null) {
        ctrl.playAlert();
    }
}
Also used : SoundController(com.waz.zclient.media.SoundController) ConfirmationCallback(com.waz.zclient.controllers.confirmation.ConfirmationCallback) TwoButtonConfirmationCallback(com.waz.zclient.controllers.confirmation.TwoButtonConfirmationCallback) GlobalTrackingController(com.waz.zclient.tracking.GlobalTrackingController) TwoButtonConfirmationCallback(com.waz.zclient.controllers.confirmation.TwoButtonConfirmationCallback) LeaveGroupConversationEvent(com.waz.zclient.controllers.tracking.events.group.LeaveGroupConversationEvent) ConfirmationRequest(com.waz.zclient.controllers.confirmation.ConfirmationRequest)

Example 9 with SoundController

use of com.waz.zclient.media.SoundController 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 10 with SoundController

use of com.waz.zclient.media.SoundController in project wire-android by wireapp.

the class ConversationFragment method onCursorButtonLongPressed.

@Override
public void onCursorButtonLongPressed(CursorMenuItem cursorMenuItem) {
    switch(cursorMenuItem) {
        case AUDIO_MESSAGE:
            if (PermissionUtils.hasSelfPermissions(getActivity(), AUDIO_PERMISSION)) {
                extendedCursorContainer.close(true);
                if (audioMessageRecordingView.getVisibility() == View.VISIBLE) {
                    break;
                }
                SoundController ctrl = inject(SoundController.class);
                if (ctrl != null) {
                    ctrl.shortVibrate();
                }
                audioMessageRecordingView.prepareForRecording();
                audioMessageRecordingView.setVisibility(View.VISIBLE);
                final IConversation conversation = getStoreFactory().getConversationStore().getCurrentConversation();
                ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(OpenedMediaActionEvent.cursorAction(OpenedMediaAction.AUDIO_MESSAGE, conversation));
                ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new StartedRecordingAudioMessageEvent(getConversationTypeString(), true));
            } else {
                ActivityCompat.requestPermissions(getActivity(), AUDIO_PERMISSION, AUDIO_PERMISSION_REQUEST_ID);
            }
            break;
    }
}
Also used : SoundController(com.waz.zclient.media.SoundController) StartedRecordingAudioMessageEvent(com.waz.zclient.core.controllers.tracking.events.media.StartedRecordingAudioMessageEvent) GlobalTrackingController(com.waz.zclient.tracking.GlobalTrackingController) IConversation(com.waz.api.IConversation)

Aggregations

SoundController (com.waz.zclient.media.SoundController)13 GlobalTrackingController (com.waz.zclient.tracking.GlobalTrackingController)13 ConfirmationCallback (com.waz.zclient.controllers.confirmation.ConfirmationCallback)10 ConfirmationRequest (com.waz.zclient.controllers.confirmation.ConfirmationRequest)10 TwoButtonConfirmationCallback (com.waz.zclient.controllers.confirmation.TwoButtonConfirmationCallback)10 BlockingEvent (com.waz.zclient.controllers.tracking.events.connect.BlockingEvent)4 IConversation (com.waz.api.IConversation)3 LeaveGroupConversationEvent (com.waz.zclient.controllers.tracking.events.group.LeaveGroupConversationEvent)3 DeleteConversationEvent (com.waz.zclient.controllers.tracking.events.conversation.DeleteConversationEvent)2 OptionsTheme (com.waz.zclient.ui.theme.OptionsTheme)2 SuppressLint (android.annotation.SuppressLint)1 Handler (android.os.Handler)1 NetworkMode (com.waz.api.NetworkMode)1 BaseScalaActivity (com.waz.zclient.BaseScalaActivity)1 RemoveContactEvent (com.waz.zclient.controllers.tracking.events.group.RemoveContactEvent)1 OpenedMoreActionsEvent (com.waz.zclient.controllers.tracking.events.navigation.OpenedMoreActionsEvent)1 Event (com.waz.zclient.core.controllers.tracking.events.Event)1 StartedRecordingAudioMessageEvent (com.waz.zclient.core.controllers.tracking.events.media.StartedRecordingAudioMessageEvent)1 ChangedContactsPermissionEvent (com.waz.zclient.core.controllers.tracking.events.settings.ChangedContactsPermissionEvent)1 ChangedImageDownloadPreferenceEvent (com.waz.zclient.core.controllers.tracking.events.settings.ChangedImageDownloadPreferenceEvent)1