Search in sources :

Example 1 with AttachmentFilteringListener

use of com.applozic.mobicomkit.listners.AttachmentFilteringListener in project Applozic-Android-SDK by AppLozic.

the class MobiComAttachmentSelectorActivity method onActivityResult.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    try {
        if (imagesAdapter != null) {
            View view = galleryImagesGridView.getChildAt(imagesAdapter.getCount() - 1);
            if (view != null) {
                ImageView imageView = view.findViewById(R.id.galleryImageView);
                if (imageView != null) {
                    imageView.setEnabled(true);
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (resultCode == Activity.RESULT_OK) {
        final Uri selectedFileUri = (intent == null ? null : intent.getData());
        Utils.printLog(MobiComAttachmentSelectorActivity.this, TAG, "selectedFileUri :: " + selectedFileUri);
        if (selectedFileUri != null) {
            if (getApplicationContext() instanceof AttachmentFilteringListener) {
                AttachmentFilteringListener filteringListener = (AttachmentFilteringListener) getApplicationContext();
                filteringListener.onAttachmentSelected(this, selectedFileUri, new AlCallback() {

                    @Override
                    public void onSuccess(Object response) {
                        processUri(selectedFileUri);
                    }

                    @Override
                    public void onError(Object error) {
                        Utils.printLog(getApplicationContext(), TAG, "Error in file : " + GsonUtils.getJsonFromObject(error, Object.class));
                    }
                });
            } else {
                processUri(selectedFileUri);
            }
        }
    }
    super.onActivityResult(requestCode, resultCode, intent);
}
Also used : ImageView(android.widget.ImageView) AlCallback(com.applozic.mobicomkit.listners.AlCallback) GridView(android.widget.GridView) ImageView(android.widget.ImageView) View(android.view.View) Uri(android.net.Uri) PatternSyntaxException(java.util.regex.PatternSyntaxException) AttachmentFilteringListener(com.applozic.mobicomkit.listners.AttachmentFilteringListener)

Example 2 with AttachmentFilteringListener

use of com.applozic.mobicomkit.listners.AttachmentFilteringListener in project Applozic-Android-SDK by AppLozic.

the class MobiComKitPeopleActivity method onGroupSelected.

@Override
public void onGroupSelected(final Channel channel) {
    Intent intent = null;
    if (Intent.ACTION_SEND.equals(action) && type != null) {
        if (!ChannelService.getInstance(MobiComKitPeopleActivity.this).processIsUserPresentInChannel(channel.getKey())) {
            Toast.makeText(this, getString(R.string.unable_share_message), Toast.LENGTH_SHORT).show();
            return;
        }
        if ("text/plain".equals(type)) {
            intent = new Intent(this, ConversationActivity.class);
            intent.putExtra(GROUP_ID, channel.getKey());
            intent.putExtra(GROUP_NAME, channel.getName());
            intent.putExtra(ConversationUIService.DEFAULT_TEXT, intentExtra.getStringExtra(Intent.EXTRA_TEXT));
            startActivity(intent);
            finish();
        } else if (type.startsWith("image/") || type.startsWith("audio/") || type.startsWith("video/")) {
            final Uri fileUri = (Uri) intentExtra.getParcelableExtra(Intent.EXTRA_STREAM);
            if (fileUri != null) {
                long maxSize = alCustomizationSettings.getMaxAttachmentSizeAllowed() * 1024 * 1024;
                if (FileUtils.isMaxUploadSizeReached(this, fileUri, maxSize)) {
                    Toast.makeText(this, getString(R.string.info_attachment_max_allowed_file_size), Toast.LENGTH_LONG).show();
                    return;
                }
                if (getApplicationContext() instanceof AttachmentFilteringListener) {
                    ((AttachmentFilteringListener) getApplicationContext()).onAttachmentSelected(this, fileUri, new AlCallback() {

                        @Override
                        public void onSuccess(Object response) {
                            processAttachmentUri(fileUri, null, channel);
                        }

                        @Override
                        public void onError(Object error) {
                            Utils.printLog(getApplicationContext(), TAG, "Error in file : " + GsonUtils.getJsonFromObject(error, Object.class));
                        }
                    });
                } else {
                    processAttachmentUri(fileUri, null, channel);
                }
            }
        }
    } else {
        intent = new Intent();
        intent.putExtra(GROUP_ID, channel.getKey());
        intent.putExtra(GROUP_NAME, channel.getName());
        finishActivity(intent);
    }
}
Also used : ConversationActivity(com.applozic.mobicomkit.uiwidgets.conversation.activity.ConversationActivity) Intent(android.content.Intent) AlCallback(com.applozic.mobicomkit.listners.AlCallback) Uri(android.net.Uri) AttachmentFilteringListener(com.applozic.mobicomkit.listners.AttachmentFilteringListener)

Example 3 with AttachmentFilteringListener

use of com.applozic.mobicomkit.listners.AttachmentFilteringListener in project Applozic-Android-SDK by AppLozic.

the class MobiComKitPeopleActivity method onCustomContactSelected.

@Override
public void onCustomContactSelected(final Contact contact) {
    Intent intent = null;
    if (Intent.ACTION_SEND.equals(action) && type != null) {
        if (contact.isBlocked()) {
            Toast.makeText(this, getString(R.string.user_is_blocked), Toast.LENGTH_SHORT).show();
            return;
        }
        if ("text/plain".equals(type)) {
            intent = new Intent(this, ConversationActivity.class);
            intent.putExtra(USER_ID, contact.getUserId());
            intent.putExtra(ConversationUIService.DEFAULT_TEXT, intentExtra.getStringExtra(Intent.EXTRA_TEXT));
            startActivity(intent);
            finish();
        } else if (type.startsWith("image/") || type.startsWith("audio/") || type.startsWith("video/")) {
            final Uri fileUri = (Uri) intentExtra.getParcelableExtra(Intent.EXTRA_STREAM);
            long maxSize = alCustomizationSettings.getMaxAttachmentSizeAllowed() * 1024 * 1024;
            if (FileUtils.isMaxUploadSizeReached(this, fileUri, maxSize)) {
                Toast.makeText(this, getString(R.string.info_attachment_max_allowed_file_size), Toast.LENGTH_LONG).show();
                return;
            }
            if (getApplicationContext() instanceof AttachmentFilteringListener) {
                ((AttachmentFilteringListener) getApplicationContext()).onAttachmentSelected(this, fileUri, new AlCallback() {

                    @Override
                    public void onSuccess(Object response) {
                        processAttachmentUri(fileUri, contact, null);
                    }

                    @Override
                    public void onError(Object error) {
                        Utils.printLog(getApplicationContext(), TAG, "Error in file : " + GsonUtils.getJsonFromObject(error, Object.class));
                    }
                });
            } else {
                processAttachmentUri(fileUri, contact, null);
            }
        }
    } else {
        if (ApplozicClient.getInstance(this).isStartGroupOfTwo()) {
            ProgressDialog progressDialog = ProgressDialog.show(this, "", getString(R.string.please_wait_creating_group_of_two), true);
            AlTask.execute(new AlGroupOfTwoCreateTask(MobiComKitPeopleActivity.this, MobiComUserPreference.getInstance(this).getParentGroupKey(), contact, new AlGroupOfTwoCreateTask.ChannelCreateListener() {

                @Override
                public void onSuccess(@NonNull Channel channel) {
                    if (progressDialog != null && progressDialog.isShowing()) {
                        progressDialog.dismiss();
                    }
                    if (channel != null) {
                        Intent intent = new Intent(MobiComKitPeopleActivity.this, ConversationActivity.class);
                        intent.putExtra(ConversationUIService.GROUP_ID, channel.getKey());
                        intent.putExtra(ConversationUIService.GROUP_NAME, channel.getName());
                        startActivity(intent);
                    }
                }

                @Override
                public void onFailure() {
                    if (progressDialog != null && progressDialog.isShowing()) {
                        progressDialog.dismiss();
                    }
                }
            }));
        } else {
            intent = new Intent();
            intent.putExtra(USER_ID, contact.getUserId());
            finishActivity(intent);
        }
    }
}
Also used : ConversationActivity(com.applozic.mobicomkit.uiwidgets.conversation.activity.ConversationActivity) AlGroupOfTwoCreateTask(com.applozic.mobicomkit.api.conversation.AlGroupOfTwoCreateTask) NonNull(androidx.annotation.NonNull) Channel(com.applozic.mobicommons.people.channel.Channel) Intent(android.content.Intent) AlCallback(com.applozic.mobicomkit.listners.AlCallback) ProgressDialog(android.app.ProgressDialog) Uri(android.net.Uri) AttachmentFilteringListener(com.applozic.mobicomkit.listners.AttachmentFilteringListener)

Aggregations

Uri (android.net.Uri)3 AlCallback (com.applozic.mobicomkit.listners.AlCallback)3 AttachmentFilteringListener (com.applozic.mobicomkit.listners.AttachmentFilteringListener)3 Intent (android.content.Intent)2 ConversationActivity (com.applozic.mobicomkit.uiwidgets.conversation.activity.ConversationActivity)2 ProgressDialog (android.app.ProgressDialog)1 View (android.view.View)1 GridView (android.widget.GridView)1 ImageView (android.widget.ImageView)1 NonNull (androidx.annotation.NonNull)1 AlGroupOfTwoCreateTask (com.applozic.mobicomkit.api.conversation.AlGroupOfTwoCreateTask)1 Channel (com.applozic.mobicommons.people.channel.Channel)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1