use of net.iGap.module.FontIconTextView in project iGap-Android by KianIranian-STDG.
the class StoryDisplayFragment method createView.
@Override
public View createView(Context context) {
fragmentView = new FrameLayout(context);
rootLayout = (FrameLayout) fragmentView;
notifyFrameLayout = new NotifyFrameLayout(context) {
@Override
public boolean dispatchKeyEventPreIme(KeyEvent event) {
if (event != null && event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
if (keyboardViewVisible) {
hideStoryReply();
return true;
}
return false;
}
return super.dispatchKeyEventPreIme(event);
}
};
notifyFrameLayout.setListener(this::onScreenSizeChanged);
rootLayout.addView(notifyFrameLayout, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.MATCH_PARENT));
storyVideoPlayer = new PlayerView(context);
storyVideoPlayer.setVisibility(View.GONE);
storyVideoPlayer.setContentDescription("storyVideoPlayer");
notifyFrameLayout.addView(storyVideoPlayer, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.MATCH_PARENT));
storyDisplayImage = new ImageView(context);
storyDisplayImage.setScaleType(ImageView.ScaleType.CENTER_CROP);
storyDisplayImage.setContentDescription("storyDisplayImage");
notifyFrameLayout.addView(storyDisplayImage, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.MATCH_PARENT));
DisplayMetrics displayMetrics = new DisplayMetrics();
requireActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int width = displayMetrics.widthPixels;
previous = new LinearLayout(context);
FrameLayout.LayoutParams previousLayoutParam = new FrameLayout.LayoutParams(width / 2, ViewGroup.LayoutParams.MATCH_PARENT, Gravity.LEFT);
previous.setContentDescription("previous");
notifyFrameLayout.addView(previous, previousLayoutParam);
next = new LinearLayout(context);
FrameLayout.LayoutParams nextLayoutParam = new FrameLayout.LayoutParams(width / 2, ViewGroup.LayoutParams.MATCH_PARENT, Gravity.RIGHT);
next.setContentDescription("next");
notifyFrameLayout.addView(next, nextLayoutParam);
storyVideoProgress = new ProgressBar(context);
storyVideoProgress.setContentDescription("storyVideoProgress");
notifyFrameLayout.addView(storyVideoProgress, LayoutCreator.createFrame(40, 40, Gravity.RIGHT | Gravity.TOP, 0, 20, 20, 0));
storyOverlay = new FrameLayout(context);
storyOverlay.setContentDescription("storyOverlay");
notifyFrameLayout.addView(storyOverlay, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.MATCH_PARENT));
topShadow = new View(context);
topShadow.setContentDescription("topShadow");
topShadow.setBackground(context.getResources().getDrawable(R.drawable.story_top_shadow));
storyOverlay.addView(topShadow, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, 60, Gravity.TOP));
storiesProgressView = new StoriesProgressView(context, null);
storiesProgressView.setContentDescription("storiesProgressView");
storiesProgressView.setPadding(8, 0, 8, 0);
storyOverlay.addView(storiesProgressView, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.WRAP_CONTENT, Gravity.TOP, 0, 2, 0, 0));
profileImage = new CircleImageView(context);
profileImage.setContentDescription("profileImage");
storyOverlay.addView(profileImage, LayoutCreator.createFrame(40, 40, Gravity.LEFT, 8, 10, 8, 8));
LinearLayout profileContainer = new LinearLayout(context);
profileContainer.setContentDescription("profileContainer");
profileContainer.setOrientation(LinearLayout.VERTICAL);
topLinearRootView = new LinearLayout(context);
topLinearRootView.setGravity(Gravity.CENTER);
topLinearRootView.setOrientation(LinearLayout.HORIZONTAL);
profileContainer.addView(topLinearRootView, 0, LayoutCreator.createLinear(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.TOP));
nickName = new TextView(context);
nickName.setContentDescription("nickName");
nickName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13);
nickName.setTypeface(ResourcesCompat.getFont(context, R.font.main_font_bold));
nickName.setTextColor(Color.WHITE);
topLinearRootView.addView(nickName, LayoutCreator.createLinear(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER));
chatIconTv = new FontIconTextView(getContext());
setTextSize(chatIconTv, R.dimen.dp14);
chatIconTv.setVisibility(View.GONE);
chatIconTv.setContentDescription("chatIconTv");
chatIconTv.setText(R.string.icon_channel);
chatIconTv.setTextColor(Color.WHITE);
topLinearRootView.addView(chatIconTv, LayoutCreator.createLinear(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER, 4, 0, 0, 0));
verifyIconTv = new FontIconTextView(getContext());
verifyIconTv.setTextColor(getContext().getResources().getColor(R.color.verify_color));
verifyIconTv.setText(R.string.icon_blue_badge);
verifyIconTv.setVisibility(View.GONE);
setTextSize(verifyIconTv, R.dimen.standardTextSize);
topLinearRootView.addView(verifyIconTv, LayoutCreator.createLinear(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER, 4, 0, 0, 0));
storyTime = new TextView(context);
storyTime.setContentDescription("storyTime");
storyTime.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
storyTime.setTypeface(nickName.getTypeface(), Typeface.BOLD);
storyTime.setTextColor(Color.WHITE);
profileContainer.addView(storyTime, LayoutCreator.createLinear(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.BOTTOM));
storyOverlay.addView(profileContainer, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.LEFT, 56, 8, 0, 0));
captionRootView = new ExpandableTextView(context);
captionRootView.setContentDescription("captionRootView");
captionRootView.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
captionRootView.setTextColor(Color.WHITE);
captionRootView.setPadding(8, 8, 8, 8);
rootLayout.addView(captionRootView, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.WRAP_CONTENT, Gravity.BOTTOM, 0, 0, 0, 80));
storySeenContainer = new LinearLayout(context);
storySeenContainer.setContentDescription("storySeenContainer");
storySeenContainer.setGravity(Gravity.CENTER_VERTICAL);
storySeenContainer.setOrientation(LinearLayout.HORIZONTAL);
eyeIcon = new TextView(context);
eyeIcon.setContentDescription("eyeIcon");
eyeIcon.setTypeface(ResourcesCompat.getFont(context, R.font.font_icons));
eyeIcon.setTextColor(Color.WHITE);
eyeIcon.setGravity(Gravity.CENTER_VERTICAL);
eyeIcon.setBackground(context.getResources().getDrawable(R.drawable.ic_view_seen));
eyeIcon.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25);
seenCount = new TextView(context);
seenCount.setContentDescription("seenCount");
seenCount.setTypeface(ResourcesCompat.getFont(context, R.font.main_font));
seenCount.setGravity(Gravity.CENTER_VERTICAL);
seenCount.setTextColor(Color.WHITE);
seenCount.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
storySeenContainer.addView(eyeIcon, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.LEFT));
storySeenContainer.addView(seenCount, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.RIGHT, 3, 0, 0, 0));
storyProgress = new ProgressBar(context);
storyProgress.setContentDescription("storyProgress");
storyProgress.setVisibility(View.GONE);
notifyFrameLayout.addView(storyProgress, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER));
GradientDrawable layer1 = new GradientDrawable();
layer1.setShape(GradientDrawable.RECTANGLE);
layer1.setCornerRadii(new float[] { LayoutCreator.dp(8), LayoutCreator.dp(8), 0, 0, 0, 0, LayoutCreator.dp(8), LayoutCreator.dp(8) });
layer1.setColor(Theme.getInstance().getToolbarBackgroundColor(context));
GradientDrawable layer2 = new GradientDrawable();
layer2.setShape(GradientDrawable.RECTANGLE);
layer2.setColor(Theme.getInstance().getReplyContentBackground(context));
InsetDrawable insetDrawable = new InsetDrawable(layer2, LayoutCreator.dp(8), 0, 0, 0);
LayerDrawable drawable = new LayerDrawable(new Drawable[] { layer1, insetDrawable });
LinearLayout replyAndKeyboardContainer = new LinearLayout(context);
replyAndKeyboardContainer.setOrientation(LinearLayout.VERTICAL);
notifyFrameLayout.addView(replyAndKeyboardContainer, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.WRAP_CONTENT, Gravity.BOTTOM));
replyContainer = new FrameLayout(context);
replyContainer.setVisibility(View.GONE);
replyContainer.setContentDescription("replyContainer");
replyContainer.setBackground(Theme.getInstance().tintDrawable(context.getResources().getDrawable(R.drawable.chat_item_sent_bg_light), context, R.attr.iGapSendMessageBubbleColor));
replyContainer.setPadding(15, 15, 15, 15);
replyAndKeyboardContainer.addView(replyContainer, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, LayoutCreator.WRAP_CONTENT, Gravity.TOP, 15, 0, 15, 10));
FrameLayout mainContentContainer = new FrameLayout(context);
replyContainer.addView(mainContentContainer, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.WRAP_CONTENT, Gravity.LEFT));
replyContentContainer = new LinearLayout(context);
replyContentContainer.setContentDescription("replyContentContainer");
replyContentContainer.setBackground(drawable);
replyContentContainer.setOrientation(LinearLayout.VERTICAL);
mainContentContainer.addView(replyContentContainer, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, 50, Gravity.LEFT, 10, 5, 45, 5));
replyThumb = new ImageView(context);
replyThumb.setContentDescription("replyThumb");
mainContentContainer.addView(replyThumb, LayoutCreator.createFrame(25, LayoutCreator.MATCH_PARENT, Gravity.RIGHT | Gravity.TOP, 0, 0, 5, 0));
replyTo = new TextView(context);
replyTo.setContentDescription("replyTo");
replyTo.setTypeface(ResourcesCompat.getFont(context, R.font.main_font_bold));
replyTo.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
replyTo.setEllipsize(TextUtils.TruncateAt.END);
replyTo.setTextColor(Theme.getInstance().getSendReplayUserColor(context));
replyContentContainer.addView(replyTo, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.TOP, 8, 0, 0, 0));
replyCaption = new TextView(context);
replyCaption.setContentDescription("replyCaption");
replyCaption.setTypeface(ResourcesCompat.getFont(context, R.font.main_font));
replyCaption.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10);
replyCaption.setEllipsize(TextUtils.TruncateAt.END);
replyCaption.setSingleLine(true);
replyCaption.setTextColor(Theme.getInstance().getSubTitleColor(context));
replyContentContainer.addView(replyCaption, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.BOTTOM, 8, 0, 8, 0));
sendReplyContainer = new FrameLayout(context);
sendReplyContainer.setContentDescription("sendReplyContainer");
replyContainer.addView(sendReplyContainer, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.WRAP_CONTENT, Gravity.BOTTOM, 0, 60, 0, 0));
emojiIcon = new TextView(context);
emojiIcon.setContentDescription("emojiIcon");
emojiIcon.setTypeface(ResourcesCompat.getFont(context, R.font.font_icons));
emojiIcon.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25);
emojiIcon.setText(R.string.icon_emoji_smile);
emojiIcon.setGravity(Gravity.CENTER);
emojiIcon.setTextColor(Theme.getInstance().getSubTitleColor(context));
sendReplyContainer.addView(emojiIcon, LayoutCreator.createFrame(50, 50, Gravity.LEFT, 5, 0, 5, 0));
replyEditText = new EventEditText(context);
replyEditText.setBackground(null);
replyEditText.setContentDescription("replyEditText");
replyEditText.setListener(this::chatMotionEvent);
replyEditText.setHintTextColor(Theme.getInstance().getSubTitleColor(context));
replyEditText.setTextColor(Theme.getInstance().getTitleTextColor(context));
sendReplyContainer.addView(replyEditText, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.MATCH_PARENT, Gravity.LEFT, 50, 0, 55, 0));
sendIcon = new TextView(context);
sendIcon.setContentDescription("sendIcon");
sendIcon.setTypeface(ResourcesCompat.getFont(context, R.font.font_icons));
sendIcon.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25);
sendIcon.setText(R.string.icon_send);
sendIcon.setGravity(Gravity.CENTER);
sendIcon.setTextColor(Theme.getInstance().getSubTitleColor(context));
sendReplyContainer.addView(sendIcon, LayoutCreator.createFrame(50, 50, Gravity.RIGHT, 5, 0, 5, 0));
keyboardContainer = new FrameLayout(context);
keyboardContainer.setContentDescription("keyboardContainer");
replyAndKeyboardContainer.addView(keyboardContainer, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, LayoutCreator.WRAP_CONTENT, Gravity.BOTTOM));
storyReplyContainer = new LinearLayout(context);
storyReplyContainer.setContentDescription("storyReplyContainer");
storyReplyContainer.setOrientation(LinearLayout.VERTICAL);
storyReplyContainer.setGravity(Gravity.CENTER_HORIZONTAL);
replyIcon = new TextView(context);
replyIcon.setContentDescription("replyIcon");
replyIcon.setTypeface(ResourcesCompat.getFont(context, R.font.font_icons));
replyIcon.setTextColor(Color.WHITE);
replyIcon.setText(R.string.icon_chevron_Down);
replyIcon.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
replyText = new TextView(context);
replyText.setContentDescription("replyText");
replyText.setTypeface(ResourcesCompat.getFont(context, R.font.main_font));
replyText.setTextColor(Color.WHITE);
replyText.setText(R.string.replay);
replyText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
storyReplyContainer.addView(replyIcon, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT));
storyReplyContainer.addView(replyText, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT));
notifyFrameLayout.addView(storySeenContainer, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM, 0, 0, 0, 20));
notifyFrameLayout.addView(storyReplyContainer, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM, 0, 0, 0, 30));
return rootLayout;
}
use of net.iGap.module.FontIconTextView in project iGap-Android by KianIranian-STDG.
the class FragmentChat method inflateReplayLayoutIntoStub.
@SuppressLint("RestrictedApi")
private void inflateReplayLayoutIntoStub(MessageObject messageObject, boolean isEdit) {
// TODO: 12/28/20 refactor message
if (rootView.findViewById(R.id.replayLayoutAboveEditText) == null) {
ViewStubCompat stubView = rootView.findViewById(R.id.replayLayoutStub);
stubView.setInflatedId(R.id.replayLayoutAboveEditText);
stubView.setLayoutResource(R.layout.layout_chat_reply);
stubView.inflate();
inflateReplayLayoutIntoStub(messageObject, isEdit);
} else {
mReplayLayout = rootView.findViewById(R.id.replayLayoutAboveEditText);
mReplayLayout.setVisibility(View.VISIBLE);
TextView replayTo = mReplayLayout.findViewById(R.id.replayTo);
replayTo.setTypeface(ResourcesCompat.getFont(mReplayLayout.getContext(), R.font.main_font));
TextView replayFrom = mReplayLayout.findViewById(R.id.replyFrom);
replayFrom.setTypeface(ResourcesCompat.getFont(mReplayLayout.getContext(), R.font.main_font));
FontIconTextView replayIcon = rootView.findViewById(R.id.lcr_imv_replay);
if (isEdit)
replayIcon.setText(getString(R.string.icon_new_conversation));
else
replayIcon.setText(getString(R.string.icon_reply));
ImageView thumbnail = mReplayLayout.findViewById(R.id.thumbnail);
thumbnail.setImageResource(android.R.color.transparent);
TextView closeReplay = mReplayLayout.findViewById(R.id.cancelIcon);
closeReplay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isEdit)
removeEditedMessage();
else
clearReplyView();
}
});
thumbnail.setVisibility(View.VISIBLE);
if (messageObject.isForwarded()) {
AppUtils.rightFileThumbnailIcon(thumbnail, messageObject.forwardedMessage.messageType, messageObject.forwardedMessage);
String _text = AppUtils.conversionMessageType(messageObject.forwardedMessage.messageType);
if (_text != null && _text.length() > 0) {
ReplySetText(replayTo, _text);
} else {
ReplySetText(replayTo, messageObject.forwardedMessage.message);
}
} else {
AppUtils.rightFileThumbnailIcon(thumbnail, messageObject.messageType, messageObject);
String _text = AppUtils.conversionMessageType(messageObject.messageType);
if (_text != null && _text.length() > 0) {
ReplySetText(replayTo, _text);
} else {
ReplySetText(replayTo, messageObject.message);
}
}
if (!isEdit) {
if (chatType == CHANNEL) {
RealmRoom realmRoom = DbManager.getInstance().doRealmTask(realm -> {
return realm.where(RealmRoom.class).equalTo("id", messageObject.roomId).findFirst();
});
if (realmRoom != null) {
replayFrom.setText(EmojiManager.getInstance().replaceEmoji(realmRoom.getTitle(), replayFrom.getPaint().getFontMetricsInt()));
}
} else {
RealmRegisteredInfo userInfo = DbManager.getInstance().doRealmTask(realm -> {
return RealmRegisteredInfo.getRegistrationInfo(realm, messageObject.userId);
});
if (userInfo != null) {
replayFrom.setText(EmojiManager.getInstance().replaceEmoji(userInfo.getDisplayName(), replayFrom.getPaint().getFontMetricsInt()));
}
}
} else {
replayFrom.setText(getString(R.string.edit));
}
// I set tag to retrieve it later when sending message
mReplayLayout.setTag(messageObject);
}
}
use of net.iGap.module.FontIconTextView in project iGap-Android by KianIranian-STDG.
the class FragmentChat method manageForwardedMessage.
/**
* do forward actions if any message forward to this room
*/
private void manageForwardedMessage(boolean isMessage) {
if ((mForwardMessages != null && !isChatReadOnly) || multiForwardList.size() > 0) {
final LinearLayout ll_Forward = rootView.findViewById(R.id.ac_ll_forward);
int multiForwardSize = multiForwardList.size();
if ((hasForward || multiForwardSize > 0) && mForwardMessages != null) {
for (int i = 0; i < mForwardMessages.size(); i++) {
if (hasForward) {
sendForwardedMessage(mForwardMessages.get(i), mRoomId, true, i, false);
} else {
for (int k = 0; k < multiForwardSize; k++) {
sendForwardedMessage(mForwardMessages.get(i), multiForwardList.get(k), false, (i + k), isMessage);
}
}
}
if (hasForward) {
imvCancelForward.performClick();
} else {
multiForwardList.clear();
removeForwardModeFromRoomList();
mForwardMessages = null;
}
} else {
imvCancelForward = rootView.findViewById(R.id.cslhf_imv_cansel);
imvCancelForward.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ll_Forward.setVisibility(View.GONE);
hasForward = false;
removeForwardModeFromRoomList();
mForwardMessages = null;
if (edtChat.getText().length() == 0) {
sendButtonVisibility(false);
}
}
});
sendButtonVisibility(true);
int _count = mForwardMessages != null ? mForwardMessages.size() : 0;
String str = _count > 1 ? G.fragmentActivity.getResources().getString(R.string.messages_selected) : G.fragmentActivity.getResources().getString(R.string.message_selected);
TextView emMessage = rootView.findViewById(R.id.cslhf_txt_message);
FontIconTextView forwardIcon = rootView.findViewById(R.id.cslhs_imv_forward);
if (HelperCalander.isPersianUnicode) {
emMessage.setText(EmojiManager.getInstance().replaceEmoji(convertToUnicodeFarsiNumber(_count + " " + str), emMessage.getPaint().getFontMetricsInt()));
} else {
emMessage.setText(EmojiManager.getInstance().replaceEmoji(_count + " " + str, emMessage.getPaint().getFontMetricsInt()));
}
hasForward = true;
ll_Forward.setVisibility(View.VISIBLE);
}
}
}
use of net.iGap.module.FontIconTextView 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);
});
}
}
use of net.iGap.module.FontIconTextView in project iGap-Android by KianIranian-STDG.
the class RoomListCell method setData.
public void setData(RealmRoom room, AvatarHandler avatarHandler, boolean isSelectedMode) {
if (room.isPinned()) {
if (!havePin) {
pinIcon = new IconView(getContext());
pinIcon.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
pinIcon.setIconColor(Theme.getInstance().getSubTitleColor(getContext()));
pinIcon.setIcon(R.string.icon_pin_to_top2);
pinView = new AppCompatImageView(getContext());
pinView.setBackgroundResource(R.drawable.pin);
pinView.setAlpha(G.themeColor == Theme.DARK ? 0.2f : 0.6f);
addView(pinView, 0);
addView(pinIcon, 1);
havePin = true;
}
} else if (havePin) {
removeView(pinIcon);
removeView(pinView);
havePin = false;
}
if (!haveAvatar) {
avatarImageView = new CircleImageView(getContext());
addView(avatarImageView);
haveAvatar = true;
final boolean isMyCloud;
isMyCloud = room.getChatRoom() != null && room.getChatRoom().getPeerId() > 0 && room.getChatRoom().getPeerId() == AccountManager.getInstance().getCurrentUser().getId();
if (isMyCloud) {
avatarHandler.removeImageViewFromHandler(avatarImageView);
avatarImageView.setImageResource(R.drawable.ic_cloud_space_blue);
} else {
avatarHandler(room, avatarHandler);
}
} else {
final boolean isMyCloud;
isMyCloud = room.getChatRoom() != null && room.getChatRoom().getPeerId() > 0 && room.getChatRoom().getPeerId() == AccountManager.getInstance().getCurrentUser().getId();
if (isMyCloud) {
avatarHandler.removeImageViewFromHandler(avatarImageView);
avatarImageView.setImageResource(R.drawable.ic_cloud_space_blue);
} else {
avatarHandler(room, avatarHandler);
}
}
if (haveName) {
roomNameTv.setText(EmojiManager.getInstance().replaceEmoji(room.getTitle(), roomNameTv.getPaint().getFontMetricsInt(), -1, false));
}
if (room.getType() == ProtoGlobal.Room.Type.CHANNEL && room.getChannelRoom().isVerified() || room.getType() == CHAT && room.getChatRoom().isVerified()) {
if (!roomVerified) {
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);
addView(verifyIconTv);
roomVerified = true;
}
} else if (roomVerified) {
removeView(verifyIconTv);
roomVerified = false;
}
if (!haveDate) {
messageDateTv = new AppCompatTextView(getContext());
messageDateTv.setSingleLine(true);
messageDateTv.setTextColor(Theme.getInstance().getSendMessageTextColor(messageDateTv.getContext()));
setTextSize(messageDateTv, R.dimen.smallTextSize);
setTypeFace(messageDateTv);
addView(messageDateTv);
haveDate = true;
}
if (room.getLastMessage() != null && room.getLastMessage().getUpdateOrCreateTime() != 0) {
messageDateTv.setText(HelperCalander.getTimeForMainRoom(room.getLastMessage().getUpdateOrCreateTime()));
}
if (room.getMute()) {
if (!isMute) {
muteIconTv = new FontIconTextView(getContext());
muteIconTv.setText(R.string.icon_mute);
muteIconTv.setGravity(Gravity.RIGHT);
muteIconTv.setTextColor(Theme.getInstance().getSendMessageTextColor(getContext()));
setTextSize(muteIconTv, R.dimen.dp13);
addView(muteIconTv);
isMute = true;
}
} else if (isMute) {
removeView(muteIconTv);
isMute = false;
}
if (room.getType() == ProtoGlobal.Room.Type.CHANNEL || room.getType() == ProtoGlobal.Room.Type.GROUP) {
if (!haveChatIcon) {
chatIconTv = new FontIconTextView(getContext());
setTextSize(chatIconTv, R.dimen.dp14);
addView(chatIconTv);
chatIconTv.setTextColor(Theme.getInstance().getSendMessageTextColor(chatIconTv.getContext()));
haveChatIcon = true;
}
if (room.getType() == ProtoGlobal.Room.Type.CHANNEL)
chatIconTv.setText(R.string.icon_channel);
else if (room.getType() == ProtoGlobal.Room.Type.GROUP)
chatIconTv.setText(R.string.icon_contacts);
} else if (haveChatIcon) {
removeView(chatIconTv);
haveChatIcon = false;
}
if (room.getTitle() != null && !haveName) {
roomNameTv = new TextView(getContext());
roomNameTv.setTypeface(ResourcesCompat.getFont(getContext(), R.font.main_font_bold));
setTextSize(roomNameTv, R.dimen.dp15);
roomNameTv.setSingleLine(true);
roomNameTv.setEllipsize(TextUtils.TruncateAt.END);
roomNameTv.setText(EmojiManager.getInstance().replaceEmoji(room.getTitle(), roomNameTv.getPaint().getFontMetricsInt(), -1, false));
roomNameTv.setTextColor(Theme.getInstance().getSendMessageTextColor(roomNameTv.getContext()));
roomNameTv.setGravity(isRtl ? Gravity.RIGHT : Gravity.LEFT | Gravity.CENTER_VERTICAL);
addView(roomNameTv);
haveName = true;
}
if (room.getLastMessage() != null) {
if (!haveLastMessage) {
lastMessageTv = new AppCompatTextView(getContext());
lastMessageTv.setPadding(4, 0, 4, 0);
lastMessageTv.setEllipsize(TextUtils.TruncateAt.END);
lastMessageTv.setGravity(isRtl ? Gravity.RIGHT : Gravity.LEFT | Gravity.CENTER_VERTICAL);
lastMessageTv.setSingleLine(true);
setTypeFace(lastMessageTv);
setTextSize(lastMessageTv, R.dimen.dp13);
addView(lastMessageTv);
haveLastMessage = true;
}
getLastMessage(room, lastMessageTv);
} else if (haveLastMessage) {
removeView(lastMessageTv);
haveLastMessage = false;
}
if (!(room.getUnreadCount() < 1)) {
if (!haveBadge) {
badgeView = new TextBadge(getContext());
setTypeFace(badgeView.getTextView());
addView(badgeView);
haveBadge = true;
}
if (room.getMute()) {
badgeView.setBadgeColor(getResources().getColor(R.color.gray_9d));
} else {
badgeView.setBadgeColor(Theme.getInstance().getAccentColor(badgeView.getContext()));
}
badgeView.setText(getUnreadCount(room.getUnreadCount()));
if (havePin) {
removeView(pinIcon);
}
} else if (haveBadge) {
removeView(badgeView);
if (havePin) {
removeView(pinIcon);
addView(pinIcon);
}
haveBadge = false;
}
if (haveLastMessage && room.getLastMessage().isAuthorMe()) {
if (!haveStatus) {
statusTv = new FontIconTextView(getContext());
setTextSize(statusTv, R.dimen.xlargeTextSize);
addView(statusTv);
haveStatus = true;
}
ProtoGlobal.RoomMessageStatus status = ProtoGlobal.RoomMessageStatus.UNRECOGNIZED;
if (room.getLastMessage().getStatus() != null) {
try {
status = ProtoGlobal.RoomMessageStatus.valueOf(room.getLastMessage().getStatus());
} catch (RuntimeException e) {
e.printStackTrace();
}
}
AppUtils.rightMessageStatus(statusTv, status, room.getLastMessage().isAuthorMe());
} else if (haveStatus) {
removeView(statusTv);
haveStatus = false;
}
if (isSelectedMode) {
if (!haveCheckBox) {
checkBox = new CheckBox(getContext(), R.drawable.round_check);
checkBox.setVisibility(VISIBLE);
addView(checkBox);
haveCheckBox = true;
}
} else if (haveCheckBox) {
removeView(checkBox);
haveCheckBox = false;
}
requestLayout();
}
Aggregations