Ejemplo n.º 1
0
 private void PollButton_Click(object sender, EventArgs e)
 {
     Button btn = (Button)sender;
     int option = (int)btn.Tag;
     LOLMessageClient service = new LOLMessageClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint);
     service.PollingStepResponseCompleted += new EventHandler<PollingStepResponseCompletedEventArgs>(service_PollingStepResponseCompleted);
     service.PollingStepResponseAsync(MessagePlaybackUtil.messageSteps [co].StepID, AndroidData.CurrentUser.AccountID, option, new Guid(AndroidData.ServiceAuthToken));
 }
        //private Context context;
        //private DBManager dbm;
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            stepID = MessagePlaybackUtil.messageSteps.Where(s => s.StepNumber == MessagePollUtil.pollStep.StepNumber).Select(s => s.StepID).FirstOrDefault();

            if (MessagePollUtil.isPhoto)
            {
                SetContentView(Resource.Layout.PhotoPoll);
                topleft = FindViewById<ImageView>(Resource.Id.imgPoll1);
                topright = FindViewById<ImageView>(Resource.Id.imgPoll2);
                bottomleft = FindViewById<ImageView>(Resource.Id.imgPoll3);
                bottomright = FindViewById<ImageView>(Resource.Id.imgPoll4);
                voteTL = FindViewById<ProgressBar>(Resource.Id.pbVoteTL);
                voteTR = FindViewById<ProgressBar>(Resource.Id.pbVoteTR);
                voteBL = FindViewById<ProgressBar>(Resource.Id.pbVoteBL);
                voteBR = FindViewById<ProgressBar>(Resource.Id.pbVoteBR);
                textPoll = FindViewById<TextView>(Resource.Id.txtPollText);
                textPoll.Text = MessagePollUtil.pollStep.PollingQuestion;
                done = FindViewById<Button>(Resource.Id.btnDone);
                done.Click += new EventHandler(btnUniBack_Click);
                btnUniBack = FindViewById<ImageView>(Resource.Id.btnUniBack);
                btnUniBack.Click += new EventHandler(btnUniBack_Click);

                if (MessagePollUtil.pollScreenType == PollingScreenType.Vote)
                {
                    voteTL.Visibility = voteTR.Visibility = voteBL.Visibility = voteBR.Visibility = ViewStates.Invisible;
                    topleft.Click += new EventHandler(topleft_Click);
                    topright.Click += new EventHandler(topright_Click);
                    bottomleft.Click += new EventHandler(bottomleft_Click);
                    bottomright.Click += new EventHandler(bottomright_Click);
                } else
                {
                    LOLMessageClient service = new LOLMessageClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint);
                    service.PollingStepGetResultsCompleted += Service_PollingStepGetResultsCompleted;
                    service.PollingStepGetResultsAsync(stepID, AndroidData.CurrentUser.AccountID, new Guid(AndroidData.ServiceAuthToken));
                }

                if (MessagePollUtil.pollStep.PollingData1.Length != 0)
                {
                    Drawable imgDataA = Drawable.CreateFromStream(new MemoryStream(MessagePollUtil.pollStep.PollingData1), "Poll1");
                    topleft.SetImageDrawable(imgDataA);
                    imgDataA.Dispose();
                }
                if (MessagePollUtil.pollStep.PollingData2.Length != 0)
                {
                    Drawable imgDataB = Drawable.CreateFromStream(new MemoryStream(MessagePollUtil.pollStep.PollingData2), "Poll2");
                    topright.SetImageDrawable(imgDataB);
                    imgDataB.Dispose();
                }
                if (MessagePollUtil.pollStep.PollingData3.Length != 0)
                {
                    Drawable imgDataC = Drawable.CreateFromStream(new MemoryStream(MessagePollUtil.pollStep.PollingData3), "Poll3");
                    bottomleft.SetImageDrawable(imgDataC);
                    imgDataC.Dispose();
                }
                if (MessagePollUtil.pollStep.PollingData4.Length != 0)
                {
                    Drawable imgDataD = Drawable.CreateFromStream(new MemoryStream(MessagePollUtil.pollStep.PollingData2), "Poll4");
                    bottomright.SetImageDrawable(imgDataD);
                    imgDataD.Dispose();
                }
            } else
            {
                SetContentView(Resource.Layout.TextPoll);
                opt1 = FindViewById<Button>(Resource.Id.btnOpt1);
                opt2 = FindViewById<Button>(Resource.Id.btnOpt2);
                opt3 = FindViewById<Button>(Resource.Id.btnOpt3);
                opt4 = FindViewById<Button>(Resource.Id.btnOpt4);
                res1 = FindViewById<ProgressBar>(Resource.Id.pbRes1);
                res2 = FindViewById<ProgressBar>(Resource.Id.pbRes2);
                res3 = FindViewById<ProgressBar>(Resource.Id.pbRes3);
                res4 = FindViewById<ProgressBar>(Resource.Id.pbRes4);
                TextView pollQ = FindViewById<TextView>(Resource.Id.txtPollText);
                pollQ.Text = MessagePollUtil.pollStep.PollingQuestion;

                finished = FindViewById<Button>(Resource.Id.btnDone);
                finished.Click += delegate
                {
                    returnToSender();
                };

                btnUniBack = FindViewById<ImageView>(Resource.Id.btnUniBack);
                btnUniBack.Click += delegate
                {
                    returnToSender();
                };

                opt1.Text = MessagePollUtil.pollStep.PollingAnswer1;
                opt2.Text = MessagePollUtil.pollStep.PollingAnswer2;
                opt3.Text = MessagePollUtil.pollStep.PollingAnswer3;
                opt4.Text = MessagePollUtil.pollStep.PollingAnswer4;

                if (MessagePollUtil.pollScreenType == PollingScreenType.Vote)
                {
                    res1.Visibility = res2.Visibility = res3.Visibility = res4.Visibility = ViewStates.Invisible;
                    opt1.Click += new EventHandler(opt1_Click);
                    opt2.Click += new EventHandler(opt2_Click);
                    opt3.Click += new EventHandler(opt3_Click);
                    opt4.Click += new EventHandler(opt4_Click);
                } else
                {
                    LOLMessageClient service = new LOLMessageClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint);
                    service.PollingStepGetResultsCompleted += Service_PollingStepGetResultsCompleted;
                    service.PollingStepGetResultsAsync(stepID, AndroidData.CurrentUser.AccountID, new Guid(AndroidData.ServiceAuthToken));
                }
            }
        }
 void topright_Click(object sender, EventArgs e)
 {
     LOLMessageClient service = new LOLMessageClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint);
     service.PollingStepResponseCompleted += new EventHandler<PollingStepResponseCompletedEventArgs>(service_PollingStepResponseCompleted);
     service.PollingStepResponseAsync(stepID, AndroidData.CurrentUser.AccountID, 2, new Guid(AndroidData.ServiceAuthToken));
 }
 void service_PollingStepResponseCompleted(object sender, PollingStepResponseCompletedEventArgs e)
 {
     LOLMessageClient service = new LOLMessageClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint);
     service.PollingStepGetResultsCompleted += Service_PollingStepGetResultsCompleted;
     service.PollingStepGetResultsAsync(stepID, AndroidData.CurrentUser.AccountID, new Guid(AndroidData.ServiceAuthToken));
 }
