コード例 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.AddNewGroup);
            userGroups = listContacts();
            group      = new AppCore.User();
            listGroups = LegionUtils.getGroupsTempToList(AppPreferences.GROUPS_TEMP, appPreferences);

            var toolbar = loadToolBar(Resource.String.newGroup);

            toolbar.SetNavigationIcon(Resource.Drawable.back);

            txvNameGroup = (TextView)FindViewById(Resource.Id.groupName);
            imvAvatar    = (ImageView)FindViewById(Resource.Id.avatar);
            imvAvatar.SetBackgroundResource(Resource.Drawable.avatar_upload);

            mRecyclerView  = FindViewById <RecyclerView>(Resource.Id.recyclerView);
            mLayoutManager = new LinearLayoutManager(this);
            mRecyclerView.SetLayoutManager(mLayoutManager);
            NewGroupAdapter userAdapter = new NewGroupAdapter(userGroups, this);

            mRecyclerView.SetAdapter(userAdapter);

            imvAvatar.Click += delegate
            {
                var imageIntent = new Intent();
                imageIntent.SetType("image/*");
                imageIntent.SetAction(Intent.ActionGetContent);
                StartActivityForResult(
                    Intent.CreateChooser(imageIntent, "Select photo"), 0);
            };
        }
コード例 #2
0
        public void saveMsg(string friend, AppCore.Message message)
        {
            string tmpMsgs = LegionUtils.parceToGson(msgs);

            appPreferences.saveKey(friend, tmpMsgs);
            saveRecentUser(friend, message);
        }
コード例 #3
0
        public virtual void Xmpp_OnMessage(object sender, MessageEventArgs e)
        {
            if (userLastContacts == null || userLastContacts.Count == 0)
            {
                return;
            }

            if (myActivity.GetType() == typeof(ChatActivity))
            {
            }
            //RunOnUiThread(() =>
            setUserRecentChat(e.From, e.Body);
            msgFriend(sender, e);
            //	);
            //}

            //save ready msg to count
            string lastMsg      = appPreferences.getValueKey("LAST_MSG" + e.From);
            bool   isSaveRecMsg = true;

            if (lastMsg != null)
            {
                if (lastMsg.Equals(e.Body))
                {
                    isSaveRecMsg = false;
                }
            }
            if (LegionUtils.GetUserNameClear(e.From) != null && isSaveRecMsg == true)
            {
                appPreferences.saveKey("LAST_MSG" + e.From, e.Body);
                int countMsg = appPreferences.getValueKeyMSGCount(LegionUtils.GetUserNameClear(e.From));
                appPreferences.saveKeyMSGCount(LegionUtils.GetUserNameClear(e.From), countMsg + 1);
            }
        }
コード例 #4
0
        public void saveMsg(string username)
        {
            string tmpMsgs = LegionUtils.parceToGson(msgs);

            appPreferences.saveKey(username, tmpMsgs);
            saveRecentUser(username);
        }
コード例 #5
0
        void saveRecentUser(string username)
        {
            UserService useruserService = new UserService();

            if (recentConversationsUserName == null)
            {
                recentConversationsUserName = useruserService.getRecentUsers(appPreferences);
            }

            if (recentConversationsUserName.TryGetValue(username, out message))
            {
                recentConversationsUserName.Remove(username);
            }

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

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

            appPreferences.saveKey(AppPreferences.CONVERSA_BY_JID, recentUserConv);
        }
コード例 #6
0
        protected virtual void XmppClient_OnRosterItem(object sender, Matrix.Xmpp.Roster.RosterEventArgs e)
        {
            List <AppCore.User> uses = LegionUtils.getListJson(appPreferences.getValueKey(AppPreferences.CONTACTS));

            uses.Add(new AppCore.User(e.RosterItem.Jid.Bare, e.RosterItem.Jid.Bare.Split('@')[0]));
            LegionUtils.saveFoundContacts(uses, appPreferences, AppPreferences.CONTACTS);
        }
