Search in sources :

Example 1 with SoundController

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

the class ConversationListManagerFragment method showBlockConfirmation.

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

        @Override
        public void positiveButtonClicked(boolean checkboxIsSelected) {
            if (getStoreFactory() == null || getControllerFactory() == null || getStoreFactory().isTornDown() || getControllerFactory().isTornDown()) {
                return;
            }
            boolean blockingCurrentConversation = user.getConversation().getId().equals(getStoreFactory().getConversationStore().getCurrentConversation().getId());
            getStoreFactory().getConnectStore().blockUser(user);
            if (blockingCurrentConversation) {
                getStoreFactory().getConversationStore().setCurrentConversationToNext(ConversationChangeRequester.BLOCK_USER);
            }
            ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new BlockingEvent(BlockingEvent.ConformationResponse.BLOCK));
        }

        @Override
        public void negativeButtonClicked() {
            if (getControllerFactory() == null || getControllerFactory().isTornDown()) {
                return;
            }
            ((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);
    ConfirmationRequest request = new ConfirmationRequest.Builder().withHeader(header).withMessage(text).withPositiveButton(confirm).withNegativeButton(cancel).withConfirmationCallback(callback).withWireTheme(getControllerFactory().getThemeController().getOptionsDarkTheme()).build();
    getControllerFactory().getConfirmationController().requestConfirmation(request, IConfirmationController.CONVERSATION_LIST);
    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) ConfirmationRequest(com.waz.zclient.controllers.confirmation.ConfirmationRequest)

Example 2 with SoundController

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

the class ConversationFragment method onCursorButtonClicked.

@SuppressLint("NewApi")
@Override
public void onCursorButtonClicked(CursorMenuItem cursorMenuItem) {
    final IConversation conversation = getStoreFactory().getConversationStore().getCurrentConversation();
    switch(cursorMenuItem) {
        case AUDIO_MESSAGE:
            if (PermissionUtils.hasSelfPermissions(getActivity(), AUDIO_PERMISSION)) {
                openExtendedCursor(ExtendedCursorContainer.Type.VOICE_FILTER_RECORDING);
            } else {
                ActivityCompat.requestPermissions(getActivity(), AUDIO_PERMISSION, AUDIO_FILTER_PERMISSION_REQUEST_ID);
            }
            break;
        case CAMERA:
            if (LayoutSpec.isTablet(getContext())) {
                KeyboardUtils.closeKeyboardIfShown(getActivity());
                getControllerFactory().getCameraController().openCamera(CameraContext.MESSAGE);
                ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(OpenedMediaActionEvent.cursorAction(OpenedMediaAction.PHOTO, conversation));
            } else {
                if (PermissionUtils.hasSelfPermissions(getContext(), EXTENDED_CURSOR_PERMISSIONS)) {
                    openExtendedCursor(ExtendedCursorContainer.Type.IMAGES);
                } else {
                    ActivityCompat.requestPermissions(getActivity(), EXTENDED_CURSOR_PERMISSIONS, OPEN_EXTENDED_CURSOR_IMAGES);
                }
            }
            break;
        case PING:
            getStoreFactory().getNetworkStore().doIfHasInternetOrNotifyUser(new DefaultNetworkAction() {

                @Override
                public void execute(NetworkMode networkMode) {
                    getStoreFactory().getConversationStore().knockCurrentConversation();
                    SoundController ctrl = inject(SoundController.class);
                    if (ctrl != null) {
                        ctrl.playPingFromMe();
                    }
                }
            });
            TrackingUtils.onSentPingMessage(((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class), getStoreFactory().getConversationStore().getCurrentConversation());
            break;
        case SKETCH:
            getControllerFactory().getDrawingController().showDrawing(null, IDrawingController.DrawingDestination.SKETCH_BUTTON);
            ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(OpenedMediaActionEvent.cursorAction(OpenedMediaAction.SKETCH, conversation));
            break;
        case FILE:
            assetIntentsManager.openFileSharing();
            ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(OpenedMediaActionEvent.cursorAction(OpenedMediaAction.FILE, conversation));
            break;
        case VIDEO_MESSAGE:
            ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(OpenedMediaActionEvent.cursorAction(OpenedMediaAction.VIDEO_MESSAGE, conversation));
            isVideoMessageButtonClicked = true;
            getCameraController().releaseCamera(new Callback<Void>() {

                @Override
                public void callback(Void v) {
                    if (!isVideoMessageButtonClicked || assetIntentsManager == null) {
                        return;
                    }
                    isVideoMessageButtonClicked = false;
                    assetIntentsManager.maybeCaptureVideo(getActivity(), AssetIntentsManager.IntentType.VIDEO_CURSOR_BUTTON);
                }
            });
            break;
        case LOCATION:
            if (ConnectionResult.SUCCESS == GooglePlayServicesUtil.isGooglePlayServicesAvailable(getContext())) {
                KeyboardUtils.hideKeyboard(getActivity());
                getControllerFactory().getLocationController().showShareLocation();
                ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(OpenedMediaActionEvent.cursorAction(OpenedMediaAction.LOCATION, conversation));
            } else {
                Toast.makeText(getContext(), R.string.location_sharing__missing_play_services, Toast.LENGTH_LONG).show();
            }
            break;
        case MORE:
        case LESS:
            ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new OpenedMoreActionsEvent(getConversationTypeString()));
            break;
        case GIF:
            getControllerFactory().getGiphyController().handleInput(cursorLayout.getText());
            ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(OpenedMediaActionEvent.cursorAction(OpenedMediaAction.GIPHY, conversation));
            break;
    }
}
Also used : SoundController(com.waz.zclient.media.SoundController) GlobalTrackingController(com.waz.zclient.tracking.GlobalTrackingController) DefaultNetworkAction(com.waz.zclient.core.stores.network.DefaultNetworkAction) IConversation(com.waz.api.IConversation) NetworkMode(com.waz.api.NetworkMode) OpenedMoreActionsEvent(com.waz.zclient.controllers.tracking.events.navigation.OpenedMoreActionsEvent) SuppressLint(android.annotation.SuppressLint)

Example 3 with SoundController

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

the class ParticipantFragment method showRemoveConfirmation.

//////////////////////////////////////////////////////////////////////////////////////////
//
//  UserProfileContainer
//
//////////////////////////////////////////////////////////////////////////////////////////
@Override
public void showRemoveConfirmation(final User user) {
    // Show confirmation dialog before removing user
    ConfirmationCallback callback = new TwoButtonConfirmationCallback() {

        @Override
        public void positiveButtonClicked(boolean checkboxIsSelected) {
            dismissUserProfile();
            new Handler().post(new Runnable() {

                @Override
                public void run() {
                    getStoreFactory().getConversationStore().getCurrentConversation().removeMember(user);
                    ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new RemoveContactEvent(true, getParticipantsCount()));
                }
            });
        }

        @Override
        public void negativeButtonClicked() {
            ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new RemoveContactEvent(false, getParticipantsCount()));
        }

        @Override
        public void onHideAnimationEnd(boolean confirmed, boolean canceled, boolean checkboxIsSelected) {
        }
    };
    String header = getString(R.string.confirmation_menu__header);
    String text = getString(R.string.confirmation_menu_text_with_name, user.getDisplayName());
    String confirm = getString(R.string.confirmation_menu__confirm_remove);
    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) BaseScalaActivity(com.waz.zclient.BaseScalaActivity) GlobalTrackingController(com.waz.zclient.tracking.GlobalTrackingController) TwoButtonConfirmationCallback(com.waz.zclient.controllers.confirmation.TwoButtonConfirmationCallback) Handler(android.os.Handler) RemoveContactEvent(com.waz.zclient.controllers.tracking.events.group.RemoveContactEvent) ConfirmationRequest(com.waz.zclient.controllers.confirmation.ConfirmationRequest)