Ejemplo n.º 5
0
        private void GetMessages()
        {
            if (!killed)
            {
                if (Messages.MessageConversations.storedMessages.Count != 0)
                    Messages.MessageConversations.storedMessages.Clear();
                List<MessageDB> message = new List<MessageDB>();
                message = dbm.GetAllMessagesForOwner(AndroidData.CurrentUser.AccountID.ToString());
                foreach (MessageDB m in message)
                    Messages.MessageConversations.storedMessages.Add(m);
                if (Messages.MessageConversations.storedMessages.Count == 0)
                {
                    List<Guid> excludeMessageGuids = new List<Guid>();
                    /*excludeMessageGuids = this.MessageItems.Values.Where (s => s.Message.MessageStepDBList.Count (t => t.StepID == default(Guid)) == 0)
                    .Select (s => s.Message.MessageID).ToList ();*/
                    excludeMessageGuids = Messages.MessageConversations.storedMessages.Where(s => s.MessageStepDBList.Count(t => t.StepID == default(Guid)) == 0)
                        .Select(s => s.MessageID).ToList();
                    LOLMessageClient service = new LOLMessageClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint);
                    service.MessageGetNewCompleted += Service_MessageGetNewCompleted;
                    service.MessageGetNewAsync(AndroidData.CurrentUser.AccountID, AndroidData.NewDeviceID,
                                                     excludeMessageGuids,
                                                     new Guid(AndroidData.ServiceAuthToken));
                } else
                {
                    List<MessageDB> messages = new List<MessageDB>();
                    List<UserDB> users = new List<UserDB>();
                    foreach (MessageDB eachMessageDB in message)
                    {
                        if (eachMessageDB != null)
                        {
                            UserDB contactUser = null;
                            Messages.MessageInfo msgInfoItem = null;

                            if (eachMessageDB.FromAccountID != AndroidData.CurrentUser.AccountID)
                            {
                                foreach (ContactDB contact in Contacts.ContactsUtil.contacts)
                                {
                                    if (contact.ContactAccountID == eachMessageDB.FromAccountID)
                                    {
                                        contactUser = UserDB.ConvertFromUser(contact.ContactUser);
                                        break;
                                    } else
                                        contactUser = dbm.GetUserWithAccountID(eachMessageDB.FromAccountGuid);
                                }

                                msgInfoItem = new Messages.MessageInfo(eachMessageDB, contactUser);
                            } else
                            {
                                contactUser = UserDB.ConvertFromUser(AndroidData.CurrentUser);
                                msgInfoItem = new Messages.MessageInfo(eachMessageDB, contactUser);

                                if (!eachMessageDB.MessageConfirmed)
                                {
                                    ContentInfo contentInfo = dbm.GetContentInfoByMessageDBID(eachMessageDB.ID);
                                    msgInfoItem.ContentInfo = contentInfo;
                                }
                            }
                            messages.Add(eachMessageDB);
                            users.Add(contactUser);
                            this.MessageItems [eachMessageDB.MessageID] = msgInfoItem;
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
        private void PrepareViews(int co)
        {
            if (co >= counter || done)
                RunOnUiThread(delegate
                {
                    t.Stop();
                    Window.ClearFlags(WindowManagerFlags.KeepScreenOn);
                    Finish();
                });

            if (!done)
                t.Start();
            float[] newSizes = new float[2];
            newSizes [0] = 200f;
            if (wowZapp.LaffOutOut.Singleton.resizeFonts)
            {
                newSizes [0] *= wowZapp.LaffOutOut.Singleton.bigger;
                newSizes [1] = newSizes [0];
            }
            this.stepViews = new Dictionary<int, View>();
            string path = System.IO.Path.Combine(wowZapp.LaffOutOut.Singleton.ContentDirectory, "tempaudio.wav");
            string videoPath = System.IO.Path.Combine(wowZapp.LaffOutOut.Singleton.ContentDirectory, "tempvideo.mp4");

            #if DEBUG
            System.Diagnostics.Debug.WriteLine("co = {0}, counter = {1}", co, counter);
            #endif
            MessageStep eachMessageStep = null;
            if (co != counter)
            {
                eachMessageStep = MessagePlaybackUtil.messageSteps [co];

                ContentPackItem packItem = null;
                MessagePlaybackUtil.contentPackItems.TryGetValue(eachMessageStep.ContentPackItemID, out packItem);

            #if DEBUG
                System.Diagnostics.Debug.WriteLine("co = {0}, messagestep type = {1}, contentPackID = {2}, packItem = {3}", co, eachMessageStep, eachMessageStep.ContentPackItemID, packItem != null ? "yes" : "no");
            #endif

                switch (eachMessageStep.StepType)
                {
                    case MessageStep.StepTypes.Text:
                        RunOnUiThread(delegate
                        {
                            using (TextView textMessage = new TextView (context))
                            {
                                textMessage.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(250f, context), (int)ImageHelper.convertDpToPixel(150f, context));
                                textMessage.SetBackgroundResource(Resource.Drawable.bubblesolidleft);
                                textMessage.Gravity = GravityFlags.Top;
                                textMessage.SetPadding((int)ImageHelper.convertDpToPixel(20f, context), (int)ImageHelper.convertDpToPixel(15f, context),
                                                (int)ImageHelper.convertDpToPixel(20f, context), (int)ImageHelper.convertDpToPixel(15f, context));
                                textMessage.SetTextColor(Color.Black);
                                textMessage.SetTextSize(Android.Util.ComplexUnitType.Pt, 12f);
                                textMessage.Text = MessagePlaybackUtil.messageSteps [co].MessageText;
                                textMessage.Visibility = ViewStates.Visible;
                                linView.AddView(textMessage);
                                this.stepViews [eachMessageStep.StepNumber] = textMessage;
                            }
                        });
                        break;

                    case MessageStep.StepTypes.Comix:
                        if (packItem != null)
                        {
                            RunOnUiThread(delegate
                            {
                                using (ImageView preview = new ImageView (context))
                                {
                                    preview.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(newSizes [0], context), (int)ImageHelper.convertDpToPixel(newSizes [1], context));
                                    preview.SetScaleType(ImageView.ScaleType.FitXy);
                                    Android.Graphics.Drawables.Drawable imgDataC = Android.Graphics.Drawables.Drawable.CreateFromStream(new MemoryStream(packItem.ContentPackItemIcon), "Comix");
                                    preview.SetImageDrawable(imgDataC);
                                    linView.AddView(preview);
                                    this.stepViews [eachMessageStep.StepNumber] = preview;
                                }
                            });
                        }
                        break;

                    case MessageStep.StepTypes.Comicon:
                        if (packItem != null)
                        {
                            RunOnUiThread(delegate
                            {
                                using (Android.Graphics.Drawables.Drawable imgDataS = Android.Graphics.Drawables.Drawable.CreateFromStream (new MemoryStream (packItem.ContentPackItemIcon), "Comicon"))
                                {
                                    using (ImageView preview = new ImageView (context))
                                    {
                                        preview.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(newSizes [0], context), (int)ImageHelper.convertDpToPixel(newSizes [1], context));
                                        preview.SetScaleType(ImageView.ScaleType.FitXy);
                                        preview.SetImageDrawable(imgDataS);
                                        linView.AddView(preview);
                                        this.stepViews [eachMessageStep.StepNumber] = preview;
                                        byte[] audio = packItem.ContentPackData;
                                        System.IO.File.WriteAllBytes(path, audio);
                                        AudioPlayer csfx = new AudioPlayer(context);
                                        t.Interval = csfx.findDuration(path) + 1000;
                                        csfx.playFromFile(path);
                                    }
                                }
                            });
                        }
                        break;
                    case MessageStep.StepTypes.SoundFX:
                        if (packItem != null)
                        {
                            RunOnUiThread(delegate
                            {
                                using (ImageView preview = new ImageView (context))
                                {
                                    preview.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(newSizes [0], context), (int)ImageHelper.convertDpToPixel(newSizes [1], context));
                                    preview.SetScaleType(ImageView.ScaleType.FitXy);
                                    preview.SetImageResource(Resource.Drawable.audiofile);
                                    linView.AddView(preview);
                                    byte[] audio = packItem.ContentPackData;
                                    System.IO.File.WriteAllBytes(path, audio);
                                    AudioPlayer csfx = new AudioPlayer(context);
                                    t.Interval = csfx.findDuration(path) + 1000;
                                    csfx.playFromFile(path);
                                    this.stepViews [eachMessageStep.StepNumber] = preview;
                                }
                            });
                        }
                        break;
                    case MessageStep.StepTypes.Emoticon:
                        if (packItem != null)
                        {
                            //RunOnUiThread (delegate {
                            t.Interval = 5000;
                            string base64String = System.Convert.ToBase64String(packItem.ContentPackData, 0, packItem.ContentPackData.Length);
                            using (WebView wv = new WebView (context))
                            {
                                string url = "<img src=\"data:image/gif;base64," + base64String + "\" width=\"" + ((int)newSizes [0]).ToString() + "\" height=\"" + ((int)newSizes [1]).ToString() + "\" />";
                                wv.LoadDataWithBaseURL(null, url, "text/html", "UTF-8", null);
                                wv.VerticalScrollBarEnabled = false;
                                wv.HorizontalScrollBarEnabled = false;
                                wv.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(200f, context), (int)ImageHelper.convertDpToPixel(200f, context));
                                wv.SetBackgroundColor(Color.Transparent);
                                RunOnUiThread(() => linView.AddView(wv));
                            }
                            //});
                        }
                        break;
                    case MessageStep.StepTypes.Voice:
                        if (MessagePlaybackUtil.voiceRecordings != null)
                        {
                            RunOnUiThread(delegate
                            {
                                using (ImageView preview = new ImageView (context))
                                {
                                    preview.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(newSizes [0], context), (int)ImageHelper.convertDpToPixel(newSizes [1], context));
                                    preview.SetScaleType(ImageView.ScaleType.FitXy);
                                    preview.SetImageResource(Resource.Drawable.microphone);
                                    linView.AddView(preview);
                                    this.stepViews [eachMessageStep.StepNumber] = preview;
                                }
                                //byte[] audio = getLocalVoiceRecording (MessagePlaybackUtil.voiceRecordings [eachMessageStep.StepNumber]);
                                AudioPlayer voice = new AudioPlayer(context);
            #if DEBUG
                                System.Diagnostics.Debug.WriteLine("audio file filename = {0}, stepNumber = {1}", MessagePlaybackUtil.voiceRecordings [eachMessageStep.StepNumber], eachMessageStep.StepNumber);
            #endif
                                t.Interval = voice.findDuration(MessagePlaybackUtil.voiceRecordings [eachMessageStep.StepNumber]) + 1000;
                                string audioPath = MessagePlaybackUtil.voiceRecordings [eachMessageStep.StepNumber];
                                if (!File.Exists(audioPath))
                                {
                                    #if DEBUG
                                    System.Diagnostics.Debug.WriteLine("audio file doesn't exist for playback");
                                    #endif
                                } else
                                    voice.playFromFile(audioPath);
                                isPlaying = true;
                            });
                        }
                        break;
                    case MessageStep.StepTypes.Video:
                        if (packItem != null)
                        {
                            RunOnUiThread(delegate
                            {
                                SurfaceView preview = new SurfaceView(context);
                                preview.LayoutParameters = new ViewGroup.LayoutParams((int)ImageHelper.convertDpToPixel(newSizes [0], context), (int)ImageHelper.convertDpToPixel(newSizes [1], context));
                                linView.AddView(preview);
                                byte[] audio = packItem.ContentPackData;
                                System.IO.File.WriteAllBytes(videoPath, audio);
                                videoPlay voice = new videoPlay(preview, videoPath);
                                t.Interval = voice.videoDuration(path) + 1000;
                                voice.videoStart();
                                this.stepViews [eachMessageStep.StepNumber] = preview;
                                isPlaying = true;
                            });
                        }
                        break;
                    case MessageStep.StepTypes.Animation:
                    /*if (eachMessageStep.AnimationData != null) {
                        string animationHtml =
                            Translator.MakePlaybackCode (eachMessageStep.AnimationData, (int)newSizes [0], (int)newSizes [1], RenderPlatformTypes.Android, JSTemplate);
                        t.Interval = Convert.ToInt32 (eachMessageStep.AnimationData.Duration) + 100;
                        using (WebView wv = new WebView (context)) {
                            wv.LoadDataWithBaseURL (null, animationHtml, "text/html", "UTF-8", null);
                            wv.VerticalScrollBarEnabled = false;
                            wv.HorizontalScrollBarEnabled = false;
                            wv.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (200f, context), (int)ImageHelper.convertDpToPixel (200f, context));
                            wv.SetBackgroundColor (Color.Transparent);
                            RunOnUiThread (() => linView.AddView (wv));
                        }
                    }*/
                        break;
                    case MessageStep.StepTypes.Polling:
                        if (MessagePlaybackUtil.pollSteps.Count > 0)
                        {
                            PollingStep pollStep = MessagePlaybackUtil.pollSteps [eachMessageStep.StepNumber];
                            if (string.IsNullOrEmpty(pollStep.PollingAnswer1))
                            {
                                t.Stop();
                                MessagePollUtil.pollStep = pollStep;
                                MessagePollUtil.recipients = MessagePlaybackUtil.recipients;
                                MessagePollUtil.isPhoto = true;
                                LOLMessageSurveyResult pollResult;
            #if DEBUG
                                System.Diagnostics.Debug.WriteLine("PollResults = {0}", MessagePlaybackUtil.pollResults == null ? "null" : "something");
            #endif
                                if (MessagePlaybackUtil.pollResults.TryGetValue(eachMessageStep.StepNumber, out pollResult))
                                    MessagePollUtil.pollScreenType = PollingScreenType.Results;
                                else
                                    MessagePollUtil.pollScreenType = PollingScreenType.Vote;

            #if DEBUG
                                System.Diagnostics.Debug.WriteLine("polltype = {0}", MessagePollUtil.pollScreenType);
            #endif

                                RunOnUiThread(delegate
                                {
                                    SetContentView(Resource.Layout.PhotoPoll);
                                    ImageView topleft = FindViewById<ImageView>(Resource.Id.imgPoll1);
                                    topleft.Tag = 1;
                                    ImageView topright = FindViewById<ImageView>(Resource.Id.imgPoll2);
                                    topright.Tag = 2;
                                    ImageView bottomleft = FindViewById<ImageView>(Resource.Id.imgPoll3);
                                    bottomleft.Tag = 3;
                                    ImageView bottomright = FindViewById<ImageView>(Resource.Id.imgPoll4);
                                    bottomright.Tag = 4;
                                    voteTL = FindViewById<ProgressBar>(Resource.Id.pbVoteTL);
                                    voteTR = FindViewById<ProgressBar>(Resource.Id.pbVoteTR);
                                    voteBL = FindViewById<ProgressBar>(Resource.Id.pbVoteBL);
                                    voteBR = FindViewById<ProgressBar>(Resource.Id.pbVoteBR);
                                    TextView textPoll = FindViewById<TextView>(Resource.Id.txtPollText);
                                    textPoll.Text = MessagePollUtil.pollStep.PollingQuestion;
                                    doner = FindViewById<Button>(Resource.Id.btnDone);
                                    if (MessagePollUtil.pollScreenType == PollingScreenType.Results)
                                    {
                                        doner.Click += delegate
                                        {
                                            Intent i = new Intent(this, typeof(MessagePlayback));
                                            i.PutExtra("position", co + 1);
                                            StartActivity(i);
                                            Finish();
                                        };
                                    } else
                                        doner.Visibility = ViewStates.Invisible;

                                    ImageButton btnUniBack = FindViewById<ImageButton>(Resource.Id.btnUniBack);
                                    btnUniBack.Visibility = ViewStates.Invisible;

                                    if (MessagePollUtil.pollScreenType == PollingScreenType.Vote)
                                    {
                                        voteTL.Visibility = voteTR.Visibility = voteBL.Visibility = voteBR.Visibility = ViewStates.Invisible;
                                        topleft.Click += new EventHandler(Photo_Click);
                                        topright.Click += new EventHandler(Photo_Click);
                                        bottomleft.Click += new EventHandler(Photo_Click);
                                        bottomright.Click += new EventHandler(Photo_Click);
                                    } else
                            if (MessagePollUtil.pollScreenType == PollingScreenType.Results)
                                    {
                                        LOLMessageClient service = new LOLMessageClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint);
                                        service.PollingStepGetResultsCompleted += Service_PollingStepGetResultsCompleted;
                                        service.PollingStepGetResultsAsync(eachMessageStep.StepID, AndroidData.CurrentUser.AccountID, new Guid(AndroidData.ServiceAuthToken));
                                    }

                                    if (MessagePollUtil.pollStep.PollingData1 != null)
                                    {
                                        if (MessagePollUtil.pollStep.PollingData1.Length != 0)
                                        {
            #if DEBUG
                                            System.Diagnostics.Debug.WriteLine("in A");
            #endif
                                            using (Drawable imgDataA = Drawable.CreateFromStream (new MemoryStream (MessagePollUtil.pollStep.PollingData1), "Poll1"))
                                            {
                                                topleft.SetImageDrawable(imgDataA);
                                            }
                                        }
                                    }
                                    if (MessagePollUtil.pollStep.PollingData2 != null)
                                    {
                                        if (MessagePollUtil.pollStep.PollingData2.Length != 0)
                                        {
            #if DEBUG
                                            System.Diagnostics.Debug.WriteLine("in B");
            #endif
                                            using (Drawable imgDataB = Drawable.CreateFromStream (new MemoryStream (MessagePollUtil.pollStep.PollingData2), "Poll2"))
                                            {
                                                topright.SetImageDrawable(imgDataB);
                                            }
                                        }
                                    }
                                    if (MessagePollUtil.pollStep.PollingData3 != null)
                                    {
                                        if (MessagePollUtil.pollStep.PollingData3.Length != 0)
                                        {
            #if DEBUG
                                            System.Diagnostics.Debug.WriteLine("in C");
            #endif
                                            using (Drawable imgDataC = Drawable.CreateFromStream (new MemoryStream (MessagePollUtil.pollStep.PollingData3), "Poll3"))
                                            {
                                                bottomleft.SetImageDrawable(imgDataC);
                                            }
                                        }
                                    }
                                    if (MessagePollUtil.pollStep.PollingData4 != null)
                                    {
                                        if (MessagePollUtil.pollStep.PollingData4.Length != 0)
                                        {
            #if DEBUG
                                            System.Diagnostics.Debug.WriteLine("in D");
            #endif
                                            using (Drawable imgDataD = Drawable.CreateFromStream (new MemoryStream (MessagePollUtil.pollStep.PollingData4), "Poll4"))
                                            {
                                                bottomright.SetImageDrawable(imgDataD);
                                            }
                                        }
                                    }
                                });
                            } else
                            {
                                MessagePollUtil.isPhoto = false;
                                MessagePollUtil.pollStep = pollStep;
                                MessagePollUtil.recipients = MessagePlaybackUtil.recipients;
                                LOLMessageSurveyResult pollResult;
                                if (MessagePlaybackUtil.pollResults.TryGetValue(eachMessageStep.StepNumber, out pollResult))
                                    MessagePollUtil.pollScreenType = PollingScreenType.Results;
                                else
                                    MessagePollUtil.pollScreenType = PollingScreenType.Vote;
                                t.Stop();

                                RunOnUiThread(delegate
                                {
                                    SetContentView(Resource.Layout.TextPoll);
                                    Button opt1 = FindViewById<Button>(Resource.Id.btnOpt1);
                                    opt1.Tag = 1;
                                    Button opt2 = FindViewById<Button>(Resource.Id.btnOpt2);
                                    opt2.Tag = 2;
                                    Button opt3 = FindViewById<Button>(Resource.Id.btnOpt3);
                                    opt3.Tag = 3;
                                    Button opt4 = FindViewById<Button>(Resource.Id.btnOpt4);
                                    opt4.Tag = 4;
                                    res1 = FindViewById<ProgressBar>(Resource.Id.pbRes1);
                                    res2 = FindViewById<ProgressBar>(Resource.Id.pbRes2);
                                    res3 = FindViewById<ProgressBar>(Resource.Id.pbRes3);
                                    res4 = FindViewById<ProgressBar>(Resource.Id.pbRes4);
                                    TextView pollQ = FindViewById<TextView>(Resource.Id.txtPollText);
                                    pollQ.Text = MessagePollUtil.pollStep.PollingQuestion;

                                    Button finished = FindViewById<Button>(Resource.Id.btnDone);
                                    finished.Click += delegate
                                    {
                                        Intent i = new Intent(this, typeof(MessagePlayback));
                                        i.PutExtra("position", co + 1);
                                        StartActivity(i);
                                        Finish();
                                    };

                                    doner = FindViewById<Button>(Resource.Id.btnDone);
                                    if (MessagePollUtil.pollScreenType == PollingScreenType.Results)
                                    {
                                        doner.Click += delegate
                                        {
                                            Intent i = new Intent(this, typeof(MessagePlayback));
                                            i.PutExtra("position", co + 1);
                                            StartActivity(i);
                                            Finish();
                                        };
                                    } else
                                        doner.Visibility = ViewStates.Invisible;

                                    ImageButton btnUniBack = FindViewById<ImageButton>(Resource.Id.btnUniBack);
                                    btnUniBack.Visibility = ViewStates.Invisible;

                                    opt1.Text = MessagePollUtil.pollStep.PollingAnswer1;
                                    opt2.Text = MessagePollUtil.pollStep.PollingAnswer2;
                                    opt3.Text = MessagePollUtil.pollStep.PollingAnswer3;
                                    opt4.Text = MessagePollUtil.pollStep.PollingAnswer4;

                                    if (MessagePollUtil.pollScreenType == PollingScreenType.Vote)
                                    {
                                        res1.Visibility = res2.Visibility = res3.Visibility = res4.Visibility = ViewStates.Invisible;
                                        opt1.Click += new EventHandler(PollButton_Click);
                                        opt2.Click += new EventHandler(PollButton_Click);
                                        opt3.Click += new EventHandler(PollButton_Click);
                                        opt4.Click += new EventHandler(PollButton_Click);
                                    } else
                                    {
                                        LOLMessageClient service = new LOLMessageClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint);
                                        service.PollingStepGetResultsCompleted += Service_PollingStepGetResultsCompleted;
                                        service.PollingStepGetResultsAsync(eachMessageStep.StepID, AndroidData.CurrentUser.AccountID, new Guid(AndroidData.ServiceAuthToken));
                                    }
                                });
                            }
                        }
                        break;
                }
            }
            if (File.Exists(path))
                File.Delete(path);

            if (File.Exists(videoPath))
                File.Delete(videoPath);
        }
