Search in sources :

Example 21 with RealmRegisteredInfo

use of net.iGap.realm.RealmRegisteredInfo 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);
    }
}
Also used : ViewStubCompat(androidx.appcompat.widget.ViewStubCompat) FontIconTextView(net.iGap.module.FontIconTextView) NumberTextView(net.iGap.messenger.ui.toolBar.NumberTextView) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) MaterialDesignTextView(net.iGap.module.MaterialDesignTextView) FontIconTextView(net.iGap.module.FontIconTextView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) RealmString(net.iGap.realm.RealmString) HelperString(net.iGap.helper.HelperString) RealmRoom(net.iGap.realm.RealmRoom) NumberTextView(net.iGap.messenger.ui.toolBar.NumberTextView) KeyboardView(net.iGap.libs.emojiKeyboard.KeyboardView) RecyclerView(androidx.recyclerview.widget.RecyclerView) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) EmojiView(net.iGap.libs.emojiKeyboard.EmojiView) BadgeView(net.iGap.adapter.items.chat.BadgeView) MaterialDesignTextView(net.iGap.module.MaterialDesignTextView) ImageView(android.widget.ImageView) CardView(androidx.cardview.widget.CardView) FontIconTextView(net.iGap.module.FontIconTextView) StructWebView(net.iGap.module.structs.StructWebView) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView) RealmRegisteredInfo(net.iGap.realm.RealmRegisteredInfo) SuppressLint(android.annotation.SuppressLint)

Example 22 with RealmRegisteredInfo

use of net.iGap.realm.RealmRegisteredInfo in project iGap-Android by KianIranian-STDG.

the class FragmentGroupProfileViewModel method onGroupAddMemberCallback.

private void onGroupAddMemberCallback() {
    G.onGroupAddMember = new OnGroupAddMember() {

        @Override
        public void onGroupAddMember(final Long roomIdUser, final Long userId) {
            G.handler.post(new Runnable() {

                @Override
                public void run() {
                    setMemberCount(roomIdUser);
                    RealmRegisteredInfo realmRegistered = DbManager.getInstance().doRealmTask(realm -> {
                        return RealmRegisteredInfo.getRegistrationInfo(realm, userId);
                    });
                    if (realmRegistered == null) {
                        if (roomIdUser == roomId) {
                            new RequestUserInfo().userInfo(userId, roomId + "");
                        }
                    }
                }
            });
        }

        @Override
        public void onError(int majorCode, int minorCode) {
        }
    };
}
Also used : RequestUserInfo(net.iGap.request.RequestUserInfo) OnGroupAddMember(net.iGap.observers.interfaces.OnGroupAddMember) RealmRegisteredInfo(net.iGap.realm.RealmRegisteredInfo)

Example 23 with RealmRegisteredInfo

use of net.iGap.realm.RealmRegisteredInfo in project iGap-Android by KianIranian-STDG.

the class UserContactsGetBlockedListResponse method handler.

@Override
public void handler() {
    super.handler();
    ProtoUserContactsGetBlockedList.UserContactsGetBlockedListResponse.Builder builder = (ProtoUserContactsGetBlockedList.UserContactsGetBlockedListResponse.Builder) message;
    List<ProtoUserContactsGetBlockedList.UserContactsGetBlockedListResponse.User> list = builder.getUserList();
    DbManager.getInstance().doRealmTask(realm -> {
        /**
         * reset blocked user in RealmRegisteredInfo and realm contact
         */
        realm.executeTransaction(new Realm.Transaction() {

            @Override
            public void execute(Realm realm) {
                RealmResults<RealmRegisteredInfo> results = realm.where(RealmRegisteredInfo.class).equalTo("blockUser", true).findAll();
                for (RealmRegisteredInfo item : results) {
                    item.setBlockUser(false);
                }
                RealmResults<RealmContacts> resultsContacts = realm.where(RealmContacts.class).equalTo("blockUser", true).findAll();
                for (RealmContacts item : resultsContacts) {
                    item.setBlockUser(false);
                }
            }
        });
        for (ProtoUserContactsGetBlockedList.UserContactsGetBlockedListResponse.User user : list) {
            RealmRegisteredInfo.getRegistrationInfo(user.getUserId(), user.getCacheId(), realm, new OnInfo() {

                @Override
                public void onInfo(Long registeredId) {
                    RealmRegisteredInfo.updateBlock(registeredId, true);
                    RealmContacts.updateBlock(registeredId, true);
                }
            });
        }
    });
}
Also used : RealmRegisteredInfo(net.iGap.realm.RealmRegisteredInfo) OnInfo(net.iGap.observers.interfaces.OnInfo) Realm(io.realm.Realm) ProtoUserContactsGetBlockedList(net.iGap.proto.ProtoUserContactsGetBlockedList) RealmContacts(net.iGap.realm.RealmContacts) RealmResults(io.realm.RealmResults)

