public MessageReceived(MessageDB message, Context c, bool readOnly = false) { MessageReceivedUtil.message = message; MessageReceivedUtil.context = c; MessageReceivedUtil.readOnly = readOnly; startActivity (c); }
private TextView messageTextBox(MessageDB message, int position, int leftOver) { TextView txtMessage = new TextView (context); using (LinearLayout.LayoutParams txtMessageParams = new LinearLayout.LayoutParams (leftOver, (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; txtMessage.SetBackgroundResource (Resource.Drawable.bubblesolidleft); txtMessage.TextSize = 16f; if (position < message.MessageStepDBList.Count) { if (string.IsNullOrEmpty (message.MessageStepDBList [position].MessageText)) txtMessage.Text = ""; else txtMessage.Text = message.MessageStepDBList [position].MessageText; } int nolines = (int)(ImageHelper.convertDpToPixel ((txtMessage.Text.Length / 27f) * 12f, context)); txtMessage.SetHeight (nolines); txtMessage.SetTextColor (Android.Graphics.Color.Black); return txtMessage; }
private LinearLayout createMessageBar(LinearLayout mBar, MessageDB message, int leftOver) { LinearLayout icons = new LinearLayout (context); icons.Orientation = Orientation.Horizontal; icons.SetGravity (GravityFlags.Left); icons.SetVerticalGravity (GravityFlags.CenterVertical); icons.SetMinimumHeight (30); icons.SetPadding ((int)ImageHelper.convertDpToPixel (10f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), 0); if (message.MessageStepDBList.Count == 0) { ImageView random1 = new ImageView (context); using (LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { lp.SetMargins (0, 0, leftOver - (int)ImageHelper.convertDpToPixel (30f, context), 0); random1.LayoutParameters = lp; } random1.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random1.SetBackgroundResource (Resource.Drawable.playblack); random1.ContentDescription = message.MessageGuid; random1.Click += delegate { Messages.MessageReceived m = new Messages.MessageReceived (message, context); }; RunOnUiThread (() => icons.AddView (random1)); } else { int end = message.MessageStepDBList.Count > 3 ? 3 : message.MessageStepDBList.Count; int iconSize = (int)ImageHelper.convertDpToPixel (34f, context); int toEnd = leftOver - (2 * iconSize) - (end * iconSize); for (int i = 0; i < end; ++i) { switch (message.MessageStepDBList [i].StepType) { case LOLMessageDelivery.MessageStep.StepTypes.Text: ImageView random2 = new ImageView (context); using (LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { lp.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (1f, context), 0); random2.LayoutParameters = lp; } random2.SetBackgroundResource (Resource.Drawable.textmsg); random2.ContentDescription = message.MessageID.ToString (); random2.Click += new EventHandler (imgMessage_Click); RunOnUiThread (() => icons.AddView (random2)); break; case LOLMessageDelivery.MessageStep.StepTypes.Animation: ImageView random3 = new ImageView (context); using (LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { lp.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (1f, context), 0); random3.LayoutParameters = lp; } random3.SetBackgroundResource (Resource.Drawable.drawicon); random3.ContentDescription = message.MessageID.ToString (); random3.Click += new EventHandler (imgMessage_Click); RunOnUiThread (() => icons.AddView (random3)); break; case LOLMessageDelivery.MessageStep.StepTypes.Comicon: ImageView random4 = new ImageView (context); using (LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { lp.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (1f, context), 0); random4.LayoutParameters = lp; } random4.SetBackgroundResource (Resource.Drawable.comicon); random4.ContentDescription = message.MessageID.ToString (); random4.Click += new EventHandler (imgMessage_Click); RunOnUiThread (() => icons.AddView (random4)); break; case LOLMessageDelivery.MessageStep.StepTypes.Comix: ImageView random5 = new ImageView (context); using (LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { lp.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (1f, context), 0); random5.LayoutParameters = lp; } random5.SetBackgroundResource (Resource.Drawable.comix); random5.ContentDescription = message.MessageID.ToString (); random5.Click += new EventHandler (imgMessage_Click); RunOnUiThread (() => icons.AddView (random5)); break; case LOLMessageDelivery.MessageStep.StepTypes.Emoticon: ImageView random6 = new ImageView (context); using (LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { lp.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (1f, context), 0); random6.LayoutParameters = lp; } random6.SetBackgroundResource (Resource.Drawable.emoticon); random6.ContentDescription = message.MessageID.ToString (); random6.Click += new EventHandler (imgMessage_Click); RunOnUiThread (() => icons.AddView (random6)); break; case LOLMessageDelivery.MessageStep.StepTypes.Polling: ImageView random7 = new ImageView (context); using (LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { lp.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (1f, context), 0); random7.LayoutParameters = lp; } random7.SetBackgroundResource (Resource.Drawable.polls); random7.ContentDescription = message.MessageID.ToString (); random7.Click += new EventHandler (imgMessage_Click); RunOnUiThread (() => icons.AddView (random7)); break; case LOLMessageDelivery.MessageStep.StepTypes.SoundFX: ImageView random8 = new ImageView (context); using (LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { lp.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (1f, context), 0); random8.LayoutParameters = lp; } random8.SetBackgroundResource (Resource.Drawable.audiofile); random8.ContentDescription = message.MessageID.ToString (); random8.Click += new EventHandler (imgMessage_Click); RunOnUiThread (() => icons.AddView (random8)); break; case LOLMessageDelivery.MessageStep.StepTypes.Video: ImageView random9 = new ImageView (context); using (LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { lp.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (1f, context), 0); random9.LayoutParameters = lp; } random9.SetBackgroundResource (Resource.Drawable.camera); random9.ContentDescription = message.MessageID.ToString (); random9.Click += new EventHandler (imgMessage_Click); RunOnUiThread (() => icons.AddView (random9)); break; case LOLMessageDelivery.MessageStep.StepTypes.Voice: ImageView randomA = new ImageView (context); using (LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { lp.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (1f, context), 0); randomA.LayoutParameters = lp; } randomA.SetBackgroundResource (Resource.Drawable.microphone); randomA.ContentDescription = message.MessageID.ToString (); randomA.Click += new EventHandler (imgMessage_Click); RunOnUiThread (() => icons.AddView (randomA)); break; } } ImageView randomp = new ImageView (context); using (LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { lp.SetMargins (toEnd, 0, 0, 0); randomp.LayoutParameters = lp; } randomp.SetBackgroundResource (Resource.Drawable.playblack); randomp.ContentDescription = message.MessageID.ToString (); randomp.Click += new EventHandler (random_Click); RunOnUiThread (() => icons.AddView (randomp)); } RunOnUiThread (() => mBar.AddView (icons)); return mBar; }
private LinearLayout contactUserInterface(MessageDB message, UserDB contact, bool direction) { LinearLayout layout = new LinearLayout (context); layout.Orientation = Android.Widget.Orientation.Horizontal; layout.SetGravity (GravityFlags.CenterVertical); string messager = ""; layout.SetPadding ((int)ImageHelper.convertDpToPixel (5f, context), 0, (int)ImageHelper.convertDpToPixel (5f, context), (int)ImageHelper.convertDpToPixel (10f, context)); ImageView profilepic = new ImageView (context); if (!direction) { 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.AccountID); profilepic.SetImageResource (Resource.Drawable.defaultuserimage); layout.AddView (profilepic); if (contact.Picture.Length == 0 && contact.HasProfileImage) getGuid.Add (contact.AccountID); else { if (contact.Picture.Length > 0) LoadUserImage (contact, profilepic); else profilepic.SetImageDrawable (Application.Context.Resources.GetDrawable (Resource.Drawable.defaultuserimage)); } LinearLayout layout2 = new LinearLayout (context); layout2.Orientation = Orientation.Vertical; layout2.SetGravity (GravityFlags.Center); if (message.MessageStepDBList.Count == 1 && message.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; text.SetBackgroundResource (Resource.Drawable.bubblesolidright); text.TextSize = 16f; for (int e = 0; e < message.MessageStepDBList.Count; ++e) { if (!string.IsNullOrEmpty (message.MessageStepDBList [e].MessageText)) { messager = message.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); } layout.AddView (layout2); } } else { LinearLayout layout2 = new LinearLayout (context); layout2.Orientation = Orientation.Vertical; layout2.SetGravity (GravityFlags.Center); if (message.MessageStepDBList.Count == 1 && message.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; text.SetBackgroundResource (Resource.Drawable.bubblesolidleft); text.TextSize = 16f; for (int e = 0; e < message.MessageStepDBList.Count; ++e) { if (!string.IsNullOrEmpty (message.MessageStepDBList [e].MessageText)) { messager = message.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); } profilepic.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (55f, context), (int)ImageHelper.convertDpToPixel (100f, context)); layout.AddView (layout2); if (contact == null) profilepic.SetImageDrawable (Application.Context.Resources.GetDrawable (Resource.Drawable.defaultuserimage)); else { profilepic.Tag = new Java.Lang.String ("profilepic_" + contact.AccountID); profilepic.SetImageResource (Resource.Drawable.defaultuserimage); layout.AddView (profilepic); if (contact.Picture.Length == 0 && contact.HasProfileImage) getGuid.Add (contact.AccountID); else { if (contact.Picture.Length > 0) LoadUserImage (contact, profilepic); else profilepic.SetImageDrawable (Application.Context.Resources.GetDrawable (Resource.Drawable.defaultuserimage)); } } } return layout; }
private void createUI(MessageDB message, UserDB contact) { #if DEBUG System.Diagnostics.Debug.WriteLine ("AccoundID (MC) = {0}", AndroidData.CurrentUser.AccountID.ToString ()); #endif int m = 0; string messager = ""; if (message != null && contact != null) { RunOnUiThread (delegate { ImageView random = null; LinearLayout layout = new LinearLayout (context); layout.Orientation = Android.Widget.Orientation.Horizontal; layout.SetGravity (GravityFlags.CenterVertical); 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 (60f, context), (int)ImageHelper.convertDpToPixel (100f, context)); profilepic.Tag = new Java.Lang.String ("profilepic_" + m.ToString ()); if (contact == null) profilepic.SetImageDrawable (Application.Context.Resources.GetDrawable (Resource.Drawable.defaultuserimage)); else { if (contact.Picture.Length > 0) { //profilepic.SetImageDrawable(Android.Graphics.Drawables.Drawable.CreateFromStream(new MemoryStream(eachContact.ContactUser.Picture), "Profile")); loadProfilePicture (contact.AccountID); } else { profilepic.SetImageDrawable (Application.Context.Resources.GetDrawable (Resource.Drawable.defaultuserimage)); } //layout.AddView(profilepic); LinearLayout layout2 = new LinearLayout (context); layout2.Orientation = Orientation.Vertical; layout2.SetGravity (GravityFlags.Center); TextView name = new TextView (context); name.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (260f, context), (int)ImageHelper.convertDpToPixel (40f, context)); name.Gravity = GravityFlags.Center; name.SetTextColor (Color.White); name.TextSize = 16f; name.Text = contact.FirstName + " " + contact.LastName; layout2.AddView (name); TextView text = new TextView (context); text.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (240f, context), (int)ImageHelper.convertDpToPixel (60f, context)); text.SetPadding ((int)ImageHelper.convertDpToPixel (10f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), 0); text.Gravity = GravityFlags.CenterVertical; if (name.Text == isMe) text.SetBackgroundResource (Resource.Drawable.bubblesolidright); else text.SetBackgroundResource (Resource.Drawable.bubblesolidleft); text.TextSize = 16f; for (int e = 0; e < message.MessageStepDBList.Count; ++e) { if (!string.IsNullOrEmpty (message.MessageStepDBList [e].MessageText)) { messager = message.MessageStepDBList [e].MessageText; break; } } if (string.IsNullOrEmpty (messager)) messager = "No text message found"; int nolines = messager.Length / 27; text.SetHeight ((nolines + 1) * 20); text.SetTextColor (Android.Graphics.Color.Black); text.Text = messager; layout2.Clickable = true; layout2.AddView (text); if (message.MessageStepDBList.Count > 1) { LinearLayout layout3 = new LinearLayout (context); layout3.Orientation = Orientation.Horizontal; if (name.Text == 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.Text != isMe) { 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 += delegate { PlayMessage(message); }; layout3.AddView (random); } for (int i = 1; i < message.MessageStepDBList.Count; ++i) { switch (message.MessageStepDBList [i].StepType) { case LOLMessageDelivery.MessageStep.StepTypes.Animation: 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: 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: 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: 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: 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: 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: 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: 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.Text == isMe) { 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 += delegate { PlayMessage(message); }; layout3.AddView (random); } layout2.AddView (layout3); } if (name.Text != isMe) { layout.AddView (profilepic); layout.AddView (layout2); } else { layout.AddView (layout2); layout.AddView (profilepic); } converse.AddView (layout); m++; } }); } }
public static Message ConvertFromMessageDB(MessageDB item) { Message toReturn = new Message (); toReturn.Errors = item.Errors; toReturn.FromAccountID = item.FromAccountID; toReturn.MessageID = item.MessageID; toReturn.MessageSent = item.MessageSent; toReturn.MessageConfirmed = item.MessageConfirmed; if (null != item.MessageStepDBList && item.MessageStepDBList.Count > 0) { MessageStep[] messageSteps = new MessageStep[item.MessageStepDBList.Count]; for (int i = 0; i < item.MessageStepDBList.Count; i++) { messageSteps [i] = MessageStepDB.ConvertFromMessageStepDB (item.MessageStepDBList [i]); }//end for toReturn.MessageSteps = messageSteps.ToList (); }//end if if (null != item.MessageRecipientDBList && item.MessageRecipientDBList.Count > 0) { Message.MessageRecipient[] recipients = new MessageRecipient[item.MessageRecipientDBList.Count]; for (int i = 0; i < item.MessageRecipientDBList.Count; i++) { recipients [i] = MessageRecipientDB.ConvertFromMessageRecipientDB (item.MessageRecipientDBList [i]); }//end for toReturn.MessageRecipients = recipients.ToList (); }//end if return toReturn; }
public static MessageDB ConvertFromMessage(Message item) { MessageDB toReturn = new MessageDB (); toReturn.Errors = item.Errors; toReturn.FromAccountID = item.FromAccountID; toReturn.MessageID = item.MessageID; toReturn.MessageSent = item.MessageSent; toReturn.MessageSteps = item.MessageSteps; toReturn.MessageConfirmed = item.MessageConfirmed; toReturn.MessageStepDBList = new List<MessageStepDB> (); if (null != item.MessageSteps && item.MessageSteps.Count > 0) { foreach (MessageStep eachMessageStep in item.MessageSteps) { toReturn.MessageStepDBList.Add (MessageStepDB.ConvertFromMessageStep (eachMessageStep)); }//end foreach }//end if toReturn.MessageRecipientDBList = new List<MessageRecipientDB> (); if (null != item.MessageRecipients && item.MessageRecipients.Count > 0) { foreach (Message.MessageRecipient eachMessageRecipient in item.MessageRecipients) { MessageRecipientDB msgRcpDB = MessageRecipientDB.ConvertFromMessageRecipient (eachMessageRecipient); msgRcpDB.MessageGuid = toReturn.MessageGuid; toReturn.MessageRecipientDBList.Add (msgRcpDB); }//end foreach }//end if return toReturn; }
private void StartPlayMessage(MessageDB message) { bool hasRespondedPollSteps = this.pollSteps.Count (s => s.Value.HasResponded) > 0; if (hasRespondedPollSteps) { RunOnUiThread (() => Toast.MakeText (context, Resource.String.pollGettingResults, ToastLength.Short).Show ()); LOLMessageClient service = new LOLMessageClient (LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint); service.PollingStepGetResultsListCompleted += Service_PollingStepGetResultsListCompleted; service.PollingStepGetResultsListAsync (message.MessageID, new Guid (AndroidData.ServiceAuthToken), message); } else { #if DEBUG System.Diagnostics.Debug.WriteLine ("about to play the message"); #endif RunOnUiThread (delegate { if (progress != null) RunOnUiThread (() => progress.Dismiss ()); List<UserDB> recipients = new List<UserDB> (); UserDB tmpUsr = null; for (int m = 0; m < message.MessageRecipientDBList.Count; ++m) { tmpUsr = dbm.GetUserWithAccountID (message.MessageRecipientDBList [m].AccountGuid); if (tmpUsr != null) recipients.Add (tmpUsr); } tmpUsr = dbm.GetUserWithAccountID (message.FromAccountGuid); if (tmpUsr != null) recipients.Add (tmpUsr); MessagePlaybackController playbackController = new MessagePlaybackController (message.MessageStepDBList, this.contentPackItems, this.voiceFiles, this.pollSteps, new Dictionary<int, LOLMessageSurveyResult> (), markAsRead, recipients, context); #if DEBUG System.Diagnostics.Debug.WriteLine ("we outa here"); #endif }); }//end if else }
private void processMessages(MessageDB message) { List<MessageInfo> messageItems = new List<MessageInfo> (); MessageInfo msgInfo = new MessageInfo (message, message.FromAccountID == AndroidData.CurrentUser.AccountID ? UserDB.ConvertFromUser (AndroidData.CurrentUser) : dbm.GetUserWithAccountID (message.FromAccountGuid)); if (msgInfo != null) messageItems.Add (msgInfo); if (messageItems.Count > 0) { foreach (MessageInfo eachMessageInfo in messageItems) { this.MessageItems [eachMessageInfo.Message.MessageID] = eachMessageInfo; } }//end if }
private void PlayMessage(MessageDB message) { voiceFiles.Clear (); contentPackItems.Clear (); pollSteps.Clear (); MessageInfo messageInfo = this.MessageItems [message.MessageID]; ContentState dlState = new ContentState (message); contentPackItems = getLocalContentPackItems (dlState.ContentPackIDQ.ToList ()) .ToDictionary (s => s.ContentPackItemID, s => ContentPackItemDB.ConvertFromContentPackItemDB (s)); if (messageInfo.HasContentInfo) { RunOnUiThread (delegate { if (progress != null) progress.Dismiss (); this.PlayUnsentMessage (messageInfo.ContentInfo); }); } else { Dictionary<Guid, Dictionary<int, string>> localVoiceFiles = getLocalVoiceFiles (new List<Pair<Guid, List<int>>> () { new Pair<Guid, List<int>>(dlState.Message.MessageID, dlState.VoiceIDQ.ToList()) }); if (!localVoiceFiles.TryGetValue (dlState.Message.MessageID, out voiceFiles)) voiceFiles = new Dictionary<int, string> (); pollSteps = getLocalPollingStepsForMessage (dlState.Message.MessageGuid) .ToDictionary (s => s.StepNumber, s => PollingStepDB.ConvertFromPollingStepDB (s)); dlState.RemoveExistingItems (contentPackItems.Keys.ToList (), voiceFiles.Keys.ToList (), pollSteps.Keys.ToList ()); if (dlState.HasContentForDownload) { #if DEBUG System.Diagnostics.Debug.WriteLine ("dlState has content for download"); #endif if (dlState.HasContentPackItems) { #if DEBUG System.Diagnostics.Debug.WriteLine ("dlState has contentpackitems for download"); #endif LOLConnectClient service = new LOLConnectClient (LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint); service.ContentPackGetItemCompleted += Service_ContentPackGetItemCompleted; service.ContentPackGetItemAsync (dlState.ContentPackIDQ.Peek (), ContentPackItem.ItemSize.Small, AndroidData.CurrentUser.AccountID, new Guid (AndroidData.ServiceAuthToken), dlState); } else if (dlState.HasVoiceRecordings) { #if DEBUG System.Diagnostics.Debug.WriteLine ("dlState has voicerecordings for download"); #endif LOLMessageClient service = new LOLMessageClient (LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint); service.MessageGetStepDataCompleted += Service_MessageGetStepData; service.MessageGetStepDataAsync (dlState.Message.MessageID, dlState.VoiceIDQ.Peek (), new Guid (AndroidData.ServiceAuthToken), dlState); } else if (dlState.HasPollingSteps) { RunOnUiThread (delegate { #if DEBUG System.Diagnostics.Debug.WriteLine ("dlState has pollingsteps for download"); #endif LOLMessageClient service = new LOLMessageClient (LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint); service.PollingStepGetCompleted += Service_PollingStepGetCompleted; service.PollingStepGetAsync (dlState.Message.MessageID, dlState.PollingIDQ.Peek (), AndroidData.CurrentUser.AccountID, new Guid (AndroidData.ServiceAuthToken), dlState); }); } } else RunOnUiThread (delegate { StartPlayMessage (message); }); } }
private void random_Click(object s, EventArgs e) { ImageView senderObj = (ImageView)s; string conID = senderObj.ContentDescription; MessageDB message = new MessageDB (); message = dbm.GetMessage (conID); MessageReceived player = new MessageReceived (message, context); }
private void playOut(string message) { MessageDB mess = new MessageDB (); mess = dbm.GetMessage (message); Messages.ComposeMessageMainUtil.messageDB = mess; Intent i = new Intent (this, typeof(Messages.ComposeMessageMainActivity)); i.PutExtra ("readonly", true); StartActivity (i); }
private LinearLayout createMessageBar(LinearLayout mBar, MessageDB message, int leftOver) { RunOnUiThread (delegate { LinearLayout icons = new LinearLayout (context); ImageView random = null; icons.Orientation = Orientation.Horizontal; icons.SetGravity (GravityFlags.Left); icons.SetVerticalGravity (GravityFlags.CenterVertical); icons.SetMinimumHeight (30); int topPos = 0; if (wowZapp.LaffOutOut.Singleton.resizeFonts) topPos = 0; icons.SetPadding ((int)ImageHelper.convertDpToPixel (10f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), 0); if (message.MessageStepDBList.Count == 0) { using (random = new ImageView (context)) { using (LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { lp.SetMargins (0, 0, leftOver - (int)ImageHelper.convertDpToPixel (30f, context), 0); random.LayoutParameters = lp; } random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context)); random.SetBackgroundResource (Resource.Drawable.playblack); random.ContentDescription = message.MessageGuid; random.Click += delegate { Messages.MessageReceived m = new Messages.MessageReceived (message, context); }; icons.AddView (random); } } else { int end = message.MessageStepDBList.Count > 3 ? 3 : message.MessageStepDBList.Count; int iconSize = (int)ImageHelper.convertDpToPixel (34f, context); int toEnd = leftOver - (2 * iconSize) - (end * iconSize); for (int i = 0; i < end; ++i) { switch (message.MessageStepDBList [i].StepType) { case LOLMessageDelivery.MessageStep.StepTypes.Text: using (random = new ImageView (context)) { using (LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { lp.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (1f, context), 0); random.LayoutParameters = lp; } random.SetBackgroundResource (Resource.Drawable.textmsg); random.ContentDescription = message.MessageID.ToString (); random.Click += new EventHandler (imgMessage_Click); icons.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Animation: using (random = new ImageView (context)) { using (LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { lp.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (1f, context), 0); random.LayoutParameters = lp; } random.SetBackgroundResource (Resource.Drawable.drawicon); random.ContentDescription = message.MessageID.ToString (); random.Click += new EventHandler (imgMessage_Click); icons.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Comicon: using (random = new ImageView (context)) { using (LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { lp.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (1f, context), 0); random.LayoutParameters = lp; } random.SetBackgroundResource (Resource.Drawable.comicon); random.ContentDescription = message.MessageID.ToString (); random.Click += new EventHandler (imgMessage_Click); icons.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Comix: using (random = new ImageView (context)) { using (LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { lp.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (1f, context), 0); random.LayoutParameters = lp; } random.SetBackgroundResource (Resource.Drawable.comix); random.ContentDescription = message.MessageID.ToString (); random.Click += new EventHandler (imgMessage_Click); icons.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Emoticon: using (random = new ImageView (context)) { using (LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { lp.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (1f, context), 0); random.LayoutParameters = lp; } random.SetBackgroundResource (Resource.Drawable.emoticon); random.ContentDescription = message.MessageID.ToString (); random.Click += new EventHandler (imgMessage_Click); icons.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Polling: using (random = new ImageView (context)) { using (LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { lp.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (1f, context), 0); random.LayoutParameters = lp; } random.SetBackgroundResource (Resource.Drawable.polls); random.ContentDescription = message.MessageID.ToString (); random.Click += new EventHandler (imgMessage_Click); icons.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.SoundFX: using (random = new ImageView (context)) { using (LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { lp.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (1f, context), 0); random.LayoutParameters = lp; } random.SetBackgroundResource (Resource.Drawable.audiofile); random.ContentDescription = message.MessageID.ToString (); random.Click += new EventHandler (imgMessage_Click); icons.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Video: using (random = new ImageView (context)) { using (LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { lp.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (1f, context), 0); random.LayoutParameters = lp; } random.SetBackgroundResource (Resource.Drawable.camera); random.ContentDescription = message.MessageID.ToString (); random.Click += new EventHandler (imgMessage_Click); icons.AddView (random); } break; case LOLMessageDelivery.MessageStep.StepTypes.Voice: using (random = new ImageView (context)) { using (LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { lp.SetMargins (0, 0, (int)ImageHelper.convertDpToPixel (1f, context), 0); random.LayoutParameters = lp; } random.SetBackgroundResource (Resource.Drawable.microphone); random.ContentDescription = message.MessageID.ToString (); random.Click += new EventHandler (imgMessage_Click); icons.AddView (random); } break; } } using (random = new ImageView (context)) { using (LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context))) { lp.SetMargins (toEnd, 0, 0, 0); random.LayoutParameters = lp; } random.SetBackgroundResource (Resource.Drawable.playblack); random.ContentDescription = message.MessageID.ToString (); random.Click += new EventHandler (random_Click); icons.AddView (random); } } mBar.AddView (icons); }); return mBar; }