Ejemplo n.º 7
0
        private void textMessage_Click(object s, EventArgs e)
        {
            TextView senderObj = (TextView)s;
            string conID = senderObj.ContentDescription;
            Guid conGUID = new Guid(conID);
            if (MessageConversations.currentConversationMessages == null)
                MessageConversations.currentConversationMessages = new List<MessageDB>();
            else
                MessageConversations.currentConversationMessages.Clear();
            // find the conversation

            LOLMessageClient client = new LOLMessageClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint);
            client.MessageGetConversationMessageCompleted += Message_GetConversationMessages;
            client.MessageGetConversationMessageAsync(AndroidData.CurrentUser.AccountID, conGUID, new DateTime(1901, 1, 1), DateTime.Now, new Guid(AndroidData.ServiceAuthToken));
        }
Ejemplo n.º 8
0
 private void getConversations()
 {
     LOLMessageClient client = new LOLMessageClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint);
     client.MessageGetConversationListCompleted += Message_ConversationsListComplete;
     client.MessageGetConversationListAsync(AndroidData.CurrentUser.AccountID, /*AndroidData.LastConvChecked*/new DateTime(1901, 1, 1), DateTime.Now,
                                             new Guid(AndroidData.ServiceAuthToken));
 }
Ejemplo n.º 9
0
        private void SendNextMessage(LOLMessageClient service)
        {
            if (!AndroidData.IsAppActive)
            {
                List<ContentInfo> cacheList = new List<ContentInfo>();
                int qCount = this.ContentInfoQ.Count;
                for (int i = 0; i < qCount; i++)
                    cacheList.Add(this.ContentInfoQ.Dequeue());

                dbm.InsertOrUpdateContentInfoItems(cacheList);
                this.IsSendingMessage = false;
                return;
            }

            if (!this.IsSendingMessage)
            {

                if (this.ContentInfoQ.Count > 0)
                {

                    ContentInfo toSend = this.ContentInfoQ.Dequeue();
                    toSend.Message.MessageSent = DateTime.Now;
                    #if DEBUG
                    //RunOnUiThread (() =>System.Diagnostics.Debug.WriteLine ("just do something here"));
                    #endif
                    this.IsSendingMessage = true;

                    if (!toSend.IsFailed && toSend.Retries++ < this.maxRetries)
                    {
                        service.MessageCreateCompleted += Service_MessageCreateCompleted;
                        service.MessageCreateAsync(toSend.Message, toSend.Message.MessageSteps, toSend.Recipients, AndroidData.CurrentUser.AccountID,
                                                    new Guid(AndroidData.ServiceAuthToken), toSend);
                    } else
                    {
                        if (toSend.Retries++ >= this.maxRetries)
                        {
                            // If the max number of retries has been reached, cache the message content and proceed.
            #if(DEBUG)
                            System.Diagnostics.Debug.WriteLine("Max retries: {0}. Will cache message for later.", toSend.Retries);
            #endif
                            dbm.InsertOrUpdateContentInfoItems(new List<ContentInfo>() { toSend });
                            this.IsSendingMessage = false;
                            this.SendNextMessage(service);
                        } else
                        {
                            this.SendNextStep(toSend, service);
                        }//end if else
                    }//end if else
                } else
                {
            #if(DEBUG)
                    System.Diagnostics.Debug.WriteLine("Finished sending messages!");
            #endif
                }//end if else
            }//end if
        }
