protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.ComposeMessageMain);
            readOnly = base.Intent.GetBooleanExtra("readonly", false);

            dbm = wowZapp.LaffOutOut.Singleton.dbm;
            mmg = wowZapp.LaffOutOut.Singleton.mmg;
            Guid profPic = Guid.Empty;
            UserDB user = null;
            ImageView btns = FindViewById<ImageView>(Resource.Id.imgNewLoginHeader);
            TextView header = FindViewById<TextView>(Resource.Id.txtFirstScreenHeader);
            RelativeLayout relLayout = FindViewById<RelativeLayout>(Resource.Id.relativeLayout1);
            ImageHelper.setupTopPanel(btns, header, relLayout, header.Context);
            context = header.Context;

            Header.headertext = Application.Context.Resources.GetString(Resource.String.messageCreateMessageTitle);
            Header.fontsize = 36f;
            ImageHelper.fontSizeInfo(header.Context);
            header.SetTextSize(Android.Util.ComplexUnitType.Dip, Header.fontsize);
            header.Text = Header.headertext;

            imgProfilePic = FindViewById<ImageView>(Resource.Id.imgProfilePic);
            imgProfilePic.SetBackgroundResource(Resource.Drawable.emptybackground);
            hasMoved = regenerate = false;

            this.thumbImageWidth = (int)ImageHelper.convertDpToPixel(80f, context);
            this.thumbImageHeight = (int)ImageHelper.convertDpToPixel(100f, context);

            btnSend = FindViewById<Button>(Resource.Id.btnSend);
            btnBack = FindViewById<ImageButton>(Resource.Id.btnBack);
            btnBack.Tag = 0;
            btnHome = FindViewById<ImageButton>(Resource.Id.btnHome);
            btnHome.Tag = 1;
            btnPlay = FindViewById<ImageView>(Resource.Id.imgPlay);
            btnPlay.Click += new EventHandler(btnPlay_Click);
            txtFullname = FindViewById<TextView>(Resource.Id.txtAuthorName);
            txtMessage = FindViewById<TextView>(Resource.Id.txtMainMessage);
            LinearLayout bottom = FindViewById<LinearLayout>(Resource.Id.bottomHolder);

            ImageButton[] buttons = new ImageButton[2];
            buttons [0] = btnBack;
            buttons [1] = btnHome;
            ImageHelper.setupButtonsPosition(buttons, bottom, context);

            if (ComposeMessageMainUtil.contentPackID == null)
                ComposeMessageMainUtil.contentPackID = new int[7];

            for (int i = 0; i < 6; ++i)
                ComposeMessageMainUtil.contentPackID [i] = -1;

            txtMessage.Click += delegate
            {
                int n = 0, t = -1;
                for (n = 0; n < ComposeMessageMainUtil.currentPosition.Length; ++n)
                {
                    if (ComposeMessageMainUtil.currentPosition [n] == 0)
                    {
                        t = n;
                        break;
                    }
                }
                if (n == ComposeMessageMainUtil.currentPosition.Length)
                {
                    for (n = 0; n < ComposeMessageMainUtil.currentPosition.Length; ++n)
                    {
                        if (ComposeMessageMainUtil.msgSteps [n].StepType == MessageStep.StepTypes.Text)
                        {
                            if (ComposeMessageMainUtil.msgSteps [n].MessageText == txtMessage.Text)
                            {
                                t = n;
                                break;
                            }
                        }
                    }
                    if (t == -1)
                        RunOnUiThread(() => Toast.MakeText(context, Application.Context.GetString(Resource.String.errorNoSpaceForText), ToastLength.Short).Show());
                } else
                {
                    RunOnUiThread(delegate
                    {
                        Intent it = new Intent(this, typeof(ComposeTextMessageActivity));
                        it.PutExtra("text", txtMessage.Text != Application.Context.Resources.GetString(Resource.String.composeTextMessagelblMessage) ?
                                     ComposeMessageMainUtil.msgSteps [t].MessageText : string.Empty);
                        it.PutExtra("CurrentStep", base.Intent.GetIntExtra("CurrentStep", 1));
                        StartActivity(it);
                    });
                }
            };

            imgSteps = new ImageView[6];
            imgSets = new bool[6];
            imgSteps [0] = FindViewById<ImageView>(Resource.Id.imgStep1);
            imgSteps [0].Tag = 0;
            imgSteps [1] = FindViewById<ImageView>(Resource.Id.imgStep2);
            imgSteps [1].Tag = 1;
            imgSteps [2] = FindViewById<ImageView>(Resource.Id.imgStep3);
            imgSteps [2].Tag = 2;
            imgSteps [3] = FindViewById<ImageView>(Resource.Id.imgStep4);
            imgSteps [3].Tag = 3;
            imgSteps [4] = FindViewById<ImageView>(Resource.Id.imgStep5);
            imgSteps [4].Tag = 4;
            imgSteps [5] = FindViewById<ImageView>(Resource.Id.imgStep6);
            imgSteps [5].Tag = 5;
            for (int z = 0; z < 6; ++z)
                imgSets [z] = true;
            bool multi = false;

            if (ComposeMessageMainUtil.messageDB != null)
            {
                if (ComposeMessageMainUtil.messageDB.MessageRecipientDBList != null)
                {
                    int n = 0;
                    for (int j = 0; j < ComposeMessageMainUtil.currentPosition.Length; ++j)
                        ComposeMessageMainUtil.currentPosition [j] = 0;
                    regenerateIcons();
                    foreach (MessageStepDB mesg in ComposeMessageMainUtil.messageDB.MessageStepDBList)
                    {
                        #if DEBUG
                        Console.WriteLine("MessageStepDB item = {0}", mesg);
                        #endif
                        MessageStep mSt = MessageStepDB.ConvertFromMessageStepDB(mesg);
                        ComposeMessageMainUtil.msgSteps.Add(mSt);
                        ComposeMessageMainUtil.currentPosition [n] = 1;
                    }
                }
            }

            if (readOnly)
            {
                user = dbm.GetUserWithAccountID(ComposeMessageMainUtil.messageDB.FromAccountID.ToString());
                if (ComposeMessageMainUtil.messageDB.MessageRecipientDBList.Count > 1)
                    multi = true;
                if (user.Picture.Length == 0)
                    profPic = user.AccountID;
                else
                    loadProfilePicture(user, imgProfilePic);
            } else
            {
                user = UserDB.ConvertFromUser(AndroidData.CurrentUser);
                if (AndroidData.CurrentUser.Picture.Length == 0)
                    profPic = AndroidData.CurrentUser.AccountID;
                else
                    loadProfilePicture(user, imgProfilePic);
            }

            imgProfilePic.Tag = new Java.Lang.String("profilepic_" + user.AccountID);
            string name = user.FirstName + " " + user.LastName;
            if (multi == true)
            {
                if (ComposeMessageMainUtil.messageDB == null)
                    name += " and " + (Contacts.SelectContactsUtil.selectedContacts.Count - 1).ToString() +
                        (Contacts.SelectContactsUtil.selectedContacts.Count - 1 > 1 ? " others" : "other");
                else
                    name += " and " + (ComposeMessageMainUtil.messageDB.MessageRecipientDBList.Count - 1).ToString() +
                        (ComposeMessageMainUtil.messageDB.MessageRecipientDBList.Count - 1 > 1 ? " others" : "other");
            }
            float fontSize = txtFullname.TextSize;
            txtFullname.SetTextSize(Android.Util.ComplexUnitType.Dip, ImageHelper.getNewFontSize(fontSize, context));
            txtFullname.Text = name;
            fontSize = txtMessage.TextSize;
            txtMessage.SetTextSize(Android.Util.ComplexUnitType.Dip, ImageHelper.getNewFontSize(fontSize, context));
            if (readOnly == false)
            {
                for (int n = 0; n < 6; ++n)
                {

                    if (imgSets [n])
                    {
                        int step = new int();
                        step = n;
                        imgSteps [step].Click -= (object s, EventArgs e) => {
                            imgClickEvent(s, e, 9, step);};
                        imgSteps [step].Click += (object s, EventArgs e) => {
                            imgClickEvent(s, e, 9, step);};
                    }
                    imgSteps [n].SetOnLongClickListener(this);
                }

                ReloadMessageSteps();
            } else
            {
                this.SetButtonImagesForMessageSteps();
                header.Text = Application.Context.Resources.GetString(Resource.String.messageReadMessage);
                btnSend.Visibility = ViewStates.Invisible;
                ImageView a1 = FindViewById<ImageView>(Resource.Id.arrow1);
                ImageView a2 = FindViewById<ImageView>(Resource.Id.arrow2);
                ImageView a3 = FindViewById<ImageView>(Resource.Id.arrow3);
                ImageView a4 = FindViewById<ImageView>(Resource.Id.arrow4);
                a1.Visibility = a2.Visibility = a3.Visibility = a4.Visibility = ViewStates.Invisible;
            }

            co = 0;

            btnBack.Click += delegate
            {
                for (int i = 0; i < 6; ++i)
                    ComposeMessageMainUtil.currentPosition [i] = 0;
                for (int i = 0; i < 7; ++i)
                    ComposeMessageMainUtil.contentPackID [i] = -1;
                ComposeMessageMainUtil.message = null;
                ComposeMessageMainUtil.messageDB = null;
                ComposeMessageMainUtil.msgSteps = null;
                ComposeMessageMainUtil.pollSteps = null;
                Finish();
            };
            btnHome.Click += delegate
            {
                Intent i = new Intent(this, typeof(Main.HomeActivity));
                i.AddFlags(ActivityFlags.ClearTop);
                StartActivity(i);
            };

            btnSend.Click += delegate
            {
                SendMessage();
                Finish();
            };

            if (profPic != Guid.Empty)
            {
                Guid finder = profPic != Guid.Empty ? profPic : AndroidData.CurrentUser.AccountID;
                LOLConnectClient service = new LOLConnectClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint);
                service.UserGetImageDataCompleted += Service_UserGetImageDataCompleted;
                service.UserGetImageDataAsync(AndroidData.CurrentUser.AccountID, finder, new Guid(AndroidData.ServiceAuthToken));
            }
        }