コード例 #7
0
        protected void addNewGroup(AppCore.User group)
        {
            group.Jid     = AddNewGroup();
            group.isGroup = true;
            listGroups.Add(group);
            saveSeachGroups(listGroups);

            ChangeGroupSubject(group.Jid, group.username);
            invictFriend(usersIsCheck(userGroups), group.Jid);

            RunOnUiThread(() =>
                          VisibleProgress(Resource.Id.pbHeaderProgress, VISIBLE)
                          );
            Task.Delay(TimeSpan.FromSeconds(5)).Wait();

            string groupJson = LegionUtils.parceToGson(group);

            appPreferences.saveKey(AppPreferences.GROUP_JSON, groupJson);

            var activityChat = new Intent(this, typeof(ChatActivity));

            activityChat.PutExtra("chatGroup", true);
            activityChat.PutExtra("groupJson", "");
            activityChat.PutExtra("isFromGroup", true);

            this.StartActivity(activityChat);
            OverridePendingTransition(Resource.Animator.slide_out_right, Resource.Animator.stable);
            RunOnUiThread(() =>
                          VisibleProgress(Resource.Id.pbHeaderProgress, INVISIBLE)
                          );
        }
コード例 #8
0
ファイル: SignUpActivity.cs プロジェクト: filiperamon/Beet
        private bool isValidLogin()
        {
            if (userName.Text.Length == 0 || userName.Text.Length < 6)
            {
                userName.SetError(GetString(Resource.String.edtLength), null);
                userName.RefreshDrawableState();
                return(false);
            }
            if (email.Text.Length == 0)
            {
                email.SetError(GetString(Resource.String.emailErro), null);
                email.RefreshDrawableState();
                return(false);
            }
            if (LegionUtils.isValidEmail(email.Text) == false)
            {
                email.SetError(GetString(Resource.String.emailErro), null);
                email.RefreshDrawableState();
                return(false);
            }

            if (password.Text.Length == 0 || password.Text.Length < 6)
            {
                password.SetError(GetString(Resource.String.edtLength), null);
                password.RefreshDrawableState();
                return(false);
            }

            return(true);
        }
コード例 #9
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);
        }
コード例 #10
0
 public void CountMessage(object sender, MessageEventArgs e)
 {
     if (LegionUtils.GetUserNameClear(e.From) != null)
     {
         appPreferences.saveKey("LAST_MSG" + e.From, e.Body);
         int countMsg = appPreferences.getValueKeyMSGCount(LegionUtils.GetUserNameClear(e.From));
         appPreferences.saveKeyMSGCount(LegionUtils.GetUserNameClear(e.From), countMsg + 1);
     }
 }
コード例 #11
0
ファイル: LegionUtils.cs プロジェクト: filiperamon/Beet
        public static Bitmap getCircleDrawable(Intent data, Activity activity)
        {
            Android.Net.Uri imageUri = data.Data;
            Bitmap          bitmap   = MediaStore.Images.Media.GetBitmap(activity.ContentResolver, imageUri);

            bitmap = LegionUtils.getResizedBitmap(bitmap, 170, 170);

            return(bitmap);
        }
コード例 #12
0
        /// <summary>
        /// Example of how to handle an incoming friend request
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected virtual void Xmpp_OnSubscribeRequest(object sender, SubscribeRequestEventArgs e)
        {
            List <AppCore.User> friedsReqs = LegionUtils.getListJson(
                appPreferences.getValueKey(AppPreferences.FRIEND_REQUEST));

            friedsReqs.Add(new AppCore.User(e.From, e.From.Split('@')[0]));

            LegionUtils.saveFoundContacts(friedsReqs, appPreferences, AppPreferences.FRIEND_REQUEST);
        }
コード例 #13
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);
                }
            }
        }
コード例 #14
0
ファイル: ActivityService.cs プロジェクト: filiperamon/Beet
        public void Xmpp_OnSubscribeRequest(object sender, SubscribeRequestEventArgs e)
        {
            ThreadPool.QueueUserWorkItem(o =>
            {
                List <AppCore.User> friedsReqs = LegionUtils.getListJson(
                    appPreferences.getValueKey(AppPreferences.FRIEND_REQUEST));
                friedsReqs.Add(new AppCore.User(e.From, e.From.Split('@')[0]));

                LegionUtils.saveFoundContacts(friedsReqs, appPreferences, AppPreferences.FRIEND_REQUEST);
            });
        }
