Search in sources :

Example 1 with SharedContentType

use of com.waz.zclient.controllers.sharing.SharedContentType in project wire-android by wireapp.

the class ImageSharingPreviewFragment method confirmShareImages.

private void confirmShareImages() {
    SharedContentType sharedContentType = getControllerFactory().getSharingController().getSharedContentType();
    if (sharedContentType == null) {
        return;
    }
    IConversation destination = getControllerFactory().getSharingController().getDestination();
    List<Uri> sharedImageUris = getControllerFactory().getSharingController().getSharedFileUris();
    switch(sharedContentType) {
        case IMAGE:
            getStoreFactory().getConversationStore().sendMessage(destination, ImageAssetFactory.getImageAsset(sharedImageUris.get(0)));
            TrackingUtils.onSentPhotoMessageFromSharing(((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class), destination);
            break;
    }
    getControllerFactory().getSharingController().onContentShared(getActivity(), destination);
    getActivity().finish();
}
Also used : GlobalTrackingController(com.waz.zclient.tracking.GlobalTrackingController) SharedContentType(com.waz.zclient.controllers.sharing.SharedContentType) IConversation(com.waz.api.IConversation) Uri(android.net.Uri)

Example 2 with SharedContentType

use of com.waz.zclient.controllers.sharing.SharedContentType in project wire-android by wireapp.

the class ShareActivity method handleIncomingIntent.

private void handleIncomingIntent() {
    ShareCompat.IntentReader intentReader = ShareCompat.IntentReader.from(this);
    if (!intentReader.isShareIntent()) {
        finish();
        return;
    }
    if (intentReader.getType().equals("text/plain")) {
        getSharingController().publishTextContent(String.valueOf(intentReader.getText()));
    } else {
        final Set<Uri> sharedFileUris = new HashSet<>();
        Uri stream = intentReader.getStream();
        if (stream != null) {
            sharedFileUris.add(stream);
        }
        for (int i = 0; i < intentReader.getStreamCount(); i++) {
            stream = intentReader.getStream(i);
            if (stream != null) {
                sharedFileUris.add(stream);
            }
        }
        if (sharedFileUris.size() == 0) {
            finish();
            return;
        }
        boolean sharingImages = intentReader.getType().startsWith("image/");
        final SharedContentType contentType;
        if (sharingImages && sharedFileUris.size() == 1) {
            contentType = SharedContentType.IMAGE;
        } else {
            contentType = SharedContentType.FILE;
        }
        List<Uri> sanitisedUris = new ArrayList<>();
        for (Uri uri : sharedFileUris) {
            String path = AssetUtils.getPath(getApplicationContext(), uri);
            if (path == null) {
                Timber.e("Something went wrong, unable to retrieve path");
                sanitisedUris.add(uri);
            } else {
                sanitisedUris.add(Uri.fromFile(new File(path)));
            }
        }
        switch(contentType) {
            case IMAGE:
                getSharingController().publishImageContent(sanitisedUris);
                break;
            case FILE:
                getSharingController().publishFileContent(sanitisedUris);
                break;
        }
    }
}
Also used : SharedContentType(com.waz.zclient.controllers.sharing.SharedContentType) ShareCompat(android.support.v4.app.ShareCompat) ArrayList(java.util.ArrayList) Uri(android.net.Uri) File(java.io.File) HashSet(java.util.HashSet)

Example 3 with SharedContentType

use of com.waz.zclient.controllers.sharing.SharedContentType in project wire-android by wireapp.

the class ImageSharingPreviewFragment method showShareImagePreview.

private void showShareImagePreview() {
    SharedContentType sharedContentType = getControllerFactory().getSharingController().getSharedContentType();
    if (sharedContentType == null) {
        return;
    }
    String title = "";
    IConversation currentConversation = getControllerFactory().getSharingController().getDestination();
    List<Uri> sharedImageUris = getControllerFactory().getSharingController().getSharedFileUris();
    Uri previewImageUri = sharedImageUris.get(0);
    switch(sharedContentType) {
        case IMAGE:
            title = String.format(getString(R.string.sharing__image_preview__title__single), currentConversation.getName().toUpperCase(getResources().getConfiguration().locale));
            break;
    }
    ImagePreviewLayout imagePreview = (ImagePreviewLayout) LayoutInflater.from(getContext()).inflate(R.layout.fragment_cursor_images_preview, imagePreviewContainer, false);
    imagePreview.showSketch(false);
    ImageAsset imageAsset = ImageAssetFactory.getImageAsset(previewImageUri);
    imagePreview.setImageAsset(imageAsset, ImagePreviewLayout.Source.CAMERA, this);
    imagePreview.setAccentColor(getControllerFactory().getAccentColorController().getAccentColor().getColor());
    imagePreview.setTitle(title);
    imagePreview.hightlightTitle();
    imagePreview.setTitleIsSingleLine(false);
    imagePreviewContainer.addView(imagePreview);
}
Also used : SharedContentType(com.waz.zclient.controllers.sharing.SharedContentType) IConversation(com.waz.api.IConversation) Uri(android.net.Uri) ImagePreviewLayout(com.waz.zclient.pages.extendedcursor.image.ImagePreviewLayout) ImageAsset(com.waz.api.ImageAsset)

Example 4 with SharedContentType

use of com.waz.zclient.controllers.sharing.SharedContentType in project wire-android by wireapp.

the class SharingConversationListManagerFragment method onDestinationSelected.

//////////////////////////////////////////////////////////////////////////////////////////
//
//  ConversationStoreObserver
//
//////////////////////////////////////////////////////////////////////////////////////////
@Override
public void onDestinationSelected(final IConversation conversation) {
    SharedContentType sharedContentType = getControllerFactory().getSharingController().getSharedContentType();
    if (sharedContentType == null) {
        return;
    }
    switch(sharedContentType) {
        case TEXT:
            String sharedText = getControllerFactory().getSharingController().getSharedText();
            getControllerFactory().getSharingController().onContentShared(getActivity(), conversation, sharedText);
            getActivity().finish();
            break;
        case IMAGE:
            sharingIndicatorView.setVisibility(View.GONE);
            getChildFragmentManager().beginTransaction().setCustomAnimations(R.anim.fade_in, R.anim.fade_out).add(R.id.fl__conversation_list__sharing_preview, ImageSharingPreviewFragment.newInstance(), ImageSharingPreviewFragment.TAG).commit();
            break;
        case FILE:
            final List<Uri> sharedFileUris = getControllerFactory().getSharingController().getSharedFileUris();
            new AlertDialog.Builder(getActivity()).setMessage(getResources().getQuantityString(R.plurals.sharing__files__message, sharedFileUris.size(), sharedFileUris.size(), conversation.getName())).setPositiveButton(R.string.sharing__files__ok, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    getControllerFactory().getSharingController().onContentShared(getActivity(), conversation, sharedFileUris);
                    getActivity().finish();
                }
            }).setNegativeButton(R.string.sharing__files__cancel, null).setCancelable(true).create().show();
            break;
    }
}
Also used : SharedContentType(com.waz.zclient.controllers.sharing.SharedContentType) DialogInterface(android.content.DialogInterface) Uri(android.net.Uri)

Aggregations

Uri (android.net.Uri)4 SharedContentType (com.waz.zclient.controllers.sharing.SharedContentType)4 IConversation (com.waz.api.IConversation)2 DialogInterface (android.content.DialogInterface)1 ShareCompat (android.support.v4.app.ShareCompat)1 ImageAsset (com.waz.api.ImageAsset)1 ImagePreviewLayout (com.waz.zclient.pages.extendedcursor.image.ImagePreviewLayout)1 GlobalTrackingController (com.waz.zclient.tracking.GlobalTrackingController)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1