public void Logout() { AndroidLoginManager loginManager = AndroidLoginManager.Instance(activity.ApplicationContext); loginManager.Logout(); GoToLoginActivity(); }
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(); } }
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); }
public LocationReporterManager(Context context) { AndroidLoginManager loginManager = AndroidLoginManager.Instance(context); this.travelerId = loginManager.GetTravelerId(); if (LocationReporterManager.locationReporter == null) { LocationReporterManager.locationReporter = new LocationReporter(context, travelerId); } }
public async void OnResume() { AndroidLoginManager loginManager = AndroidLoginManager.Instance(activity.ApplicationContext); if (!await loginManager.IsLoggedIn()) { //Display the login screen activity.StartActivity(typeof(LoginActivity)); } }
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); }
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); }
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)); } }
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(); }
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); } }
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); } }
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"); } }
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); }
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(); } } }
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); } }
public void rejectTerms() { AndroidLoginManager loginManager = AndroidLoginManager.Instance(activity.ApplicationContext); loginManager.Logout(); }