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); }; }
public void saveMsg(string friend, AppCore.Message message) { string tmpMsgs = LegionUtils.parceToGson(msgs); appPreferences.saveKey(friend, tmpMsgs); saveRecentUser(friend, message); }
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); } }
public void saveMsg(string username) { string tmpMsgs = LegionUtils.parceToGson(msgs); appPreferences.saveKey(username, tmpMsgs); saveRecentUser(username); }
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); }
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); }
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) ); }
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); }
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); }
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); } }
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); }
/// <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); }
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); } } }
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); }); }
public List <string> listJidsRoster() { if (appPreferences.getValueKey(AppPreferences.JIDSFROM_SERVER) != null) { return(LegionUtils.getListStringJson(appPreferences.getValueKey(AppPreferences.JIDSFROM_SERVER))); } else { return(new List <string>()); } }
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); }
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); }
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(); } }
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); } }
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); } }
void validaSaveContactNext() { Log.Info("Load Contacts Complete"); if (user.users.Count > 0) { LegionUtils.saveFoundContacts(user.users.Distinct().ToList(), appPreferences, AppPreferences.CONTACTS); updateComplete(); } else { updateComplete(); } }
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); } }
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); } }
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); } }
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); }
void clearUnreadMessage() { string jidUser = ""; inChatJid = null; if (isGroupChat) { jidUser = groupFromGson.Jid; } else { jidUser = friend.Jid; } appPreferences.saveKeyMSGCount(LegionUtils.GetUserNameClear(jidUser.Split('@')[0]), 0); }
public void updateContatcs() { totalContactReady = 0; showProgress(); System.Threading.ThreadPool.QueueUserWorkItem(o => { contatcsBooks = LegionUtils.readContacts(addressBook); if (contatcsBooks == null) { updateListCardUi(); } processContacts(contatcsBooks); }); }
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(); } } }
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); } }
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); }); } } }