Ejemplo n.º 10
0
        private void SendAnimationSteps(ContentInfo contentInfo, LOLMessageClient service)
        {
            #if(DEBUG)
            Console.WriteLine("Send animation steps!");
            #endif

            AnimationInfo animationInfoToSend = contentInfo.AnimationItems [contentInfo.ContentState.AnimationIDQ.Peek()];
            animationInfoToSend.MessageID = contentInfo.Message.MessageID;
            contentInfo.AnimationItems [contentInfo.ContentState.AnimationIDQ.Peek()] = animationInfoToSend;

            foreach (FrameInfo eachFrameInfo in animationInfoToSend.FrameItems.Values)
            {
                Console.WriteLine("In frame: {0}", eachFrameInfo.ID);
                foreach (LayerInfo eachLayerItem in eachFrameInfo.Layers.Values)
                {
                    Console.WriteLine("\tIn layer: {0}", eachLayerItem.ID);
                    foreach (TransitionInfo eachTrItem in eachLayerItem.Transitions.Values)
                    {
                        foreach (TransitionEffectSettings efSetting in eachTrItem.Settings.Values)
                        {
                            Console.WriteLine("\t\tSetting: {0}. Duration: {1}.", efSetting.EffectType, efSetting.Duration);
                        }//end foreach
                    }//end foreach
                }//end foreach
            }//end foreach
            AnimationStep animStep = animationInfoToSend.CreateAnimationStep();
            foreach (AnimationTransition eachTransition in animStep.TransitionItems)
            {
                Console.WriteLine("Step transition duration: {0}", eachTransition.TransitionDuration);

                foreach (KeyValuePair<AnimationTypesTransitionEffectType, double> eachSetting in eachTransition.EffectDelays)
                {
                    Console.WriteLine("\tStep duration: {0}", eachTransition.EffectDurations [eachSetting.Key]);
                    Console.WriteLine("\tStep delay: {0}", eachTransition.EffectDelays [eachSetting.Key]);
                    Console.WriteLine("\tStep rotation: {0}", eachTransition.EffectRotations [eachSetting.Key]);
                }//end foreach
            }//end foreach

            // Upload animation step
            service.AnimationStepSaveCompleted += Service_AnimationStepSaveCompleted;
            service.AnimationStepSaveAsync(animStep,
                                           AndroidData.CurrentUser.AccountID,
                                           new Guid(AndroidData.ServiceAuthToken), contentInfo);
        }
        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 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 LoadContactsAndMessages(bool fromLocalOnly)
        {
            this.MessageItems.Clear ();
            conversationItems.Clear ();
            contacts.Clear ();
            this.contacts = dbm.GetAllContactsForOwner (AndroidData.CurrentUser.AccountID.ToString ()).ToDictionary (s => s.ContactAccountID, s => s);
            List<MessageDB> message = new List<MessageDB> ();
            message = dbm.GetAllMessagesForOwner (AndroidData.CurrentUser.AccountID.ToString ());
            List<MessageDB> messages = new List<MessageDB> ();
            List<UserDB> users = new List<UserDB> ();

            foreach (MessageDB eachMessageDB in message) {
                ContactDB msgContact = null;
                UserDB contactUser = null;
                MessageInfo msgInfoItem = null;

                if (eachMessageDB.FromAccountID != AndroidData.CurrentUser.AccountID) {
                    if (this.contacts.TryGetValue (eachMessageDB.FromAccountID, out msgContact))
                        contactUser = UserDB.ConvertFromUser (msgContact.ContactUser);
                    else
                        contactUser = dbm.GetUserWithAccountID (eachMessageDB.FromAccountGuid);

                    msgInfoItem = new MessageInfo (eachMessageDB, contactUser);
                } else {
                    contactUser = UserDB.ConvertFromUser (AndroidData.CurrentUser);
                    msgInfoItem = new MessageInfo (eachMessageDB, contactUser);

                    if (!eachMessageDB.MessageConfirmed) {
                        ContentInfo contentInfo = dbm.GetContentInfoByMessageDBID (eachMessageDB.ID);
                        msgInfoItem.ContentInfo = contentInfo;
                    }
                }
                messages.Add (eachMessageDB);
                users.Add (contactUser);
                this.MessageItems [eachMessageDB.MessageID] = msgInfoItem;
                /*if (isConversation == false) {
                    RunOnUiThread (delegate {
                        createUI (messages, users);
                    });
                }*/
            }

            if (fromLocalOnly) {
                RunOnUiThread (delegate {
                    if (progress != null)
                        progress.Dismiss ();
                    GetRowsForMessages ();
                    CreatePreviewUI ();
                });
            } else {
                List<Guid> excludeMessageGuids = new List<Guid> ();
                excludeMessageGuids = this.MessageItems.Values.Where (s => s.Message.MessageStepDBList.Count (t => t.StepID == default(Guid)) == 0)
                    .Select (s => s.Message.MessageID).ToList ();

                LOLMessageClient service = new LOLMessageClient (LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint);
            #if DEBUG
                System.Diagnostics.Debug.WriteLine ("**Will call MessageGetConversations with params: account id {0}, start date: new DateTime(1900, 1, 1), end date: new DateTime(2099, 1, 1), service auth token: {1}",
                                  AndroidData.CurrentUser.AccountID, new Guid (AndroidData.ServiceAuthToken));
            #endif
            #if DEBUG
                if (null == excludeMessageGuids) {

                    System.Diagnostics.Debug.WriteLine ("**Exclude message ids is NULL!");

                } else {
                    System.Diagnostics.Debug.WriteLine ("**Exclude message ids count: {0}", excludeMessageGuids.Count);

                    foreach (Guid eachMessageID in excludeMessageGuids) {
                        System.Diagnostics.Debug.WriteLine ("**Each message id to exclude: {0}", eachMessageID);
                    }//end foreach
                }//end if
                #endif

                service.MessageGetConversationsCompleted += Service_MessageGetConversationsCompleted;
                service.MessageGetConversationsAsync (AndroidData.CurrentUser.AccountID,
                                                     new DateTime (1900, 1, 1),
                                                     new DateTime (2099, 1, 1), 50,
                                                     excludeMessageGuids,
                                                     new Guid (AndroidData.ServiceAuthToken));
            }//end if else
        }