Example 24 with RealmRegisteredInfo

use of net.iGap.realm.RealmRegisteredInfo in project iGap-Android by KianIranian-STDG.

the class FragmentMap method initComponent.

private void initComponent(View view, int type, long roomId, String senderId) {
    SupportMapFragment mapFragment = new SupportMapFragment();
    if (getActivity() != null) {
        new HelperFragment(getActivity().getSupportFragmentManager(), mapFragment).setReplace(false).setAddToBackStack(false).setResourceContainer(mf_fragment_map_view).load();
    }
    mapFragment.getMapAsync(FragmentMap.this);
    rvSendPosition = view.findViewById(R.id.mf_rv_send_position);
    rvSendPosition.setBackgroundColor(new Theme().getPrimaryColor(getContext()));
    if (mode == Mode.sendPosition) {
        fabOpenMap.hide();
        rvSendPosition.setVisibility(View.VISIBLE);
        rvSeePosition.setVisibility(View.GONE);
        rvSendPosition.setOnClickListener(this);
    } else if (mode == Mode.seePosition) {
        rvSeePosition.setVisibility(View.VISIBLE);
        fabOpenMap.show();
        rvSendPosition.setVisibility(View.GONE);
        fabOpenMap.setOnClickListener(this);
        DbManager.getInstance().doRealmTask(realm -> {
            CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fabOpenMap.getLayoutParams();
            if (HelperCalander.isPersianUnicode) {
                // params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
                params.anchorGravity = Gravity.LEFT | Gravity.BOTTOM;
                txtUserName.setGravity(Gravity.RIGHT);
                ((RelativeLayout.LayoutParams) txtUserName.getLayoutParams()).addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            } else {
                // params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
                params.anchorGravity = Gravity.RIGHT | Gravity.BOTTOM;
                txtUserName.setGravity(Gravity.LEFT);
                ((RelativeLayout.LayoutParams) txtUserName.getLayoutParams()).addRule(RelativeLayout.ALIGN_PARENT_LEFT);
            }
            if (type == ProtoGlobal.Room.Type.CHAT.getNumber() || type == ProtoGlobal.Room.Type.GROUP.getNumber()) {
                RealmRegisteredInfo realmRegisteredInfo = realm.where(RealmRegisteredInfo.class).equalTo("id", Long.parseLong(senderId)).findFirst();
                txtUserName.setText(realmRegisteredInfo.getDisplayName());
                setAvatar(Long.parseLong(senderId));
            } else {
                RealmRoom realmRoom = realm.where(RealmRoom.class).equalTo("id", roomId).findFirst();
                txtUserName.setText(realmRoom.getTitle());
                setAvatar(roomId);
            }
        });
    }
}
Also used : CameraUpdateFactory(com.google.android.gms.maps.CameraUpdateFactory) Bundle(android.os.Bundle) PackageManager(android.content.pm.PackageManager) Uri(android.net.Uri) ImageView(android.widget.ImageView) Theme(net.iGap.module.Theme) LocationListener(android.location.LocationListener) Drawable(android.graphics.drawable.Drawable) G(net.iGap.G) ColorStateList(android.content.res.ColorStateList) HelperSetAction(net.iGap.helper.HelperSetAction) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) Display(android.view.Display) View(android.view.View) HelperError(net.iGap.helper.HelperError) ContextCompat(androidx.core.content.ContextCompat) HelperFragment(net.iGap.helper.HelperFragment) Log(android.util.Log) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType) CoordinatorLayout(androidx.coordinatorlayout.widget.CoordinatorLayout) HelperCalander(net.iGap.helper.HelperCalander) LatLng(com.google.android.gms.maps.model.LatLng) AsyncTask(android.os.AsyncTask) CameraPosition(com.google.android.gms.maps.model.CameraPosition) RealmRoom(net.iGap.realm.RealmRoom) PorterDuff(android.graphics.PorterDuff) ViewGroup(android.view.ViewGroup) FileNotFoundException(java.io.FileNotFoundException) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) RealmRegisteredInfo(net.iGap.realm.RealmRegisteredInfo) ActivityNotFoundException(android.content.ActivityNotFoundException) G.isLocationFromBot(net.iGap.G.isLocationFromBot) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) RelativeLayout(android.widget.RelativeLayout) Location(android.location.Location) Marker(com.google.android.gms.maps.model.Marker) LocationManager(android.location.LocationManager) R.id.mf_fragment_map_view(net.iGap.R.id.mf_fragment_map_view) Context(android.content.Context) Criteria(android.location.Criteria) Intent(android.content.Intent) BitmapFactory(android.graphics.BitmapFactory) SuppressLint(android.annotation.SuppressLint) Build(android.os.Build) SupportMapFragment(com.google.android.gms.maps.SupportMapFragment) AvatarHandler(net.iGap.helper.avatar.AvatarHandler) OutputStream(java.io.OutputStream) LayoutInflater(android.view.LayoutInflater) ActivityCompat(androidx.core.app.ActivityCompat) MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) FileOutputStream(java.io.FileOutputStream) Point(android.graphics.Point) File(java.io.File) Color(android.graphics.Color) Gravity(android.view.Gravity) OnMapReadyCallback(com.google.android.gms.maps.OnMapReadyCallback) HelperString(net.iGap.helper.HelperString) Bitmap(android.graphics.Bitmap) ProtoGlobal(net.iGap.proto.ProtoGlobal) R(net.iGap.R) GoogleMap(com.google.android.gms.maps.GoogleMap) DbManager(net.iGap.module.accountManager.DbManager) InputStream(java.io.InputStream) CoordinatorLayout(androidx.coordinatorlayout.widget.CoordinatorLayout) SupportMapFragment(com.google.android.gms.maps.SupportMapFragment) RelativeLayout(android.widget.RelativeLayout) Theme(net.iGap.module.Theme) RealmRoom(net.iGap.realm.RealmRoom) HelperFragment(net.iGap.helper.HelperFragment) RealmRegisteredInfo(net.iGap.realm.RealmRegisteredInfo)