Exemplo n.º 2
0
 protected override void OnCreate(Bundle bundle)
 {
     base.OnCreate(bundle);
     dbm = wowZapp.LaffOutOut.Singleton.dbm;
     mmg = wowZapp.LaffOutOut.Singleton.mmg;
     MessageItems = new Dictionary<Guid, MessageInfo>();
     contentPackItems = new Dictionary<int, ContentPackItem>();
     this.voiceFiles = new Dictionary<int, string>();
     this.contacts = new Dictionary<Guid, ContactDB>();
     this.pollSteps = new Dictionary<int, PollingStep>();
     this.conversationItems = new Dictionary<string, ConversationInfo>();
     this.animationStep = new Dictionary<int, AnimationInfo>();
     ContentPath = wowZapp.LaffOutOut.Singleton.ContentDirectory;
     isMe = AndroidData.CurrentUser.FirstName + " " + AndroidData.CurrentUser.LastName;
     SetContentView(Resource.Layout.previewSoundFX);
     context = MessageReceivedUtil.context;
     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);
     UserDB user = dbm.GetUserWithAccountID(MessageReceivedUtil.message.FromAccountGuid);
     if (user == null)
         user = UserDB.ConvertFromUser(AndroidData.CurrentUser);
     MessageReceivedUtil.userFrom = UserDB.ConvertFromUserDB(user);
     Header.headertext = user.FirstName + " " + user.LastName;
     Header.fontsize = 36f;
     ImageHelper.fontSizeInfo(header.Context);
     header.SetTextSize(Android.Util.ComplexUnitType.Pt, Header.fontsize);
     header.Text = Header.headertext;
     RunOnUiThread(delegate
     {
         progress = ProgressDialog.Show(context, Application.Context.Resources.GetString(Resource.String.messageViewingMessage),
                                                 Application.Context.Resources.GetString(Resource.String.messageViewingPleaseWait));
     });
     processMessages(MessageReceivedUtil.message);
     PlayMessage(MessageReceivedUtil.message);
     markAsRead = true;
     Finish();
 }