Ejemplo n.º 14
0
        private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            #if(DEBUG)
            System.Diagnostics.Debug.WriteLine("Downloading messages!");
            #endif
            // If another call is in progress, skip this one
            if (!this.isMsgInProgress)
            {

                this.isMsgInProgress = true;
            #if DEBUG
                System.Diagnostics.Debug.WriteLine("Actually doing something now. this.messageService = {0}", this.messageService);
            #endif

                List<Guid> excludeMessageIDs = new List<Guid>();
                excludeMessageIDs = dbm.GetUnreadMessages(false, AndroidData.CurrentUser.AccountID.ToString()).Select(s => s.MessageID).ToList();

                if (null == this.messageService)
                {
                    this.messageService = new LOLMessageClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint);
                }//end if
                this.messageService.MessageGetNewCompleted += Service_MessageGetNewCompleted;
                this.messageService.MessageGetNewAsync(AndroidData.CurrentUser.AccountID, AndroidData.NewDeviceID, excludeMessageIDs,
                                                       new Guid(AndroidData.ServiceAuthToken));
            }
        }
        private void Service_ContentPackGetItemCompleted(object sender, ContentPackGetItemCompletedEventArgs e)
        {
            LOLConnectClient service = (LOLConnectClient)sender;

            if (null == e.Error) {
                ContentPackItem result = e.Result;

                if (result.Errors.Count > 0) {
            #if(DEBUG)
                    System.Diagnostics.Debug.WriteLine ("Error in getting content pack items! {0}", StringUtils.CreateErrorMessageFromGeneralErrors (result.Errors.ToArray ()));
            #endif
                } else {
            #if DEBUG
                    System.Diagnostics.Debug.WriteLine ("Content pack. Result = {0}", result);
            #endif
                    this.contentPackItems [result.ContentPackItemID] = result;
                    ContentPackItemDB contentPackItem = ContentPackItemDB.ConvertFromContentPackItem (result);
                    RunOnUiThread (delegate {
                        SaveContentPackItem (contentPackItem);
                        dbm.InsertOrUpdateContentPackItems (new List<ContentPackItemDB> () { contentPackItem });
                    });
                }//end if else

                ContentState stateObj = (ContentState)e.UserState;
                stateObj.ContentPackIDQ.Dequeue ();

                if (stateObj.HasContentPackItems) {
            #if DEBUG
                    System.Diagnostics.Debug.WriteLine ("Contentpack get item completed async");
            #endif

                    service.ContentPackGetItemAsync (stateObj.ContentPackIDQ.Peek (),
                                                     ContentPackItem.ItemSize.Small,
                                                     AndroidData.CurrentUser.AccountID,
                                                     new Guid (AndroidData.ServiceAuthToken), stateObj);
                } else
                if (stateObj.HasVoiceRecordings) {
            #if DEBUG
                    System.Diagnostics.Debug.WriteLine ("Contentpack get item completed - has voice recordings");
            #endif
                    service.ContentPackGetItemCompleted -= Service_ContentPackGetItemCompleted;

                    LOLMessageClient msgService = new LOLMessageClient (LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint);
                    msgService.MessageGetStepDataCompleted += Service_MessageGetStepData;
                    msgService.MessageGetStepDataAsync (stateObj.Message.MessageID, stateObj.VoiceIDQ.Peek (), new Guid (AndroidData.ServiceAuthToken), stateObj);
                } else
                if (stateObj.HasPollingSteps) {
            #if DEBUG
                    System.Diagnostics.Debug.WriteLine ("Contentpack get item completed - has poll steps");
            #endif
                    service.ContentPackGetItemCompleted -= Service_ContentPackGetItemCompleted;

                    LOLMessageClient msgService = new LOLMessageClient (LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint);
                    msgService.PollingStepGetCompleted += Service_PollingStepGetCompleted;
                    msgService.PollingStepGetAsync (stateObj.Message.MessageID,
                                                    stateObj.PollingIDQ.Peek (),
                                                    AndroidData.CurrentUser.AccountID,
                                                    new Guid (AndroidData.ServiceAuthToken), stateObj);
                } else {
            #if DEBUG
                    System.Diagnostics.Debug.WriteLine ("Contentpack get item completed - startplaymessage");
            #endif
                    service.ContentPackGetItemCompleted -= Service_ContentPackGetItemCompleted;
                    RunOnUiThread (delegate {
                        StartPlayMessage (stateObj.Message);
                    });
                }//end if else
            } else {
            #if(DEBUG)
                System.Diagnostics.Debug.WriteLine ("Exception in getting content pack items! {0}--{1}", e.Error.Message, e.Error.StackTrace);
            #endif
            }//end if else
        }
        private void MarkMessagesAsRead()
        {
            string ownerID = AndroidData.CurrentUser.AccountID.ToString ();
            Queue<MessageDB> msgQ = new Queue<MessageDB> ();
            foreach (MessageDB eachMessageDB in ConversationInfo.Messages.Values.Select(s => s.Message)
                .Where(s => s.MessageRecipientDBList.Count(t => t.AccountGuid == ownerID && !t.IsRead) > 0))
                msgQ.Enqueue (eachMessageDB);

            if (msgQ.Count > 0) {
                LOLMessageClient service = new LOLMessageClient (LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint);
                service.MessageMarkReadCompleted += Service_MessageMarkReadCompleted;
                service.MessageMarkReadAsync (msgQ.Peek ().MessageID, AndroidData.CurrentUser.AccountID, AndroidData.NewDeviceID,
                    new Guid (AndroidData.ServiceAuthToken), msgQ);
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate (savedInstanceState);
            Window.AddFlags (WindowManagerFlags.KeepScreenOn);
            SetContentView (Resource.Layout.previewSoundFX);

            if (MessageReceivedUtil.userFrom != null) {
                UserDB user = UserDB.ConvertFromUser (MessageReceivedUtil.userFrom);
                Header.headertext = user.FirstName + " " + user.LastName;
                MessageReceivedUtil.userFrom = null;
            } else {
                if (MessagePlaybackUtil.recipients != null) {
                    for (int i = 0; i < MessagePlaybackUtil.recipients.Count; ++i) {
                        if (MessagePlaybackUtil.recipients [i] != null) {
                            Header.headertext = MessagePlaybackUtil.recipients [i].FirstName + " " + MessagePlaybackUtil.recipients [i].LastName;
                            break;
                        }
                    }
                    //}
                } else
                    Header.headertext = "Ann Onymouse";
            }
            linView = FindViewById<LinearLayout> (Resource.Id.linearHolder);
            context = linView.Context;

            ImageView btns = FindViewById<ImageView> (Resource.Id.imgNewUserHeader);
            TextView header = FindViewById<TextView> (Resource.Id.txtFirstScreenHeader);
            RelativeLayout relLayout = FindViewById<RelativeLayout> (Resource.Id.relativeLayout1);
            ImageHelper.setupTopPanel (btns, header, relLayout, header.Context);
            Header.fontsize = 36f;
            ImageHelper.fontSizeInfo (header.Context);
            header.SetTextSize (Android.Util.ComplexUnitType.Dip, Header.fontsize);
            header.Text = Header.headertext;

            parent = linView;
            //preview = FindViewById<ImageView> (Resource.Id.imgComicon);
            progress = FindViewById<ProgressBar> (Resource.Id.prgPreview);
            co = base.Intent.GetIntExtra ("position", 0);
            counter = MessagePlaybackUtil.messageSteps.Count;
            dbm = wowZapp.LaffOutOut.Singleton.dbm;
            isPlaying = false;

            stepID = Guid.Empty;

            #if DEBUG
            System.Diagnostics.Debug.WriteLine ("number of steps = {0}", counter);
            #endif
            linView.RemoveAllViewsInLayout ();
            t = new System.Timers.Timer ();
            t.Interval = 2500;
            t.Elapsed += new System.Timers.ElapsedEventHandler (t_Elapsed);

            increments = 100 / (counter + 1);

            if (co != 0) {
                RunOnUiThread (() => progress.Progress = co * increments);
                increments *= co + co;
            }

            if (MessagePlaybackUtil.markAsRead) {
                ThreadPool.QueueUserWorkItem (delegate {
                    Guid messageID = MessagePlaybackUtil.messageSteps [0].MessageID;

                    LOLMessageClient service = new LOLMessageClient (LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint);
                    service.MessageMarkReadCompleted += Service_MessageMarkReadCompleted;
                    service.MessageMarkReadAsync (messageID, AndroidData.CurrentUser.AccountID, AndroidData.NewDeviceID, new Guid (AndroidData.ServiceAuthToken), messageID);
                });
            }

            ImageButton btnPreAdd = FindViewById<ImageButton> (Resource.Id.imgAdd);
            btnPreAdd.Tag = 1;
            ImageButton btnBack = FindViewById<ImageButton> (Resource.Id.btnBack);
            btnBack.Tag = 0;
            btnBack.Click += delegate {
                Window.ClearFlags (WindowManagerFlags.KeepScreenOn);
                Finish ();
            };
            LinearLayout bottom = FindViewById<LinearLayout> (Resource.Id.bottomHolder);
            ImageButton[] buttons = new ImageButton[2];
            buttons [0] = btnBack;
            buttons [1] = btnPreAdd;
            ImageHelper.setupButtonsPosition (buttons, bottom, context);

            if (MessageReceivedUtil.readOnly)
                btnPreAdd.Visibility = ViewStates.Invisible;
            else
                btnPreAdd.Click += delegate {
                    StartActivity (typeof(ComposeMessageChooseContent));
                };
            #if DEBUG
            int m = 0;
            foreach (MessageStep eachMessageStep in MessagePlaybackUtil.messageSteps)
                System.Diagnostics.Debug.WriteLine ("step {0} = {1}", m++, eachMessageStep.StepType.ToString ());
            #endif

            RunOnUiThread (delegate {
                PrepareViews (co);
            });
        }
Ejemplo n.º 18
0
 private void SendNextStep(ContentInfo contentInfo, LOLMessageClient service)
 {
     #if(DEBUG)
     System.Diagnostics.Debug.WriteLine("Send next step!");
     #endif
     if (contentInfo.ContentState != null)
     {
         if (contentInfo.ContentState.HasVoiceRecordings)
         {
             this.SendVoiceData(contentInfo, service);
         } else
         if (contentInfo.ContentState.HasPollingSteps)
         {
             this.SendPollingSteps(contentInfo, service);
         } else
         {
             service.MessageConfirmSendCompleted += Service_MessageConfirmSendCompleted;
             service.MessageConfirmSendAsync(contentInfo.Message.MessageID, AndroidData.CurrentUser.AccountID, new Guid(AndroidData.ServiceAuthToken), contentInfo);
         }
     }
 }
Ejemplo n.º 19
0
 private void getNewMessages(List<Guid> newMessages)
 {
     LOLMessageClient client = new LOLMessageClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint);
     client.MessageGetByListCompleted += MessageListUpdatedComplete;
     client.MessageGetByListAsync(AndroidData.CurrentUser.AccountID, newMessages, AndroidData.CurrentUser.AccountID,
                                   new Guid(AndroidData.ServiceAuthToken));
 }