コード例 #15
0
 public List <string> listJidsRoster()
 {
     if (appPreferences.getValueKey(AppPreferences.JIDSFROM_SERVER) != null)
     {
         return(LegionUtils.getListStringJson(appPreferences.getValueKey(AppPreferences.JIDSFROM_SERVER)));
     }
     else
     {
         return(new List <string>());
     }
 }
コード例 #16
0
ファイル: UserAdapter.cs プロジェクト: filiperamon/Beet
        void OnClick(string calltype, int position)
        {
            User   userChat     = user.users.ElementAt(position);
            string jsonTmp      = LegionUtils.parceToGson(userChat);
            var    activityChat = new Intent(activity, typeof(ChatActivity));

            activityChat.PutExtra("userChat", jsonTmp);
            activityChat.PutExtra("isDirectCall", true);
            activityChat.PutExtra("callType", calltype);
            activity.StartActivity(activityChat);
        }
コード例 #17
0
ファイル: LegionUtils.cs プロジェクト: filiperamon/Beet
        public static string bitmapToBase64(byte[] data)
        {
            Bitmap bitmap = BitmapFactory.DecodeByteArray(data, 0, data.Length);
            var    ms     = new MemoryStream();

            bitmap.Compress(Bitmap.CompressFormat.Png, 0, ms);
            var    imageByteArray     = ms.ToArray();
            string avatarBase64String = Convert.ToBase64String(imageByteArray);

            LegionUtils.disposeBitmap(bitmap);
            return(avatarBase64String);
        }
コード例 #18
0
 void importContacts()
 {
     try
     {
         this.users = LegionUtils.readContacts(addressBook);
         RunOnUiThread(() => processContacts(users));
     }
     catch (Exception ex) {
         Toast.MakeText(ApplicationContext, "some problem in importing " + ex.Message,
                        ToastLength.Short).Show();
     }
 }
コード例 #19
0
 public void updateIndexUserRecentMensages(MessageEventArgs e)
 {
     if (user.users.Any(u => u.Jid.Split('@')[0].Equals(e.From.Split('@')[0])))
     {
         setRecentUser(user.users, e);
     }
     else
     {
         List <AppCore.User> userGroups = LegionUtils.getGroupsTempToList(AppPreferences.GROUPS_TEMP, appPreferences);
         setRecentUser(userGroups, e);
     }
 }
コード例 #20
0
ファイル: ActivityService.cs プロジェクト: filiperamon/Beet
        public void XmppClient_OnRosterItem(object sender, Matrix.Xmpp.Roster.RosterEventArgs e)
        {
            List <AppCore.User> uses = LegionUtils.getListJson(appPreferences.getValueKey(AppPreferences.CONTACTS));

            uses.Add(new AppCore.User(e.RosterItem.Jid.Bare, e.RosterItem.Jid.Bare.Split('@')[0]));
            LegionUtils.saveFoundContacts(uses, appPreferences, AppPreferences.CONTACTS);

            if (context.GetType() == typeof(ContacPhoneActivity))
            {
                ContacPhoneActivity cpa = (ContacPhoneActivity)context;
                cpa.XmppClient_OnRosterItem(sender, e);
            }
        }
コード例 #21
0
 void validaSaveContactNext()
 {
     Log.Info("Load Contacts Complete");
     if (user.users.Count > 0)
     {
         LegionUtils.saveFoundContacts(user.users.Distinct().ToList(), appPreferences, AppPreferences.CONTACTS);
         updateComplete();
     }
     else
     {
         updateComplete();
     }
 }
コード例 #22
0
        public List <AppCore.Message> getMsgs(string friend)
        {
            List <AppCore.Message> ms =
                LegionUtils.getListMessageJson(appPreferences.getValueKey(friend));

            if (ms == null)
            {
                return(new List <AppCore.Message>());
            }
            else
            {
                return(ms);
            }
        }
