private async Task LoginUser()
        {
            var loginModel = new LoginModel
            {
                Email    = emailInput.Text,
                Password = passwordInput.Text
            };
            var tokenModel = await this.signInService.SignInUserStandard(loginModel);

            if (tokenModel != null)
            {
                preferenceHelper.SetSharedPreference <string>(SharedPreferencesKeys.BEARER_TOKEN, tokenModel.Token);
                if (tokenModel.UserHasToSetNickName)
                {
                    GoToActivity(new Intent(this, typeof(StartActivity)));
                }
                else
                {
                    SetUserNameInAppSettings(tokenModel.UserName);
                    GoToActivity(new Intent(this, typeof(MainActivity)));
                }
            }
            else
            {
                AlertsService.ShowLongToast(this, "Podany email lub has³o s¹ b³êdne");
            }
        }
Exemple #2
0
        private async Task StartConversationBtn_Click(object sender, EventArgs e)
        {
            if (!advertisement.IsActive)
            {
                AlertsService.ShowShortToast(this, "Og³oszenie jest nieaktualne dlatego nie mo¿esz wys³aæ wiadomoœci autorowi og³oszenia");
            }
            else
            {
                progress.ShowProgressDialog("Proszê czekaæ. Trwa przetwarzanie informacji..");
                var conversationInfoModel = await messagesService.GetConversationInfoModel(this.advertisement.SellerId);

                progress.CloseProgressDialog();
                if (conversationInfoModel.ConversationId == 0)
                {
                    //if 0 that means user is trying to send message to himself
                    AlertsService.ShowLongToast(this, "Nie mo¿esz wys³aæ wiadomoœci do samego siebie :)");
                }
                else
                {
                    var conversationIntent = new Intent(this, typeof(ConversationActivity));
                    conversationIntent.PutExtra(ExtrasKeys.CONVERSATION_INFO_MODEL, JsonConvert.SerializeObject(conversationInfoModel));
                    StartActivity(conversationIntent);
                }
            }
        }
        private async Task RegisterUser()
        {
            var registerModel = new RegisterModel
            {
                Email           = emailInput.Text,
                Password        = passwordInput.Text,
                ConfirmPassword = confirmPasswordInput.Text
            };

            var tokenModel = await this.signInService.RegisterUser(registerModel);

            if (tokenModel != null)
            {
                if (String.IsNullOrEmpty(tokenModel.Token))
                {
                    AlertsService.ShowLongToast(this, "Podany email ju¿ istnieje w bazie u¿ytkowników!");
                }
                else
                {
                    var preferenceHelper = new SharedPreferencesHelper(this);
                    preferenceHelper.SetSharedPreference <string>(SharedPreferencesKeys.BEARER_TOKEN, tokenModel.Token);
                    GoToStartActivity();
                }
            }
            else
            {
                AlertsService.ShowLongToast(this, "Coœ posz³o nie tak na serwerze!");
            }
        }
        private async void BtnSetNickName_Click(object sender, EventArgs e)
        {
            userNameEditText.Text = userNameEditText.Text.Replace(" ", "");
            if (userNameEditText.Text.Length < 4)
            {
                AlertsService.ShowLongToast(this, "Nick musi składać się z conajmniej czterech znaków");
            }
            else
            {
                try
                {
                    this.progressHelper.ShowProgressDialog("Przetwarzanie danych..");
                    bool result = await this.signInService.SetUserName(userNameEditText.Text, GetTokenModel());

                    this.progressHelper.CloseProgressDialog();
                    if (result)
                    {
                        SharedPreferencesHelper.SetUserNameInAppSettings(this, userNameEditText.Text);
                        StartMainOrLoginActivity(true);
                    }
                    else
                    {
                        AlertsService.ShowLongToast(this, "Podany nick jest już zajęty. Wpisz inny nick.");
                    }
                }
                catch (Exception exc)
                {
                    AlertsService.ShowLongToast(this, "Wystąpił błąd połączenia z serwerem.");
                    this.progressHelper.CloseProgressDialog();
                }
            }
        }
Exemple #5
0
 private void AddToFavourites()
 {
     AlertsService.ShowConfirmDialog(this, "Czy na pewno dodaæ to og³oszenie do ulubionych?", async() =>
     {
         var idApiModel = new SingleIdModelForPostRequests {
             Id = this.advertisement.Id
         };
         var responseMessage = await this.advertisementItemService.AddToUserFavouritesAdvertisements(idApiModel);
         AlertsService.ShowLongToast(this, responseMessage);
     });
 }