Ejemplo n.º 20
0
        private void SendPollingSteps(ContentInfo contentInfo, LOLMessageClient service)
        {
            #if(DEBUG)
            System.Diagnostics.Debug.WriteLine("Send polling steps!");
            #endif

            PollingStep pollStepToSend = contentInfo.PollingSteps [contentInfo.ContentState.PollingIDQ.Peek()];
            pollStepToSend.MessageID = contentInfo.Message.MessageID;
            contentInfo.PollingSteps [contentInfo.ContentState.PollingIDQ.Peek()] = pollStepToSend;

            if (pollStepToSend is PollingStepDB)
            {
                PollingStepDB converted = (PollingStepDB)pollStepToSend;
                pollStepToSend = PollingStepDB.ConvertFromPollingStepDB(converted);
            }//end if

            // Upload step data
            service.PollingStepSaveCompleted += Service_PollingStepSaveCompleted;
            service.PollingStepSaveAsync(pollStepToSend, AndroidData.CurrentUser.AccountID, new Guid(AndroidData.ServiceAuthToken), contentInfo);
        }
Ejemplo n.º 21
0
        private void SendVoiceData(ContentInfo contentInfo, LOLMessageClient service)
        {
            #if(DEBUG)
            System.Diagnostics.Debug.WriteLine("Send voice data!");
            #endif

            int stepNumber = contentInfo.ContentState.VoiceIDQ.Peek();
            if (contentInfo.VoiceRecordings.Count != 0)
            {
                SaveVoiceRecordingFile(contentInfo.VoiceRecordings [stepNumber], contentInfo.Message.MessageID, stepNumber);

                // Upload voice recordings
                service.MessageStepDataSaveCompleted += Service_MessageStepDataSaveCompleted;
                service.MessageStepDataSaveAsync(contentInfo.Message.MessageID, stepNumber, contentInfo.VoiceRecordings [stepNumber],
                                                  AndroidData.CurrentUser.AccountID, new Guid(AndroidData.ServiceAuthToken), contentInfo);
            } else
                this.SendNextMessage(service);
        }
