示例#1
0
        public void Logout()
        {
            AndroidLoginManager loginManager = AndroidLoginManager.Instance(activity.ApplicationContext);

            loginManager.Logout();
            GoToLoginActivity();
        }
示例#2
0
        public async void OnResume()
        {
            loginManager = AndroidLoginManager.Instance(activity.ApplicationContext);
            if (await loginManager.IsLoggedIn())
            {
                TravelerModel traveler = await new AccountManager().GetTravelerById(loginManager.GetTravelerId());

                if (traveler.InformedConsent == false)
                {
                    loginManager.Logout();
                    activity.StartActivity(typeof(LoginActivity));
                    activity.Finish();
                }
                else
                {
                    LoadTrips();
                    RegisterGCM(activity);
                }
            }
            else
            {
                //Display the login screen
                activity.StartActivity(typeof(LoginActivity));
                activity.Finish();
            }
        }
示例#3
0
        private static async void CancelTrip(Activity activity, TripDetailsPresenter cancelTripListener, Trip trip, AlertDialog dialog)
        {
            int  travelerId = AndroidLoginManager.Instance(activity).GetTravelerId();
            bool success    = await new UserTripDataManager().CancelTripForUser(travelerId, trip);

            dialog.Dismiss();
            cancelTripListener.OnTripCancelComplete(success);
        }
示例#4
0
        public LocationReporterManager(Context context)
        {
            AndroidLoginManager loginManager = AndroidLoginManager.Instance(context);

            this.travelerId = loginManager.GetTravelerId();
            if (LocationReporterManager.locationReporter == null)
            {
                LocationReporterManager.locationReporter = new LocationReporter(context, travelerId);
            }
        }
示例#5
0
        public async void OnResume()
        {
            AndroidLoginManager loginManager = AndroidLoginManager.Instance(activity.ApplicationContext);

            if (!await loginManager.IsLoggedIn())
            {
                //Display the login screen
                activity.StartActivity(typeof(LoginActivity));
            }
        }
示例#6
0
        public async void SearchAndDisplayResults()
        {
            UserTripDataManager dataManager  = new UserTripDataManager();
            AndroidLoginManager loginManager = AndroidLoginManager.Instance(activity.ApplicationContext);
            int         travelerId           = loginManager.GetTravelerId();
            List <Trip> tripsInHistory       = await dataManager.GetPastTrips(travelerId, 100);

            this.view.ShowTrips(tripsInHistory);
            this.view.ShowBusy(false);
        }
示例#7
0
        private TravelerLocation CreateTravelerLocation()
        {
            AndroidLoginManager loginMngr        = AndroidLoginManager.Instance(context);
            TravelerLocation    travelerLocation = new TravelerLocation();

            travelerLocation.Latitude   = location.Latitude;
            travelerLocation.Longitude  = location.Longitude;
            travelerLocation.TimeStamp  = DateTime.Now;
            travelerLocation.UserId     = loginMngr.GetUserId();
            travelerLocation.TravelerId = loginMngr.GetTravelerId();
            return(travelerLocation);
        }
示例#8
0
        public async void OnResume()
        {
            this.view.ShowBusy(true);
            AndroidLoginManager loginManager = AndroidLoginManager.Instance(activity.ApplicationContext);

            if (await loginManager.IsLoggedIn())
            {
                SearchAndDisplayResults();
            }
            else
            {
                //Display the login screen
                activity.StartActivity(typeof(LoginActivity));
            }
        }
示例#9
0
        public async void accpetTerms()
        {
            AndroidLoginManager loginManager = AndroidLoginManager.Instance(activity.ApplicationContext);
            string email = loginManager.GetUsername();

            AccountManager acm      = new AccountManager();
            TravelerModel  traveler = await acm.GetTravelerByEmail(email);

            traveler.InformedConsent     = true;
            traveler.InformedConsentDate = DateTime.UtcNow;
            traveler = await acm.UpdateTraveler(traveler);

            Intent intent = new Intent(activity.ApplicationContext, typeof(HomeActivity));

            activity.StartActivity(intent);
            activity.Finish();
        }
示例#10
0
        private async Task Register(string username, string password, string password_verify, string firstname, string lastname)
        {
            AndroidLoginManager loginManager = AndroidLoginManager.Instance(activity.ApplicationContext);
            //LoginResult loginResult = await loginManager.Register (username, password, firstname, lastname);
            LoginResult loginResult = await new RegistrationApplicant(username, password, password_verify, firstname, lastname).Register(loginManager);

            activity.sendGaEvent("ui_action", "register user", "register result", Convert.ToInt16(loginResult.Success));

            if (loginResult.Success)
            {
                LoginAndGoHome(username, password);
            }
            else
            {
                view.OnRegistrationError(loginResult.ErrorString);
            }
        }
