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();
                }
            }
        }
        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!");
            }
        }
Esempio n. 3
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            ActivityInstance = this;
            progress         = new ProgressDialogHelper(this);
            signInService    = new SignInService();
            bitmapService    = new BitmapOperationService();
            appSettings      = SharedPreferencesHelper.GetAppSettings(this);
            if (!appSettings.ChatDisabled)
            {
                this.chatHubClientService = ChatHubClientService.GetServiceInstance(bearerToken);
            }
            this.messagesService = new MessagesService(bearerToken);
            SetContentView(Resource.Layout.ConversationActivity);
            SetupViews(savedInstanceState);
            SetupConversationToolbar();
            pageNumber = 0;
            GetExtras();
            player = new MediaPlayer();
            player.SetDataSource(this, Android.Net.Uri.Parse("android.resource://" + this.PackageName + "/raw/" + Resource.Raw.message_sound));
            player.Prepare();
            progress.ShowProgressDialog("Trwa pobieranie wiadomoœci...");
            await SetupIntelocutorInfo();
            await GetAndDisplayMesages(savedInstanceState);

            coversationsLayoutWrapper.Visibility = ViewStates.Visible;
            progress.CloseProgressDialog();
        }
		protected override async void OnCreate(Bundle savedInstanceState) {
			base.OnCreate(savedInstanceState);
			this.sharedPreferencesHelper = new SharedPreferencesHelper(this);
			SetContentView(Resource.Layout.AdvertisementItemDetailsActivity);
			SetupViews();
			CalculateSizeForPhotoImageView();
			await GetAndShowAdvertisementDetails();
		}
Esempio n. 5
0
        public override void OnReceive(Context context, Intent intent)
        {
            this.sharedPreferencesHelper = new SharedPreferencesHelper(context);
            var settingsModel = (AppSettingsModel)this.sharedPreferencesHelper.GetSharedPreference <AppSettingsModel>(SharedPreferencesKeys.APP_SETTINGS);

            if (!settingsModel.ChatDisabled && !MessengerService.ServiceIsRunning)
            {
                context.StartService(new Intent(context.ApplicationContext, typeof(MessengerService)));
            }
            WakeUpAlarmReceiver.SetWakeUpAlarmRepeating(context, 1000 * 60 * 1);
        }
		protected override async void OnCreate(Bundle savedInstanceState)
		{
			base.OnCreate(savedInstanceState);
			ActivityInstance = this;
			this.preferenceHelper = new SharedPreferencesHelper(this);
			bearerToken = (string)preferenceHelper.GetSharedPreference<string>(SharedPreferencesKeys.BEARER_TOKEN);
			this.chatHubClientService = ChatHubClientService.GetServiceInstance(bearerToken);
			SetContentView(Resource.Layout.ConversationActivity);
			GetExtras();
			pageNumber = 0;
			await SetupViews(savedInstanceState);
		}
Esempio n. 7
0
 public NavigationViewMenu(BaseActivityWithNavigationDrawer activity, SharedPreferencesHelper sharedPreferencesHelper)
 {
     this.activity = activity;
     signInService = new SignInService();
     this.bitmapOperationService  = new BitmapOperationService();
     this.progressDialogHelper    = new ProgressDialogHelper(activity);
     this.sharedPreferencesHelper = sharedPreferencesHelper;
     this.gpsService           = GpsLocationService.GetServiceInstance(activity);
     this.googleMapsAPIService = new GoogleMapsAPIService();
     this.categoriesHelper     = new CategoriesSelectingHelper(activity, (string)this.sharedPreferencesHelper.GetSharedPreference <string>(SharedPreferencesKeys.BEARER_TOKEN));
     this.sizeSelectingHelper  = new SizeSelectingHelper(activity);
     this.appSettings          = SharedPreferencesHelper.GetAppSettings(activity);
     SetupViews(activity);
 }
