Search in sources :

Example 1 with CheckBox

use of net.iGap.module.customView.CheckBox 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();
}
Also used : CircleImageView(net.iGap.module.CircleImageView) IconView(net.iGap.messenger.ui.components.IconView) CheckBox(net.iGap.module.customView.CheckBox) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) FontIconTextView(net.iGap.module.FontIconTextView) ProtoGlobal(net.iGap.proto.ProtoGlobal) FontIconTextView(net.iGap.module.FontIconTextView) TextView(android.widget.TextView) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) TextBadge(net.iGap.module.customView.TextBadge)

Example 2 with CheckBox

use of net.iGap.module.customView.CheckBox in project iGap-Android by KianIranian-STDG.

the class ViewMaker method getViewItemCall.

// *******************************************************************************************
public static View getViewItemCall(Context context) {
    LinearLayout linearLayout_205 = new LinearLayout(context);
    linearLayout_205.setId(R.id.mainContainer);
    LinearLayout.LayoutParams layout_218 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    linearLayout_205.setLayoutParams(layout_218);
    TypedValue rippleView = new TypedValue();
    context.getTheme().resolveAttribute(android.R.attr.selectableItemBackground, rippleView, true);
    linearLayout_205.setBackgroundResource(rippleView.resourceId);
    FrameLayout avatarContainer = new FrameLayout(context);
    avatarContainer.setId(R.id.avatarContainer);
    linearLayout_205.addView(avatarContainer, LayoutCreator.createLinear(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, CENTER, 10, 0, 10, 0));
    CheckBox checkBox = new CheckBox(context);
    checkBox.setId(R.id.fcsl_check_box);
    checkBox.setVisibility(View.VISIBLE);
    checkBox.setClickable(false);
    CircleImageView fcsl_imv_picture = new CircleImageView(context);
    fcsl_imv_picture.setId(R.id.fcsl_imv_picture);
    avatarContainer.addView(fcsl_imv_picture, LayoutCreator.createFrame(48, 48, CENTER));
    avatarContainer.addView(checkBox, LayoutCreator.createFrame(20, 20, Gravity.BOTTOM | END));
    LinearLayout linearLayout_71 = new LinearLayout(context);
    linearLayout_71.setOrientation(VERTICAL);
    LinearLayout.LayoutParams layout_794 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, i_Dp(R.dimen.dp68));
    linearLayout_71.setLayoutParams(layout_794);
    LinearLayout linearLayout_470 = new LinearLayout(context);
    linearLayout_470.setOrientation(HORIZONTAL);
    LinearLayout.LayoutParams layout_822 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1);
    linearLayout_470.setPadding(0, i_Dp(R.dimen.dp12), 0, 0);
    linearLayout_470.setLayoutParams(layout_822);
    LinearLayout linearLayout_983 = new LinearLayout(context);
    linearLayout_983.setOrientation(VERTICAL);
    LinearLayout.LayoutParams layout_313 = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1);
    layout_313.leftMargin = i_Dp(R.dimen.dp6);
    linearLayout_983.setLayoutParams(layout_313);
    AppCompatTextView fcsl_txt_name = new AppCompatTextView(context);
    fcsl_txt_name.setId(R.id.fcsl_txt_name);
    fcsl_txt_name.setPadding(0, 0, 0, dpToPixel(1));
    fcsl_txt_name.setText("Name");
    fcsl_txt_name.setSingleLine(true);
    fcsl_txt_name.setTextColor(Theme.getInstance().getTitleTextColor(context));
    setTextSize(fcsl_txt_name, R.dimen.standardTextSize);
    fcsl_txt_name.setTypeface(ResourcesCompat.getFont(fcsl_txt_name.getContext(), R.font.main_font));
    LinearLayout.LayoutParams layout_415 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layout_415.gravity = Gravity.START;
    fcsl_txt_name.setLayoutParams(layout_415);
    linearLayout_983.addView(fcsl_txt_name);
    LinearLayout linearLayout_976 = new LinearLayout(G.context);
    linearLayout_976.setOrientation(HORIZONTAL);
    LinearLayout.LayoutParams layout_106 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    linearLayout_976.setLayoutParams(layout_106);
    AppCompatTextView fcsl_txt_time_info = new AppCompatTextView(G.context);
    fcsl_txt_time_info.setId(R.id.fcsl_txt_time_info);
    fcsl_txt_time_info.setGravity(Gravity.START);
    fcsl_txt_time_info.setSingleLine(true);
    fcsl_txt_time_info.setText("(4) 9:24 am");
    fcsl_txt_time_info.setTextColor(Theme.getInstance().getSubTitleColor(context));
    setTextSize(fcsl_txt_time_info, R.dimen.smallTextSize);
    fcsl_txt_time_info.setTypeface(ResourcesCompat.getFont(fcsl_txt_time_info.getContext(), R.font.main_font));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        fcsl_txt_time_info.setTextDirection(View.TEXT_DIRECTION_LOCALE);
    }
    LinearLayout.LayoutParams layout_959 = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1);
    fcsl_txt_time_info.setLayoutParams(layout_959);
    linearLayout_976.addView(fcsl_txt_time_info);
    linearLayout_983.addView(linearLayout_976);
    linearLayout_470.addView(linearLayout_983);
    LinearLayout linearLayout_202 = new LinearLayout(context);
    linearLayout_202.setOrientation(VERTICAL);
    LinearLayout.LayoutParams layout_803 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT);
    layout_803.rightMargin = i_Dp(R.dimen.dp8);
    layout_803.leftMargin = i_Dp(R.dimen.dp8);
    linearLayout_202.setLayoutParams(layout_803);
    MaterialDesignTextView fcsl_txt_icon = new MaterialDesignTextView(context);
    fcsl_txt_icon.setId(R.id.fcsl_txt_icon);
    fcsl_txt_icon.setText(R.string.icon_single_contact);
    fcsl_txt_icon.setTextColor(ContextCompat.getColor(context, R.color.green));
    setTextSize(fcsl_txt_icon, R.dimen.dp18);
    LinearLayout.LayoutParams layout_178 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layout_178.gravity = Gravity.END;
    fcsl_txt_icon.setLayoutParams(layout_178);
    linearLayout_202.addView(fcsl_txt_icon);
    AppCompatTextView fcsl_txt_dureation_time = new AppCompatTextView(context);
    fcsl_txt_dureation_time.setId(R.id.fcsl_txt_dureation_time);
    fcsl_txt_dureation_time.setText("2:24");
    fcsl_txt_dureation_time.setTextColor(ContextCompat.getColor(context, R.color.btn_start_page5));
    setTextSize(fcsl_txt_dureation_time, R.dimen.dp12);
    fcsl_txt_dureation_time.setTypeface(ResourcesCompat.getFont(fcsl_txt_dureation_time.getContext(), R.font.main_font));
    LinearLayout.LayoutParams layout_483 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    fcsl_txt_dureation_time.setLayoutParams(layout_483);
    linearLayout_202.addView(fcsl_txt_dureation_time);
    linearLayout_470.addView(linearLayout_202);
    linearLayout_71.addView(linearLayout_470);
    View textView_316 = new View(context);
    textView_316.setBackgroundColor(G.context.getResources().getColor(R.color.gray_3c));
    LinearLayout.LayoutParams layout_241 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1);
    textView_316.setLayoutParams(layout_241);
    linearLayout_71.addView(textView_316);
    linearLayout_205.addView(linearLayout_71);
    return linearLayout_205;
}
Also used : CircleImageView(net.iGap.module.CircleImageView) MaterialDesignTextView(net.iGap.module.MaterialDesignTextView) CheckBox(net.iGap.module.customView.CheckBox) FrameLayout(android.widget.FrameLayout) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) View(android.view.View) MaterialDesignTextView(net.iGap.module.MaterialDesignTextView) CircleImageView(net.iGap.module.CircleImageView) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout) TypedValue(android.util.TypedValue)

Aggregations

TextView (android.widget.TextView)2 AppCompatImageView (androidx.appcompat.widget.AppCompatImageView)2 AppCompatTextView (androidx.appcompat.widget.AppCompatTextView)2 CircleImageView (net.iGap.module.CircleImageView)2 CheckBox (net.iGap.module.customView.CheckBox)2 TypedValue (android.util.TypedValue)1 View (android.view.View)1 FrameLayout (android.widget.FrameLayout)1 LinearLayout (android.widget.LinearLayout)1 IconView (net.iGap.messenger.ui.components.IconView)1 FontIconTextView (net.iGap.module.FontIconTextView)1 MaterialDesignTextView (net.iGap.module.MaterialDesignTextView)1 TextBadge (net.iGap.module.customView.TextBadge)1 ProtoGlobal (net.iGap.proto.ProtoGlobal)1