Ejemplo n.º 22
0
        public void QueueMessage(ContentInfo contentInfo, bool isNew, Context c)
        {
            context = c;
            if (isNew)
            {
                ThreadPool.QueueUserWorkItem(delegate
                {
                    dbm.InsertOrUpdateContentInfoItems(new List<ContentInfo>() { contentInfo });
                });
            }//end if

            this.ContentInfoQ.Enqueue(contentInfo);

            if (!this.IsSendingMessage)
            {

                this.IsSendingMessage = true;

                ContentInfo toSend = this.ContentInfoQ.Dequeue();
                toSend.Message.MessageSent = DateTime.Now;

                try
                {
                    LOLMessageClient service = new LOLMessageClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint);
                    service.MessageCreateCompleted += Service_MessageCreateCompleted;
                    service.MessageCreateAsync(contentInfo.Message,
                                           contentInfo.Message.MessageSteps,
                                           contentInfo.Recipients, AndroidData.CurrentUser.AccountID,
                                           new Guid(AndroidData.ServiceAuthToken), toSend);
                } catch (Exception e)
                {
                    #if DEBUG
                    System.Diagnostics.Debug.WriteLine("Exception thrown - {0}--{1}", e.Message, e.StackTrace);
                    #endif
                }

            }//end if else
        }
