public void afterTextChanged(Editable s) { try { if (!TextUtils.isEmpty(s.toString()) && s.toString().trim().length() > 0 && !typingStarted) { typingStarted = true; handleSendAndRecordButtonView(true); if (contact != null || channel != null && !Channel.GroupType.OPEN.getValue().equals(channel.getType()) || contact != null) { Applozic.publishTypingStatus(getContext(), channel, contact, typingStarted); } } else if (s.toString().trim().length() == 0 && typingStarted) { typingStarted = false; handleSendAndRecordButtonView(false); if (contact != null || channel != null && !Channel.GroupType.OPEN.getValue().equals(channel.getType()) || contact != null) { Applozic.publishTypingStatus(getContext(), channel, contact, typingStarted); } } } catch (Exception e) { } //sendButton.setVisibility((s == null || s.toString().trim().length() == 0) && TextUtils.isEmpty(filePath) ? View.GONE : View.VISIBLE); //attachButton.setVisibility(s == null || s.toString().trim().length() == 0 ? View.VISIBLE : View.GONE); } });
public void loadFile(Uri uri, File file) { if (uri == null || file == null) { Toast.makeText(getActivity(), R.string.file_not_selected, Toast.LENGTH_LONG).show(); return; } handleSendAndRecordButtonView(true); errorEditTextView.setVisibility(View.GONE); long fileSize = file.length() / 1024; long maxFileSize = alCustomizationSettings.getMaxAttachmentSizeAllowed() * 1024 * 1024; if (fileSize > maxFileSize) { Toast.makeText(getActivity(), R.string.info_attachment_max_allowed_file_size, Toast.LENGTH_LONG).show(); return; } String mimeType = URLConnection.guessContentTypeFromName(file.getName()); if (mimeType != null && (mimeType.startsWith("image"))) { AttachmentAsyncTask attachmentAsyncTask = new AttachmentAsyncTask(uri, file, getActivity()); attachmentAsyncTask.setImageViewLayoutWeakReference(mediaContainer); attachmentAsyncTask.setRelativeLayoutWeakReference(attachmentLayout); attachmentAsyncTask.setTextViewWeakReference(attachedFile); attachmentAsyncTask.setAlCustomizationSettingsLayoutWeakReference(alCustomizationSettings); attachmentAsyncTask.execute(); } else { filePath = Uri.parse(file.getAbsolutePath()).toString(); } }
@Override public void onClick(View view) { if (alCustomizationSettings.isMessageFastScrollEnabled()) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { recyclerView.smoothScrollToPosition(messageList.size()); recyclerView.getLayoutManager().scrollToPosition(messageList.size()); } }); } emoticonsFrameLayout.setVisibility(View.GONE); sendMessage(); if (contact != null && !contact.isBlocked() || channel != null) { handleSendAndRecordButtonView(false); } } }
@Override public void onClick(View view) { if (!isToastVisible && !typingStarted) { vibrate(); errorEditTextView.requestFocus(); errorEditTextView.setError(getResources().getString(R.string.hold_to_record_release_to_send)); isToastVisible = true; new CountDownTimer(3000, 1000) { @Override public void onTick(long millisUntilFinished) { } @Override public void onFinish() { errorEditTextView.setError(null); messageEditText.requestFocus(); isToastVisible = false; } }.start(); } else { errorEditTextView.setError(null); isToastVisible = false; } emoticonsFrameLayout.setVisibility(View.GONE); sendMessage(); handleSendAndRecordButtonView(false); errorEditTextView.setVisibility(View.VISIBLE); } }