Esempio n. 1
0
        public override void ViewDidLayoutSubviews() //called after ViewWillTransitionToSize
        {
            dpWidth  = UIScreen.MainScreen.Bounds.Width;
            dpHeight = UIScreen.MainScreen.Bounds.Height;

            UIWindow window = UIApplication.SharedApplication.KeyWindow;

            safeAreaLeft  = window.SafeAreaInsets.Left;
            safeAreaRight = window.SafeAreaInsets.Right;

            ImagesUploaded.SetTileSize();
            ImagesUploaded.Reposition();
            ImagesUploaded.RefitImagesContainer();

            base.ViewDidLayoutSubviews();
        }
Esempio n. 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try {
                base.OnCreate(savedInstanceState);

                //c.CW("OnCreate savedInstanceState is null " + (savedInstanceState is null));

                //Test reset

                /*
                 * ListActivity.initialized = false;
                 * savedInstanceState = new Bundle();
                 * savedInstanceState.PutString("Session", c.SerializeSession());
                 *
                 * ListActivity.initialized = false;
                 * Type type = typeof(Session);
                 * FieldInfo[] fieldInfo = type.GetFields();
                 * foreach (FieldInfo field in fieldInfo)
                 * {
                 *      field.SetValue(null, null);
                 * }
                 */

                if (!ListActivity.initialized && !(savedInstanceState is null))
                {
                    c.Log("ProfileEditActivity not initialized, restoring");

                    ListActivity.initialized       = true;
                    IntentData.profileViewPageType = Constants.ProfileViewType_Self;
                    GetScreenMetrics(true);
                    c.LoadSettings(false);
                    c.DeSerializeSession(savedInstanceState.GetString("Session"));
                    imageEditorFrameBorderWidth = savedInstanceState.GetInt("imageEditorFrameBorderWidth");
                }
                else if (!ListActivity.initialized && savedInstanceState is null)
                {
                    c.Log(LocalClassName.Split(".")[1] + " Not initialized");

                    c.ReportErrorSilent("Initialization error");

                    Intent i = new Intent(this, typeof(ListActivity));
                    i.SetFlags(ActivityFlags.ReorderToFront);
                    StartActivity(i);
                }

                if (Settings.DisplaySize == 1)
                {
                    SetContentView(Resource.Layout.activity_profileedit_normal);
                }
                else
                {
                    SetContentView(Resource.Layout.activity_profileedit_small);
                }

                //ProfilePage start

                MainScroll         = FindViewById <TouchScrollView>(Resource.Id.MainScroll);
                MainLayout         = FindViewById <ConstraintLayout>(Resource.Id.MainLayout);
                Email              = FindViewById <EditText>(Resource.Id.Email);
                Username           = FindViewById <EditText>(Resource.Id.Username);
                CheckUsername      = FindViewById <Button>(Resource.Id.CheckUsername);
                Name               = FindViewById <EditText>(Resource.Id.Name);
                ImagesUploaded     = FindViewById <ImageFrameLayout>(Resource.Id.ImagesUploaded);
                Images             = FindViewById <Button>(Resource.Id.Images);
                ImagesProgressText = FindViewById <TextView>(Resource.Id.ImagesProgressText);
                LoaderCircle       = FindViewById <ImageView>(Resource.Id.LoaderCircle);
                ImagesProgress     = FindViewById <ProgressBar>(Resource.Id.ImagesProgress);
                Description        = FindViewById <EditText>(Resource.Id.Description);

                UseLocationSwitch   = FindViewById <Switch>(Resource.Id.UseLocationSwitch);
                LocationShareAll    = FindViewById <Switch>(Resource.Id.LocationShareAll);
                LocationShareLike   = FindViewById <Switch>(Resource.Id.LocationShareLike);
                LocationShareMatch  = FindViewById <Switch>(Resource.Id.LocationShareMatch);
                LocationShareFriend = FindViewById <Switch>(Resource.Id.LocationShareFriend);
                LocationShareNone   = FindViewById <Switch>(Resource.Id.LocationShareNone);

                DistanceShareAll    = FindViewById <Switch>(Resource.Id.DistanceShareAll);
                DistanceShareLike   = FindViewById <Switch>(Resource.Id.DistanceShareLike);
                DistanceShareMatch  = FindViewById <Switch>(Resource.Id.DistanceShareMatch);
                DistanceShareFriend = FindViewById <Switch>(Resource.Id.DistanceShareFriend);
                DistanceShareNone   = FindViewById <Switch>(Resource.Id.DistanceShareNone);

                ImageEditorFrame       = FindViewById <View>(Resource.Id.ImageEditorFrame);
                ImageEditorFrameBorder = FindViewById <View>(Resource.Id.ImageEditorFrameBorder);
                ImageEditor            = FindViewById <ScaleImageView>(Resource.Id.ImageEditor);
                ImageEditorControls    = FindViewById <LinearLayout>(Resource.Id.ImageEditorControls);
                ImageEditorCancel      = FindViewById <ImageButton>(Resource.Id.ImageEditorCancel);
                ImageEditorOK          = FindViewById <ImageButton>(Resource.Id.ImageEditorOK);
                TopSeparator           = FindViewById <View>(Resource.Id.TopSeparator);

                //ProfilePage end

                Women = FindViewById <Switch>(Resource.Id.Women);
                Men   = FindViewById <Switch>(Resource.Id.Men);

                EditAccountData             = FindViewById <TextView>(Resource.Id.EditAccountData);
                EditChangePassword          = FindViewById <TextView>(Resource.Id.EditChangePassword);
                EditLocationSettings        = FindViewById <TextView>(Resource.Id.EditLocationSettings);
                EditMoreOptions             = FindViewById <TextView>(Resource.Id.EditMoreOptions);
                EditAccountDataSection      = FindViewById <ConstraintLayout>(Resource.Id.EditAccountDataSection);
                EditChangePasswordSection   = FindViewById <ConstraintLayout>(Resource.Id.EditChangePasswordSection);
                EditLocationSettingsSection = FindViewById <ConstraintLayout>(Resource.Id.EditLocationSettingsSection);

                EditOldPassword     = FindViewById <EditText>(Resource.Id.EditOldPassword);
                EditNewPassword     = FindViewById <EditText>(Resource.Id.EditNewPassword);
                EditConfirmPassword = FindViewById <EditText>(Resource.Id.EditConfirmPassword);

                Save   = FindViewById <Button>(Resource.Id.Save);
                Cancel = FindViewById <Button>(Resource.Id.Cancel);

                DeactivateAccount = FindViewById <Button>(Resource.Id.DeactivateAccount);
                DeleteAccount     = FindViewById <Button>(Resource.Id.DeleteAccount);

                ImagesUploaded.numColumns  = 3;                //it does not get passed in the layout file
                ImagesUploaded.tileSpacing = 2;
                ImagesUploaded.SetTileSize();

                c.view = MainLayout;
                rc     = new RegisterCommonMethods(this);
                imm    = (InputMethodManager)GetSystemService(InputMethodService);

                Women.Click += Women_Click;
                Men.Click   += Men_Click;

                EditAccountData.Click      += EditAccountData_Click;
                EditChangePassword.Click   += EditChangePassword_Click;
                EditLocationSettings.Click += EditLocationSettings_Click;
                EditMoreOptions.Click      += EditMoreOptions_Click;

                Save.Click              += Save_Click;
                Cancel.Click            += Cancel_Click;
                DeactivateAccount.Click += DeactivateAccount_Click;
                DeleteAccount.Click     += DeleteAccount_Click;
            }
            catch (Exception ex)
            {
                c.ReportErrorSilent(ex.Message + System.Environment.NewLine + ex.StackTrace);
            }
        }
        protected async override void OnResume()         //will be called after opening the file selector and permission results
        {
            try
            {
                base.OnResume();

                if (!ListActivity.initialized)
                {
                    return;
                }

                GetScreenMetrics(false);
                ImagesUploaded.SetTileSize();
                MainLayout.RequestFocus();
                Images.Enabled = true;

                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.SetSelection(int.Parse(arr[0]));
                    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("|");
                        uploadedImages = new List <string>(images);
                    }
                    else
                    {
                        uploadedImages = new List <string>();
                    }

                    if (uploadedImages.Count > 1)
                    {
                        ImagesProgressText.Text = res.GetString(Resource.String.ImagesRearrange);
                    }
                    else
                    {
                        ImagesProgressText.Text = "";
                    }

                    ImagesUploaded.RemoveAllViews();
                    ImagesUploaded.drawOrder = new List <int>();

                    ImageCache.imagesInProgress     = new List <string>();
                    ImageCache.imageViewToLoadLater = new Dictionary <ImageView, string>();

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

                    if (imagesUploading)
                    {
                        rc.StartAnim();
                    }

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

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

                if (!eulaLoaded)
                {
                    string responseString = await c.MakeRequest("action=eula&ios=0");                     //deleting images from server

                    if (responseString.Substring(0, 2) == "OK")
                    {
                        eulaLoaded = true;
                        if (Build.VERSION.SdkInt >= BuildVersionCodes.N)
                        {
                            EulaText.TextFormatted = Html.FromHtml(responseString.Substring(3), FromHtmlOptions.ModeLegacy);
                        }
                        else
                        {
#pragma warning disable CS0618 // Type or member is obsolete
                            EulaText.TextFormatted = Html.FromHtml(responseString.Substring(3));
#pragma warning restore CS0618 // Type or member is obsolete
                        }
                    }
                    else
                    {
                        c.ReportError(responseString);
                    }
                }

                if (selectedFile != null)
                {
                    OnResumeEnd();
                }

                c.Log("OnResume end");
            }
            catch (Exception ex)
            {
                c.ReportErrorSilent(ex.Message + System.Environment.NewLine + ex.StackTrace);
            }
        }