Exemple #6
0
        private void AdvertisementItemListAdapter_EditAdvertisementItemClick(object sender, FabOnAdvertisementItemRowClicked clickArgs)
        {
            if (clickArgs.Id == 0)
            {
                AlertsService.ShowLongToast(this, "Wyst¹pi³ b³¹d");
                return;
            }

            var message = clickArgs.Action.GetDisplayName();

            AlertsService.ShowConfirmDialog(this, message, GetPrepareToAdvertisementEditAction(clickArgs.Id));
        }
Exemple #7
0
        private void AdvertisementItemListAdapter_DeleteAdvertisementItemClick(object sender, FabOnAdvertisementItemRowClicked clickArgs)
        {
            if (clickArgs.Id == 0)
            {
                AlertsService.ShowLongToast(this, "Wyst¹pi³ b³¹d");
                return;
            }

            var message = clickArgs.Action.GetDisplayName();

            AlertsService.ShowConfirmDialog(this, message, async() =>
            {
                var success = false;
                if (clickArgs.Action == Models.Enums.ActionKindAfterClickFabOnAdvertisementItemRow.Restart)
                {
                    Action actionOnConfirmEditFirst = () =>
                    {
                        GetPrepareToAdvertisementEditAction(clickArgs.Id)();
                    };

                    Action actionOnCancelEditFirst = async() =>
                    {
                        success = await this.advertisementItemService.RestartAdvertisement(clickArgs.Id);
                        if (success)
                        {
                            AlertsService.ShowLongToast(this, "Pomyœlnie zakoñczono tê operacjê.");
                            RefreshAdvertisementList(true);
                        }
                        else
                        {
                            AlertsService.ShowLongToast(this, "Nie uda³o siê wykonaæ tej operacji.");
                        }
                    };

                    AlertsService.ShowConfirmDialog(this, "Czy chcesz wczeœniej zaktualizowaæ treœæ lub zdjêcia?", actionOnConfirmEditFirst, actionOnCancelEditFirst);
                }
                else
                {
                    success = await this.advertisementItemService.DeleteAdvertisement(clickArgs.Id, this.advertisementsSearchModel.AdvertisementsKind);
                    if (success)
                    {
                        AlertsService.ShowLongToast(this, "Pomyœlnie zakoñczono tê operacjê.");
                        RefreshAdvertisementList(true);
                    }
                    else
                    {
                        AlertsService.ShowLongToast(this, "Nie uda³o siê wykonaæ tej operacji.");
                    }
                }
            });
        }
        private void SetupViews()
        {
            this.textViewAppVersion = FindViewById <TextView>(Resource.Id.textViewAppVersion);
            var version = this.ApplicationContext.PackageManager.GetPackageInfo(this.ApplicationContext.PackageName, 0).VersionName;

            this.textViewAppVersion.Text = String.Format("Wersja aplikacji: {0}", version);
            this.infoLayout             = FindViewById <NestedScrollView>(Resource.Id.appInfoLayout);
            this.contactLayout          = FindViewById <RelativeLayout>(Resource.Id.contactLayout);
            this.btnSendFeedback        = FindViewById <Button>(Resource.Id.btnSendFeedback);
            this.btnSendFeedback.Click += (s, e) =>
            {
                TogleLayouts();
            };
            this.btnSubmitSenInfo   = FindViewById <Button>(Resource.Id.btnSubmitSenInfo);
            btnSubmitSenInfo.Click += async(s, e) =>
            {
                if (selectedMessageTypeItemPosition == 0 && String.IsNullOrEmpty(telModel.Text))
                {
                    AlertsService.ShowShortToast(this, "Podaj model telefonu");
                    return;
                }
                if (String.IsNullOrEmpty(messageINfoContet.Text))
                {
                    AlertsService.ShowShortToast(this, "WprowadŸ treœæ wiadomoœci.");
                    return;
                }
                progress.ShowProgressDialog("Wysy³anie zg³oszenia...");
                var model = new NotificationFromUser();
                model.Title          = messageTypeStringContent;
                model.TelModel       = this.telModel.Text;
                model.MessageContent = this.messageINfoContet.Text;
                progress.CloseProgressDialog();
                var success = await this.feedbackService.SendNotificationFromUser(model);

                if (success)
                {
                    AlertsService.ShowLongToast(this, "Zg³oszenie zosta³o wys³ane. Dziêkujemy.");
                    ClearViews();
                    OnBackPressed();
                }
                else
                {
                    AlertsService.ShowShortToast(this, "Nie uda³o siê wys³aæ zg³oszenia.");
                }
            };
            this.messageType       = FindViewById <Spinner>(Resource.Id.messageType);
            this.telModel          = FindViewById <EditText>(Resource.Id.telModel);
            this.messageINfoContet = FindViewById <EditText>(Resource.Id.messageINfoContet);

            SetupSpinner();
        }
        private void SetupFacebookLogin()
        {
            callbackManager  = CallbackManagerFactory.Create();
            facebookLoginBtn = FindViewById <LoginButton>(Resource.Id.facebookLoginBtn);
            facebookLoginBtn.SetReadPermissions("public_profile", "email");
            var loginCallback = new FacebookCallback <LoginResult>
            {
                HandleSuccess = async loginResult =>
                {
                    progress.ShowProgressDialog("Trwa logowanie w aplikacji... Proszê czekaæ");
                    var token = await LoginWithFacebook();

                    if (token != null)
                    {
                        progress.CloseProgressDialog();
                        if (token.UserHasToSetNickName)
                        {
                            GoToActivity(new Intent(this, typeof(StartActivity)));
                        }
                        else
                        {
                            SetUserNameInAppSettings(token.UserName);
                            GoToActivity(new Intent(this, typeof(MainActivity)));
                        }
                    }
                    else
                    {
                        progress.CloseProgressDialog();
                        AlertsService.ShowLongToast(this, "Facebook zwróci³ token, ale coœ posz³o nie tak z logowaniem na serwerze");
                    }
                },
                HandleCancel = () =>
                {
                    progress.CloseProgressDialog();
                    AlertsService.ShowLongToast(this, "Przerwano logowanie z facebookiem");
                },
                HandleError = loginError =>
                {
                    progress.CloseProgressDialog();
                    AlertsService.ShowLongToast(this, "Wyst¹pi³ b³¹d podczas logowania z facebookiem");
                }
            };

            facebookLoginBtn.RegisterCallback(this.callbackManager, loginCallback);
        }
