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();
}
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;
}
}
}
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);
}
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;
}
}
Aggregations