Example 25 with RealmRegisteredInfo

use of net.iGap.realm.RealmRegisteredInfo in project iGap-Android by KianIranian-STDG.

the class FragmentiGapMap method getInitials.

private static Bitmap getInitials(Realm realm, long userId) {
    String initials = "";
    String color = "";
    RealmRegisteredInfo realmRegisteredInfo = RealmRegisteredInfo.getRegistrationInfo(realm, userId);
    if (realmRegisteredInfo != null) {
        initials = realmRegisteredInfo.getInitials();
        color = realmRegisteredInfo.getColor();
    }
    return HelperImageBackColor.drawAlphabetOnPicture((int) G.context.getResources().getDimension(R.dimen.dp60), initials, color);
}
Also used : RealmRegisteredInfo(net.iGap.realm.RealmRegisteredInfo)

Aggregations

RealmRegisteredInfo (net.iGap.realm.RealmRegisteredInfo)37 ArrayList (java.util.ArrayList)15 View (android.view.View)13 RealmRoom (net.iGap.realm.RealmRoom)12 List (java.util.List)11 TextView (android.widget.TextView)10 RecyclerView (androidx.recyclerview.widget.RecyclerView)10 G (net.iGap.G)10 R (net.iGap.R)10 DbManager (net.iGap.module.accountManager.DbManager)10 ProtoGlobal (net.iGap.proto.ProtoGlobal)10 ViewGroup (android.view.ViewGroup)9 AvatarHandler (net.iGap.helper.avatar.AvatarHandler)9 Bundle (android.os.Bundle)8 AppCompatTextView (androidx.appcompat.widget.AppCompatTextView)8 File (java.io.File)8 Log (android.util.Log)7 LayoutInflater (android.view.LayoutInflater)7 Nullable (androidx.annotation.Nullable)7 RequestUserInfo (net.iGap.request.RequestUserInfo)7