示例#11
0
        protected override async void OnRegistered(Context context, string registrationId)
        {
            Log.Info("IDTO", "GCM Registered: " + registrationId);
            RegistrationID = registrationId;
            Hub            = new NotificationHub(Constants.NotificationHubPath, Constants.ConnectionString);
            try {
                await Hub.UnregisterAllAsync(registrationId);
            }
            catch (Exception ex) {
                Console.WriteLine(ex);
            }


            AndroidLoginManager loginMngr = AndroidLoginManager.Instance(context);

            if (!await loginMngr.IsLoggedIn())
            {
                Log.Info("IDTO", "HandleRegistration Error: Not logged in");
                return;
            }
            int           travelerID = loginMngr.GetTravelerId();
            TravelerModel traveler   = await new AccountManager().GetTravelerById(travelerID);
            string        email      = "";

            if (traveler != null)
            {
                email = traveler.Email;
            }
            var tags = new List <string> ()
            {
                email,
                travelerID.ToString()
            };

            try {
                NativeRegistration = await Hub.RegisterNativeAsync(registrationId, tags);

                ISharedPreferencesEditor editor = GetPreferences(context).Edit();
                editor.PutBoolean(KEY_REGISTERED, true);
            }
            catch (Exception ex) {
                Console.WriteLine(ex);
            }
        }
示例#12
0
        public async void OnAttemptLogin(string email, string password)
        {
            try{
                if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
                {
                    view.OnLoginError("You must enter a username and password");
                }
                else
                {
                    AndroidLoginManager loginManager = AndroidLoginManager.Instance(activity.ApplicationContext);
                    LoginResult         loginResult  = await loginManager.Login(email, password);

                    view.ShowBusy(false);

                    activity.sendGaEvent("ui_action", "user login", "login result", Convert.ToInt16(loginResult.Success));
                    if (loginResult.Success)
                    {
                        AccountManager acm      = new AccountManager();
                        TravelerModel  traveler = await acm.GetTravelerByEmail(email);

                        if (traveler.InformedConsent)
                        {
                            Intent intent = new Intent(activity.ApplicationContext, typeof(HomeActivity));
                            activity.StartActivity(intent);
                            activity.Finish();
                        }
                        else
                        {
                            view.showTerms();
                        }
                    }
                    else
                    {
                        view.OnLoginError(loginResult.ErrorString);
                    }
                }
            }catch (Exception e) {
                Console.WriteLine(e);
                view.OnLoginError("Login failed");
            }
        }
示例#13
0
        public async void OnResume()
        {
            view.ShowBusy(true);
            AndroidLoginManager loginManager = AndroidLoginManager.Instance(activity.ApplicationContext);

            if (!await loginManager.IsLoggedIn())
            {
                GoToLoginActivity();
            }
            else
            {
                username = loginManager.GetUsername();
                view.ShowUserInfo(username);

                AccountManager acm      = new AccountManager();
                TravelerModel  traveler = await acm.GetTravelerByEmail(username);

                view.ShowPromoCode(traveler.PromoCode);
            }
            view.ShowBusy(false);
        }
示例#14
0
        private async void LoginAndGoHome(string username, string password)
        {
            AndroidLoginManager loginManager = AndroidLoginManager.Instance(activity.ApplicationContext);

            if (await loginManager.IsLoggedIn())
            {
                GoToHome();
            }
            else
            {
                LoginResult lr = await loginManager.Login(username, password);

                if (lr.Success)
                {
                    GoToHome();
                }
                else
                {
                    GoToLogin();
                }
            }
        }
示例#15
0
        public async void Save()
        {
            try{
                if (isTripValid)
                {
                    int    travelerId         = AndroidLoginManager.Instance(activity).GetTravelerId();
                    string prioritycode       = "1";
                    bool   isWheelchariNeeded = false;
                    bool   isBikeRackNeeded   = false;
                    bool   success            = await new UserTripDataManager().SaveTripForUser(travelerId, itinerary,
                                                                                                startLocation, endLocation, prioritycode, isWheelchariNeeded, isBikeRackNeeded);


                    OnTripSaveComplete(success);
                }
                else
                {
                    OnTripSaveComplete(false);
                }
            }catch (Exception e) {
                Console.WriteLine(e);
                OnTripSaveComplete(false);
            }
        }
示例#16
0
        public void rejectTerms()
        {
            AndroidLoginManager loginManager = AndroidLoginManager.Instance(activity.ApplicationContext);

            loginManager.Logout();
        }