Beispiel #1
0
 public ChateCardAdapter(User user, Activity activity, AppCore.Message message, List <AppCore.Message> msgs)
 {
     this.user     = user;
     this.activity = activity;
     this.message  = message;
     this.msgs     = msgs;
 }
Beispiel #2
0
        public void saveMsg(string friend, AppCore.Message message)
        {
            string tmpMsgs = LegionUtils.parceToGson(msgs);

            appPreferences.saveKey(friend, tmpMsgs);
            saveRecentUser(friend, message);
        }
Beispiel #3
0
        List <User> usersByRecentConversation(Dictionary <string, AppCore.Message> recents)
        {
            List <User> usersFriend = new List <User>();

            if (recents != null)
            {
                foreach (var item in recents.Reverse())
                {
                    AppCore.Message m      = item.Value;
                    User            friend = new User();

                    friend.username = item.Key;
                    if (item.Value.GroupId != null)
                    {
                        friend.isGroup = true;
                    }
                    else
                    {
                        friend.Jid = friend.username;
                    }

                    //In Session Phone assumed callback menssages
                    if (LegionUtils.IsBase64String(m.Msg))
                    {
                        m.Msg = "@ Photo";
                    }
                    friend.Phone = LegionUtils.Truncate(m.Msg, 26);
                    string photo = appPreferences.getValueKey(friend.username + "_ICON");
                    if (photo != null || photo != "")
                    {
                        friend.Photo = photo;
                    }
                    usersFriend.Add(friend);
                }
            }

            // add groups list conversations
            List <AppCore.User> listGroupTmp = getGroupsTempToList(AppPreferences.GROUPS_TEMP);

            if (listGroupTmp != null)
            {
                //var varUser = listGroupTmp.Where(y => usersFriend.Any(z => z.Jid == y.Jid));

                List <string> jidstmps = new List <string>();
                foreach (AppCore.User u in usersFriend)
                {
                    jidstmps.Add(u.Jid);
                }

                foreach (AppCore.User g in listGroupTmp)
                {
                    if (!jidstmps.Contains(g.Jid))
                    {
                        usersFriend.Add(g);
                    }
                }
            }

            return(usersFriend);
        }
Beispiel #4
0
        public void msgFriend(object sender, MessageEventArgs e)
        {
            string userNameFriend = LegionUtils.GetUserNameClear(e.From);

            AppCore.Message m   = null;
            Bitmap          bit = null;

            //byte[] bytes = LegionUtils.base64ToByte(e.Body);
            //if (bytes != null)
            //{
            //	bit = BitmapFactory.DecodeByteArray(bytes, 0, bytes.Length);
            //}
            if (bit == null)
            {
                if (e.From.Contains(AppCore.Utils._MUS_SERVER))
                {
                    m = new AppCore.Message(e.From, e.Body, DateTime.Now, false, true);
                }
                else
                {
                    m = new AppCore.Message(e.From, e.Body, DateTime.Now, false);
                }
            }
            else
            {
                string fileName = LegionUtils.SaveBitmapGalerry(bit);
                if (e.From.Contains(AppCore.Utils._MUS_SERVER))
                {
                    m = new AppCore.Message(e.From, e.Body, DateTime.Now, false, true, fileName, true);
                }
                else
                {
                    m = new AppCore.Message(e.From, e.Body, DateTime.Now, false, fileName, true);
                }
            }

            this.message = m;
            if (this.msgs == null)
            {
                msgs = getMsgs(e.From);
            }
            this.msgs.Add(m);
            saveMsg(userNameFriend);

            if (friend != null)
            {
                if (friend.Jid.Split('@')[0].Equals(e.From))
                {
                    RefrashRecycleView(friend);
                }
                else
                {
                    CountMessage(sender, e);
                }
            }
        }
Beispiel #5
0
        void messageToGroup()
        {
            AppCore.Message m = new AppCore.Message(groupFromGson.Jid, edtMsg.Text, DateTime.Now, true, true);
            this.message = m;
            this.msgs.Add(m);

            sendMessageGroup(m.Msg);
            edtMsg.Text = "";
            saveMsg(m);
            hidenKeyBoard();
            rvList.SmoothScrollToPosition(msgs.Count - 1);
            RefrashRecycleView();
        }
Beispiel #6
0
        void messageToFriend(string image64, string filename)
        {
            AppCore.Message m = new AppCore.Message(friend.username, image64, DateTime.Now, true, filename, true);
            this.message = m;
            this.msgs.Add(m);

            sendMessage(image64);
            //edtMsg.Text = "";
            saveMsg();
            //hidenKeyBoard();
            rvList.SmoothScrollToPosition(msgs.Count - 1);
            RefrashRecycleView();
        }
Beispiel #7
0
        void messageToFriend()
        {
            AppCore.Message m = new AppCore.Message(friend.username, edtMsg.Text, DateTime.Now, true);
            this.message = m;
            this.msgs.Add(m);

            sendMessage(edtMsg.Text);
            edtMsg.Text = "";
            saveMsg();
            hidenKeyBoard();
            rvList.SmoothScrollToPosition(msgs.Count - 1);
            RefrashRecycleView();
        }
Beispiel #8
0
        void msgFriend(object sender, MessageEventArgs e)
        {
            string friend = e.From;
            int    index  = e.From.LastIndexOf("@");

            if (index > 0)
            {
                friend = e.From.Substring(0, index);
            }

            this.msgs = getMsgs(friend);
            AppCore.Message m = new AppCore.Message(friend, e.Body, DateTime.Now, false);
            this.msgs.Add(m);
            saveMsg(friend, m);
            //RefrashRecycleView();
        }
Beispiel #9
0
        public void saveMsg(AppCore.Message msg)
        {
            string tmpMsgs   = LegionUtils.parceToGson(msgs);
            string recentKey = null;

            if (msg.isGroup)
            {
                recentKey = msg.GroupId;
                appPreferences.saveKey(msg.GroupId, tmpMsgs);
            }
            else
            {
                recentKey = friend.username;
                appPreferences.saveKey(friend.username, tmpMsgs);
            }
            saveRecentUser(recentKey);
        }
Beispiel #10
0
        void saveRecentUser(string friend, AppCore.Message message)
        {
            recentConversationsUserName = userService.getRecentUsers(appPreferences);
            if (recentConversationsUserName.TryGetValue(friend, out message))
            {
                recentConversationsUserName.Remove(friend);
            }

            Dictionary <string, AppCore.Message> reTm = new Dictionary <string, AppCore.Message>();

            foreach (var item in recentConversationsUserName)
            {
                reTm.Add(item.Key, item.Value);
            }
            reTm.Add(friend, msgs[msgs.Count - 1]);
            string recentUserConv = LegionUtils.parceToGson(reTm);

            appPreferences.saveKey(AppPreferences.CONVERSA_BY_JID, recentUserConv);
        }