Esempio n. 8
0
        public override StartCommandResult OnStartCommand(Intent intent, [GeneratedEnum] StartCommandFlags flags, int startId)
        {
            ServiceIsRunning = true;

            searchModelForNotifications  = new AdvertisementsSearchModelForNotifications();
            this.sharedPreferencesHelper = new SharedPreferencesHelper(Application.ApplicationContext);
            var bearerToken = (string)this.sharedPreferencesHelper.GetSharedPreference <string>(SharedPreferencesKeys.BEARER_TOKEN);

            this.advertisementItemService = new AdvertisementItemService(bearerToken);
            this.gpsLocationService       = new GpsLocationService(Application.ApplicationContext, null);

            DoWork();

            return(StartCommandResult.Sticky);
        }
		private void DoWork()
		{
			this.signalRThread = new Thread(() =>
			{
				this.sharedPreferencesHelper = new SharedPreferencesHelper(Application.ApplicationContext);
				this.bearerToken = (string)this.sharedPreferencesHelper.GetSharedPreference<string>(SharedPreferencesKeys.BEARER_TOKEN);
				this.chatHubClientService = ChatHubClientService.GetServiceInstance(bearerToken);
				this.chatHubClientService.RegisterReceiveMessages(ShowNotification);

				var timer = new Timer(new TimerCallback(TimerCallBackMethod));
				timer.Change(0, 5000);
			}
		);
			signalRThread.Start();
		}
		protected override async void OnCreate(Bundle savedInstanceState)
		{
			base.OnCreate(savedInstanceState);
			this.gpsLocationService = new GpsLocationService(this, null);
			this.sharedPreferencesHelper = new SharedPreferencesHelper(this);

			SetContentView(Resource.Layout.MainActivity);




			SetupToolbar();
			advertisementsPage = savedInstanceState == null ? 0 : savedInstanceState.GetInt(ExtrasKeys.ADVERTISEMENTS_LIST_PAGE);
			await SetupViews(savedInstanceState != null);
		}
        protected override void OnStart()
        {
            base.OnStart();
            var settingsModel = SharedPreferencesHelper.GetAppSettings(this);

            if (settingsModel != null)
            {
                WakeUpAlarmReceiver.SetWakeUpAlarmRepeating(this.ApplicationContext, AlarmManager.IntervalHour);
                if (!settingsModel.ChatDisabled && !MessengerService.ServiceIsRunning)
                {
                    StartService(new Intent(this.ApplicationContext, typeof(MessengerService)));
                }
            }
            IsInStack = true;
        }
		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) {
				var preferenceHelper = new SharedPreferencesHelper(this);
				preferenceHelper.SetSharedPreference<string>(SharedPreferencesKeys.BEARER_TOKEN, tokenModel.Token);
				GoToMainActivity();
			}
			else {
				AlertsService.ShowToast(this, "Coœ posz³o nie tak na serwerze!");
			}
		}
        public override async void OnReceive(Context context, Intent intent)
        {
            bearerToken = SharedPreferencesHelper.GetBearerToken(context);
            if (bearerToken == null)
            {
                return;
            }
            var isUserConnectedToInternet = await DoesUserHasInternetConnection(bearerToken);

            if (!isUserConnectedToInternet)
            {
                return;
            }
            this.context = context.ApplicationContext;
            var powerManager = (PowerManager)context.GetSystemService(Context.PowerService);

            _wakeLock = powerManager.NewWakeLock(WakeLockFlags.Partial, "MSH");
            _wakeLock.Acquire();
            timerTick     = 1;
            timerInterval = 1000 * 5;
            timer         = new System.Threading.Timer(new TimerCallback(TimerCallBackMethod));
            timer.Change(timerInterval, timerInterval);

            this.appsettings = SharedPreferencesHelper.GetAppSettings(this.context);
            if (!appsettings.ChatDisabled)
            {
                MessengerService.AddOutsidePendingWork();
                chatHubServiceInstance = ChatHubClientService.GetServiceInstance(bearerToken);
            }
            if (!appsettings.NotificationsDisabled)
            {
                SetCheckingNewAdvertisementsAction(context);
                checkingNewAdvertsAction();
            }
            else
            {
                checkingNewAdvertsFinished = true;
            }
        }
Esempio n. 14
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.");
                    }
                }
            }
        }
Esempio n. 15
0
        private void DoWork()
        {
            this.signalRThread = new Thread(() =>
            {
                timeoutInSeconds             = 15;
                timerInterval                = 1000 * 5;
                displayManager               = (DisplayManager)GetSystemService(Context.DisplayService);
                powerManager                 = (PowerManager)GetSystemService(Context.PowerService);
                this.sharedPreferencesHelper = new SharedPreferencesHelper(Application.ApplicationContext);
                this.bearerToken             = (string)this.sharedPreferencesHelper.GetSharedPreference <string>(SharedPreferencesKeys.BEARER_TOKEN);
                this.chatHubClientService    = ChatHubClientService.GetServiceInstance(bearerToken);
                lastConnectionDate           = DateTime.Now;
                this.chatHubClientService.RegisterReceiveMessages(ShowNotification);
                this.chatHubClientService.RegisterNotReceivedMessagesChecked(SetCheckedNotReceivedMessages);


                timer = new Timer(new TimerCallback(TimerCallBackMethod));
                timer.Change(timerInterval, timerInterval);
            }
                                            );
            signalRThread.Start();
        }