コード例 #23
0
        public List <AppCore.Message> getMsgs(string username)
        {
            List <AppCore.Message> ms =
                LegionUtils.getListMessageJson(appPreferences.getValueKey(username));

            if (ms == null || ms.Equals(""))
            {
                return(new List <AppCore.Message>());
            }
            else
            {
                return(ms);
            }
        }
コード例 #24
0
ファイル: UserService.cs プロジェクト: filiperamon/Beet
        public Dictionary <string, AppCore.Message> getRecentUsers(AppPreferences appPreferences)
        {
            Dictionary <string, AppCore.Message> recentConversationsUserName =
                LegionUtils.getMenssagesByUserName(appPreferences.getValueKey(AppPreferences.CONVERSA_BY_JID));

            if (recentConversationsUserName == null)
            {
                return(new Dictionary <string, AppCore.Message>());
            }
            else
            {
                return(recentConversationsUserName);
            }
        }
コード例 #25
0
ファイル: LegionUtils.cs プロジェクト: filiperamon/Beet
        public static List <AppCore.User> getGroupsTempToList(string APP_PREF, AppPreferences appPref)
        {
            string jsonGroup = appPref.getValueKey(APP_PREF);
            List <AppCore.User> usersGroups = null;

            if (jsonGroup != null || jsonGroup != "")
            {
                usersGroups = LegionUtils.getListJson(jsonGroup);
            }
            else
            {
                usersGroups = new List <User>();
            }
            return(usersGroups);
        }
コード例 #26
0
        void clearUnreadMessage()
        {
            string jidUser = "";

            inChatJid = null;
            if (isGroupChat)
            {
                jidUser = groupFromGson.Jid;
            }
            else
            {
                jidUser = friend.Jid;
            }
            appPreferences.saveKeyMSGCount(LegionUtils.GetUserNameClear(jidUser.Split('@')[0]), 0);
        }
コード例 #27
0
        public void updateContatcs()
        {
            totalContactReady = 0;
            showProgress();

            System.Threading.ThreadPool.QueueUserWorkItem(o =>
            {
                contatcsBooks = LegionUtils.readContacts(addressBook);
                if (contatcsBooks == null)
                {
                    updateListCardUi();
                }
                processContacts(contatcsBooks);
            });
        }
コード例 #28
0
 void validaSaveContactNext()
 {
     if (totalContactReady == this.users.Count)
     {
         Log.Info("Load Contacts Complete");
         if (contactJIdList.Count > 0)
         {
             LegionUtils.saveFoundContacts(contactJIdList, appPreferences, AppPreferences.CONTACTS);
             loadNewActivity();
         }
         else
         {
             loadNewActivity();
         }
     }
 }
コード例 #29
0
ファイル: ActivityService.cs プロジェクト: filiperamon/Beet
        public void setNameFromGroup(string groupName, string From)
        {
            List <AppCore.User> groups = LegionUtils.getGroupsTempToList(AppPreferences.GROUPS_TEMP, appPreferences);
            var index = groups.FindIndex(c => c.Jid.Split('@')[0] == From.Split('@')[0]);

            groups[index].username = groupName;
            groups[index].Nick     = groupName;

            LegionUtils.saveFoundGroups(groups, appPreferences, AppPreferences.GROUPS_TEMP);

            if (context.GetType() == typeof(SessionActivity))
            {
                SessionActivity o = (SessionActivity)context;
                o.updateUIListGroupsUsers(groups);
            }
        }
コード例 #30
0
        void verifySubscriptFriend()
        {
            List <AppCore.User> friedsReqs = LegionUtils.getListJson(
                appPreferences.getValueKey(AppPreferences.FRIEND_REQUEST));

            if (friedsReqs.Count > 0)
            {
                foreach (AppCore.User u in friedsReqs)
                {
                    RunOnUiThread(() =>
                    {
                        alertSub(this, u);
                    });
                }
            }
        }