Example #1
0
        private async void DeleteUploadedImage_Click(object sender, EventArgs e)
        {
            if (rc.imagesUploading)
            {
                context.c.Snack(LangEnglish.ImagesUploading);
                return;
            }
            else if (rc.imagesDeleting)
            {
                context.c.Snack(LangEnglish.ImagesDeleting);
                return;
            }

            if (context is ProfileEditActivity)
            {
                if (rc.uploadedImages.Count == 1)
                {
                    context.c.Snack(LangEnglish.LastImageToDelete);
                    return;
                }
            }
            else if (rc.uploadedImages.Count == 1)
            {
                rc.ImagesProgressText.Text = "";
            }

            rc.imagesDeleting = true;
            rc.StartAnim();

            UploadedItem item  = (UploadedItem)((UIButton)sender).Superview.Superview;
            int          index = Array.IndexOf(Subviews, item);    //GetDrawPosFromChildIndex(Array.IndexOf(Subviews, item));

            if (context is ProfileEditActivity)
            {
                string responseString = await context.c.MakeRequest("action=deleteexisting&imageName=" + CommonMethods.UrlEncode(rc.uploadedImages[index]) + "&ID=" + Session.ID + "&SessionID=" + Session.SessionID);

                if (responseString.Substring(0, 2) == "OK")
                {
                    rc.uploadedImages.RemoveAt(index);
                    Session.Pictures = rc.uploadedImages.ToArray();

                    RemovePicture(index);
                    if (rc.uploadedImages.Count == 1)
                    {
                        rc.ImagesProgressText.Text = "";
                    }
                }
                else
                {
                    context.c.ReportError(responseString);
                    rc.imagesDeleting = false;
                }
            }
            else
            {
                context.c.Log("DeleteUploadedImage_Click index: " + index + " count " + rc.uploadedImages.Count);

                string responseString = await context.c.MakeRequest("action=deletetemp&imageName=" + CommonMethods.UrlEncode(rc.uploadedImages[index]) + "&regsessionid=" + RegisterActivity.regsessionid);

                if (responseString.Substring(0, 2) == "OK")
                {
                    rc.uploadedImages.RemoveAt(index);

                    RemovePicture(index);
                    if (rc.uploadedImages.Count == 1)
                    {
                        rc.ImagesProgressText.Text = "";
                    }
                    else if (rc.uploadedImages.Count == 0)
                    {
                        File.Delete(RegisterActivity.regSessionFile);
                    }
                }
                else
                {
                    context.c.ReportError(responseString);
                    rc.imagesDeleting = false;
                }
            }

            rc.StopAnim();
        }
Example #2
0
        public override void ViewWillAppear(bool animated)
        {
            try
            {
                base.ViewWillAppear(animated);

                SetSexChoice();
                Email.Text        = Session.Email;
                Username.Text     = Session.Username;
                Name.Text         = Session.Name;
                rc.uploadedImages = new List <string>(Session.Pictures);

                int i;
                for (i = ImagesUploaded.Subviews.Length - 1; i >= 0; i--)
                {
                    ImagesUploaded.Subviews[i].RemoveFromSuperview();
                }
                ImagesUploaded.RefitImagesContainer();

                i = 0;
                foreach (string image in rc.uploadedImages)
                {
                    ImagesUploaded.AddPicture(image, i);
                    i++;
                }

                if (rc.uploadedImages.Count > 1)
                {
                    ImagesProgressText.Text = LangEnglish.ImagesRearrange;
                }
                else
                {
                    ImagesProgressText.Text = "";
                }

                //works only if activity is resuming. It is recreated when pressing cancel and coming here again. Can it happen?
                if (rc.imagesUploading)
                {
                    rc.StartAnim();
                }

                DescriptionText.Text = Session.Description;

                UseLocationSwitch.On = (bool)Session.UseLocation;
                rc.EnableLocationSwitches((bool)Session.UseLocation);
                rc.SetLocationShareLevel((byte)Session.LocationShare);
                rc.SetDistanceShareLevel((byte)Session.DistanceShare);

                if ((bool)Session.ActiveAccount)
                {
                    DeactivateAccount.SetTitle(LangEnglish.DeactivateAccount, UIControlState.Normal);
                }
                else
                {
                    DeactivateAccount.SetTitle(LangEnglish.ActivateAccount, UIControlState.Normal);
                }
            }
            catch (Exception ex)
            {
                c.ReportErrorSilent(ex.Message + Environment.NewLine + ex.StackTrace);
            }
        }
Example #3
0
        public async override void ViewWillAppear(bool animated)
        {
            try
            {
                base.ViewWillAppear(animated);

                if (!(ListActivity.listProfiles is null))
                {
                    ListActivity.listProfiles.Clear();
                    ListActivity.totalResultCount = null;
                }

                Session.LastDataRefresh = null;
                Session.LocationTime    = null;

                registerCompleted = false;

                if (File.Exists(regSaveFile))
                {
                    string[] arr = File.ReadAllLines(regSaveFile);
                    Sex.Select(int.Parse(arr[0]), 0, false);
                    Email.Text           = arr[1];
                    Password.Text        = arr[2];
                    ConfirmPassword.Text = arr[3];
                    Username.Text        = arr[4];
                    Name.Text            = arr[5];
                    if (arr[6] != "") //it would give one element
                    {
                        string[] images = arr[6].Split("|");
                        rc.uploadedImages = new List <string>(images);
                    }
                    else
                    {
                        rc.uploadedImages = new List <string>();
                    }

                    int i;
                    for (i = ImagesUploaded.Subviews.Length - 1; i >= 0; i--)
                    {
                        ImagesUploaded.Subviews[i].RemoveFromSuperview();
                    }
                    ImagesUploaded.RefitImagesContainer();
                    //ImagesUploaded.drawOrder = new List<int>();

                    i = 0;
                    foreach (string image in rc.uploadedImages)
                    {
                        ImagesUploaded.AddPicture(image, i);
                        i++;
                    }

                    if (rc.uploadedImages.Count > 1)
                    {
                        ImagesProgressText.Text = LangEnglish.ImagesRearrange;
                    }
                    else
                    {
                        ImagesProgressText.Text = "";
                    }

                    //works only if activity is resuming. It is recreaed when pressing cancel and coming here again.
                    if (rc.imagesUploading)
                    {
                        rc.StartAnim();
                    }

                    DescriptionText.Text = arr[7].Replace("[newline]", "\n");

                    UseLocationSwitch.On = bool.Parse(arr[8]);
                    rc.EnableLocationSwitches(UseLocationSwitch.On);
                    rc.SetLocationShareLevel(byte.Parse(arr[9]));
                    rc.SetDistanceShareLevel(byte.Parse(arr[10]));
                }
                else //in case we are stepping back from a successful registration
                {
                    ResetForm();
                }

                string responseString = await c.MakeRequest("action=eula"); //deleting images from server

                if (responseString.Substring(0, 2) == "OK")
                {
                    NSError error      = null;
                    string  s          = "<span style=\"font-family: '-apple-system', 'HelveticaNeue'; font-size: 12px\">" + responseString.Substring(3) + "</span>";
                    var     htmlString = new NSAttributedString(s, new NSAttributedStringDocumentAttributes {
                        DocumentType = NSDocumentType.HTML
                    }, ref error);
                    EulaText.AttributedText = htmlString;
                    EulaText.TextColor      = UIColor.FromName("PrimaryDark");
                }
                else
                {
                    c.ReportError(responseString);
                }
            }
            catch (Exception ex)
            {
                c.ReportErrorSilent(ex.Message + Environment.NewLine + ex.StackTrace);
            }
        }