private void Privacy_Follow_Pref_PreferenceChange(object sender, Preference.PreferenceChangeEventArgs e)
        {
            try
            {
                if (e.Handled)
                {
                    ListPreference etp         = (ListPreference)sender;
                    var            value       = e.NewValue.ToString();
                    var            valueAsText = etp.GetEntries()[Int32.Parse(value)];
                    etp.Summary = valueAsText;

                    S_WhoCanFollowMe = value;

                    if (IMethods.CheckConnectivity())
                    {
                        var dataPrivacy = new Dictionary <string, string>
                        {
                            { "follow_privacy", S_WhoCanFollowMe },
                        };

                        var data = Global.Update_User_Data(dataPrivacy)
                                   .ConfigureAwait(false);
                    }
                    else
                    {
                        Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_Error_check_internet_connection),
                                       ToastLength.Long).Show();
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Beispiel #2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            try
            {
                //Set our view from the "Last_Stories_Fragment" layout resource
                view = inflater.Inflate(Resource.Layout.Last_Stories_Fragment, container, false);

                //Get values
                LastStoriessRecyler = view.FindViewById <RecyclerView>(Resource.Id.lastStoriessRecyler);
                LastStoriess_Empty  = (LinearLayout)view.FindViewById(Resource.Id.lastStoriess_LinerEmpty);
                Icon_lastStories    = view.FindViewById <AppCompatTextView>(Resource.Id.lastStories_icon);

                IMethods.Set_TextViewIcon("1", Icon_lastStories, IonIcons_Fonts.IosCameraOutline);
                Icon_lastStories.SetTextColor(Android.Graphics.Color.ParseColor(AppSettings.MainColor));

                LastStoriessRecyler.Visibility = ViewStates.Visible;
                LastStoriess_Empty.Visibility  = ViewStates.Gone;
                LastStoriessRecyler.SetItemAnimator(null);

                mLayoutManager = new LinearLayoutManager(this.Context);
                LastStoriessRecyler.SetLayoutManager(mLayoutManager);
                StoryAdapter              = new Last_Stories_Adapter(this.Context);
                StoryAdapter.OnItemClick += StoryAdapterOnOnItemClick;
                LastStoriessRecyler.SetAdapter(StoryAdapter);

                GetStory_Api();

                return(view);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(null);
            }
        }
        //About
        private void About_Me_Pref_PreferenceChange(object sender, Preference.PreferenceChangeEventArgs e)
        {
            try
            {
                EditTextPreference etp = (EditTextPreference)sender;
                var value = etp.EditText.Text;
                etp.Summary = value;

                var datauser = Classes.MyProfileList.FirstOrDefault(a => a.user_id == UserDetails.User_id);
                if (datauser != null)
                {
                    datauser.about = etp.EditText.Text;
                    S_About        = etp.EditText.Text;
                }

                if (IMethods.CheckConnectivity())
                {
                    var dataPrivacy = new Dictionary <string, string>
                    {
                        { "about", value },
                    };

                    var data = Global.Update_User_Data(dataPrivacy)
                               .ConfigureAwait(false);
                }
                else
                {
                    Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_Error_check_internet_connection),
                                   ToastLength.Long).Show();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Beispiel #4
0
        private async void RegisterButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (Chk_agree.Checked)
                {
                    if (IMethods.CheckConnectivity())
                    {
                        if (!String.IsNullOrEmpty(UsernameEditext.Text) ||
                            !String.IsNullOrEmpty(PasswordEditext.Text) ||
                            !String.IsNullOrEmpty(PasswordRepeatEditext.Text) ||
                            !String.IsNullOrEmpty(EmailEditext.Text))
                        {
                            var check = IMethods.Fun_String.IsEmailValid(EmailEditext.Text);
                            if (!check)
                            {
                                IMethods.DialogPopup.InvokeAndShowDialog(this,
                                                                         GetText(Resource.String.Lbl_VerificationFailed),
                                                                         GetText(Resource.String.Lbl_IsEmailValid), GetText(Resource.String.Lbl_Ok));
                            }
                            else
                            {
                                if (PasswordRepeatEditext.Text == PasswordEditext.Text)
                                {
                                    progressBar.Visibility    = ViewStates.Visible;
                                    RegisterButton.Visibility = ViewStates.Gone;

                                    var settingsResult = await Current.GetSettings();

                                    if (settingsResult.Item1 == 200)
                                    {
                                        var PushID = settingsResult.Item2.PushId.ToString();
                                        if (OneSignalNotification.OneSignalAPP_ID == "")
                                        {
                                            OneSignalNotification.OneSignalAPP_ID = PushID;
                                            if (AppSettings.ShowNotification)
                                            {
                                                OneSignalNotification.RegisterNotificationDevice();
                                            }
                                        }

                                        var(Api_status, Respond) =
                                            await WoWonder_API.Requests.RequestsAsync.Global.Get_Create_Account(
                                                UsernameEditext.Text,
                                                PasswordEditext.Text, PasswordRepeatEditext.Text, EmailEditext.Text);

                                        if (Api_status == 200)
                                        {
                                            if (Respond is CreatAccountObject result)
                                            {
                                                Current.AccessToken = result.access_token;

                                                UserDetails.Username     = UsernameEditext.Text;
                                                UserDetails.Full_name    = UsernameEditext.Text;
                                                UserDetails.Password     = PasswordEditext.Text;
                                                UserDetails.access_token = result.access_token;
                                                UserDetails.User_id      = result.user_id;
                                                UserDetails.Status       = "Active";
                                                UserDetails.Cookie       = result.access_token;
                                                UserDetails.Email        = EmailEditext.Text;

                                                //Insert user data to database
                                                var user = new DataTables.LoginTB
                                                {
                                                    UserID       = UserDetails.User_id,
                                                    access_token = UserDetails.access_token,
                                                    Cookie       = UserDetails.Cookie,
                                                    Username     = UsernameEditext.Text,
                                                    Password     = PasswordEditext.Text,
                                                    Status       = "Active",
                                                    Lang         = ""
                                                };

                                                Classes.DataUserLoginList.Add(user);

                                                var dbDatabase = new SqLiteDatabase();
                                                dbDatabase.InsertRow(user);
                                                dbDatabase.Dispose();

                                                StartActivity(new Intent(this, typeof(AppIntroWalkTroutPage)));
                                            }

                                            progressBar.Visibility    = ViewStates.Gone;
                                            RegisterButton.Visibility = ViewStates.Visible;
                                            Finish();
                                        }
                                        else if (Api_status == 220)
                                        {
                                            //var dialog = new MaterialDialog.Builder(this);

                                            //dialog.Title(GetText(Resource.String.Lbl_ActivationSent));
                                            //dialog.Content(GetText(Resource.String.Lbl_ActivationDetails)
                                            //    .Replace("@", EmailEditext.Text));
                                            //dialog.PositiveText(GetText(Resource.String.Lbl_Ok)).OnPositive(this);

                                            //dialog.AlwaysCallSingleChoiceCallback();
                                            // dialog.Build().Show();
                                            var obj = new IMethods.DialogPopup(this);

                                            var x = await obj.ShowDialog("Success",
                                                                         "Registration successful! We have sent you an email, Please check your inbox/spam to verify your email.");

                                            StartActivity(new Intent(this, typeof(MainActivity)));
                                        }
                                        else if (Api_status == 400)
                                        {
                                            var error = Respond as ErrorObject;
                                            if (error != null)
                                            {
                                                var errortext = error._errors.Error_text;

                                                var errorid = error._errors.Error_id;

                                                if (errorid == "3")
                                                {
                                                    IMethods.DialogPopup.InvokeAndShowDialog(this,
                                                                                             GetText(Resource.String.Lbl_Security),
                                                                                             GetText(Resource.String.Lbl_ErrorRegister_3),
                                                                                             GetText(Resource.String.Lbl_Ok));
                                                }
                                                else if (errorid == "4")
                                                {
                                                    IMethods.DialogPopup.InvokeAndShowDialog(this,
                                                                                             GetText(Resource.String.Lbl_Security),
                                                                                             GetText(Resource.String.Lbl_ErrorRegister_4),
                                                                                             GetText(Resource.String.Lbl_Ok));
                                                }
                                                else if (errorid == "5")
                                                {
                                                    IMethods.DialogPopup.InvokeAndShowDialog(this,
                                                                                             GetText(Resource.String.Lbl_Security),
                                                                                             GetText(Resource.String.Lbl_Something_went_wrong),
                                                                                             GetText(Resource.String.Lbl_Ok));
                                                }
                                                else if (errorid == "6")
                                                {
                                                    IMethods.DialogPopup.InvokeAndShowDialog(this,
                                                                                             GetText(Resource.String.Lbl_Security),
                                                                                             GetText(Resource.String.Lbl_ErrorRegister_6),
                                                                                             GetText(Resource.String.Lbl_Ok));
                                                }
                                                else if (errorid == "7")
                                                {
                                                    IMethods.DialogPopup.InvokeAndShowDialog(this,
                                                                                             GetText(Resource.String.Lbl_Security),
                                                                                             GetText(Resource.String.Lbl_ErrorRegister_7),
                                                                                             GetText(Resource.String.Lbl_Ok));
                                                }
                                                else if (errorid == "8")
                                                {
                                                    IMethods.DialogPopup.InvokeAndShowDialog(this,
                                                                                             GetText(Resource.String.Lbl_Security),
                                                                                             GetText(Resource.String.Lbl_ErrorRegister_8),
                                                                                             GetText(Resource.String.Lbl_Ok));
                                                }
                                                else if (errorid == "9")
                                                {
                                                    IMethods.DialogPopup.InvokeAndShowDialog(this,
                                                                                             GetText(Resource.String.Lbl_Security),
                                                                                             GetText(Resource.String.Lbl_ErrorRegister_9),
                                                                                             GetText(Resource.String.Lbl_Ok));
                                                }
                                                else if (errorid == "10")
                                                {
                                                    IMethods.DialogPopup.InvokeAndShowDialog(this,
                                                                                             GetText(Resource.String.Lbl_Security),
                                                                                             GetText(Resource.String.Lbl_ErrorRegister_10),
                                                                                             GetText(Resource.String.Lbl_Ok));
                                                }
                                                else if (errorid == "11")
                                                {
                                                    IMethods.DialogPopup.InvokeAndShowDialog(this,
                                                                                             GetText(Resource.String.Lbl_Security),
                                                                                             GetText(Resource.String.Lbl_ErrorRegister_11),
                                                                                             GetText(Resource.String.Lbl_Ok));
                                                }
                                                else
                                                {
                                                    IMethods.DialogPopup.InvokeAndShowDialog(this,
                                                                                             GetText(Resource.String.Lbl_Security), errortext,
                                                                                             GetText(Resource.String.Lbl_Ok));
                                                }
                                            }

                                            progressBar.Visibility    = ViewStates.Gone;
                                            RegisterButton.Visibility = ViewStates.Visible;
                                        }
                                        else if (Api_status == 404)
                                        {
                                            progressBar.Visibility    = ViewStates.Gone;
                                            RegisterButton.Visibility = ViewStates.Visible;
                                            IMethods.DialogPopup.InvokeAndShowDialog(this,
                                                                                     GetText(Resource.String.Lbl_Security),
                                                                                     GetText(Resource.String.Lbl_Error_Login),
                                                                                     GetText(Resource.String.Lbl_Ok));
                                        }
                                    }
                                }
                                else
                                {
                                    progressBar.Visibility    = ViewStates.Gone;
                                    RegisterButton.Visibility = ViewStates.Visible;

                                    IMethods.DialogPopup.InvokeAndShowDialog(this,
                                                                             GetText(Resource.String.Lbl_Security),
                                                                             GetText(Resource.String.Lbl_Error_Register_password),
                                                                             GetText(Resource.String.Lbl_Ok));
                                }
                            }
                        }
                        else
                        {
                            progressBar.Visibility    = ViewStates.Gone;
                            RegisterButton.Visibility = ViewStates.Visible;
                            IMethods.DialogPopup.InvokeAndShowDialog(this, GetText(Resource.String.Lbl_Security),
                                                                     GetText(Resource.String.Lbl_Please_enter_your_data), GetText(Resource.String.Lbl_Ok));
                        }
                    }
                    else
                    {
                        progressBar.Visibility    = ViewStates.Gone;
                        RegisterButton.Visibility = ViewStates.Visible;

                        IMethods.DialogPopup.InvokeAndShowDialog(this, this.GetText(Resource.String.Lbl_Security),
                                                                 this.GetText(Resource.String.Lbl_Error_check_internet_connection),
                                                                 this.GetText(Resource.String.Lbl_Ok));
                        return;
                    }
                }
                else
                {
                    IMethods.DialogPopup.InvokeAndShowDialog(this, this.GetText(Resource.String.Lbl_Warning),
                                                             this.GetText(Resource.String.Lbl_Error_Terms), this.GetText(Resource.String.Lbl_Ok));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                progressBar.Visibility    = ViewStates.Gone;
                RegisterButton.Visibility = ViewStates.Visible;
                IMethods.DialogPopup.InvokeAndShowDialog(this, this.GetText(Resource.String.Lbl_Authentication_failed),
                                                         ex.Message, this.GetText(Resource.String.Lbl_Ok));
            }
        }
Beispiel #5
0
        public async void GetStory_Api()
        {
            try
            {
                if (!IMethods.CheckConnectivity())
                {
                }
                else
                {
                    var(apiStatus, respond) = await WoWonder_API.Requests.RequestsAsync.Story.Get_Stories();

                    if (apiStatus == 200)
                    {
                        if (respond is GetStoriesObject result)
                        {
                            if (result.stories.Length > 0)
                            {
                                Classes.StoryList = new Dictionary <List <GetStoriesObject.Story>, string>(); // Key ListData , Value : user_id
                                Classes.StoryList.Clear();

                                foreach (var story in result.stories)
                                {
                                    List <GetStoriesObject.Story> listOfStories = new List <GetStoriesObject.Story>();
                                    var checkUser = StoryAdapter.mStoryList.FirstOrDefault(a => a.user_id == story.user_id);
                                    if (checkUser != null)
                                    {
                                        if (Classes.StoryList == null)
                                        {
                                            continue;
                                        }

                                        var checkUserExits = Classes.StoryList.FirstOrDefault(a => a.Value == checkUser.user_id);
                                        if (checkUserExits.Value == null)
                                        {
                                            var ch = checkUserExits.Key?.FirstOrDefault(a => a.id == checkUser.id);
                                            if (ch == null)
                                            {
                                                listOfStories.Add(story);
                                                Classes.StoryList.Add(listOfStories, story.user_id);
                                            }
                                        }
                                        else
                                        {
                                            foreach (var item in Classes.StoryList.Keys.ToList())
                                            {
                                                string userId = item.FirstOrDefault(a => a.user_id == checkUser.user_id)?.user_id;
                                                if (checkUserExits.Value == userId)
                                                {
                                                    var ch = item.FirstOrDefault(a => a.id == story.id);
                                                    if (ch == null)
                                                    {
                                                        item.Add(story);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        StoryAdapter.Add(story);

                                        listOfStories.Clear();

                                        if (Classes.StoryList == null)
                                        {
                                            continue;
                                        }

                                        var checkUserExits = Classes.StoryList.FirstOrDefault(a => a.Value == story.user_id);
                                        if (checkUserExits.Value == null)
                                        {
                                            listOfStories.Add(story);
                                            Classes.StoryList.Add(listOfStories, story.user_id);
                                        }
                                    }
                                }

                                this.Activity.RunOnUiThread(() =>
                                {
                                    StoryAdapter.BindEnd();
                                });
                            }
                        }
                    }
                    else if (apiStatus == 400)
                    {
                        if (respond is ErrorObject error)
                        {
                            var errortext = error._errors.Error_text;


                            if (errortext.Contains("Invalid or expired access_token"))
                            {
                                API_Request.Logout(Activity);
                            }
                        }
                    }
                    else if (apiStatus == 404)
                    {
                        var error = respond.ToString();
                    }
                }

                if (StoryAdapter.mStoryList.Count > 0)
                {
                    LastStoriessRecyler.Visibility = ViewStates.Visible;
                    LastStoriess_Empty.Visibility  = ViewStates.Gone;
                }
                else
                {
                    LastStoriessRecyler.Visibility = ViewStates.Gone;
                    LastStoriess_Empty.Visibility  = ViewStates.Visible;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        private async void ButtonClickOnClick(object sender, EventArgs eventArgs)
        {
            try
            {
                if (!IMethods.CheckConnectivity())
                {
                    IMethods.DialogPopup.InvokeAndShowDialog(this, GetText(Resource.String.Lbl_Security),
                                                             GetText(Resource.String.Lbl_Error_check_internet_connection), GetText(Resource.String.Lbl_Ok));
                }
                else
                {
                    if (!string.IsNullOrEmpty(UsernameEditext.Text) || !string.IsNullOrEmpty(PasswordEditext.Text))
                    {
                        progressBar.Visibility = ViewStates.Visible;
                        Btn_Login.Visibility   = ViewStates.Gone;

                        var(apiStatus, response) = await WoWonder_API.Current.GetSettings();

                        if (apiStatus == 200)
                        {
                            if (response is GetSiteSettingsObject.Config result)
                            {
                                var PushID = result.pushId.ToString();
                                if (OneSignalNotification.OneSignalAPP_ID == "")
                                {
                                    OneSignalNotification.OneSignalAPP_ID = PushID;
                                    if (AppSettings.ShowNotification)
                                    {
                                        OneSignalNotification.RegisterNotificationDevice();
                                    }
                                }

                                string timeZone = IMethods.ITime.GetTimeZone();
                                var(Api_status, Respond) = await Global.Get_Auth(UsernameEditext.Text, PasswordEditext.Text, "UTC");

                                if (Api_status == 200)
                                {
                                    if (Respond is AuthObject auth)
                                    {
                                        Current.AccessToken = auth.access_token;

                                        UserDetails.Username     = UsernameEditext.Text;
                                        UserDetails.Full_name    = UsernameEditext.Text;
                                        UserDetails.Password     = PasswordEditext.Text;
                                        UserDetails.access_token = auth.access_token;
                                        UserDetails.User_id      = auth.user_id;
                                        UserDetails.Status       = "Active";
                                        UserDetails.Cookie       = auth.access_token;
                                        UserDetails.Email        = UsernameEditext.Text;

                                        //Insert user data to database
                                        var user = new DataTables.LoginTB()
                                        {
                                            UserID       = UserDetails.User_id,
                                            access_token = UserDetails.access_token,
                                            Cookie       = UserDetails.Cookie,
                                            Username     = UsernameEditext.Text,
                                            Password     = PasswordEditext.Text,
                                            Status       = "Active",
                                            Lang         = ""
                                        };
                                        Classes.DataUserLoginList.Add(user);

                                        var dbDatabase = new SqLiteDatabase();
                                        dbDatabase.InsertRow(user);
                                        dbDatabase.Dispose();

                                        if (AppSettings.Show_WalkTroutPage)
                                        {
                                            StartActivity(new Intent(this, typeof(AppIntroWalkTroutPage)));
                                        }
                                        else
                                        {
                                            StartActivity(new Intent(this, typeof(Tabbed_Main_Page)));

                                            //Get data profile
                                            var data = API_Request.Get_MyProfileData_Api(this).ConfigureAwait(false);
                                        }

                                        progressBar.Visibility = ViewStates.Gone;
                                        Finish();
                                    }
                                }
                                else if (Api_status == 400)
                                {
                                    var error = Respond as ErrorObject;
                                    if (error != null)
                                    {
                                        var errortext = error._errors.Error_text;
                                        var errorid   = error._errors.Error_id;

                                        if (errorid == "3")
                                        {
                                            IMethods.DialogPopup.InvokeAndShowDialog(this,
                                                                                     GetText(Resource.String.Lbl_Security),
                                                                                     GetText(Resource.String.Lbl_ErrorLogin_3), GetText(Resource.String.Lbl_Ok));
                                        }
                                        else if (errorid == "4")
                                        {
                                            IMethods.DialogPopup.InvokeAndShowDialog(this,
                                                                                     GetText(Resource.String.Lbl_Security),
                                                                                     GetText(Resource.String.Lbl_ErrorLogin_4), GetText(Resource.String.Lbl_Ok));
                                        }
                                        else if (errorid == "5")
                                        {
                                            IMethods.DialogPopup.InvokeAndShowDialog(this,
                                                                                     GetText(Resource.String.Lbl_Security),
                                                                                     GetText(Resource.String.Lbl_ErrorLogin_5), GetText(Resource.String.Lbl_Ok));
                                        }
                                        else
                                        {
                                            IMethods.DialogPopup.InvokeAndShowDialog(this,
                                                                                     GetText(Resource.String.Lbl_Security), errortext,
                                                                                     GetText(Resource.String.Lbl_Ok));
                                        }
                                    }
                                }


                                progressBar.Visibility = ViewStates.Gone;
                                Btn_Login.Visibility   = ViewStates.Visible;
                            }
                        }
                        else if (apiStatus == 400)
                        {
                            var error = response as ErrorObject;
                            if (error != null)
                            {
                                var errortext = error._errors.Error_text;
                                var errorid   = error._errors.Error_id;

                                if (errorid == "3")
                                {
                                    IMethods.DialogPopup.InvokeAndShowDialog(this,
                                                                             GetText(Resource.String.Lbl_Security),
                                                                             GetText(Resource.String.Lbl_ErrorLogin_3), GetText(Resource.String.Lbl_Ok));
                                }
                                else if (errorid == "4")
                                {
                                    IMethods.DialogPopup.InvokeAndShowDialog(this,
                                                                             GetText(Resource.String.Lbl_Security),
                                                                             GetText(Resource.String.Lbl_ErrorLogin_4), GetText(Resource.String.Lbl_Ok));
                                }
                                else if (errorid == "5")
                                {
                                    IMethods.DialogPopup.InvokeAndShowDialog(this,
                                                                             GetText(Resource.String.Lbl_Security),
                                                                             GetText(Resource.String.Lbl_ErrorLogin_5), GetText(Resource.String.Lbl_Ok));
                                }
                                else
                                {
                                    IMethods.DialogPopup.InvokeAndShowDialog(this,
                                                                             GetText(Resource.String.Lbl_Security), errortext,
                                                                             GetText(Resource.String.Lbl_Ok));
                                }
                            }
                        }
                        else if (apiStatus == 404)
                        {
                            //var Error = Respond.ToString();
                            IMethods.DialogPopup.InvokeAndShowDialog(this, GetText(Resource.String.Lbl_Security),
                                                                     GetText(Resource.String.Lbl_Error_Login), GetText(Resource.String.Lbl_Ok));
                        }
                    }
                    else
                    {
                        progressBar.Visibility = ViewStates.Gone;
                        Btn_Login.Visibility   = ViewStates.Visible;
                        IMethods.DialogPopup.InvokeAndShowDialog(this, GetText(Resource.String.Lbl_Security),
                                                                 GetText(Resource.String.Lbl_Please_enter_your_data), GetText(Resource.String.Lbl_Ok));
                    }
                }
            }
            catch (Exception exception)
            {
                progressBar.Visibility = ViewStates.Gone;
                Btn_Login.Visibility   = ViewStates.Visible;
                IMethods.DialogPopup.InvokeAndShowDialog(this, GetText(Resource.String.Lbl_Security), exception.Message,
                                                         GetText(Resource.String.Lbl_Ok));
                Console.WriteLine(exception);
            }
        }