Ejemplo n.º 23
0
        void service_PollingStepResponseCompleted(object sender, PollingStepResponseCompletedEventArgs e)
        {
            LOLMessageClient myService = (LOLMessageClient)sender;
            myService.PollingStepResponseCompleted -= service_PollingStepResponseCompleted;

            if (e.Error == null)
            {
                LOLMessageDelivery.GeneralError result = e.Result;
                if (!string.IsNullOrEmpty(result.ErrorNumber) && result.ErrorNumber != "0")
                {
                    RunOnUiThread(() => Toast.MakeText(context, Application.Context.Resources.GetString(Resource.String.errorUploadPollingMessage), ToastLength.Short).Show());
            #if DEBUG
                    System.Diagnostics.Debug.WriteLine("Error in voting - {0}", result.ErrorDescription);
            #endif
                } else
                {
                    MessagePollUtil.pollStep.HasResponded = true;
                    dbm.SetPollingStepHasResponded(MessagePollUtil.pollStep.MessageID.ToString(), MessagePollUtil.pollStep.StepNumber);
                    //RunOnUiThread (() => restartTimerFromPoll ());
                    LOLMessageClient service = new LOLMessageClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint);
                    service.PollingStepGetResultsCompleted += Service_PollingStepGetResultsCompleted;
                    service.PollingStepGetResultsAsync(MessagePlaybackUtil.messageSteps [co].StepID, AndroidData.CurrentUser.AccountID, new Guid(AndroidData.ServiceAuthToken));
                }
            } else
            {
            #if DEBUG
                System.Diagnostics.Debug.WriteLine("Exception sending vote {0}--{1}", e.Error.Message, e.Error.StackTrace);
            #endif
            }
        }
Ejemplo n.º 24
0
        private void AppDelegate_ReceivedMessages(object sender, IncomingMessageEventArgs e)
        {
            List <Messages.MessageInfo> messageItems = new List<Messages.MessageInfo>();
            Guid me = AndroidData.CurrentUser.AccountID;

            //RunOnUiThread (delegate {
            foreach (LOLMessageDelivery.Message eachMessage in e.Messages)
            {
                MessageDB msgDB = MessageDB.ConvertFromMessage(eachMessage);
                UserDB user = msgDB.FromAccountID == me ? UserDB.ConvertFromUser(AndroidData.CurrentUser) :
                        dbm.GetUserWithAccountID(msgDB.FromAccountGuid);

                if (user == null)
                {
                    unknownContacts.Add(msgDB.FromAccountID);
                    //Contacts.AddUnknownUser uku = new Contacts.AddUnknownUser (unknowns, context);
                }

                Messages.MessageInfo msgInfo = new Messages.MessageInfo(msgDB, user);

                if (msgInfo != null)
                {
                    messageItems.Add(msgInfo);
                }
            }

            if (messageItems.Count > 0)
            {
                if (message == null)
                    message = new List<MessageDB>();
                else
                    message.Clear();
                foreach (Messages.MessageInfo eachMessageInfo in messageItems)
                {
                    this.MessageItems [eachMessageInfo.Message.MessageID] = eachMessageInfo;
                    message.Add(eachMessageInfo.Message);
                }

                dbm.InsertOrUpdateMessages(message);
                messageItem = messageItems [0];
                markAsRead = message.Count;
                current = 0;
                LOLMessageClient service = new LOLMessageClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint);
                service.MessageMarkReadCompleted += Service_MessageMarkReadCompleted;
                service.MessageMarkReadAsync(message [current].MessageID, AndroidData.CurrentUser.AccountID, AndroidData.NewDeviceID, new Guid(AndroidData.ServiceAuthToken),
                                              message [current].MessageID);
            }
            //});
        }