Search in sources :

Example 1 with SignalPlace

use of org.thoughtcrime.securesms.components.location.SignalPlace in project Signal-Android by WhisperSystems.

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_IMAGE:
            boolean isGif = MediaUtil.isGif(MediaUtil.getMimeType(this, data.getData()));
            setMedia(data.getData(), isGif ? MediaType.GIF : MediaType.IMAGE);
            break;
        case PICK_VIDEO:
            setMedia(data.getData(), MediaType.VIDEO);
            break;
        case PICK_AUDIO:
            setMedia(data.getData(), MediaType.AUDIO);
            break;
        case PICK_CONTACT_INFO:
            addAttachmentContactInfo(data.getData());
            break;
        case GROUP_EDIT:
            recipients = RecipientFactory.getRecipientsForIds(this, data.getLongArrayExtra(GroupCreateActivity.GROUP_RECIPIENT_EXTRA), true);
            recipients.addListener(this);
            titleView.setTitle(recipients);
            setBlockedUserState(recipients, isSecureText, isDefaultSms);
            supportInvalidateOptionsMenu();
            break;
        case TAKE_PHOTO:
            if (attachmentManager.getCaptureUri() != null) {
                setMedia(attachmentManager.getCaptureUri(), MediaType.IMAGE);
            }
            break;
        case ADD_CONTACT:
            recipients = RecipientFactory.getRecipientsForIds(ConversationActivity.this, recipients.getIds(), true);
            recipients.addListener(this);
            fragment.reloadList();
            break;
        case PICK_LOCATION:
            SignalPlace place = new SignalPlace(PlacePicker.getPlace(data, this));
            attachmentManager.setLocation(masterSecret, 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 : SignalPlace(org.thoughtcrime.securesms.components.location.SignalPlace)

Example 2 with SignalPlace

use of org.thoughtcrime.securesms.components.location.SignalPlace 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

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