Exemple #10
0
        private async Task <List <AdvertisementItemShort> > GetAdvertisements()
        {
            this.advertisementsSearchModel.Page = advertisementsPage;

            switch (this.advertisementsSearchModel.AdvertisementsKind)
            {
            case AdvertisementsKind.AdvertisementsAroundUserCurrentLocation:
                try
                {
                    this.advertisementsSearchModel.CoordinatesModel = this.gpsLocationService.GetCoordinatesModel(advertisementsSearchModel.CoordinatesModel.MaxDistance);
                }
                catch (Exception exc)
                {
                    return(new List <AdvertisementItemShort>());
                }

                break;

            case AdvertisementsKind.AdvertisementsArounUserHomeLocation:
                var settingsMOdel = SharedPreferencesHelper.GetAppSettings(this);
                if (settingsMOdel != null && settingsMOdel.LocationSettings.Latitude > 0.0D)
                {
                    this.advertisementsSearchModel.CoordinatesModel.Latitude  = settingsMOdel.LocationSettings.Latitude;
                    this.advertisementsSearchModel.CoordinatesModel.Longitude = settingsMOdel.LocationSettings.Longitude;
                }
                else
                {
                    AlertsService.ShowLongToast(this, "Nie masz ustawionej lokalizacji domowej. Mo¿esz to zrobiæ w lewym panelu");
                    return(new List <AdvertisementItemShort>());
                }
                break;
            }

            var list = default(List <AdvertisementItemShort>);

            list = await this.advertisementItemService.GetAdvertisements(this.advertisementsSearchModel);

            return(list);
        }
Exemple #11
0
        private void ImgBtnHomeLocalization_Click(object sender, EventArgs e)
        {
            var confirmMessage = "Czy na pewno chcesz ustaliæ aktualn¹ lokalizacjê i ustawiæ j¹ jako domow¹?";

            AlertsService.ShowConfirmDialog(activity, confirmMessage, async() =>
            {
                this.progressDialogHelper.ShowProgressDialog("Trwa ustalanie Twojej aktualnej lokalizacji");
                try
                {
                    if (!this.gpsService.CanGetLocation)
                    {
                        AlertsService.ShowLongToast(activity, "W³¹cz gps w ustawieniach");
                    }
                    else
                    {
                        var location = this.gpsService.GetLocation();
                        var address  = await this.googleMapsAPIService.GetAddress(location.Latitude, location.Longitude);
                        appSettings.LocationSettings.Latitude        = location.Latitude;
                        appSettings.LocationSettings.Longitude       = location.Longitude;
                        appSettings.LocationSettings.LocationAddress = address;
                        SetAppSettings(appSettings);
                        SetHomeLocationSettings(appSettings);
                        if (address != string.Empty)
                        {
                            var infoMessage = String.Format("Adres lokalizacji to w przybli¿eniu: {0}. Na odczyt lokalizacji wp³ywa wiele czynników dlatego wiemy, ¿e adres mo¿e nie byæ w 100% idealny. Twoja lokalizacja wraz z adresem nie bêdzie nikomu udostêpniona.", address);
                            AlertsService.ShowAlertDialog(activity, infoMessage);
                        }
                    }
                }
                catch (Exception)
                {
                    AlertsService.ShowLongToast(activity, "Wyst¹pi³ problem z okreœleniem Twojej lokalizacji. Spróbuj ponownie póŸniej");
                }
                finally
                {
                    this.progressDialogHelper.CloseProgressDialog();
                }
            });
        }
