private void showParticipants(object s, EventArgs e, List<UserDB> contacts) { contactsDialog = new Dialog (this, Resource.Style.lightbox_dialog); contactsDialog.SetContentView (Resource.Layout.ModalContactsConversation); LinearLayout mainLayout = ((LinearLayout)contactsDialog.FindViewById (Resource.Id.contactMainLayout)); Context localContext = mainLayout.Context; List<Guid> profilePicsToBeGrabbed = new List<Guid> (); RunOnUiThread (delegate { for (int n = 0; n < contacts.Count; n++) { LinearLayout layout = new LinearLayout (context); layout.Orientation = Android.Widget.Orientation.Horizontal; layout.LayoutParameters = new ViewGroup.LayoutParams (LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent); layout.SetPadding ((int)ImageHelper.convertDpToPixel (20f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), (int)ImageHelper.convertDpToPixel (10f, context)); ImageView profilepic = new ImageView (context); profilepic.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (60f, context), (int)ImageHelper.convertDpToPixel (60f, context)); profilepic.Tag = new Java.Lang.String ("profilepic_" + contacts [n].AccountID); if (contacts [n].HasProfileImage == true && contacts [n].Picture.Length == 0) { profilePicsToBeGrabbed.Add (contacts [n].AccountID); } else { if (contacts [n].Picture.Length > 0) LoadUserImage (contacts [n], profilepic); else profilepic.SetImageDrawable (Application.Context.Resources.GetDrawable (Resource.Drawable.defaultuserimage)); } layout.AddView (profilepic); TextView text = new TextView (context); text.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (235f, context), (int)ImageHelper.convertDpToPixel (40f, context)); text.SetPadding ((int)ImageHelper.convertDpToPixel (10f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), 0); text.Gravity = GravityFlags.CenterVertical; text.TextSize = 16f; text.SetTextColor (Android.Graphics.Color.White); if (contacts [n].FirstName != "" || contacts [n].LastName != "") { text.Text = contacts [n].FirstName + " " + contacts [n].LastName; } else { text.Text = contacts [n].EmailAddress; } layout.AddView (text); mainLayout.AddView (layout); } }); ((Button)contactsDialog.FindViewById (Resource.Id.btnCancel)).Click += delegate { DismissModalPreviewDialog (); }; if (profilePicsToBeGrabbed.Count > 0) { cpUI = 0; LOLConnectClient service = new LOLConnectClient (LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint); service.UserGetImageDataCompleted += Service_UserGetImageDataCompleted; service.UserGetImageDataAsync (AndroidData.CurrentUser.AccountID, profilePicsToBeGrabbed [0], new Guid (AndroidData.ServiceAuthToken)); } contactsDialog.Show (); }
private void CreatePreviewUI() { int m = 0; isConversation = false; header = FindViewById<TextView> (Resource.Id.txtFirstScreenHeader); Header.headertext = Application.Context.Resources.GetString (Resource.String.messageListHeaderViewTitle); Header.fontsize = 36f; ImageHelper.fontSizeInfo (header.Context); header.SetTextSize (Android.Util.ComplexUnitType.Dip, Header.fontsize); header.Text = Header.headertext; listWrapper.RemoveAllViewsInLayout (); Dictionary<string, MessageInfo> latestMessages = new Dictionary<string, MessageInfo> (); Dictionary<string, string> unreadMessageCounts = new Dictionary<string, string> (); string ownerAccountId = AndroidData.CurrentUser.AccountID.ToString (); foreach (ConversationInfo eachConversationInfo in this.conversationItems.Values) { MessageInfo latestMessage = eachConversationInfo.GetLatestMessage (); string messageCountStr = eachConversationInfo.Messages .Count (s => s.Value.Message.MessageRecipientDBList.Count (t => t.AccountGuid == ownerAccountId && !t.IsRead) > 0) .ToString (); latestMessages.Add (eachConversationInfo.ConversationID, latestMessage); unreadMessageCounts.Add (eachConversationInfo.ConversationID, messageCountStr); } if (getGuid != null) getGuid.Clear (); RunOnUiThread (delegate { foreach (KeyValuePair<string, MessageInfo> eachMessage in latestMessages) { eachMessage.Value.Message.MessageRecipientDBList = eachMessage.Value.Message.MessageRecipientDBList.Where (x => x != null).ToList (); string messager = string.Empty; string tmpName = string.Empty; ImageView random = null; LinearLayout.LayoutParams randomParams = null; LinearLayout layout = new LinearLayout (context); LinearLayout.LayoutParams layoutparams = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent); layoutparams.SetMargins (0, 0, 0, (int)ImageHelper.convertDpToPixel (10f, context)); layout.LayoutParameters = layoutparams; layout.Orientation = Android.Widget.Orientation.Horizontal; layout.SetGravity (GravityFlags.Center); layout.SetPadding ((int)ImageHelper.convertDpToPixel (5f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), (int)ImageHelper.convertDpToPixel (10f, context)); ImageView profilepic = new ImageView (context); profilepic.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (55f, context), (int)ImageHelper.convertDpToPixel (100f, context)); if (eachMessage.Key != null) { UserDB who = null; if (eachMessage.Value.MessageUser != null) who = eachMessage.Value.MessageUser; else who = null; if (who.AccountGuid == AndroidData.CurrentUser.AccountID.ToString ()) who = dbm.GetUserWithAccountID (eachMessage.Value.Message.MessageRecipientDBList [0].AccountGuid); if (who == null) { #if DEBUG System.Diagnostics.Debug.WriteLine ("UserDB = null for {0}, bugging out", latestMessages); #endif m++; } else { profilepic.Tag = new Java.Lang.String ("profilepic_" + who.AccountID); profilepic.SetImageResource (Resource.Drawable.defaultuserimage); layout.AddView (profilepic); if (eachMessage.Value.Message.MessageRecipientDBList.Count > 1) { List<UserDB> imageList = new List<UserDB> (); foreach (MessageRecipientDB human in eachMessage.Value.Message.MessageRecipientDBList) { imageList.Add (dbm.GetUserWithAccountID (human.AccountGuid)); } RunOnUiThread (delegate { createMultipleForContact (imageList); if (multipleContact != null) profilepic.SetImageBitmap (multipleContact); else profilepic.SetImageResource (Resource.Drawable.defaultuserimage); }); } else { if (who.Picture.Length == 0 && who.HasProfileImage) getGuid.Add (who.AccountID); else { if (who.Picture.Length > 0) this.LoadUserImage (who, profilepic); else profilepic.SetImageResource (Resource.Drawable.defaultuserimage); } } LinearLayout layout2 = new LinearLayout (context); layout2.Orientation = Orientation.Vertical; layout2.SetGravity (GravityFlags.Left); using (TextView name = new TextView (context)) { name.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (240f, context), (int)ImageHelper.convertDpToPixel (25f, context)); name.SetPadding ((int)ImageHelper.convertDpToPixel (20f, context), 0, (int)ImageHelper.convertDpToPixel (20f, context), 0); name.Gravity = GravityFlags.Left; name.SetTextColor (Color.White); name.TextSize = 16f; tmpName = who.FirstName + " " + who.LastName; if (eachMessage.Value.Message.MessageRecipientDBList.Count > 1) { if (eachMessage.Value.Message.MessageRecipientDBList.Count == 1 || eachMessage.Value.Message.MessageRecipientDBList.Count - 1 == 1) tmpName += " 1 other"; else tmpName += " " + string.Format ("{0} others", eachMessage.Value.Message.MessageRecipientDBList.Count - 1); } name.Text = tmpName; layout2.AddView (name); } if (eachMessage.Value.Message.MessageStepDBList.Count == 1 && eachMessage.Value.Message.MessageStepDBList [0].StepType == MessageStep.StepTypes.Text) { using (TextView txtMessage = new TextView (context)) { using (LinearLayout.LayoutParams txtMessageParams = new LinearLayout.LayoutParams ((int)ImageHelper.convertDpToPixel (220f, context), (int)ImageHelper.convertDpToPixel (60f, context))) { txtMessageParams.SetMargins ((int)ImageHelper.convertDpToPixel (10f, context), 0, 0, 0); txtMessage.LayoutParameters = txtMessageParams; } txtMessage.SetPadding ((int)ImageHelper.convertDpToPixel (20f, context), (int)ImageHelper.convertDpToPixel (10f, context), (int)ImageHelper.convertDpToPixel (20f, context), (int)ImageHelper.convertDpToPixel (10f, context)); txtMessage.Gravity = GravityFlags.CenterVertical; if (eachMessage.Value.Message.FromAccountID == AndroidData.CurrentUser.AccountID) txtMessage.SetBackgroundResource (Resource.Drawable.bubblesolidright); else txtMessage.SetBackgroundResource (Resource.Drawable.bubblesolidleft); txtMessage.TextSize = 16f; for (int e = 0; e < eachMessage.Value.Message.MessageStepDBList.Count; ++e) { if (!string.IsNullOrEmpty (eachMessage.Value.Message.MessageStepDBList [e].MessageText)) { messager = eachMessage.Value.Message.MessageStepDBList [e].MessageText; break; } } if (string.IsNullOrEmpty (messager)) messager = ""; int nolines = (int)(ImageHelper.convertDpToPixel ((messager.Length / 27f) * 12f, context)); txtMessage.SetHeight (nolines); txtMessage.SetTextColor (Android.Graphics.Color.Black); txtMessage.Text = messager; txtMessage.ContentDescription = eachMessage.Key; txtMessage.Click += ConversationItem_Clicked; layout2.AddView (txtMessage); } } else { int text = 0; for (int tt = 0; tt < eachMessage.Value.Message.MessageStepDBList.Count; ++tt) { if (eachMessage.Value.Message.MessageStepDBList [tt].StepType == MessageStep.StepTypes.Text) text++; } LinearLayout layout3 = new LinearLayout (context); LinearLayout.LayoutParams layout3params = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent); layout3params.SetMargins ((int)ImageHelper.convertDpToPixel (10f, context), (int)ImageHelper.convertDpToPixel (5f, context), 0, (int)ImageHelper.convertDpToPixel (5f, context)); layout3.LayoutParameters = layout3params; layout3.Orientation = Orientation.Horizontal; layout3.SetGravity (GravityFlags.Left); layout3.ContentDescription = eachMessage.Key; layout3.Click += ConversationLayItem_Clicked; layout3.SetBackgroundResource (Resource.Drawable.attachmentspreviewbkgr); layout3.SetVerticalGravity (GravityFlags.CenterVertical); layout3.SetMinimumHeight (30); layout3.SetPadding ((int)ImageHelper.convertDpToPixel (10f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), 0); int end = eachMessage.Value.Message.MessageStepDBList.Count > 3 ? 3 : eachMessage.Value.Message.MessageStepDBList.Count; for (int i = 0; i < end; ++i) { switch (eachMessage.Value.Message.MessageStepDBList [i].StepType) { case LOLMessageDelivery.MessageStep.StepTypes.Text: if (text == 1) { using (TextView txtMessage = new TextView (context)) { using (LinearLayout.LayoutParams txtMessageParams = new LinearLayout.LayoutParams ((int)ImageHelper.convertDpToPixel (220f, context), (int)ImageHelper.convertDpToPixel (60f, context))) { txtMessageParams.SetMargins ((int)ImageHelper.convertDpToPixel (10f, context), 0, 0, 0); txtMessage.LayoutParameters = txtMessageParams; } txtMessage.SetPadding ((int)ImageHelper.convertDpToPixel (20f, context), (int)ImageHelper.convertDpToPixel (10f, context), (int)ImageHelper.convertDpToPixel (20f, context), (int)ImageHelper.convertDpToPixel (10f, context)); txtMessage.Gravity = GravityFlags.CenterVertical; if (eachMessage.Value.Message.FromAccountID == AndroidData.CurrentUser.AccountID) txtMessage.SetBackgroundResource (Resource.Drawable.bubblesolidright); else txtMessage.SetBackgroundResource (Resource.Drawable.bubblesolidleft); txtMessage.TextSize = 16f; for (int e = 0; e < eachMessage.Value.Message.MessageStepDBList.Count; ++e) { if (!string.IsNullOrEmpty (eachMessage.Value.Message.MessageStepDBList [e].MessageText)) { messager = eachMessage.Value.Message.MessageStepDBList [e].MessageText; break; } } if (string.IsNullOrEmpty (messager)) messager = "No text message found"; int nolines = (int)(ImageHelper.convertDpToPixel ((messager.Length / 27f) * 12f, context)); txtMessage.SetHeight (nolines); txtMessage.SetTextColor (Android.Graphics.Color.Black); txtMessage.Text = messager; txtMessage.ContentDescription = eachMessage.Key; txtMessage.Click += ConversationItem_Clicked; layout2.AddView (txtMessage); } } else { if (text > 1) { using (random = new ImageView (context)) { using (randomParams = new LinearLayout.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { randomParams.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (5f, context), 0); random.LayoutParameters = randomParams; } random.ContentDescription = eachMessage.Key; random.Click += ConversationPicItem_Clicked; random.SetBackgroundResource (Resource.Drawable.icotext); layout3.AddView (random); } } } break; case LOLMessageDelivery.MessageStep.StepTypes.Animation: using (random = new ImageView (context)) { using (randomParams = new LinearLayout.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { randomParams.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (5f, context), 0); random.LayoutParameters = randomParams; } random.ContentDescription = eachMessage.Key; random.Click += ConversationPicItem_Clicked; random.SetBackgroundResource (Resource.Drawable.icoanimation); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Comicon: using (random = new ImageView (context)) { using (randomParams = new LinearLayout.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { randomParams.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (5f, context), 0); random.LayoutParameters = randomParams; } random.ContentDescription = eachMessage.Key; random.Click += ConversationPicItem_Clicked; random.SetBackgroundResource (Resource.Drawable.icocomicons); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Comix: using (random = new ImageView (context)) { using (randomParams = new LinearLayout.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { randomParams.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (5f, context), 0); random.LayoutParameters = randomParams; } random.ContentDescription = eachMessage.Key; random.Click += ConversationPicItem_Clicked; random.SetBackgroundResource (Resource.Drawable.icocomix); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Emoticon: using (random = new ImageView (context)) { using (randomParams = new LinearLayout.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { randomParams.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (5f, context), 0); random.LayoutParameters = randomParams; } random.ContentDescription = eachMessage.Key; random.Click += ConversationPicItem_Clicked; random.SetBackgroundResource (Resource.Drawable.icoemoticons); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Polling: using (random = new ImageView (context)) { using (randomParams = new LinearLayout.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { randomParams.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (5f, context), 0); random.LayoutParameters = randomParams; } random.ContentDescription = eachMessage.Key; random.Click += ConversationPicItem_Clicked; random.SetBackgroundResource (Resource.Drawable.icopolls); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.SoundFX: using (random = new ImageView (context)) { using (randomParams = new LinearLayout.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { randomParams.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (5f, context), 0); random.LayoutParameters = randomParams; } random.ContentDescription = eachMessage.Key; random.Click += ConversationPicItem_Clicked; random.SetBackgroundResource (Resource.Drawable.icosoundfx); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Video: using (random = new ImageView (context)) { using (randomParams = new LinearLayout.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { randomParams.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (5f, context), 0); random.LayoutParameters = randomParams; } random.ContentDescription = eachMessage.Key; random.Click += ConversationPicItem_Clicked; random.SetBackgroundResource (Resource.Drawable.icovideo); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Voice: using (random = new ImageView (context)) { using (randomParams = new LinearLayout.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { randomParams.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (5f, context), 0); random.LayoutParameters = randomParams; } random.ContentDescription = eachMessage.Key; random.Click += ConversationPicItem_Clicked; random.SetBackgroundResource (Resource.Drawable.icovoice); layout3.AddView (random); } break; } } using (random = new ImageView (context)) { random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.playblack); random.ContentDescription = eachMessage.Value.Message.MessageGuid; random.Click += PlayButton_Clicked; layout3.AddView (random); } layout2.AddView (layout3); } LinearLayout layout4 = new LinearLayout (context); layout4.Orientation = Orientation.Vertical; layout4.SetGravity (GravityFlags.Right); using (TextView noMessages = new TextView (context)) { noMessages.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (240f, context), (int)ImageHelper.convertDpToPixel (20f, context)); noMessages.SetPadding ((int)ImageHelper.convertDpToPixel (10f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), 0); noMessages.SetTextColor (Color.White); noMessages.TextSize = 12f; noMessages.Text = unreadMessageCounts [eachMessage.Key] + " messages unread"; noMessages.Gravity = GravityFlags.Right; layout4.AddView (noMessages); } layout2.AddView (layout4); layout.AddView (layout2); listWrapper.AddView (layout); m++; } } } }); if (getGuid.Count > 0) { cpUI = 0; LOLConnectClient service = new LOLConnectClient (LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint); service.UserGetImageDataCompleted += Service_UserGetImageDataCompleted; service.UserGetImageDataAsync (AndroidData.CurrentUser.AccountID, getGuid [0], new Guid (AndroidData.ServiceAuthToken)); } }
private void createUI(List<MessageDB> message, List<UserDB> contact, string nameTitle, bool clear = false) { message.Reverse (); contact.Reverse (); int m = 0; string messager = ""; bool dd = false; if (message != null && contact != null) { if (clear == false) RunOnUiThread (() => listWrapper.RemoveAllViewsInLayout ()); string othername = string.Empty; for (int i = 0; i < contact.Count; ++i) { if (string.IsNullOrEmpty (nameTitle)) othername = contact [i].FirstName + " " + contact [i].LastName; else othername = nameTitle; if (isMe != othername) { RunOnUiThread (delegate { Header.headertext = othername; Header.fontsize = 36f; ImageHelper.fontSizeInfo (header.Context); header.SetTextSize (Android.Util.ComplexUnitType.Dip, Header.fontsize); header.Text = Header.headertext; }); break; } } if (contact.Count > 1) { string toReturn = ""; List<UserDB> sortedList = new List<UserDB> (); sortedList = contact.OrderBy (s => s.LastName).OrderBy (s => s.FirstName).ToList (); foreach (UserDB eachItem in sortedList) toReturn += string.Format ("{0} {1}, ", eachItem.FirstName, eachItem.LastName); int last = toReturn.LastIndexOf (", "); toReturn = toReturn.Remove (last); RunOnUiThread (delegate { using (LinearLayout btnlayout = new LinearLayout (context)) { btnlayout.Orientation = Android.Widget.Orientation.Vertical; btnlayout.SetGravity (GravityFlags.Center); btnlayout.LayoutParameters = new ViewGroup.LayoutParams (LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent); btnlayout.SetPadding ((int)ImageHelper.convertDpToPixel (5f, context), 0, (int)ImageHelper.convertDpToPixel (5f, context), (int)ImageHelper.convertDpToPixel (10f, context)); using (TextView name = new TextView(context)) { name.Text = toReturn; name.SetTextSize (Android.Util.ComplexUnitType.Dip, 18f); name.SetTextColor (Color.Black); btnlayout.AddView (name); } using (Button showAll = new Button (context)) { showAll.Gravity = GravityFlags.CenterVertical; showAll.Text = Application.Context.Resources.GetString (Resource.String.messageShowAllInConversation); showAll.Click += (object sender, EventArgs e) => { showParticipants (sender, e, contact); }; showAll.SetWidth ((int)ImageHelper.convertDpToPixel (180f, context)); showAll.SetHeight ((int)ImageHelper.convertDpToPixel (30f, context)); showAll.SetBackgroundResource (Resource.Drawable.button); btnlayout.AddView (showAll); } listWrapper.AddView (btnlayout); } }); } if (getGuid != null) getGuid.Clear (); RunOnUiThread (delegate { foreach (MessageDB messages in message) { string name = contact [m].FirstName + " " + contact [m].LastName; ImageView random = null; LinearLayout layout = new LinearLayout (context); layout.Orientation = Android.Widget.Orientation.Horizontal; layout.SetGravity (GravityFlags.CenterVertical); layout.SetPadding ((int)ImageHelper.convertDpToPixel (5f, context), 0, (int)ImageHelper.convertDpToPixel (5f, context), (int)ImageHelper.convertDpToPixel (10f, context)); LinearLayout layout2 = new LinearLayout (context); layout2.Orientation = Orientation.Vertical; layout2.SetGravity (GravityFlags.Center); if (name == isMe) layout.AddView (contactUserInterface (messages, contact [m], true)); else layout.AddView (contactUserInterface (messages, contact [m], false)); /*ImageView profilepic = new ImageView (context); profilepic.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (55f, context), (int)ImageHelper.convertDpToPixel (100f, context)); if (contact == null) profilepic.SetImageDrawable (Application.Context.Resources.GetDrawable (Resource.Drawable.defaultuserimage)); else { profilepic.Tag = new Java.Lang.String ("profilepic_" + contact [m].AccountID); profilepic.SetImageResource (Resource.Drawable.defaultuserimage); layout.AddView (profilepic); if (contact [m].Picture.Length == 0 && contact [m].HasProfileImage) getGuid.Add (contact [m].AccountID); else { if (contact [m].Picture.Length > 0) LoadUserImage (contact [m], profilepic); else profilepic.SetImageDrawable (Application.Context.Resources.GetDrawable (Resource.Drawable.defaultuserimage)); } TextView name = new TextView (context); name.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (230f, context), (int)ImageHelper.convertDpToPixel (40f, context)); name.Gravity = GravityFlags.Center; name.SetTextColor (Color.White); name.TextSize = 16f; layout2.AddView (name); if (messages.MessageStepDBList.Count == 1 && messages.MessageStepDBList [0].StepType == MessageStep.StepTypes.Text) { TextView text = new TextView (context); text.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (220f, context), (int)ImageHelper.convertDpToPixel (60f, context)); text.SetPadding ((int)ImageHelper.convertDpToPixel (20f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), 0); text.Gravity = GravityFlags.CenterVertical; if (name == isMe) text.SetBackgroundResource (Resource.Drawable.bubblesolidright); else text.SetBackgroundResource (Resource.Drawable.bubblesolidleft); text.TextSize = 16f; for (int e = 0; e < messages.MessageStepDBList.Count; ++e) { if (!string.IsNullOrEmpty (messages.MessageStepDBList [e].MessageText)) { messager = messages.MessageStepDBList [e].MessageText; break; } } if (string.IsNullOrEmpty (messager)) messager = "No text message found"; int nolines = (int)(ImageHelper.convertDpToPixel ((messager.Length / 27f) * 12f, context)); text.SetHeight (nolines); text.SetTextColor (Android.Graphics.Color.Black); text.Text = messager; layout2.Clickable = true; layout2.AddView (text); } else {*/ LinearLayout layout3 = new LinearLayout (context); layout3.Orientation = Orientation.Horizontal; if (name == isMe) layout3.SetGravity (GravityFlags.Right); else layout3.SetGravity (GravityFlags.Left); layout3.SetBackgroundResource (Resource.Drawable.attachmentspreviewbkgr); layout3.SetVerticalGravity (GravityFlags.CenterVertical); layout3.SetMinimumHeight (30); layout3.SetPadding ((int)ImageHelper.convertDpToPixel (10f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), 0); if (name != isMe) { using (random = new ImageView (context)) { random.Tag = m; random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.playblack); random.ContentDescription = messages.MessageGuid; random.Click += PlayButton_Clicked; layout3.AddView (random); } } int textt = 0; for (int tt = 0; tt < messages.MessageStepDBList.Count; ++tt) { if (messages.MessageStepDBList [tt].StepType == MessageStep.StepTypes.Text) textt++; } for (int i = 0; i < messages.MessageStepDBList.Count; ++i) { switch (messages.MessageStepDBList [i].StepType) { case LOLMessageDelivery.MessageStep.StepTypes.Text: if (textt == 1) { TextView text = new TextView (context); text.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (220f, context), (int)ImageHelper.convertDpToPixel (60f, context)); text.SetPadding ((int)ImageHelper.convertDpToPixel (20f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), 0); text.Gravity = GravityFlags.CenterVertical; if (name == isMe) text.SetBackgroundResource (Resource.Drawable.bubblesolidright); else text.SetBackgroundResource (Resource.Drawable.bubblesolidleft); text.TextSize = 16f; for (int e = 0; e < messages.MessageStepDBList.Count; ++e) { if (!string.IsNullOrEmpty (messages.MessageStepDBList [e].MessageText)) { messager = messages.MessageStepDBList [e].MessageText; break; } } if (string.IsNullOrEmpty (messager)) messager = "No text message found"; int nolines = (int)(ImageHelper.convertDpToPixel ((messager.Length / 27f) * 12f, context)); text.SetHeight (nolines); text.SetTextColor (Android.Graphics.Color.Black); text.Text = messager; layout2.Clickable = true; layout2.AddView (text); } else { if (textt > 1) { using (random = new ImageView (context)) { random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.textmsg); layout3.AddView (random); } } } break; case LOLMessageDelivery.MessageStep.StepTypes.Animation: using (random = new ImageView (context)) { random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.drawicon); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Comicon: using (random = new ImageView (context)) { random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.comicon); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Comix: using (random = new ImageView (context)) { random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.comicmsgs); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Emoticon: using (random = new ImageView (context)) { random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.emoticonmsg); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Polling: using (random = new ImageView (context)) { random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.pollmsg); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.SoundFX: using (random = new ImageView (context)) { random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.soundfxmsg); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Video: using (random = new ImageView (context)) { random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.videomsg); layout3.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Voice: using (random = new ImageView (context)) { random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.voicemsg); layout3.AddView (random); } break; } } if (name == isMe) { using (random = new ImageView (context)) { random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.playblack); random.Click += (object ss, EventArgs ee) => { random_Click (ss, ee, message); }; layout3.AddView (random); } } layout2.AddView (layout3); layout.AddView (layout2); listWrapper.AddView (layout); if (m + 1 < contact.Count) m++; } //} }); if (getGuid.Count > 0) { cpUI = 0; LOLConnectClient service = new LOLConnectClient (LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint); service.UserGetImageDataCompleted += Service_UserGetImageDataCompleted; service.UserGetImageDataAsync (AndroidData.CurrentUser.AccountID, getGuid [0], new Guid (AndroidData.ServiceAuthToken)); } } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.ComposeMessageMain); readOnly = base.Intent.GetBooleanExtra("readonly", false); dbm = wowZapp.LaffOutOut.Singleton.dbm; mmg = wowZapp.LaffOutOut.Singleton.mmg; Guid profPic = Guid.Empty; UserDB user = null; ImageView btns = FindViewById<ImageView>(Resource.Id.imgNewLoginHeader); TextView header = FindViewById<TextView>(Resource.Id.txtFirstScreenHeader); RelativeLayout relLayout = FindViewById<RelativeLayout>(Resource.Id.relativeLayout1); ImageHelper.setupTopPanel(btns, header, relLayout, header.Context); context = header.Context; Header.headertext = Application.Context.Resources.GetString(Resource.String.messageCreateMessageTitle); Header.fontsize = 36f; ImageHelper.fontSizeInfo(header.Context); header.SetTextSize(Android.Util.ComplexUnitType.Dip, Header.fontsize); header.Text = Header.headertext; imgProfilePic = FindViewById<ImageView>(Resource.Id.imgProfilePic); imgProfilePic.SetBackgroundResource(Resource.Drawable.emptybackground); hasMoved = regenerate = false; this.thumbImageWidth = (int)ImageHelper.convertDpToPixel(80f, context); this.thumbImageHeight = (int)ImageHelper.convertDpToPixel(100f, context); btnSend = FindViewById<Button>(Resource.Id.btnSend); btnBack = FindViewById<ImageButton>(Resource.Id.btnBack); btnBack.Tag = 0; btnHome = FindViewById<ImageButton>(Resource.Id.btnHome); btnHome.Tag = 1; btnPlay = FindViewById<ImageView>(Resource.Id.imgPlay); btnPlay.Click += new EventHandler(btnPlay_Click); txtFullname = FindViewById<TextView>(Resource.Id.txtAuthorName); txtMessage = FindViewById<TextView>(Resource.Id.txtMainMessage); LinearLayout bottom = FindViewById<LinearLayout>(Resource.Id.bottomHolder); ImageButton[] buttons = new ImageButton[2]; buttons [0] = btnBack; buttons [1] = btnHome; ImageHelper.setupButtonsPosition(buttons, bottom, context); if (ComposeMessageMainUtil.contentPackID == null) ComposeMessageMainUtil.contentPackID = new int[7]; for (int i = 0; i < 6; ++i) ComposeMessageMainUtil.contentPackID [i] = -1; txtMessage.Click += delegate { int n = 0, t = -1; for (n = 0; n < ComposeMessageMainUtil.currentPosition.Length; ++n) { if (ComposeMessageMainUtil.currentPosition [n] == 0) { t = n; break; } } if (n == ComposeMessageMainUtil.currentPosition.Length) { for (n = 0; n < ComposeMessageMainUtil.currentPosition.Length; ++n) { if (ComposeMessageMainUtil.msgSteps [n].StepType == MessageStep.StepTypes.Text) { if (ComposeMessageMainUtil.msgSteps [n].MessageText == txtMessage.Text) { t = n; break; } } } if (t == -1) RunOnUiThread(() => Toast.MakeText(context, Application.Context.GetString(Resource.String.errorNoSpaceForText), ToastLength.Short).Show()); } else { RunOnUiThread(delegate { Intent it = new Intent(this, typeof(ComposeTextMessageActivity)); it.PutExtra("text", txtMessage.Text != Application.Context.Resources.GetString(Resource.String.composeTextMessagelblMessage) ? ComposeMessageMainUtil.msgSteps [t].MessageText : string.Empty); it.PutExtra("CurrentStep", base.Intent.GetIntExtra("CurrentStep", 1)); StartActivity(it); }); } }; imgSteps = new ImageView[6]; imgSets = new bool[6]; imgSteps [0] = FindViewById<ImageView>(Resource.Id.imgStep1); imgSteps [0].Tag = 0; imgSteps [1] = FindViewById<ImageView>(Resource.Id.imgStep2); imgSteps [1].Tag = 1; imgSteps [2] = FindViewById<ImageView>(Resource.Id.imgStep3); imgSteps [2].Tag = 2; imgSteps [3] = FindViewById<ImageView>(Resource.Id.imgStep4); imgSteps [3].Tag = 3; imgSteps [4] = FindViewById<ImageView>(Resource.Id.imgStep5); imgSteps [4].Tag = 4; imgSteps [5] = FindViewById<ImageView>(Resource.Id.imgStep6); imgSteps [5].Tag = 5; for (int z = 0; z < 6; ++z) imgSets [z] = true; bool multi = false; if (ComposeMessageMainUtil.messageDB != null) { if (ComposeMessageMainUtil.messageDB.MessageRecipientDBList != null) { int n = 0; for (int j = 0; j < ComposeMessageMainUtil.currentPosition.Length; ++j) ComposeMessageMainUtil.currentPosition [j] = 0; regenerateIcons(); foreach (MessageStepDB mesg in ComposeMessageMainUtil.messageDB.MessageStepDBList) { #if DEBUG Console.WriteLine("MessageStepDB item = {0}", mesg); #endif MessageStep mSt = MessageStepDB.ConvertFromMessageStepDB(mesg); ComposeMessageMainUtil.msgSteps.Add(mSt); ComposeMessageMainUtil.currentPosition [n] = 1; } } } if (readOnly) { user = dbm.GetUserWithAccountID(ComposeMessageMainUtil.messageDB.FromAccountID.ToString()); if (ComposeMessageMainUtil.messageDB.MessageRecipientDBList.Count > 1) multi = true; if (user.Picture.Length == 0) profPic = user.AccountID; else loadProfilePicture(user, imgProfilePic); } else { user = UserDB.ConvertFromUser(AndroidData.CurrentUser); if (AndroidData.CurrentUser.Picture.Length == 0) profPic = AndroidData.CurrentUser.AccountID; else loadProfilePicture(user, imgProfilePic); } imgProfilePic.Tag = new Java.Lang.String("profilepic_" + user.AccountID); string name = user.FirstName + " " + user.LastName; if (multi == true) { if (ComposeMessageMainUtil.messageDB == null) name += " and " + (Contacts.SelectContactsUtil.selectedContacts.Count - 1).ToString() + (Contacts.SelectContactsUtil.selectedContacts.Count - 1 > 1 ? " others" : "other"); else name += " and " + (ComposeMessageMainUtil.messageDB.MessageRecipientDBList.Count - 1).ToString() + (ComposeMessageMainUtil.messageDB.MessageRecipientDBList.Count - 1 > 1 ? " others" : "other"); } float fontSize = txtFullname.TextSize; txtFullname.SetTextSize(Android.Util.ComplexUnitType.Dip, ImageHelper.getNewFontSize(fontSize, context)); txtFullname.Text = name; fontSize = txtMessage.TextSize; txtMessage.SetTextSize(Android.Util.ComplexUnitType.Dip, ImageHelper.getNewFontSize(fontSize, context)); if (readOnly == false) { for (int n = 0; n < 6; ++n) { if (imgSets [n]) { int step = new int(); step = n; imgSteps [step].Click -= (object s, EventArgs e) => { imgClickEvent(s, e, 9, step);}; imgSteps [step].Click += (object s, EventArgs e) => { imgClickEvent(s, e, 9, step);}; } imgSteps [n].SetOnLongClickListener(this); } ReloadMessageSteps(); } else { this.SetButtonImagesForMessageSteps(); header.Text = Application.Context.Resources.GetString(Resource.String.messageReadMessage); btnSend.Visibility = ViewStates.Invisible; ImageView a1 = FindViewById<ImageView>(Resource.Id.arrow1); ImageView a2 = FindViewById<ImageView>(Resource.Id.arrow2); ImageView a3 = FindViewById<ImageView>(Resource.Id.arrow3); ImageView a4 = FindViewById<ImageView>(Resource.Id.arrow4); a1.Visibility = a2.Visibility = a3.Visibility = a4.Visibility = ViewStates.Invisible; } co = 0; btnBack.Click += delegate { for (int i = 0; i < 6; ++i) ComposeMessageMainUtil.currentPosition [i] = 0; for (int i = 0; i < 7; ++i) ComposeMessageMainUtil.contentPackID [i] = -1; ComposeMessageMainUtil.message = null; ComposeMessageMainUtil.messageDB = null; ComposeMessageMainUtil.msgSteps = null; ComposeMessageMainUtil.pollSteps = null; Finish(); }; btnHome.Click += delegate { Intent i = new Intent(this, typeof(Main.HomeActivity)); i.AddFlags(ActivityFlags.ClearTop); StartActivity(i); }; btnSend.Click += delegate { SendMessage(); Finish(); }; if (profPic != Guid.Empty) { Guid finder = profPic != Guid.Empty ? profPic : AndroidData.CurrentUser.AccountID; LOLConnectClient service = new LOLConnectClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint); service.UserGetImageDataCompleted += Service_UserGetImageDataCompleted; service.UserGetImageDataAsync(AndroidData.CurrentUser.AccountID, finder, new Guid(AndroidData.ServiceAuthToken)); } }
private void AddNewUsers(List<User> users) { User user = new User(); user = users [counter]; #if DEBUG System.Diagnostics.Debug.WriteLine("Users to add : {0}", user.FirstName + " " + user.LastName); #endif RunOnUiThread(delegate { ModalNewContact = new Dialog(this, Resource.Style.lightbox_dialog); ModalNewContact.SetContentView(Resource.Layout.ModalNewContacts); ((Button)ModalNewContact.FindViewById(Resource.Id.btnAccept)).Click += delegate { if (user.Picture.Length > 0) { Contacts.ContactsUtil.contactFilenames.Add(user.AccountID.ToString()); System.IO.File.WriteAllBytes(System.IO.Path.Combine(wowZapp.LaffOutOut.Singleton.ImageDirectory, user.AccountID.ToString()), user.Picture); } DismissModalDialog(); counter++; ContactDB contact = new ContactDB(); contact.Blocked = false; contact.ContactAccountID = user.AccountID; contact.OwnerAccountID = AndroidData.CurrentUser.AccountID; contact.ContactUser = user; contacts.Add(contact); if (counter < users.Count) AddNewUsers(users); else { DismissModalDialog(); returnToSender(); } }; ((Button)ModalNewContact.FindViewById(Resource.Id.btnDecline)).Click += delegate { DismissModalDialog(); counter++; if (counter < users.Count) AddNewUsers(users); else { DismissModalDialog(); returnToSender(); } }; ((TextView)ModalNewContact.FindViewById(Resource.Id.txtContactName)).Text = user.FirstName + " " + user.LastName; modalImage = ((ImageView)ModalNewContact.FindViewById(Resource.Id.imgContact)); if (Contacts.ContactsUtil.contactFilenames.Contains(user.AccountID.ToString())) { Bitmap bm = BitmapFactory.DecodeFile(System.IO.Path.Combine(wowZapp.LaffOutOut.Singleton.ImageDirectory, user.AccountID.ToString())); System.IO.MemoryStream ms = new System.IO.MemoryStream(); bm.Compress(Bitmap.CompressFormat.Jpeg, 80, ms); byte[] img = ms.ToArray(); displayImage(img, modalImage); } else { if (user.Picture.Length == 0) RunOnUiThread(() => modalImage.SetBackgroundResource(Resource.Drawable.defaultuserimage)); else { if (user.Picture.Length == 0) { LOLConnectClient service = new LOLConnectClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint); service.UserGetImageDataCompleted += Service_UserGetImageDataCompleted; service.UserGetImageDataAsync(AndroidData.CurrentUser.AccountID, user.AccountID, new Guid(AndroidData.ServiceAuthToken)); } else { Bitmap bm = BitmapFactory.DecodeResource(this.Resources, Resource.Drawable.defaultuserimage); System.IO.MemoryStream ms = new System.IO.MemoryStream(); bm.Compress(Bitmap.CompressFormat.Jpeg, 80, ms); byte[] img = ms.ToArray(); displayImage(img, modalImage); } } } ModalNewContact.Show(); }); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.EditContact); TextView header = FindViewById<TextView>(Resource.Id.txtFirstScreenHeader); ImageView btns = FindViewById<ImageView>(Resource.Id.imgNewloginHeader); RelativeLayout relLayout = FindViewById<RelativeLayout>(Resource.Id.relativeLayout1); ImageHelper.setupTopPanel(btns, header, relLayout, header.Context); context = header.Context; Header.headertext = Application.Context.Resources.GetString(Resource.String.editContactTitle); Header.fontsize = 36f; ImageHelper.fontSizeInfo(header.Context); header.SetTextSize(Android.Util.ComplexUnitType.Dip, Header.fontsize); header.Text = Header.headertext; TextView name = FindViewById<TextView>(Resource.Id.txtContactName); name.Text = EditContactUtil.UserContact.ContactUser.FirstName + " " + EditContactUtil.UserContact.ContactUser.LastName; contactpic = FindViewById<ImageView>(Resource.Id.imgContactPic); contactpic.Tag = new Java.Lang.String("profilepic_1"); dbm = wowZapp.LaffOutOut.Singleton.dbm; blockcontact = FindViewById<Button>(Resource.Id.btnBlockUser); Button deletecontact = FindViewById<Button>(Resource.Id.btnDeleteUser); ImageButton uniback = FindViewById<ImageButton>(Resource.Id.btnUniBack); LinearLayout bottom = FindViewById<LinearLayout>(Resource.Id.bottomHolder); uniback.Click += delegate { Finish(); }; blockcontact.Text = Application.Context.Resources.GetString(EditContactUtil.UserContact.Blocked ? Resource.String.editContactUnblock : Resource.String.editContactBlock); blockcontact.Click += new EventHandler(blockcontact_Click); deletecontact.Click += new EventHandler(deletecontact_Click); float size = 100f; if (wowZapp.LaffOutOut.Singleton.resizeFonts) size *= wowZapp.LaffOutOut.Singleton.bigger; xSize = (int)ImageHelper.convertDpToPixel(size, context); ySize = xSize; if (ContactsUtil.contactFilenames.Contains(EditContactUtil.UserContact.ContactAccountGuid)) { #if DEBUG System.Diagnostics.Debug.WriteLine("using cache"); #endif using (Bitmap bm = BitmapFactory.DecodeFile (System.IO.Path.Combine (wowZapp.LaffOutOut.Singleton.ImageDirectory, EditContactUtil.UserContact.ContactAccountGuid))) { using (MemoryStream ms = new MemoryStream ()) { bm.Compress(Bitmap.CompressFormat.Jpeg, 80, ms); byte[] image = ms.ToArray(); displayImage(image, contactpic); } } } else { if (EditContactUtil.UserContact.ContactUser.Picture.Length > 0) { #if DEBUG System.Diagnostics.Debug.WriteLine("grabbing"); #endif LOLConnectClient service = new LOLConnectClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint); service.UserGetImageDataCompleted += Service_UserGetImageDataCompleted; service.UserGetImageDataAsync(AndroidData.CurrentUser.AccountID, EditContactUtil.UserContact.ContactAccountID, new Guid(AndroidData.ServiceAuthToken)); } else { System.Diagnostics.Debug.WriteLine("no pic"); using (Bitmap bm = BitmapFactory.DecodeResource (this.Resources, Resource.Drawable.defaultuserimage)) { using (MemoryStream ms = new MemoryStream ()) { bm.Compress(Bitmap.CompressFormat.Jpeg, 80, ms); byte[] image = ms.ToArray(); displayImage(image, contactpic); } } } } }
private void LoadContactsFromDB() { if (contactsDB != null) contactsDB.Clear(); if (listWrapper != null) RunOnUiThread(() => listWrapper.RemoveAllViews()); RunOnUiThread(() => ShowLightboxDialog(Application.Resources.GetString(Resource.String.manageContactsRetrievingContacts))); contactsDB = db.GetAllContactsForOwner(AndroidData.CurrentUser.AccountID.ToString()); if (contactsDB.Count > 0) sortContacts(); int m = 0; //RunOnUiThread (delegate { foreach (ContactDB eachContact in contactsDB) { eachContact.LastMessageSent = db.GetLastMessageDateTimeForUser(eachContact.ContactAccountGuid, true); LinearLayout layout = new LinearLayout(context); layout.Orientation = Android.Widget.Orientation.Horizontal; layout.SetGravity(GravityFlags.Center); layout.SetPadding((int)ImageHelper.convertDpToPixel(10f, context), 0, (int)ImageHelper.convertDpToPixel(10f, context), (int)ImageHelper.convertDpToPixel(10f, context)); ImageView profilepic = new ImageView(context); profilepic.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(imageSize [0], context), (int)ImageHelper.convertDpToPixel(imageSize [1], context)); profilepic.Tag = new Java.Lang.String("profilepic_" + eachContact.ContactAccountID.ToString()); if (ContactsUtil.contactFilenames.Contains(eachContact.ContactAccountID.ToString())) { string file = System.IO.Path.Combine(wowZapp.LaffOutOut.Singleton.ImageDirectory, eachContact.ContactAccountID.ToString()); FileInfo f = new FileInfo(file); long s1 = f.Length; if (s1 > 0 && s1 != 2) { using (Bitmap bm = BitmapFactory.DecodeFile (file)) { using (MemoryStream ms = new MemoryStream ()) { bm.Compress(Bitmap.CompressFormat.Jpeg, 80, ms); byte[] image = ms.ToArray(); displayImage(image, profilepic); } } } } else { if (eachContact.ContactUser.Picture.Length == 0) { profilePicsToBeGrabbed.Add(eachContact.ContactAccountID); } else { if (eachContact.ContactUser.Picture.Length > 0 && eachContact.ContactUser.Picture.Length != 2) displayImage(eachContact.ContactUser.Picture, profilepic); else RunOnUiThread(() => profilepic.SetImageDrawable(Application.Context.Resources.GetDrawable(Resource.Drawable.defaultuserimage))); } } RunOnUiThread(() => layout.AddView(profilepic)); TextView text = new TextView(context); text.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(260f, context), (int)ImageHelper.convertDpToPixel(40f, context)); text.SetPadding((int)ImageHelper.convertDpToPixel(10f, context), 0, (int)ImageHelper.convertDpToPixel(10f, context), 0); text.Gravity = GravityFlags.CenterVertical; text.TextSize = 16f; text.SetTextColor(Android.Graphics.Color.White); if (eachContact.ContactUser.FirstName != "" || eachContact.ContactUser.LastName != "") { text.Text = eachContact.ContactUser.FirstName + " " + eachContact.ContactUser.LastName; } else { text.Text = eachContact.ContactUser.EmailAddress; } int contactId = new int(); contactId = m; layout.Clickable = true; layout.Click += delegate { handleContactClick(text, contactId); }; RunOnUiThread(delegate { layout.AddView(text); listWrapper.AddView(layout); }); m++; } RunOnUiThread(() => DismissLightboxDialog()); if (profilePicsToBeGrabbed.Count > 0) { profilePicsGrabIndex = 0; LOLConnectClient service = new LOLConnectClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint); service.UserGetImageDataCompleted += Service_UserGetImageDataCompleted; service.UserGetImageDataAsync(AndroidData.CurrentUser.AccountID, profilePicsToBeGrabbed [0], new Guid(AndroidData.ServiceAuthToken)); } }
private void generateMessageBarAndAnimate(string message, MessageDB msgList, UserDB contact, bool shutUp = false) { //RunOnUiThread (delegate { bool rpong = false; if (shutUp != true) { AudioPlayer ap = new AudioPlayer (context); Android.Content.Res.AssetManager am = this.Assets; ap.playFromAssets (am, "incoming.mp3"); } Guid grabGuid = Guid.Empty; RunOnUiThread (() => messageBar.SetPadding ((int)ImageHelper.convertDpToPixel (5f, context), 0, (int)ImageHelper.convertDpToPixel (5f, context), (int)ImageHelper.convertDpToPixel (10f, context))); int leftOver = Convert.ToInt32 (wowZapp.LaffOutOut.Singleton.ScreenXWidth - (picSize + 40)); LinearLayout.LayoutParams layParams; if (contact == null) throw new Exception ("Contact is null in generateMessageBarAndAnimate"); ImageView profilePic = new ImageView (context); using (layParams = new LinearLayout.LayoutParams (picSize, picSize)) { layParams.SetMargins ((int)ImageHelper.convertDpToPixel (15f, context), (int)ImageHelper.convertDpToPixel (20f, context), 0, 0); profilePic.LayoutParameters = layParams; } profilePic.SetBackgroundResource (Resource.Drawable.defaultuserimage); profilePic.Tag = new Java.Lang.String ("profilepic_" + contact.AccountID); RunOnUiThread (() => messageBar.AddView (profilePic)); if (Contacts.ContactsUtil.contactFilenames.Contains (contact.AccountGuid)) { rpong = true; using (Bitmap bm = BitmapFactory.DecodeFile (System.IO.Path.Combine (wowZapp.LaffOutOut.Singleton.ImageDirectory, contact.AccountGuid))) { using (MemoryStream ms = new MemoryStream ()) { bm.Compress (Bitmap.CompressFormat.Jpeg, 80, ms); byte[] image = ms.ToArray (); displayImage (image, profilePic); } } } else { if (contact.Picture.Length == 0) grabGuid = contact.AccountID; else { if (contact.Picture.Length > 0) loadProfilePicture (contact, profilePic); } } LinearLayout fromTVH = new LinearLayout (context); fromTVH.Orientation = Orientation.Vertical; fromTVH.LayoutParameters = new ViewGroup.LayoutParams (LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.FillParent); float textNameSize = wowZapp.LaffOutOut.Singleton.resizeFonts == true ? (int)ImageHelper.convertPixelToDp (((25 * picSize) / 100), context) : 16f; TextView textFrom = new TextView (context); using (layParams = new LinearLayout.LayoutParams (leftOver, (int)textNameSize)) { layParams.SetMargins ((int)ImageHelper.convertDpToPixel (9.3f, context), (int)ImageHelper.convertPixelToDp (textNameSize - 1, context), 0, 0); textFrom.LayoutParameters = layParams; } float fontSize = wowZapp.LaffOutOut.Singleton.resizeFonts == true ? ImageHelper.convertPixelToDp (((12 * picSize) / 100), context) : ImageHelper.convertPixelToDp (14f, context); textFrom.SetTextSize (Android.Util.ComplexUnitType.Dip, fontSize); textFrom.SetTextColor (Color.Black); if (contact != null) textFrom.Text = contact.FirstName + " " + contact.LastName; else textFrom.Text = "Ann Onymouse"; RunOnUiThread (() => fromTVH.AddView (textFrom)); float textMessageSize = wowZapp.LaffOutOut.Singleton.resizeFonts == true ? ImageHelper.convertPixelToDp (((70 * picSize) / 100), context) : ImageHelper.convertDpToPixel (39f, context); TextView textMessage = new TextView (context); using (layParams = new LinearLayout.LayoutParams (leftOver, (int)textMessageSize)) { layParams.SetMargins ((int)ImageHelper.convertDpToPixel (10f, context), 0, (int)ImageHelper.convertDpToPixel (10, context), 0); textMessage.LayoutParameters = layParams; } float fontSize2 = wowZapp.LaffOutOut.Singleton.resizeFonts == true ? ImageHelper.convertPixelToDp (((12 * picSize) / 100), context) : ImageHelper.convertPixelToDp (16f, context); textMessage.SetTextSize (Android.Util.ComplexUnitType.Dip, fontSize2); textMessage.SetTextColor (Color.White); textMessage.SetPadding ((int)ImageHelper.convertDpToPixel (20f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), 0); if (!string.IsNullOrEmpty (message)) textMessage.SetBackgroundResource (Resource.Drawable.bubblesolidleft); textMessage.Text = message != string.Empty ? message : ""; textMessage.ContentDescription = msgList.MessageGuid; textMessage.Click += new EventHandler (textMessage_Click); RunOnUiThread (() => fromTVH.AddView (textMessage)); //} if (msgList != null) { LinearLayout messageItems = new LinearLayout (context); messageItems.Orientation = Orientation.Horizontal; float messageBarSize = wowZapp.LaffOutOut.Singleton.resizeFonts == true ? ImageHelper.convertPixelToDp (((35 * picSize) / 100), context) : ImageHelper.convertDpToPixel (40f, context); using (layParams = new LinearLayout.LayoutParams (leftOver, (int)messageBarSize)) { layParams.SetMargins ((int)ImageHelper.convertDpToPixel (14f, context), (int)ImageHelper.convertDpToPixel (3.3f, context), (int)ImageHelper.convertDpToPixel (12.7f, context), (int)ImageHelper.convertDpToPixel (4f, context)); messageItems.LayoutParameters = layParams; } messageItems.SetPadding ((int)ImageHelper.convertDpToPixel (10f, context), (int)ImageHelper.convertDpToPixel (3.3f, context), (int)ImageHelper.convertDpToPixel (10f, context), 0); messageItems.SetGravity (GravityFlags.Left); messageItems = createMessageBar (messageItems, msgList, leftOver); RunOnUiThread (() => fromTVH.AddView (messageItems)); } RunOnUiThread (() => messageBar.AddView (fromTVH)); RunOnUiThread (delegate { hsv.RemoveAllViews (); hsv.AddView (messageBar); }); if (grabGuid != null) { LOLConnectClient service = new LOLConnectClient (LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint); service.UserGetImageDataCompleted += Service_UserGetImageDataCompleted; service.UserGetImageDataAsync (AndroidData.CurrentUser.AccountID, grabGuid, new Guid (AndroidData.ServiceAuthToken)); } //}); RunOnUiThread (delegate { Handler handler = new Handler (); handler.PostDelayed (new Action (() => { hsv.SmoothScrollTo (newX, 0); }), 2000); }); }
private Bitmap getContactImage(Guid accountId, bool getImages) { Bitmap blank = null; if (!getImages) { blank = BitmapFactory.DecodeResource(context.Resources, Resource.Drawable.defaultuserimage); return blank; } if (!Contacts.ContactsUtil.contactFilenames.Contains(accountId.ToString())) { LOLConnectClient client = new LOLConnectClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint); client.UserGetImageDataCompleted += (object sender, UserGetImageDataCompletedEventArgs e) => { if (e.Error == null) { if (e.Result.ImageData.Length == 0) blank = BitmapFactory.DecodeResource(context.Resources, Resource.Drawable.defaultuserimage); else { Contacts.ContactsUtil.contactFilenames.Add(accountId.ToString()); File.WriteAllBytes(System.IO.Path.Combine(wowZapp.LaffOutOut.Singleton.ImageDirectory, e.Result.AccountID.ToString()), e.Result.ImageData); blank = BitmapFactory.DecodeFile(System.IO.Path.Combine(wowZapp.LaffOutOut.Singleton.ImageDirectory, accountId.ToString())); } //tcs.SetResult (blank); } }; client.UserGetImageDataAsync(AndroidData.CurrentUser.AccountID, accountId, new Guid(AndroidData.ServiceAuthToken)); } return blank; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.FindContactResults); listWrapper = FindViewById<LinearLayout>(Resource.Id.linearResultsWrapper); ImageButton btnBack = FindViewById<ImageButton>(Resource.Id.btnBack); Button btnDone = FindViewById<Button>(Resource.Id.btnDone); context = listWrapper.Context; TextView header = FindViewById<TextView>(Resource.Id.txtFirstScreenHeader); ImageView btns = FindViewById<ImageView>(Resource.Id.imgNewUserHeader); RelativeLayout relLayout = FindViewById<RelativeLayout>(Resource.Id.relativeLayout1); ImageHelper.setupTopPanel(btns, header, relLayout, header.Context); Header.headertext = Application.Context.Resources.GetString(Resource.String.findContactbtnSearch); Header.fontsize = 36f; ImageHelper.fontSizeInfo(header.Context); header.SetTextSize(Android.Util.ComplexUnitType.Dip, Header.fontsize); header.Text = Header.headertext; db = wowZapp.LaffOutOut.Singleton.dbm; contacts = FindContactResultsUtil.contacts; profilePicsGrabIndex = 0; profilePicsToBeGrabbed = new List<Guid>(); LinearLayout bottomHolder = FindViewById<LinearLayout>(Resource.Id.bottomHolder); //xSize = (int)ImageHelper.convertDpToPixel (40f, context); //ySize = xSize; btnBack.Click += delegate { Finish(); }; btnDone.Click += delegate { Finish(); }; ImageHelper.setupButtonsPosition(btnBack, btnDone, bottomHolder, context, true); newSizes = new float[2]; newSizes [0] = newSizes [1] = 40f; newSizes = ImageHelper.getNewSizes(newSizes, context); for (int n = 0; n < contacts.Count; n++) { LinearLayout layout = new LinearLayout(context); layout.Orientation = Android.Widget.Orientation.Horizontal; layout.SetGravity(GravityFlags.Center); layout.SetPadding((int)ImageHelper.convertDpToPixel(10f, context), 0, (int)ImageHelper.convertDpToPixel(10f, context), (int)ImageHelper.convertDpToPixel(10f, context)); ImageView profilepic = new ImageView(context); profilepic.LayoutParameters = new ViewGroup.LayoutParams((int)newSizes [0], (int)newSizes [1]); profilepic.Tag = new Java.Lang.String("profilepic_" + contacts [n].ContactAccountID.ToString()); if (Contacts.ContactsUtil.contactFilenames.Contains(contacts [n].ContactAccountID.ToString())) { using (Bitmap bm = BitmapFactory.DecodeFile (System.IO.Path.Combine (wowZapp.LaffOutOut.Singleton.ImageDirectory, contacts [n].ContactAccountID.ToString ()))) { using (MemoryStream ms = new MemoryStream ()) { bm.Compress(Bitmap.CompressFormat.Jpeg, 80, ms); byte[] image = ms.ToArray(); displayImage(image, profilepic); } } } else { if (contacts [n].ContactUser.Picture.Length > 0) { profilePicsToBeGrabbed.Add(contacts [n].ContactAccountID); } else { profilepic.SetImageDrawable(Application.Context.Resources.GetDrawable(Resource.Drawable.defaultuserimage)); } } layout.AddView(profilepic); using (TextView text = new TextView (context)) { text.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(235f, context), (int)ImageHelper.convertDpToPixel(40f, context)); text.SetPadding((int)ImageHelper.convertDpToPixel(10f, context), 0, (int)ImageHelper.convertDpToPixel(10f, context), 0); text.Gravity = GravityFlags.CenterVertical; text.TextSize = 16f; text.SetTextColor(Android.Graphics.Color.White); if (contacts [n].ContactUser.FirstName != "" || contacts [n].ContactUser.LastName != "") { text.Text = contacts [n].ContactUser.FirstName + " " + contacts [n].ContactUser.LastName; } else { text.Text = contacts [n].ContactUser.EmailAddress; } layout.AddView(text); } ImageView checkbox = new ImageView(context); checkbox.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(25f, context), (int)ImageHelper.convertDpToPixel(25f, context)); if (db.CheckContactExistsForOwner(contacts [n].ContactAccountID.ToString(), AndroidData.CurrentUser.AccountID.ToString()) == true) { checkbox.SetImageDrawable(Application.Context.Resources.GetDrawable(Resource.Drawable.@checkedbox)); checkbox.ContentDescription = ADD_DISABLED; } else { checkbox.SetImageDrawable(Application.Context.Resources.GetDrawable(Resource.Drawable.add)); checkbox.ContentDescription = ADD_ENABLED; } int contactId = new int(); contactId = n; layout.Clickable = true; layout.Click += delegate { AddContact(checkbox, contactId); }; layout.AddView(checkbox); this.listWrapper.AddView(layout); } if (profilePicsToBeGrabbed.Count > 0) { profilePicsGrabIndex = 0; LOLConnectClient service = new LOLConnectClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint); service.UserGetImageDataCompleted += Service_UserGetImageDataCompleted; service.UserGetImageDataAsync(AndroidData.CurrentUser.AccountID, profilePicsToBeGrabbed [0], new Guid(AndroidData.ServiceAuthToken)); } }