Search in sources :

Example 1 with MediaType

use of org.thoughtcrime.securesms.mms.AttachmentManager.MediaType in project Signal-Android by signalapp.

the class ConversationActivity method initializeDraft.

// /// Initializers
private void initializeDraft() {
    final String draftText = getIntent().getStringExtra(TEXT_EXTRA);
    final Uri draftMedia = getIntent().getData();
    final MediaType draftMediaType = MediaType.from(getIntent().getType());
    if (draftText != null)
        composeText.setText(draftText);
    if (draftMedia != null && draftMediaType != null)
        setMedia(draftMedia, draftMediaType);
    if (draftText == null && draftMedia == null && draftMediaType == null) {
        initializeDraftFromDatabase();
    } else {
        updateToggleButtonState();
    }
}
Also used : MediaType(org.thoughtcrime.securesms.mms.AttachmentManager.MediaType) ByteString(com.google.protobuf.ByteString) Uri(android.net.Uri)

Example 2 with MediaType

use of org.thoughtcrime.securesms.mms.AttachmentManager.MediaType in project Signal-Android by WhisperSystems.

the class ConversationActivity method initializeDraft.

///// Initializers
private void initializeDraft() {
    final String draftText = getIntent().getStringExtra(TEXT_EXTRA);
    final Uri draftMedia = getIntent().getData();
    final MediaType draftMediaType = MediaType.from(getIntent().getType());
    if (draftText != null)
        composeText.setText(draftText);
    if (draftMedia != null && draftMediaType != null)
        setMedia(draftMedia, draftMediaType);
    if (draftText == null && draftMedia == null && draftMediaType == null) {
        initializeDraftFromDatabase();
    } else {
        updateToggleButtonState();
    }
}
Also used : MediaType(org.thoughtcrime.securesms.mms.AttachmentManager.MediaType) ByteString(com.google.protobuf.ByteString) Uri(android.net.Uri)

Example 3 with MediaType

use of org.thoughtcrime.securesms.mms.AttachmentManager.MediaType in project Signal-Android by signalapp.

the class ConversationActivity method onActivityResult.

@Override
public void onActivityResult(final int reqCode, int resultCode, Intent data) {
    Log.w(TAG, "onActivityResult called: " + reqCode + ", " + resultCode + " , " + data);
    super.onActivityResult(reqCode, resultCode, data);
    if ((data == null && reqCode != TAKE_PHOTO && reqCode != SMS_DEFAULT) || (resultCode != RESULT_OK && reqCode != SMS_DEFAULT)) {
        return;
    }
    switch(reqCode) {
        case PICK_GALLERY:
            MediaType mediaType;
            String mimeType = MediaUtil.getMimeType(this, data.getData());
            if (MediaUtil.isGif(mimeType))
                mediaType = MediaType.GIF;
            else if (MediaUtil.isVideo(mimeType))
                mediaType = MediaType.VIDEO;
            else
                mediaType = MediaType.IMAGE;
            setMedia(data.getData(), mediaType);
            break;
        case PICK_DOCUMENT:
            setMedia(data.getData(), MediaType.DOCUMENT);
            break;
        case PICK_AUDIO:
            setMedia(data.getData(), MediaType.AUDIO);
            break;
        case PICK_CONTACT_INFO:
            addAttachmentContactInfo(data.getData());
            break;
        case GROUP_EDIT:
            recipient = Recipient.from(this, data.getParcelableExtra(GroupCreateActivity.GROUP_ADDRESS_EXTRA), true);
            recipient.addListener(this);
            titleView.setTitle(glideRequests, recipient);
            setBlockedUserState(recipient, isSecureText, isDefaultSms);
            supportInvalidateOptionsMenu();
            break;
        case TAKE_PHOTO:
            if (attachmentManager.getCaptureUri() != null) {
                setMedia(attachmentManager.getCaptureUri(), MediaType.IMAGE);
            }
            break;
        case ADD_CONTACT:
            recipient = Recipient.from(this, recipient.getAddress(), true);
            recipient.addListener(this);
            fragment.reloadList();
            break;
        case PICK_LOCATION:
            SignalPlace place = new SignalPlace(PlacePicker.getPlace(data, this));
            attachmentManager.setLocation(place, getCurrentMediaConstraints());
            break;
        case PICK_GIF:
            setMedia(data.getData(), MediaType.GIF);
            break;
        case ScribbleActivity.SCRIBBLE_REQUEST_CODE:
            setMedia(data.getData(), MediaType.IMAGE);
            break;
        case SMS_DEFAULT:
            initializeSecurity(isSecureText, isDefaultSms);
            break;
    }
}
Also used : MediaType(org.thoughtcrime.securesms.mms.AttachmentManager.MediaType) ByteString(com.google.protobuf.ByteString) SignalPlace(org.thoughtcrime.securesms.components.location.SignalPlace)

Aggregations

ByteString (com.google.protobuf.ByteString)3 MediaType (org.thoughtcrime.securesms.mms.AttachmentManager.MediaType)3 Uri (android.net.Uri)2 SignalPlace (org.thoughtcrime.securesms.components.location.SignalPlace)1