Exemple #12
0
        private void SendMessage()
        {
            if (editTextMessage.Text != null & editTextMessage.Text != string.Empty)
            {
                if (chatHubClientService != null && chatHubClientService.IsConnected())
                {
                    var date    = DateTime.Now;
                    var message = new ConversationMessage();
                    message.MessageContent = editTextMessage.Text;
                    message.UserWasSender  = true;
                    message.ConversationId = this.conversationInfoModel.ConversationId;
                    message.MessageHeader  = String.Format("ja, {0} {1}", date.GetDateDottedStringFormat(), date.GetTimeColonStringFormat());

                    this.conversationMessagesListAdapter.AddReceivedMessage(message);
                    chatHubClientService.SendMessage(editTextMessage.Text, this.conversationInfoModel.InterlocutorId.ToString(), this.conversationInfoModel.ConversationId);

                    editTextMessage.Text = string.Empty;
                }
                else
                {
                    if (appSettings.ChatDisabled)
                    {
                        Action actionOnConfirm = () =>
                        {
                            appSettings.ChatDisabled = false;
                            SharedPreferencesHelper.SetAppSettings(this, appSettings);
                            StartService(new Intent(this.ApplicationContext, typeof(MessengerService)));
                            this.chatHubClientService = ChatHubClientService.GetServiceInstance(bearerToken);
                        };

                        AlertsService.ShowConfirmDialog(this, "Masz wy³¹czon¹ us³ugê czatu. Czy chcesz j¹ teraz w³¹czyæ?", actionOnConfirm);
                    }
                    else
                    {
                        AlertsService.ShowLongToast(this, "Nie mogê po³¹czyæ siê z serwerem. Upewnij siê czy masz dostêp do internetu.");
                    }
                }
            }
        }
Exemple #13
0
        private async Task CreateAdvertisement()
        {
            if (AdvertisementItemDataIsValidate())
            {
                var location = gpsLocationService.GetLocation();
                if (location.Longitude != 0.0 && location.Latitude != 0.0)
                {
                    var photosBytesArraysList = await GetPhotosByteArray(this.photosPaths);

                    var photosListModel = await this.advertisementItemService.UploadNewAdvertisementPhotos(photosBytesArraysList);

                    if (photosListModel != null)
                    {
                        var newAdvertisementModel = CreateNewAdvertisementItemModel(photosListModel);
                        var success = await this.advertisementItemService.CreateNewAdvertisement(newAdvertisementModel);

                        if (success)
                        {
                            foreach (var tempPath in tempPhotosPaths)
                            {
                                System.IO.File.Delete(tempPath);
                            }
                            var message = editModel == null ? "Pomyœlnie utworzone nowe og³oszenie" : "Pomyœlnie zaktualizowano og³oszenie";
                            AlertsService.ShowLongToast(this, message);

                            this.Finish();
                        }
                        else
                        {
                            AlertsService.ShowLongToast(this, "Nie uda³o siê utworzyæ nowego og³oszenia. Spróbuj ponownie");
                        }
                    }
                }
                else
                {
                    Toast.MakeText(this, "Nie mogê ustaliæ wspó³rzêdnych. Upewnij siê, ¿e masz w³¹czon¹ lokalizacje.", ToastLength.Long).Show();
                }
            }
        }
Exemple #14
0
        private async Task SaveProfilePhoto(string profilePhotoPath)
        {
            //wysy³anko do serwera
            try
            {
                this.progressDialogHelper.ShowProgressDialog("Zapisywanie zdjêcia profilowego");
                var photoResized = await this.bitmapOperationService.GetScaledDownPhotoByteArray(profilePhotoPath, true, true);

                var profileImagePath = System.IO.Path.Combine(Application.Context.FilesDir.AbsolutePath, "profilePicture.jpg");
                System.IO.File.WriteAllBytes(profileImagePath, photoResized);
                appSettings.ProfileImagePath = profileImagePath;
                SetAppSettings(appSettings);
                await signInService.UploadUserProfilePhoto(activity.BearerToken, photoResized);
            }
            catch (Exception exc)
            {
                AlertsService.ShowLongToast(activity, "Wyst¹pi³ b³¹d.");
            }
            finally
            {
                this.progressDialogHelper.CloseProgressDialog();
            }
        }