Search in sources :

Example 1 with OpenedMoreActionsEvent

use of com.waz.zclient.controllers.tracking.events.navigation.OpenedMoreActionsEvent 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)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 IConversation (com.waz.api.IConversation)1 NetworkMode (com.waz.api.NetworkMode)1 OpenedMoreActionsEvent (com.waz.zclient.controllers.tracking.events.navigation.OpenedMoreActionsEvent)1 DefaultNetworkAction (com.waz.zclient.core.stores.network.DefaultNetworkAction)1 SoundController (com.waz.zclient.media.SoundController)1 GlobalTrackingController (com.waz.zclient.tracking.GlobalTrackingController)1