Example 4 with SoundController

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

the class ParticipantFragment method deleteConversation.

public void deleteConversation(final IConversation conversation) {
    ConfirmationCallback callback = new TwoButtonConfirmationCallback() {

        @Override
        public void positiveButtonClicked(boolean checkboxIsSelected) {
        }

        @Override
        public void negativeButtonClicked() {
        }

        @Override
        public void onHideAnimationEnd(boolean confirmed, boolean canceled, boolean checkboxIsSelected) {
            if (getStoreFactory() == null || getStoreFactory().isTornDown() || getControllerFactory() == null || getControllerFactory().isTornDown()) {
                return;
            }
            if (!confirmed) {
                ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new DeleteConversationEvent(ConversationType.getValue(conversation), DeleteConversationEvent.Context.LIST, DeleteConversationEvent.Response.CANCEL));
                return;
            }
            IConversation currentConversation = getStoreFactory().getConversationStore().getCurrentConversation();
            boolean deleteCurrentConversation = conversation != null && currentConversation != null && conversation.getId().equals(currentConversation.getId());
            getStoreFactory().getConversationStore().deleteConversation(conversation, checkboxIsSelected);
            ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new DeleteConversationEvent(ConversationType.getValue(conversation), DeleteConversationEvent.Context.PARTICIPANTS, DeleteConversationEvent.Response.DELETE));
            if (deleteCurrentConversation) {
                getStoreFactory().getConversationStore().setCurrentConversationToNext(ConversationChangeRequester.DELETE_CONVERSATION);
            }
            if (LayoutSpec.isTablet(getActivity())) {
                getControllerFactory().getConversationScreenController().hideParticipants(false, true);
            }
        }
    };
    String header = getString(R.string.confirmation_menu__meta_delete);
    String text = getString(R.string.confirmation_menu__meta_delete_text);
    String confirm = getString(R.string.confirmation_menu__confirm_delete);
    String cancel = getString(R.string.confirmation_menu__cancel);
    ConfirmationRequest.Builder builder = new ConfirmationRequest.Builder().withHeader(header).withMessage(text).withPositiveButton(confirm).withNegativeButton(cancel).withConfirmationCallback(callback).withWireTheme(getControllerFactory().getThemeController().getThemeDependentOptionsTheme());
    if (conversation.getType() == IConversation.Type.GROUP) {
        builder = builder.withCheckboxLabel(getString(R.string.confirmation_menu__delete_conversation__checkbox__label)).withCheckboxSelectedByDefault();
    }
    getControllerFactory().getConfirmationController().requestConfirmation(builder.build(), 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) IConversation(com.waz.api.IConversation) DeleteConversationEvent(com.waz.zclient.controllers.tracking.events.conversation.DeleteConversationEvent) ConfirmationRequest(com.waz.zclient.controllers.confirmation.ConfirmationRequest)

Example 5 with SoundController

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

the class SingleParticipantFragment method showBlockConfirmation.

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

        @Override
        public void positiveButtonClicked(boolean checkboxIsSelected) {
            getStoreFactory().getConnectStore().blockUser(user);
            // Dismiss common user profile
            getContainer().dismissUserProfile();
            ((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.USER_PROFILE);
    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)

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