use of net.iGap.module.MaterialDesignTextView in project iGap-Android by KianIranian-STDG.
the class PhotoViewer method createView.
@SuppressLint("ResourceType")
@Override
public View createView(Context context) {
if (getActivity() != null) {
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
rootView = new NotifyFrameLayout(context) {
@Override
public boolean dispatchKeyEventPreIme(KeyEvent event) {
if (event != null && event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
if (isKeyboardVisible()) {
showPopUPView(-1);
return true;
}
return false;
}
return super.dispatchKeyEventPreIme(event);
}
};
rootView.setListener(this);
rootView.setBackgroundColor(context.getResources().getColor(R.color.black_register));
rootView.setClickable(true);
toolbar = new Toolbar(context);
toolbar.setContentInsetStartWithNavigation(0);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
toolbar.setLayoutDirection(View.LAYOUT_DIRECTION_LTR);
rootView.setLayoutDirection(View.LAYOUT_DIRECTION_LTR);
} else {
ViewCompat.setLayoutDirection(toolbar, ViewCompat.LAYOUT_DIRECTION_LTR);
ViewCompat.setLayoutDirection(rootView, ViewCompat.LAYOUT_DIRECTION_LTR);
}
toolbar.setBackgroundColor(context.getResources().getColor(R.color.colorEditImageBlack));
viewPager = new CustomViewPager(context);
rootView.addView(viewPager, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER));
cancelCropLayout = new LinearLayout(context);
cancelCropLayout.setOrientation(LinearLayout.HORIZONTAL);
cancelCropLayout.setBackgroundColor(context.getResources().getColor(R.color.colorEditImageBlack2));
rippleView = new RippleView(context);
rippleView.setCentered(true);
rippleView.setRippleAlpha(200);
rippleView.setRippleDuration(0);
rippleView.setRipplePadding(5);
cancelCropLayout.addView(rippleView, LayoutCreator.createLinear(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT));
designTextView = new MaterialDesignTextView(new ContextThemeWrapper(context, R.style.myIconToolbarStyle));
designTextView.setText(context.getString(R.string.icon_close));
designTextView.setTextColor(context.getResources().getColor(R.color.whit_background));
designTextView.setGravity(Gravity.CENTER);
rippleView.addView(designTextView, LayoutCreator.createRelative(48, LayoutCreator.MATCH_PARENT));
emptyView = new View(context);
cancelCropLayout.addView(emptyView, LayoutCreator.createLinear(0, LayoutCreator.MATCH_PARENT, 1F));
revertTextView = new MaterialDesignTextView(new ContextThemeWrapper(context, R.style.myIconToolbarStyle));
revertTextView.setText(context.getString(R.string.icon_forward));
revertTextView.setTextColor(context.getResources().getColor(R.color.whit_background));
revertTextView.setGravity(Gravity.CENTER);
revertTextView.setVisibility(View.GONE);
cancelCropLayout.addView(revertTextView, LayoutCreator.createLinear(52, 52));
cropTextView = new MaterialDesignTextView(new ContextThemeWrapper(context, R.style.myIconToolbarStyle));
cropTextView.setGravity(Gravity.CENTER);
cropTextView.setText(context.getString(R.string.icon_crop_picture));
cropTextView.setTextColor(context.getResources().getColor(R.color.whit_background));
cancelCropLayout.addView(cropTextView, LayoutCreator.createLinear(52, LayoutCreator.MATCH_PARENT));
editTextView = new MaterialDesignTextView(new ContextThemeWrapper(context, R.style.myIconToolbarStyle));
editTextView.setGravity(Gravity.CENTER);
editTextView.setText(getString(R.string.icon_edit_picture));
editTextView.setTextColor(context.getResources().getColor(R.color.whit_background));
cancelCropLayout.addView(editTextView, LayoutCreator.createLinear(52, LayoutCreator.MATCH_PARENT, 0, 0, 8, 0));
emoji = new MaterialDesignTextView(new ContextThemeWrapper(context, R.style.myIconToolbarStyle));
emoji.setGravity(Gravity.CENTER);
emoji.setText(getString(R.string.icon_emoji_smile));
emoji.setTextColor(context.getResources().getColor(R.color.white));
emoji.setTextSize(26);
cancelCropLayout.addView(emoji, LayoutCreator.createLinear(52, LayoutCreator.MATCH_PARENT, 0, 0, 8, 0));
addTextView = new MaterialDesignTextView(new ContextThemeWrapper(context, R.style.myIconToolbarStyle));
addTextView.setGravity(Gravity.CENTER);
addTextView.setBackground(context.getResources().getDrawable(R.drawable.ic_cam_text));
addTextView.setTextColor(context.getResources().getColor(R.color.whit_background));
cancelCropLayout.addView(addTextView, LayoutCreator.createLinear(30, 30, 0, 0, 8, 0));
paintTextView = new MaterialDesignTextView(new ContextThemeWrapper(context, R.style.myIconToolbarStyle));
paintTextView.setGravity(Gravity.CENTER);
paintTextView.setText(getString(R.string.icon_edit));
paintTextView.setTextColor(context.getResources().getColor(R.color.whit_background));
cancelCropLayout.addView(paintTextView, LayoutCreator.createLinear(52, 52, 0, 0, 8, 0));
rootView.addView(cancelCropLayout, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, 60, Gravity.TOP));
LinearLayout bottomRootView = new LinearLayout(context);
bottomRootView.setOrientation(LinearLayout.VERTICAL);
LinearLayout bottomRecyclerViewContainer = new LinearLayout(context);
bottomRecyclerViewContainer.setOrientation(LinearLayout.VERTICAL);
bottomRecyclerViewContainer.setBackground(context.getResources().getDrawable(R.drawable.background_transparent));
bottomRootView.addView(bottomRecyclerViewContainer, LayoutCreator.createLinear(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER, 0, 0, 0, 7));
previewRecycler = new RecyclerView(context);
previewRecycler.setLayoutManager(new LinearLayoutManager(context, RecyclerView.HORIZONTAL, false));
bottomRecyclerViewContainer.addView(previewRecycler, LayoutCreator.createLinear(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER));
bottomLayoutPanel = new LinearLayout(context);
bottomLayoutPanel.setOrientation(LinearLayout.VERTICAL);
bottomLayoutPanel.setBackgroundColor(context.getResources().getColor(R.color.colorEditImageBlack));
bottomRootView.addView(bottomLayoutPanel, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER));
layoutCaption = new LinearLayout(context);
layoutCaption.setOrientation(LinearLayout.HORIZONTAL);
layoutCaption.setMinimumHeight(48);
layoutCaption.setPadding(4, 0, 4, 0);
bottomLayoutPanel.addView(layoutCaption, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, 60, Gravity.CENTER));
keyboardEmoji = new MaterialDesignTextView(new ContextThemeWrapper(context, R.style.myIconToolbarStyle));
keyboardEmoji.setGravity(Gravity.CENTER);
keyboardEmoji.setPadding(8, 0, 8, 8);
keyboardEmoji.setText(context.getString(R.string.icon_emoji_smile));
keyboardEmoji.setTextColor(context.getResources().getColor(R.color.white));
keyboardEmoji.setTextSize(26);
layoutCaption.addView(keyboardEmoji, LayoutCreator.createLinear(30, 30, Gravity.CENTER, 0, 0, 0, 0));
captionEditText = new EventEditText(context);
captionEditText.setGravity(Gravity.BOTTOM);
captionEditText.setHint(context.getString(R.string.type_message));
captionEditText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
captionEditText.setMaxLines(4);
captionEditText.setPadding(10, 0, 10, 8);
captionEditText.setTextColor(context.getResources().getColor(R.color.white));
captionEditText.setHintTextColor(context.getResources().getColor(R.color.light_gray));
captionEditText.setTextSize(14);
captionEditText.setBackground(null);
layoutCaption.addView(captionEditText, LayoutCreator.createLinear(0, LayoutCreator.WRAP_CONTENT, 1, Gravity.CENTER));
iconOkTextView = new MaterialDesignTextView(new ContextThemeWrapper(context, R.style.myIconToolbarStyle));
iconOkTextView.setGravity(Gravity.BOTTOM);
iconOkTextView.setPadding(8, 0, 8, 8);
iconOkTextView.setText(context.getString(R.string.icon_check_ok));
iconOkTextView.setTextColor(context.getResources().getColor(R.color.white));
iconOkTextView.setTextSize(26);
iconOkTextView.setVisibility(View.GONE);
layoutCaption.addView(iconOkTextView, LayoutCreator.createLinear(52, 52, Gravity.BOTTOM));
chatKeyBoardContainer = new FrameLayout(context);
bottomLayoutPanel.addView(chatKeyBoardContainer, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, LayoutCreator.WRAP_CONTENT));
pickerViewSendButton = new ImageView(context);
pickerViewSendButton.setScaleType(ImageView.ScaleType.CENTER);
pickerViewSendButton.setImageResource(R.drawable.attach_send);
layoutCaption.addView(pickerViewSendButton, LayoutCreator.createLinear(40, 40, Gravity.RIGHT | Gravity.CENTER_VERTICAL, 0, 0, 8, 0));
progressBar = new ProgressBar(context);
progressBar.setVisibility(View.GONE);
layoutCaption.addView(progressBar, LayoutCreator.createLinear(40, 40, Gravity.RIGHT | Gravity.CENTER_VERTICAL, 0, 0, 8, 0));
sendTextView = new MaterialDesignTextView(new ContextThemeWrapper(context, R.style.myIconToolbarStyle));
sendTextView.setGravity(Gravity.CENTER);
sendTextView.setText(context.getString(R.string.icon_send));
sendTextView.setTextColor(context.getResources().getColor(R.color.whit_background));
sendTextView.setVisibility(View.GONE);
rootView.addView(bottomRootView, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.WRAP_CONTENT, Gravity.BOTTOM));
return rootView;
}
use of net.iGap.module.MaterialDesignTextView in project iGap-Android by KianIranian-STDG.
the class StoryGalleryFragment method onCreateView.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
fragmentView = new LinearLayout(context);
rootView = (LinearLayout) fragmentView;
rootView.setOrientation(LinearLayout.VERTICAL);
if (tfMain == null)
tfMain = ResourcesCompat.getFont(getContext(), R.font.main_font);
toolbarView = new FrameLayout(context);
toolbarView.setBackgroundResource(new Theme().getToolbarDrawableSharpe(getContext()));
backIcon = new MaterialDesignTextView(new ContextThemeWrapper(context, R.style.myIconToolbarStyle));
backIcon.setText(getString(R.string.icon_back));
backIcon.setTextColor(context.getResources().getColor(R.color.white));
backIcon.setTextSize(22);
backIcon.setGravity(Gravity.CENTER);
toolbarView.addView(backIcon, LayoutCreator.createFrame(40, 40, Gravity.LEFT | Gravity.CENTER_VERTICAL, 8, 0, 0, 0));
sendIcon = new MaterialDesignTextView(new ContextThemeWrapper(context, R.style.myIconToolbarStyle));
sendIcon.setText(getString(R.string.icon_send));
sendIcon.setTextColor(context.getResources().getColor(R.color.white));
sendIcon.setTextSize(22);
sendIcon.setVisibility(View.GONE);
sendIcon.setGravity(Gravity.CENTER);
toolbarView.addView(sendIcon, LayoutCreator.createFrame(40, 40, Gravity.RIGHT | Gravity.CENTER_VERTICAL, 8, 0, 0, 0));
toolbarTitle = new AppCompatTextView(context);
toolbarTitle.setText(getString(R.string.gallery));
toolbarTitle.setTypeface(tfMain);
toolbarTitle.setTextSize(22);
toolbarTitle.setTextColor(getResources().getColor(R.color.whit_background));
toolbarView.addView(toolbarTitle, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER, 0, 0, 0, 0));
rootView.addView(toolbarView, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, 60, Gravity.CENTER | Gravity.TOP));
nestedScrollableHost = new NestedScrollableHost(context);
mainRecyclerView = new RecyclerView(context);
mainRecyclerView.setLayoutManager(new GridLayoutManager(context, 4));
nestedScrollableHost.addView(mainRecyclerView, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.MATCH_PARENT, Gravity.CENTER));
rootView.addView(nestedScrollableHost, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, 0, 1F, Gravity.CENTER));
return rootView;
}
use of net.iGap.module.MaterialDesignTextView in project iGap-Android by KianIranian-STDG.
the class FragmentChat method initComponent.
@SuppressLint("ClickableViewAccessibility")
private void initComponent() {
final RealmRoom realmRoom = getRoom();
ll_attach_text = rootView.findViewById(R.id.ac_ll_attach_text);
txtFileNameForSend = rootView.findViewById(R.id.ac_txt_file_neme_for_sending);
btnCancelSendingFile = rootView.findViewById(R.id.ac_btn_cancel_sending_file);
btnCancelSendingFile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ll_attach_text.setVisibility(View.GONE);
edtChat.setFilters(new InputFilter[] {});
edtChat.setText(EmojiManager.getInstance().replaceEmoji(edtChat.getText(), edtChat.getPaint().getFontMetricsInt(), LayoutCreator.dp(22), false));
edtChat.setSelection(edtChat.getText().length());
if (edtChat.getText().length() == 0) {
sendButtonVisibility(false);
}
}
});
// final int screenWidth = (int) (getResources().getDisplayMetrics().widthPixels / 1.2);
imvSmileButton = rootView.findViewById(R.id.tv_chatRoom_emoji);
edtChat.requestFocus();
edtChat.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isEmojiSHow) {
imvSmileButton.performClick();
}
if (botInit != null)
botInit.close();
}
});
if (viewAttachFile != null) {
// LinearLayout linearLayout = (LinearLayout) viewAttachFile;
// voiceHintTextView = new HintView(G.context, 9);
}
imvAttachFileButton = rootView.findViewById(R.id.vtn_chatRoom_attach);
layoutAttachBottom = rootView.findViewById(R.id.ll_chatRoom_send);
imvMicButton = rootView.findViewById(R.id.btn_chatRoom_mic);
imvAddStoryButton = rootView.findViewById(R.id.btn_chatRoom_add_story);
actionButtonsRootView = rootView.findViewById(R.id.chat_action_buttons_root_view);
customStatusActionLayout = rootView.findViewById(R.id.custom_status_action_root);
floatActionLayout = rootView.findViewById(R.id.add_story_action_root);
customStatusActionLayout.setBackground(Theme.createSimpleSelectorCircleDrawable(LayoutCreator.dp(56), Theme.getInstance().getToolbarBackgroundColor(context), Theme.getInstance().getAccentColor(context)));
floatActionLayout.setBackground(Theme.createSimpleSelectorCircleDrawable(LayoutCreator.dp(56), Theme.getInstance().getToolbarBackgroundColor(context), Theme.getInstance().getAccentColor(context)));
hideFloatingButton(true);
if (isBot) {
botInit = new BotInit(rootView, false);
sendButtonVisibility(false);
RealmRoomMessage rm = null;
String lastMessage = "";
boolean backToMenu = true;
RealmResults<RealmRoomMessage> result = DbManager.getInstance().doRealmTask(realm -> {
return realm.where(RealmRoomMessage.class).equalTo("roomId", mRoomId).notEqualTo("authorHash", RealmUserInfo.getCurrentUserAuthorHash()).findAll();
});
if (result.size() > 0) {
rm = result.last();
if (rm.getMessage() != null) {
lastMessage = rm.getMessage();
}
}
try {
if (rm.getRealmAdditional() != null && rm.getRealmAdditional().getAdditionalType() == AdditionalType.UNDER_KEYBOARD_BUTTON) {
botInit.updateCommandList(false, lastMessage, getActivity(), backToMenu, rm, rm.getRoomId());
}
} catch (Exception e) {
}
}
mAdapter = new MessagesAdapter<>(managedRoom, this, this, this, avatarHandler, compositeDisposable, isCloudRoom);
mAdapter.getItemFilter().withFilterPredicate(new IItemAdapter.Predicate<AbstractMessage>() {
@Override
public boolean filter(AbstractMessage item, CharSequence constraint) {
return !item.messageObject.message.toLowerCase().contains(constraint.toString().toLowerCase());
}
});
// FragmentMain.PreCachingLayoutManager layoutManager = new FragmentMain.PreCachingLayoutManager(ActivityChat.this, 7500);
MyLinearLayoutManager layoutManager = new MyLinearLayoutManager(G.fragmentActivity);
layoutManager.setStackFromEnd(true);
if (recyclerView == null) {
recyclerView = rootView.findViewById(R.id.chl_recycler_view_chat);
}
recyclerView.setItemAnimator(null);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(mAdapter);
recyclerView.setItemViewCacheSize(20);
if (realmRoom != null && !realmRoom.getReadOnly()) {
ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT) {
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
return true;
}
@Override
public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
super.clearView(recyclerView, viewHolder);
try {
// TODO: 12/28/20 MESSAGE_REFACTOR
MessageObject message_ = (mAdapter.getItem(viewHolder.getAdapterPosition())).messageObject;
if (message_ != null && message_.status != ProtoGlobal.RoomMessageStatus.SENDING_VALUE && message_.status != ProtoGlobal.RoomMessageStatus.FAILED_VALUE) {
if (isReply)
reply((mAdapter.getItem(viewHolder.getAdapterPosition())).messageObject, false);
}
} catch (Exception ignored) {
ignored.printStackTrace();
}
isReply = false;
}
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
}
@Override
public void onChildDraw(@NotNull Canvas c, @NotNull RecyclerView recyclerView, @NotNull RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
if (actionState == ACTION_STATE_SWIPE && isCurrentlyActive) {
setTouchListener(recyclerView, dX);
}
dX = dX + ViewMaker.dpToPixel(25);
if (dX > 0)
dX = 0;
if (dX < -ViewMaker.dpToPixel(150)) {
dX = -ViewMaker.dpToPixel(150);
}
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
}
@Override
public float getSwipeThreshold(@NonNull RecyclerView.ViewHolder viewHolder) {
return super.getSwipeThreshold(viewHolder);
}
@Override
public int getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
// TODO: 12/28/20 MESSAGE_REFACTOR
MessageObject message_ = null;
try {
message_ = (mAdapter.getItem(viewHolder.getAdapterPosition())).messageObject;
} catch (Exception e) {
e.printStackTrace();
}
if (message_ != null && (message_.status == ProtoGlobal.RoomMessageStatus.SENDING_VALUE || message_.status == ProtoGlobal.RoomMessageStatus.FAILED_VALUE)) {
return 0;
} else if (viewHolder instanceof VoiceItem.ViewHolder) {
return 0;
} else if (viewHolder instanceof AudioItem.ViewHolder) {
return 0;
} else if (viewHolder instanceof NewChatItemHolder) {
return super.getSwipeDirs(recyclerView, viewHolder);
}
// we disable swipe with returning Zero
return 0;
}
@Override
public int convertToAbsoluteDirection(int flags, int layoutDirection) {
if (swipeBack) {
swipeBack = false;
return 0;
}
return super.convertToAbsoluteDirection(flags, layoutDirection);
}
@Override
public boolean isItemViewSwipeEnabled() {
return !FragmentChat.isInSelectionMode;
}
};
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleItemTouchCallback);
itemTouchHelper.attachToRecyclerView(recyclerView);
}
/**
* load message , use handler for load async
*/
visibilityTextEmptyMessages();
mAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
@Override
public void onItemRangeInserted(int positionStart, int itemCount) {
super.onItemRangeInserted(positionStart, itemCount);
visibilityTextEmptyMessages();
}
@Override
public void onItemRangeRemoved(int positionStart, int itemCount) {
super.onItemRangeRemoved(positionStart, itemCount);
visibilityTextEmptyMessages();
}
});
// added run time -> counter of un read messages
llScrollNavigate = rootView.findViewById(R.id.ac_ll_scrool_navigate);
txtNewUnreadMessage = new BadgeView(getContext());
txtNewUnreadMessage.getTextView().setTypeface(ResourcesCompat.getFont(txtNewUnreadMessage.getContext(), R.font.main_font));
txtNewUnreadMessage.getTextView().setSingleLine();
// set max length
txtNewUnreadMessage.getTextView().setFilters(new InputFilter[] { new InputFilter.LengthFilter(5) });
txtNewUnreadMessage.setBadgeColor(new Theme().getPrimaryDarkColor(txtNewUnreadMessage.getContext()));
llScrollNavigate.addView(txtNewUnreadMessage, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER | Gravity.TOP));
G.handler.post(() -> {
AndroidUtils.globalQueue.postRunnable(this::getMessages);
manageForwardedMessage(false);
});
MaterialDesignTextView txtNavigationLayout = rootView.findViewById(R.id.ac_txt_down_navigation);
llScrollNavigate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
cancelAllRequestFetchHistory();
// Todo : also needed: block future Request
latestButtonClickTime = System.currentTimeMillis();
/**
* have unread
*/
if (countNewMessage > 0 && getFirstUnreadMessage() != null) {
if (!getFirstUnreadMessage().isValid() || getFirstUnreadMessage().isDeleted()) {
resetAndGetFromEnd();
return;
}
int position = mAdapter.findPositionByMessageId(getFirstUnreadMessage().getMessageId());
String m = getFirstUnreadMessage().getMessage();
if (position > 0) {
mAdapter.add(position, new UnreadMessage(mAdapter, FragmentChat.this).setMessage(MessageObject.create(makeUnreadMessage(countNewMessage))).withIdentifier(SUID.id().get()));
isShowLayoutUnreadMessage = true;
LinearLayoutManager linearLayout = (LinearLayoutManager) recyclerView.getLayoutManager();
linearLayout.scrollToPositionWithOffset(position, 0);
} else {
resetMessagingValue();
unreadCount = countNewMessage;
getMessages();
if (getFirstUnreadMessage() == null) {
resetAndGetFromEnd();
return;
}
int position1 = mAdapter.findPositionByMessageId(getFirstUnreadMessage().getMessageId());
if (position1 > 0) {
LinearLayoutManager linearLayout = (LinearLayoutManager) recyclerView.getLayoutManager();
linearLayout.scrollToPositionWithOffset(position1 - 1, 0);
}
}
setCountNewMessageZero();
} else {
if (!addToView) {
resetMessagingValue();
getMessages();
} else {
scrollToEnd();
}
}
}
});
recyclerView.setOnFlingListener(new RecyclerView.OnFlingListener() {
@Override
public boolean onFling(int velocityX, int velocityY) {
return false;
}
});
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
G.imageLoader.resume();
} else if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
G.imageLoader.pause();
}
}
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
int visibleItemCount = recyclerView.getLayoutManager().getChildCount();
int totalItemCount = recyclerView.getLayoutManager().getItemCount();
int pastVisibleItems = ((LinearLayoutManager) recyclerView.getLayoutManager()).findLastVisibleItemPosition();
cardFloatingTime.setVisibility(View.VISIBLE);
long item = mAdapter.getItemByPosition(layoutManager.findFirstVisibleItemPosition());
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(item);
if (item != 0L) {
txtFloatingTime.setText(TimeUtils.getChatSettingsTimeAgo(G.fragmentActivity, calendar.getTime()));
}
gongingHandler.removeCallbacks(gongingRunnable);
gongingHandler.postDelayed(gongingRunnable, 1000);
if (totalItemCount - pastVisibleItems <= 2 && !isAnimateStart) {
isAnimateStart = true;
isAnimateStart = false;
setDownBtnGone();
// llScrollNavigate.animate()
// .alpha(0.0f)
// .translationY(llScrollNavigate.getHeight() / 2)
// .setDuration(200)
// .setListener(new AnimatorListenerAdapter() {
// @Override
// public void onAnimationEnd(Animator animation) {
// super.onAnimationEnd(animation);
// }
// });
} else if (!isScrollEnd && !isAnimateStart) {
isAnimateStart = true;
setDownBtnVisible();
isAnimateStart = false;
// llScrollNavigate.animate()
// .alpha(1.0f)
// .translationY(0)
// .setDuration(200)
// .setListener(new AnimatorListenerAdapter() {
// @Override
// public void onAnimationEnd(Animator animation) {
// super.onAnimationEnd(animation);
// }
// });
txtNewUnreadMessage.getTextView().setText(countNewMessage + "");
if (countNewMessage == 0) {
txtNewUnreadMessage.setVisibility(View.GONE);
} else {
txtNewUnreadMessage.setVisibility(View.VISIBLE);
}
}
}
});
/* if (event.getAction() == MotionEvent.ACTION_CANCEL) {
card.setCardBackgroundColor(Color.parseColor("#ffffff"));
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
// event.addBatch(0,0,0,0,0,0);
// card.setCardBackgroundColor(Color.parseColor("#ffffff"));
} else if (event.getAction() == android.view.MotionEvent.ACTION_DOWN) {
card.setCardBackgroundColor(Color.parseColor("#20000000"));
} else if (event.getAction() == android.view.MotionEvent.ACTION_UP) {
*/
/* Reset Color */
/*
card.setCardBackgroundColor(Color.parseColor("#ffffff"));
// card.setOnClickListener(clickListener);
}
return false;
*/
recyclerView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return false;
}
});
imvSendButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
lastChar = null;
if (!addToView) {
resetAndGetFromEnd();
}
if (suggestedLayout != null) {
if (suggestedLayout.getVisibility() == View.VISIBLE)
suggestedLayout.setVisibility(View.GONE);
lastChar = null;
}
if (isShowLayoutUnreadMessage) {
removeLayoutUnreadMessage();
}
HelperSetAction.setCancel(mRoomId);
clearDraftRequest();
if (hasForward) {
manageForwardedMessage(false);
if (edtChat.getText().length() == 0) {
return;
}
}
if (ll_attach_text.getVisibility() == View.VISIBLE) {
if (listPathString.size() == 0) {
return;
}
sendMessage(latestRequestCode, listPathString.get(0));
listPathString.clear();
ll_attach_text.setVisibility(View.GONE);
edtChat.setFilters(new InputFilter[] {});
edtChat.setText("");
clearReplyView();
return;
}
if (edtChat.getTag() != null && edtChat.getTag() instanceof MessageObject) {
final MessageObject messageInfo = (MessageObject) edtChat.getTag();
final String message = getWrittenMessage();
if (!message.equals(messageInfo.message) && edtChat.getText().toString().trim().length() > 0) {
if (G.connectionState == ConnectionState.WAITING_FOR_NETWORK) {
Toast.makeText(getContext(), getResources().getString(R.string.please_check_your_connenction), Toast.LENGTH_SHORT).show();
return;
}
chatRoom_send_container.setVisibility(View.VISIBLE);
imvSendButton.setVisibility(View.GONE);
editTextProgress.setVisibility(View.VISIBLE);
getMessageController().editMessage(messageInfo.id, messageInfo.documentId, mRoomId, message, chatType.getNumber());
} else {
removeEditedMessage();
}
} else {
// new message has written
sendNewMessage(getWrittenMessage());
scrollToEnd();
}
oldMessageLentghCounter = 0;
messageLentghCounter = 0;
}
});
G.openBottomSheetItem = new OpenBottomSheetItem() {
@Override
public void openBottomSheet(boolean isNew) {
if (mAttachmentPopup != null)
mAttachmentPopup.setIsNewDialog(isNew);
imvAttachFileButton.performClick();
if (mAttachmentPopup != null)
mAttachmentPopup.notifyRecyclerView();
}
};
FragmentEditImage.completeEditImage = new FragmentEditImage.CompleteEditImage() {
@Override
public void result(String path, String message, HashMap<String, StructBottomSheet> textImageList) {
listPathString = null;
listPathString = new ArrayList<>();
if (textImageList.size() == 0) {
return;
}
ArrayList<StructBottomSheet> itemList = new ArrayList<StructBottomSheet>();
for (Map.Entry<String, StructBottomSheet> items : textImageList.entrySet()) {
itemList.add(items.getValue());
}
Collections.sort(itemList);
for (StructBottomSheet item : itemList) {
edtChat.setText(EmojiManager.getInstance().replaceEmoji(item.getText(), edtChat.getPaint().getFontMetricsInt(), LayoutCreator.dp(22), false));
listPathString.add(item.getPath());
latestRequestCode = AttachFile.requestOpenGalleryForImageMultipleSelect;
ll_attach_text.setVisibility(View.VISIBLE);
imvSendButton.performClick();
}
}
};
imvAttachFileButton.setOnClickListener(view -> {
if (getActivity() == null)
return;
if (mAttachmentPopup == null)
initPopupAttachment();
mAttachmentPopup.setMessagesLayoutHeight(recyclerView.getMeasuredHeight());
hideKeyboard();
mAttachmentPopup.show();
});
sendMoney.setOnClickListener(view -> {
if ((chatType == CHAT) && !isCloudRoom && !isBot) {
showSelectItem();
} else {
showCardToCard();
}
if (keyboardViewVisible) {
hideKeyboard();
}
});
customStatusActionLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (getActivity() != null) {
hideFloatingButton(true);
new HelperFragment(getActivity().getSupportFragmentManager(), new StatusTextFragment(true, mRoomId, 0, title)).setReplace(false).load();
}
}
});
floatActionLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (getActivity() != null) {
hideFloatingButton(true);
new HelperFragment(getActivity().getSupportFragmentManager(), new StoryPagerFragment(true, mRoomId, 0, title)).setReplace(false).load();
}
}
});
imvAddStoryButton.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
if (keyboardViewVisible) {
hideKeyboard();
}
if (!MessageController.isSendingRoomStory && !MessageController.isSendingStory) {
hideFloatingButton(false);
}
return true;
}
});
imvAddStoryButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
hideFloatingButton(true);
micAndAddStoryAnimateVisible(false);
}
});
imvMicButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (chatType == CHANNEL) {
if (channelRole == ChannelChatRole.OWNER && !isRecording) {
micAndAddStoryAnimateVisible(true);
}
}
}
});
Runnable recordVoiceRunnable = new Runnable() {
@Override
public void run() {
isLongPress = true;
if (isLongPress) {
Vibrator vibrator = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(100);
if (mustCheckPermission()) {
if (currentRoomAccess != null && !currentRoomAccess.getRealmPostMessageRights().isCanSendMedia()) {
Toast.makeText(getContext(), getResources().getString(R.string.restrictions_on_sending_multimedia_messages), Toast.LENGTH_SHORT).show();
isLongPress = false;
}
}
if (keyboardViewVisible)
hideKeyboard();
if (ContextCompat.checkSelfPermission(G.fragmentActivity, Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
try {
HelperPermission.getMicroPhonePermission(G.fragmentActivity, null);
} catch (IOException e) {
e.printStackTrace();
}
} else {
isRecording = true;
voiceRecord.setItemTag("ivVoice");
viewMicRecorder.setVisibility(View.VISIBLE);
AppUtils.setVibrator(50);
voiceRecord.startVoiceRecord();
}
}
}
};
imvMicButton.setOnTouchListener((v, event) -> {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
G.runOnUiThread(recordVoiceRunnable, longClickDuration);
} else if (event.getAction() == MotionEvent.ACTION_UP) {
G.cancelRunOnUiThread(recordVoiceRunnable);
isLongPress = false;
}
return isLongPress;
});
imvSmileButton.setOnClickListener(v -> onEmojiButtonClick());
edtChat.addTextChangedListener(new TextWatcher() {
boolean processChange = false;
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence text, int start, int before, int count) {
if (text.length() > 0) {
HelperSetAction.setActionTyping(mRoomId, chatType);
}
// if in the seeting page send by enter is on message send by enter key
if (text.toString().endsWith(System.getProperty("line.separator"))) {
if (sendByEnter)
imvSendButton.performClick();
}
messageLentghCounter = ((int) Math.ceil((float) text.length() / (float) Config.MAX_TEXT_LENGTH));
if (messageLentghCounter > 1 && messageLentghCounter != oldMessageLentghCounter && getContext() != null) {
oldMessageLentghCounter = messageLentghCounter;
Toast.makeText(getContext(), getString(R.string.message_is_long) + " " + messageLentghCounter + " " + getString(R.string.message), Toast.LENGTH_SHORT).show();
}
if ((count - before) > 1) {
processChange = true;
}
}
@Override
public void afterTextChanged(Editable editable) {
if (ll_attach_text.getVisibility() == View.GONE && !hasForward) {
if (edtChat.getText() != null && edtChat.getText().length() > 0) {
sendButtonVisibility(true);
} else {
if (!isEditMessage) {
sendButtonVisibility(false);
}
}
if (processChange) {
ImageSpan[] spans = editable.getSpans(0, editable.length(), ImageSpan.class);
for (ImageSpan span : spans) {
editable.removeSpan(span);
}
EmojiManager.getInstance().replaceEmoji(editable, edtChat.getPaint().getFontMetricsInt(), LayoutCreator.dp(20), false);
processChange = false;
}
}
if (edtChat.getText() != null && !EmojiManager.getInstance().isValidEmoji(edtChat.getText()) && suggestedLayout != null && suggestedLayout.getVisibility() == View.VISIBLE) {
suggestedLayout.setVisibility(View.GONE);
lastChar = null;
} else if (lastChar != null) {
lastChar = null;
}
}
});
}
use of net.iGap.module.MaterialDesignTextView in project iGap-Android by KianIranian-STDG.
the class FragmentChat method initPinedMessage.
private void initPinedMessage() {
CountDownLatch countdown = new CountDownLatch(1);
final long[] pinMessageId = new long[1];
final long[] pinDocumentId = new long[1];
getMessageDataStorage().getStorageQueue().postRunnable(() -> {
try {
pinMessageId[0] = DbManager.getInstance().doRealmTask(realm -> {
return RealmRoom.hasPinedMessage(realm, mRoomId, false);
});
pinDocumentId[0] = DbManager.getInstance().doRealmTask(realm -> {
return RealmRoom.hasPinedMessage(realm, mRoomId, true);
});
countdown.countDown();
} catch (Exception e) {
FileLog.e(e);
} finally {
countdown.countDown();
}
});
try {
countdown.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
pinedMessageLayout = rootView.findViewById(R.id.ac_ll_strip_Pin);
if (pinMessageId[0] > 0) {
RealmRoomMessage realmRoomMessage = DbManager.getInstance().doRealmTask(realm -> {
return realm.where(RealmRoomMessage.class).equalTo("messageId", pinMessageId[0]).findFirst();
});
if (realmRoomMessage != null && realmRoomMessage.isValid() && !realmRoomMessage.isDeleted()) {
realmRoomMessage = RealmRoomMessage.getFinalMessage(realmRoomMessage);
isPinAvailable = true;
changePinnedMessageVisibility(true, true, MusicPlayer.isMusicPlyerEnable, CallManager.getInstance().isCallAlive());
// pinedMessageLayout.setVisibility(View.VISIBLE);
TextView txtPinMessage = rootView.findViewById(R.id.pl_txt_pined_Message);
MaterialDesignTextView iconPinClose = rootView.findViewById(R.id.pl_btn_close);
String text = realmRoomMessage.getMessage();
if (text == null || text.length() == 0) {
text = AppUtils.conversionMessageType(realmRoomMessage.getMessageType());
}
txtPinMessage.setText(text);
iconPinClose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (channelRole == ChannelChatRole.MEMBER || groupRole == GroupChatRole.MEMBER || isNotJoin) {
RealmRoom.updatePinedMessageDeleted(mRoomId, false);
changePinnedMessageVisibility(true, false, MusicPlayer.isMusicPlyerEnable, CallManager.getInstance().isCallAlive());
isPinAvailable = false;
} else {
sendRequestPinMessage(0, 0);
}
}
});
pinedMessageLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!goToPositionWithAnimation(pinMessageId[0], 1000)) {
RealmRoomMessage rm = DbManager.getInstance().doRealmTask(realm -> {
return realm.where(RealmRoomMessage.class).equalTo("messageId", pinMessageId[0]).findFirst();
});
rm = RealmRoomMessage.getFinalMessage(rm);
if (rm != null) {
resetMessagingValue();
savedScrollMessageId = pinMessageId[0];
savedScrollDocumentId = pinDocumentId[0];
firstVisiblePositionOffset = 0;
getMessages();
} else {
new RequestClientGetRoomMessage().clientGetRoomMessage(mRoomId, pinMessageId[0], pinDocumentId[0], new OnClientGetRoomMessage() {
@Override
public void onClientGetRoomMessageResponse(ProtoGlobal.RoomMessage message) {
G.handler.post(new Runnable() {
@Override
public void run() {
DbManager.getInstance().doRealmTask(realm -> {
realm.executeTransactionAsync(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
RealmRoomMessage.setGapInTransaction(realm, messageId, documentId);
}
}, () -> {
resetMessagingValue();
savedScrollMessageId = pinMessageId[0];
savedScrollDocumentId = pinDocumentId[0];
firstVisiblePositionOffset = 0;
getMessages();
});
});
}
});
}
@Override
public void onError(int majorCode, int minorCode) {
}
});
}
}
}
});
} else {
changePinnedMessageVisibility(true, false, MusicPlayer.isMusicPlyerEnable, CallManager.getInstance().isCallAlive());
}
} else {
changePinnedMessageVisibility(true, false, MusicPlayer.isMusicPlyerEnable, CallManager.getInstance().isCallAlive());
}
}
use of net.iGap.module.MaterialDesignTextView in project iGap-Android by KianIranian-STDG.
the class StoryCell method initView.
public void initView(Context context, boolean needDivider, CircleStatus status, ImageLoadingView.Status imageLoadingStatus, IconClicked iconClicked, long createTime) {
removeAllViews();
if (G.themeColor == Theme.DARK) {
setBackground(Theme.getSelectorDrawable(Theme.getInstance().getDividerColor(context)));
} else {
setBackgroundColor(Color.WHITE);
}
this.status = status;
this.needDivider = needDivider;
this.iconClicked = iconClicked;
this.context = context;
setWillNotDraw(!needDivider);
View view;
switch(this.status) {
case CIRCLE_IMAGE:
circleImage = new CircleImageView(getContext());
circleImage.setLayoutParams(LayoutCreator.createFrame(56, 56, (isRtl ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL, isRtl ? 0 : padding, 8, isRtl ? padding : 0, 8));
view = circleImage;
break;
case LOADING_CIRCLE_IMAGE:
circleImageLoading = new ImageLoadingView(context);
circleImageLoading.setStatus(imageLoadingStatus);
circleImageLoading.setLayoutParams(LayoutCreator.createFrame(72, 72, (isRtl ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL, isRtl ? 0 : 8, 8, isRtl ? 8 : 0, 8));
view = circleImageLoading;
break;
default:
throw new IllegalStateException("Unexpected value: " + this.status);
}
addView(view);
addIcon = new MaterialDesignTextView(context);
addIcon.setText(R.string.icon_add_whit_circle);
addIcon.setTextColor(getResources().getColor(R.color.green));
addIcon.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
addIcon.setGravity(isRtl ? Gravity.LEFT : Gravity.RIGHT);
addView(addIcon, LayoutCreator.createFrame(18, 18, (isRtl ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM, isRtl ? 0 : padding, 8, isRtl ? padding : 0, 8));
topViewRootView = new LinearLayout(context);
topViewRootView.setOrientation(LinearLayout.HORIZONTAL);
topViewRootView.setGravity(Gravity.CENTER);
addView(topViewRootView, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, (isRtl ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, isRtl ? padding : ((padding * 2) + 56), 11.5f, isRtl ? ((padding * 2) + 56) : padding, 0));
channelIconTv = new FontIconTextView(getContext());
setTextSize(channelIconTv, R.dimen.dp14);
channelIconTv.setText(R.string.icon_channel);
channelIconTv.setTextColor(Theme.getInstance().getAccentColor(channelIconTv.getContext()));
channelIconTv.setVisibility(GONE);
topViewRootView.addView(channelIconTv, LayoutCreator.createLinear(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER));
topText = new TextView(context);
topText.setSingleLine();
topText.setTypeface(ResourcesCompat.getFont(getContext(), R.font.main_font_bold));
ViewMaker.setTextSize(topText, R.dimen.dp15);
topText.setSingleLine(true);
topText.setEllipsize(TextUtils.TruncateAt.END);
topText.setTextColor(Theme.getInstance().getSendMessageTextColor(topText.getContext()));
topText.setGravity((isRtl ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
topViewRootView.addView(topText, LayoutCreator.createLinear(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER, !isRtl && roomId != 0 && userId != AccountManager.getInstance().getCurrentUser().getId() ? 4 : 0, 0, isRtl && roomId != 0 && userId != AccountManager.getInstance().getCurrentUser().getId() ? 4 : 0, 0));
verifyIconTv = new FontIconTextView(getContext());
verifyIconTv.setTextColor(getContext().getResources().getColor(R.color.verify_color));
verifyIconTv.setText(R.string.icon_blue_badge);
setTextSize(verifyIconTv, R.dimen.standardTextSize);
verifyIconTv.setVisibility(GONE);
topViewRootView.addView(verifyIconTv, LayoutCreator.createLinear(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER, !isRtl && roomId != 0 && userId != AccountManager.getInstance().getCurrentUser().getId() ? 4 : 0, 0, isRtl && roomId != 0 && userId != AccountManager.getInstance().getCurrentUser().getId() ? 4 : 0, 0));
middleText = new TextView(context);
middleText.setSingleLine();
middleText.setTypeface(ResourcesCompat.getFont(getContext(), R.font.main_font_bold));
ViewMaker.setTextSize(middleText, R.dimen.dp15);
middleText.setSingleLine(true);
middleText.setEllipsize(TextUtils.TruncateAt.END);
middleText.setTextColor(Theme.getInstance().getPrimaryTextColor(context));
middleText.setGravity((isRtl ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
middleText.setVisibility(GONE);
addView(middleText, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, (isRtl ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL, isRtl ? padding : ((padding * 2) + 56), 0, isRtl ? ((padding * 2) + 56) : padding, 0));
bottomText = new TextView(context);
bottomText.setSingleLine();
ViewMaker.setTypeFace(bottomText);
ViewMaker.setTextSize(bottomText, R.dimen.dp13);
bottomText.setGravity((isRtl ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
bottomText.setTextColor(Color.GRAY);
addView(bottomText, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, (isRtl ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, isRtl ? padding : ((padding * 2) + 56), 34.5f, isRtl ? ((padding * 2) + 56) : padding, 0));
icon = new IconView(getContext());
icon.setTypeface(ResourcesCompat.getFont(context, R.font.font_icons));
icon.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
addView(icon, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, (isRtl ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, padding, 0, padding, 0));
icon2 = new IconView(getContext());
icon2.setTypeface(ResourcesCompat.getFont(context, R.font.font_icons));
icon2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
addView(icon2, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, (isRtl ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, isRtl ? (padding + 30) : padding, 0, isRtl ? padding : (30 + padding), 0));
LinearLayout iconsRootView = new LinearLayout(getContext());
iconsRootView.setOrientation(LinearLayout.HORIZONTAL);
iconsRootView.setGravity(Gravity.CENTER);
addView(iconsRootView, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, (isRtl ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, isRtl ? 0 : 8, 8, isRtl ? 8 : 0, 8));
uploadIcon = new MaterialDesignTextView(getContext());
uploadIcon.setTypeface(ResourcesCompat.getFont(context, R.font.font_icons));
uploadIcon.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 23);
uploadIcon.setText(R.string.icon_upload);
uploadIcon.setVisibility(GONE);
uploadIcon.setTextColor(Theme.getInstance().getSendMessageTextColor(uploadIcon.getContext()));
uploadIcon.setGravity(Gravity.CENTER);
uploadIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if ((circleImageLoading.getStatus() == ImageLoadingView.Status.FAILED && isFromMyStatus && !isRoom) || (circleImageLoading.getStatus() == ImageLoadingView.Status.FAILED && isFromMyStatus && isRoom && mode == 1)) {
deleteIcon.setVisibility(GONE);
uploadIcon.setVisibility(GONE);
middleText.setTextColor(Theme.getInstance().getTitleTextColor(context));
middleText.setText(context.getString(R.string.story_sending));
circleImageLoading.setStatus(ImageLoadingView.Status.LOADING);
StoryObject realmStoryProto;
if (fileToken != null) {
realmStoryProto = MessageDataStorage.getInstance(AccountManager.selectedAccount).getStoryWithFileToken(fileToken);
} else {
realmStoryProto = MessageDataStorage.getInstance(AccountManager.selectedAccount).getStoryWithUploadId(uploadId);
}
if (realmStoryProto != null && realmStoryProto.fileToken != null) {
MessageDataStorage.getInstance(AccountManager.selectedAccount).updateStoryStatus(realmStoryProto.id, MessageObject.STATUS_SENDING);
List<ProtoStoryUserAddNew.StoryAddRequest> storyAddRequests = new ArrayList<>();
ProtoStoryUserAddNew.StoryAddRequest.Builder storyAddRequest = ProtoStoryUserAddNew.StoryAddRequest.newBuilder();
storyAddRequest.setToken(realmStoryProto.fileToken);
storyAddRequest.setCaption(realmStoryProto.caption);
storyAddRequests.add(storyAddRequest.build());
if (isRoom) {
MessageController.getInstance(AccountManager.selectedAccount).addMyRoomStory(storyAddRequests, roomId);
} else {
MessageController.getInstance(AccountManager.selectedAccount).addMyStory(storyAddRequests);
}
} else if (realmStoryProto != null && !Uploader.getInstance().isCompressingOrUploading(String.valueOf(realmStoryProto.id))) {
MessageDataStorage.getInstance(AccountManager.selectedAccount).updateStoryStatus(realmStoryProto.id, MessageObject.STATUS_SENDING);
HttpUploader.isStoryUploading = true;
Uploader.getInstance().upload(UploadObject.createForStory(realmStoryProto.id, realmStoryProto.attachmentObject.filePath, null, realmStoryProto.caption, ProtoGlobal.RoomMessageType.STORY));
}
EventManager.getInstance(AccountManager.selectedAccount).postEvent(EventManager.STORY_SENDING);
} else {
deleteStory.deleteStory(StoryCell.this, storyId, roomId, isRoom);
}
}
});
deleteIcon = new MaterialDesignTextView(getContext());
deleteIcon.setTypeface(ResourcesCompat.getFont(context, R.font.font_icons));
deleteIcon.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 23);
deleteIcon.setText(R.string.icon_other_horizontal_dots);
deleteIcon.setVisibility(GONE);
deleteIcon.setTextColor(Theme.getInstance().getSendMessageTextColor(deleteIcon.getContext()));
deleteIcon.setGravity(Gravity.CENTER);
deleteIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
deleteStory.deleteStory(StoryCell.this, storyId, roomId, isRoom);
}
});
iconsRootView.addView(uploadIcon, LayoutCreator.createLinear(72, 72, Gravity.CENTER_VERTICAL));
iconsRootView.addView(deleteIcon, LayoutCreator.createLinear(72, 72, Gravity.CENTER_VERTICAL));
if (status == CircleStatus.LOADING_CIRCLE_IMAGE) {
setOnClickListener(v -> {
deleteStory.onStoryClick(this);
});
circleImageLoading.setOnClickListener(v -> {
deleteStory.onStoryClick(this);
});
}
}
Aggregations