Esempio n. 16
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);
        }
 private void SetCheckingNewAdvertisementsAction(Context context)
 {
     checkingNewAdvertsAction = async() =>
     {
         try
         {
             searchModelForNotifications   = new AdvertisementsSearchModelForNotifications();
             this.appsettings              = SharedPreferencesHelper.GetAppSettings(this.context);
             this.advertisementItemService = new AdvertisementItemService(bearerToken);
             this.gpsLocationService       = new GpsLocationService(context.ApplicationContext, null);
             var coordinates = await CheckNewAdvertisementsAroundUserCurrentLocation();
             await CheckNewAdvertisementsAroundUserHomeLocation(coordinates);
         }
         catch
         {
         }
         finally
         {
             checkingNewAdvertsFinished = true;
         }
     };
 }
        private async Task <bool> SignInUser()
        {
            var userIsLogged = false;

            preferenceHelper = new SharedPreferencesHelper(this);
            var bearerToken = (string)preferenceHelper.GetSharedPreference <string>(SharedPreferencesKeys.BEARER_TOKEN);

            if (bearerToken != null)
            {
                userIsLogged = await signInService.SignInUserWithBearerToken(GetTokenModel());
            }
            if (!userIsLogged)
            {
                if (AccessToken.CurrentAccessToken != null && AccessToken.CurrentAccessToken.Token != null)
                {
                    var facebookToken = new FacebookTokenViewModel {
                        FacebookToken = AccessToken.CurrentAccessToken.Token
                    };
                    var tokenModel = await signInService.SignInUserWithFacebookToken(facebookToken);

                    if (tokenModel != null)
                    {
                        preferenceHelper.SetSharedPreference <string>(SharedPreferencesKeys.BEARER_TOKEN, tokenModel.Token);
                        if (tokenModel.UserHasToSetNickName)
                        {
                            throw new UserHasToSetNickNameException();
                        }
                        else
                        {
                            SharedPreferencesHelper.SetUserNameInAppSettings(this, tokenModel.UserName);
                        }
                        userIsLogged = true;
                    }
                }
            }

            return(userIsLogged);
        }
		private async Task<bool> SignInUser()
		{
			var userIsLogged = false;
			var preferenceHelper = new SharedPreferencesHelper(this);
			var bearerToken = (string)preferenceHelper.GetSharedPreference<string>(SharedPreferencesKeys.BEARER_TOKEN);
			if (bearerToken != null)
			{
				userIsLogged = await signInService.SignInUserWithBearerToken(new TokenModel { Token = bearerToken });
			}
			if (!userIsLogged)
			{
				if (AccessToken.CurrentAccessToken != null && AccessToken.CurrentAccessToken.Token != null)
				{
					var facebookToken = new FacebookTokenViewModel { FacebookToken = AccessToken.CurrentAccessToken.Token };
					var tokenModel = await signInService.SignInUserWithFacebookToken(facebookToken);
					if (tokenModel != null)
					{
						preferenceHelper.SetSharedPreference<string>(SharedPreferencesKeys.BEARER_TOKEN, tokenModel.Token);
						userIsLogged = true;
					}
				}
			}

			return userIsLogged;
		}
 public LoginActivity()
 {
     this.signInService    = new SignInService();
     this.preferenceHelper = new SharedPreferencesHelper(this);
 }
 private void SetUserNameInAppSettings(string userName)
 {
     SharedPreferencesHelper.SetUserNameInAppSettings(this, userName);
 }
		public GpsLocationService(Context context, ISettingWindowCloseListener settingWindowListener) {
			this.mContext = context;
			this.settingWindowListener = settingWindowListener;
			this.sharedPreferencesHelper = new SharedPreferencesHelper(context);
			this.location = GetLocation();
		}
		public LoginActivity() {
			this.signInService = new SignInService();
			this.preferenceHelper = new SharedPreferencesHelper(this);
		}
		public AddNewAdvertisementActivity() {
			this.bitmapOperationService = new BitmapOperationService();
			this.advertisementItemService = new AdvertisementItemService();
			this.sharedPreferencesHelper = new SharedPreferencesHelper(this);
		}
 protected override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     this.sharedPreferencesHelper = new SharedPreferencesHelper(this);
     bearerToken = (string)this.sharedPreferencesHelper.GetSharedPreference <string>(SharedPreferencesKeys.BEARER_TOKEN);
 }