protected override void OnResume() { if (App.Locator.DetailSeekios.IsSeekiosDeleted) { App.Locator.DetailSeekios.IsSeekiosDeleted = false; Finish(); } _seekiosSelected = App.Locator.DetailSeekios.SeekiosSelected; base.OnResume(); SetDataToView(); DisplayLastAlertSOS(); if (App.Locator.DetailSeekios.ActivityNeedsUIToBeUpdated) { SetDataToView(); App.Locator.DetailSeekios.ActivityNeedsUIToBeUpdated = false; } App.RemainingRequestChanged += OnRemainingRequestChanged; App.SeekiosChanged += App_SeekiosChanged; OnConnectionStateChanged += UpdateUIOnConnectionStateChanged; MapLinearLayout.Click += OnMapLayoutClick; ModeLinearLayout.Click += OnModeLayoutClick; BatteryRefreshButton.Click += OnBatteryRefreshButtonClick; SOSLinearLayout.Click += OnAlertSOSLayoutClick; ParameterLinearLayout.Click += OnParameterLayoutClick; SeekiosInformationLayout.Click += OnMapLayoutClick; FirmwareUpdateSvgImageView.Click += FirmwareUpdateImageView_Click; CreditLayout.Click += CreditLayout_Click; }
private void ScrollToEndToShowLastitemMenu(SeekiosDTO item) { if (item != App.Locator.ListSeekios.LsSeekios.LastOrDefault()) { return; } SeekiosListView.SetSelection(SeekiosListView.Count - 1); }
/// <summary> /// Navigate to Map /// </summary> public void GoToMap(SeekiosDTO seekios) { MapViewModelBase.Seekios = seekios; if (_navigationService != null && _navigationService.CurrentPageKey != App.MAP_PAGE) { _navigationService.NavigateTo(App.MAP_PAGE); } }
private void SetData() { _user = new UserDTO() { IdUser = _IdUser }; _seekios = new SeekiosDTO() { Idseekios = _idseekios, SeekiosName = "TestSeekios", SeekiosPicture = null, SeekiosDateCreation = DateTime.Now, BatteryLife = 20, SignalQuality = 99, DateLastCommunication = DateTime.Now, LastKnownLocation_longitude = 0.0, LastKnownLocation_latitude = 0.0, LastKnownLocation_altitude = 0.0, LastKnownLocation_accuracy = 0.0, LastKnownLocation_dateLocationCreation = DateTime.Now, Subscription_idsubscription = 2, Category_idcategory = 1, User_iduser = _iduser, HasGetLastInstruction = false, IsAlertLowBattery = true, IsInPowerSaving = false, PowerSaving_hourStart = 0, PowerSaving_hourEnd = 0, AlertSOS_idalert = null, IsRefreshingBattery = false, FreeCredit = 100 }; _UserEnvironmentDTO = new UserEnvironmentDTO() { LsSeekios = new List <SeekiosDTO>() , LsMode = new List <ModeDTO>() , LsAlert = new List <AlertDTO>() , LsAlertFavorites = new List <AlertFavoriteDTO>() , LsAlertRecipient = new List <AlertRecipientDTO>() , LsFavoriteArea = new List <FavoriteAreaDTO>() , LsFriend = new List <FriendUserDTO>() , LsSharing = new List <SharingDTO>() , LsLocations = new List <LocationDTO>() , LsModeDefinition = new List <ModeDefinitionDTO>() }; App.CurrentUserEnvironment = _UserEnvironmentDTO; App.CurrentUserEnvironment.User = _user; }
/// <summary> /// On iOS 10.3.3 a local notification does not exist like Android, we need to show a simple popup /// </summary> public async void SendNotification(SeekiosDTO seekios, string title, string message, bool isAlert = false, bool isLowBattery = false) { var dialogService = SimpleIoc.Default.GetInstance <IDialogService>(); if (dialogService == null) { throw new Exception("SendNotification: dialogService can not be null"); } await dialogService.ShowMessage(message, title); }
/// <summary> /// Initialise les objets de la vue /// </summary> private void GetObjectsFromView() { ToolbarPage = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); LoadingLayout = FindViewById <RelativeLayout>(Resource.Id.loadingPanel); SeekiosInformationLayout = FindViewById <RelativeLayout>(Resource.Id.detailSeekios_seekiosLayout); SeekiosNameTextView = FindViewById <TextView>(Resource.Id.detailSeekios_seekiosName); ButtonRightLayout = FindViewById <RelativeLayout>(Resource.Id.myseekios_ButtonsRight); SeekiosRoundedImageView = FindViewById <RoundedImageView>(Resource.Id.detailSeekios_seekiosImage); PowerSavingImageView = FindViewById <ImageView>(Resource.Id.detailSeekios_powerSavingImage); FirmwareUpdateSvgImageView = FindViewById <XamSvg.SvgImageView>(Resource.Id.detailSeekios_firmwareUpdate); LastLocationTextView = FindViewById <TextView>(Resource.Id.detailSeekios_lastPosition); ModeSvgImageView = FindViewById <SvgImageView>(Resource.Id.detailSeekios_modeImage); ModeTitleTextView = FindViewById <TextView>(Resource.Id.detailSeekios_modeImageText); ModeLayout = FindViewById <LinearLayout>(Resource.Id.detailSeekios_modeSeekiosLayout); AlertTextView = FindViewById <TextView>(Resource.Id.detailSeekios_alertImageText); AlertSvgImageView = FindViewById <SvgImageView>(Resource.Id.detailSeekios_alertImage); AlertSeekiosLayout = FindViewById <LinearLayout>(Resource.Id.detailSeekios_alertLayout); BatterySvgImageView = FindViewById <SvgImageView>(Resource.Id.detailSeekios_batteryPicture); BatteryTextView = FindViewById <TextView>(Resource.Id.detailSeekios_batteryText); BatteryRefreshButton = FindViewById <TextView>(Resource.Id.detailSeekios_refreshButton); BatteryLoaderLayout = FindViewById <LinearLayout>(Resource.Id.detailSeekios_loaderLayoutBattery); //MonthlyCreditNumberTextView = FindViewById<TextView>(Resource.Id.detailSeekios_creditFreeNumber); //MonthlyCreditInfoTextView = FindViewById<TextView>(Resource.Id.detailSeekios_creditFreeText); //GeneralCreditNumberTextView = FindViewById<TextView>(Resource.Id.detailSeekios_creditGeneralNumber); //MonthlyCreditLayout = FindViewById<LinearLayout>(Resource.Id.detailSeekios_creditFreeLayout); //GeneralCreditLayout = FindViewById<LinearLayout>(Resource.Id.detailSeekios_creditGeneralLayout); MapLinearLayout = FindViewById <LinearLayout>(Resource.Id.detailSeekios_mapLayout); ModeLinearLayout = FindViewById <LinearLayout>(Resource.Id.detailSeekios_modeLayout); //ShareLinearLayout = FindViewById<LinearLayout>(Resource.Id.detailSeekios_shareLayout); SOSLinearLayout = FindViewById <LinearLayout>(Resource.Id.detailSeekios_sosLayout); ParameterLinearLayout = FindViewById <LinearLayout>(Resource.Id.detailSeekios_parameterLayout); ModeLayoutSvgImageView = FindViewById <SvgImageView>(Resource.Id.detailSeekios_modePicture); ModeLayoutTextView = FindViewById <TextView>(Resource.Id.detailSeekios_modeText); //ShareLayoutSvgImageView = FindViewById<SvgImageView>(Resource.Id.detailSeekios_sharePicture); //Disable color button //ShareLayoutSvgImageView.SetSvg(this, Resource.Drawable.Share2, "ffffff=999999"); ShareLayoutTextView = FindViewById <TextView>(Resource.Id.detailSeekios_shareText); ParameterLayoutSvgImageView = FindViewById <SvgImageView>(Resource.Id.detailSeekios_parameterPicture); ParameterLayoutTextView = FindViewById <TextView>(Resource.Id.detailSeekios_parameterText); //DeleteSeekiosButton = FindViewById<TextView>(Resource.Id.detailSeekios_deleteSeekiosButton); ModeInformationLayout = FindViewById <LinearLayout>(Resource.Id.detailSeekios_informationModeLayout); ModeInformationSvgImageView = FindViewById <SvgImageView>(Resource.Id.detailSeekios_informationModePicture); ModeInformationTextView = FindViewById <TextView>(Resource.Id.detailSeekios_informationModeText); AlertInformationTextView = FindViewById <TextView>(Resource.Id.detailSeekios_informationAlertText); TrackingInformationTextView = FindViewById <TextView>(Resource.Id.detailSeekios_informationTrackingText); ShareInformationLayout = FindViewById <LinearLayout>(Resource.Id.detailSeekios_informationShareLayout); ShareInformationTextView = FindViewById <TextView>(Resource.Id.detailSeekios_informationShareText); _seekiosSelected = App.Locator.DetailSeekios.SeekiosSelected; }
/// <summary> /// Navigate to Seekios parameters /// </summary> public void GoToParameter(SeekiosDTO seekios) { App.Locator.AddSeekios.UpdatingSeekios = seekios; App.Locator.AddSeekios.SeekiosIMEI = seekios.Imei; App.Locator.AddSeekios.SeekiosName = seekios.SeekiosName; if (seekios.SeekiosPicture != null) { App.Locator.AddSeekios.SeekiosImage = Convert.FromBase64String(seekios.SeekiosPicture); } App.Locator.AddSeekios.IsAdding = false; _navigationService.NavigateTo(App.ADD_SEEKIOS_PAGE); }
/// <summary> /// Add a seekios to the list OnDemand /// Start the count down /// </summary> public void AddSeekiosOnTracking(SeekiosDTO seekios, ModeDTO mode) { // if a seekios on tracking is already present (protection against double entry) var seekiosOnTrackingAlreadyCreated = App.Locator.Map.LsSeekiosOnTracking.FirstOrDefault(x => x.Seekios.Idseekios == seekios.Idseekios); if (seekiosOnTrackingAlreadyCreated != null) { if (seekiosOnTrackingAlreadyCreated.Timer != null && seekiosOnTrackingAlreadyCreated.Timer.IsRunning) { seekiosOnTrackingAlreadyCreated.Timer.Stop(); } App.Locator.Map.LsSeekiosOnTracking.RemoveAll(x => x.Seekios.Idseekios == seekios.Idseekios); } // setup the seekios on demand var seekiosOnTracking = new SeekiosOnTracking() { Seekios = seekios, Mode = mode }; // get the refresh time var refreshTime = 0; var param = mode.Trame.Split(';'); if (mode.ModeDefinition_idmodeDefinition == (int)ModeDefinitionEnum.ModeZone) { if (param?.Count() > 1) { if (int.TryParse(param[1], out refreshTime)) { seekiosOnTracking.RefreshTime = refreshTime; } } } else { if (param?.Count() > 1) { if (int.TryParse(param[1], out refreshTime)) { seekiosOnTracking.RefreshTime = refreshTime; } } } seekiosOnTracking.Timer = new Timers.Timer(); seekiosOnTracking.Timer.Interval = new TimeSpan(0, 0, 1); // add the seekios in the list that contains all the seekios in refreshing state (OnDemand) App.Locator.Map.LsSeekiosOnTracking.Add(seekiosOnTracking); }
public override void SetDataAndStyleToView() { InitialiseAllStrings(); _seekiosSelected = App.Locator.DetailSeekios.SeekiosSelected; AddAlertButton.Layer.MasksToBounds = true; AddAlertButton.Layer.CornerRadius = 4; PreviousButton.Layer.MasksToBounds = true; PreviousButton.Layer.CornerRadius = 4; NextButton.Layer.MasksToBounds = true; NextButton.Layer.CornerRadius = 4; }
/// <summary> /// Add a seekios /// </summary> private async Task <bool> InsertSeekios(string seekiosName, string imei, string pin, byte[] seekiosPicture) { try { _dialogService.ShowLoadingLayout(); var seekiosToAdd = new SeekiosDTO(); seekiosToAdd.Imei = imei; seekiosToAdd.SeekiosName = seekiosName.ToUpperCaseFirst(); seekiosToAdd.PinCode = pin; seekiosToAdd.SeekiosPicture = seekiosPicture == null ? null : Convert.ToBase64String(seekiosPicture); // Add seekios in the database seekiosToAdd = await _dataService.InsertSeekios(seekiosToAdd); if (seekiosToAdd == null || seekiosToAdd.Idseekios <= 0) { _dialogService.HideLoadingLayout(); return(false); } // Add seekios in local data App.CurrentUserEnvironment.LsSeekios.Add(seekiosToAdd); _dialogService.HideLoadingLayout(); return(true); } catch (TimeoutException) { await _dialogService.ShowError( Resources.TimeoutError , Resources.TimeoutErrorTitle , Resources.Close, null); } catch (WebException) { await _dialogService.ShowError( Resources.TimeoutError , Resources.TimeoutErrorTitle , Resources.Close, null); } catch (Exception) { await _dialogService.ShowError( Resources.UnexpectedError , Resources.UnexpectedErrorTitle , Resources.Close, null); } _dialogService.HideLoadingLayout(); return(false); }
private void GetObjectsFromView() { ToolbarPage = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); LoadingLayout = FindViewById <RelativeLayout>(Resource.Id.loadingPanel); SeekiosInformationLayout = FindViewById <RelativeLayout>(Resource.Id.detailSeekios_seekiosLayout); SeekiosNameTextView = FindViewById <TextView>(Resource.Id.detailSeekios_seekiosName); ButtonRightLayout = FindViewById <RelativeLayout>(Resource.Id.myseekios_ButtonsRight); SeekiosRoundedImageView = FindViewById <RoundedImageView>(Resource.Id.detailSeekios_seekiosImage); PowerSavingImageView = FindViewById <SvgImageView>(Resource.Id.detailSeekios_powerSavingImage); FirmwareUpdateSvgImageView = FindViewById <SvgImageView>(Resource.Id.detailSeekios_firmwareUpdate); LastLocationTextView = FindViewById <TextView>(Resource.Id.detailSeekios_lastPosition); ModeSvgImageView = FindViewById <SvgImageView>(Resource.Id.detailSeekios_modeImage); ModeTitleTextView = FindViewById <TextView>(Resource.Id.detailSeekios_modeImageText); ModeLayout = FindViewById <LinearLayout>(Resource.Id.detailSeekios_modeSeekiosLayout); AlertTextView = FindViewById <TextView>(Resource.Id.detailSeekios_alertImageText); AlertSvgImageView = FindViewById <SvgImageView>(Resource.Id.detailSeekios_alertImage); AlertSeekiosLayout = FindViewById <LinearLayout>(Resource.Id.detailSeekios_alertLayout); BatterySvgImageView = FindViewById <SvgImageView>(Resource.Id.detailSeekios_batteryPicture); BatteryTextView = FindViewById <TextView>(Resource.Id.detailSeekios_batteryText); BatteryRefreshButton = FindViewById <TextView>(Resource.Id.detailSeekios_refreshButton); BatteryLoaderProgressBar = FindViewById <ProgressBar>(Resource.Id.detailSeekios_loaderBattery); CreditsTextView = FindViewById <TextView>(Resource.Id.detailSeekios_credits); FreeCreditTextView = FindViewById <TextView>(Resource.Id.detailSeekios_freeCredits); FreeCreditReloadDateTextView = FindViewById <TextView>(Resource.Id.detailSeekios_freeCreditsReloadDate); CreditLayout = FindViewById <LinearLayout>(Resource.Id.detailSeekios_creditLayout); MapLinearLayout = FindViewById <LinearLayout>(Resource.Id.detailSeekios_mapLayout); ModeLinearLayout = FindViewById <LinearLayout>(Resource.Id.detailSeekios_modeLayout); SOSLinearLayout = FindViewById <LinearLayout>(Resource.Id.detailSeekios_sosLayout); ParameterLinearLayout = FindViewById <LinearLayout>(Resource.Id.detailSeekios_parameterLayout); ModeLayoutSvgImageView = FindViewById <SvgImageView>(Resource.Id.detailSeekios_modePicture); ModeLayoutTextView = FindViewById <TextView>(Resource.Id.detailSeekios_modeText); ParameterLayoutSvgImageView = FindViewById <SvgImageView>(Resource.Id.detailSeekios_parameterPicture); ParameterLayoutTextView = FindViewById <TextView>(Resource.Id.detailSeekios_parameterText); ModeInformationLayout = FindViewById <LinearLayout>(Resource.Id.detailSeekios_informationModeLayout); ModeInformationSvgImageView = FindViewById <SvgImageView>(Resource.Id.detailSeekios_informationModePicture); ModeInformationTextView = FindViewById <TextView>(Resource.Id.detailSeekios_informationModeText); AlertInformationTextView = FindViewById <TextView>(Resource.Id.detailSeekios_informationAlertText); TrackingInformationTextView = FindViewById <TextView>(Resource.Id.detailSeekios_informationTrackingText); _seekiosSelected = App.Locator.DetailSeekios.SeekiosSelected; }
public override void SetDataAndStyleToView() { InitialiseAllStrings(); _seekiosSelected = App.Locator.DetailSeekios.SeekiosSelected; if (_seekiosSelected.VersionEmbedded_idversionEmbedded < (int)VersionEmbeddedEnum.V1007) { TitlePowerSavingButton.Hidden = true; PowerSavingNextImage.Hidden = true; PowerSavingImage.Hidden = true; DescriptionPowerSavingLabel.Hidden = true; ActivatePowerSavingLabel.Hidden = true; PowerSavingSwitch.Hidden = true; } // set up the data App.Locator.ModeZone.WaitingForAlerts = false; // set up the ui component ActivateButton.Layer.MasksToBounds = true; ActivateButton.Layer.CornerRadius = 4; }
public override void ViewWillAppear(bool animated) { if (App.Locator.AddSeekios.IsGoingBack) { App.Locator.AddSeekios.IsGoingBack = false; GoBack(false); return; } Title = Application.LocalizedString("DetailSeekiosTitle"); _seekiosSelected = App.CurrentUserEnvironment.LsSeekios.FirstOrDefault(f => f.UIdSeekios == App.Locator.DetailSeekios.SeekiosSelected.UIdSeekios); if (_seekiosSelected.LastKnownLocation_latitude == App.DefaultLatitude && _seekiosSelected.LastKnownLocation_longitude == App.DefaultLongitude) { _firstInitialise = true; } else { _firstInitialise = false; } base.ViewWillAppear(animated); }
private void ListSeekiosView_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (ListSeekiosView.SelectedItem == null) { return; } // Get the current seekios MapViewModelBase.Seekios = ListSeekiosView.SelectedItem as SeekiosDTO; // usefull fot the viewmodel SeekiosApp.App.Locator.DetailSeekios.SeekiosSelected = ListSeekiosView.SelectedItem as SeekiosDTO; // usefull fot the viewmodel _selectedSeekios = ListSeekiosView.SelectedItem as SeekiosDTO; // usefull for the view logic // Is the seekios a new one ? (without position) InitializeFirstLocation(); // Setup the battery InitializeBattery(); // Setup the map InitializeMap(); }
private void SetDataToView() { // If no position yet, we block mode configurations if (_seekiosSelected == null) { _seekiosSelected = App.Locator.DetailSeekios.SeekiosSelected; } if (_seekiosSelected.LastKnownLocation_latitude == App.DefaultLatitude && _seekiosSelected.LastKnownLocation_longitude == App.DefaultLongitude) { ModeLinearLayout.Enabled = false; ModeLayoutSvgImageView.SetSvg(this, Resource.Drawable.SelectMode, "62da73=999999"); } else { ModeLinearLayout.Enabled = true; ModeLayoutSvgImageView.SetSvg(this, Resource.Drawable.SelectMode, "999999=62da73"); } var _seekiosOnDemand = App.Locator.Map.LsSeekiosOnDemand.FirstOrDefault(x => x.Seekios.Idseekios == _seekiosSelected.Idseekios); if (_seekiosOnDemand != null) { _seekiosOnDemand.OnSuccess = null; _seekiosOnDemand.OnSuccess += () => { InitialiseSeekiosInformation(); }; } InitialiseSeekiosInformation(); InitialiseBatteryInformation(); //InitialiseInformationLayout(); RefreshDisplayedCreditCount(); ModeInformationLayout.Visibility = ViewStates.Gone; FreeCreditReloadDateTextView.Text = string.Format(Resources.GetString(Resource.String.detailSeekios_freeCreditsReloadDate) , CreditHelper.CalculateNextReload()); }
private void DisplayLastAlertSOS() { if (App.Locator.DetailSeekios.AlertNeedsToBeRead()) { var popup = AlertControllerHelper.CreateAlertToInformAlertSOS(async() => { if (await App.Locator.DetailSeekios.NotifyAlertSOSHasBeenRead(_seekiosSelected.Idseekios) <= 0) { await AlertControllerHelper.ShowAlert(string.Empty , Application.LocalizedString("AlertCannotBeSavedAsRead") , Application.LocalizedString("Close")); } else { _seekiosSelected = App.CurrentUserEnvironment.LsSeekios.FirstOrDefault(f => f.UIdSeekios == App.Locator.DetailSeekios.SeekiosSelected.UIdSeekios); SetDataAndStyleToView(); UpdateBatteryView(); } }); PresentViewController(popup, true, () => { popup.Dispose(); }); } }
private void App_SeekiosChanged(object sender, int e) { InvokeOnMainThread(() => { _seekiosSelected = App.CurrentUserEnvironment.LsSeekios.FirstOrDefault(f => f.UIdSeekios == App.Locator.DetailSeekios.SeekiosSelected.UIdSeekios); if (_seekiosSelected.LastKnownLocation_latitude == App.DefaultLatitude && _seekiosSelected.LastKnownLocation_longitude == App.DefaultLongitude) { _firstInitialise = true; } else { _firstInitialise = false; } if (_firstInitialise) { _firstInitialise = false; Tableview.Source = new DetailSeekiosSource(this, _seekiosSelected); Tableview.ReloadData(); if (_seekiosSelected.LastKnownLocation_dateLocationCreation.HasValue && _seekiosSelected.LastKnownLocation_dateLocationCreation.Value.Year != 1) { SeekiosLastPositionLabel.Text = _seekiosSelected.LastKnownLocation_dateLocationCreation.Value.FormatDateFromNow(); } else { Tableview.ScrollToRow(NSIndexPath.FromRowSection(0, 0) , UITableViewScrollPosition.Top, false); SeekiosLastPositionLabel.Text = Application.LocalizedString("NoPosition"); } } SetDataAndStyleToView(); UpdateBatteryView(); }); }
/// <summary> /// Add a seekios to the list OnDemand /// Start the count down /// </summary> public void AddSeekiosOnDemand(SeekiosDTO seekios, DateTime dateEndRefreshTimer) { // setup the seekios on demand var seekiosOnDemand = new SeekiosOnDemand() { Seekios = seekios, DateEndRefreshTimer = dateEndRefreshTimer }; // setup the timer var timer = new Timers.Timer(); timer.Interval = new TimeSpan(0, 0, 1); timer.CountDown = (dateEndRefreshTimer - DateTime.Now).TotalSeconds; timer.Tick = async() => { if (timer.CountDown <= 0) { timer.Stop(); seekiosOnDemand.OnFailed?.Invoke(); App.Locator.Map.LsSeekiosOnDemand.Remove(seekiosOnDemand); var dialogService = GalaSoft.MvvmLight.Ioc.SimpleIoc.Default.GetInstance <Interfaces.IDialogService>(); await dialogService.ShowMessage(string.Format(Resources.OnDemandMessageFailedBody , seekios.SeekiosName) , Resources.OnDemandMessageFailedTitle); } else { timer.UpdateUI?.Invoke(); timer.CountDown--; } }; seekiosOnDemand.Timer = timer; // add the seekios in the list that contains all the seekios in refreshing state (OnDemand) App.Locator.Map.LsSeekiosOnDemand.Add(seekiosOnDemand); // start the timer timer.Start(); }
public override void ViewDidUnload() { base.ViewDidUnload(); App.SeekiosChanged -= App_SeekiosChanged; App.RemainingRequestChanged -= OnRemainingRequestChanged; App.Locator.ModeDontMove.SeekiosMovedNotified -= ModeDontMove_SeekiosMovedNotified; App.Locator.ModeZone.OnSeekiosOutOfZoneNotified -= ModeZone_OnSeekiosOutOfZoneNotified; RefreshBatteryButton.TouchUpInside -= RefreshBatteryButton_TouchUpInside; HelpCreditCostButton.TouchDown -= HelpCreditCostButton_TouchDown; NeedUpdateButton.TouchDown -= NeedUpdateButton_TouchDown; SeekiosImageView.Dispose(); CreditsTitleLabel.Dispose(); NextRefillLabel.Dispose(); LastRefreshBatteryLabel.Dispose(); RefreshBatteryButton.Dispose(); BatteryLabel.Dispose(); BatteryIndicator.Dispose(); RefreshBatteryButton.Dispose(); //Tableview.Dispose(); _seekiosSelected = null; }
public void AddSeekiosInDontMove(SeekiosDTO seekios) { }
// string[] itemName = new string[] { "Carte", "Recharge credits", "Mode Zone", "Mode Dont Move", "Mode Tracking", "Parametres" }; // string[] itemDetail = new string[] { "Vous pouvez rafraichir la position du seekios", " ", "Vous etes alerte si le seekios sort de la zone", "Vous etes alerte si le seekios bouge", "suivre le chemin du seekios", " " }; // string[] itemImage = new string[] { "MapDetail", "CreditUser", "ModeZone", "ModeDontMove", "ModeTracking", "SeekiosParameter" }; #endregion #region ===== Constructor ================================================================= public DetailSeekiosSource(DetailSeekiosView _controller, SeekiosDTO _seekiosSelected) { this._controller = _controller; this._seekiosSelected = _seekiosSelected; }
/// <summary> /// Handle the notifications from OneSignal that have data passed in order to update the UI /// </summary> private void HandleNotificationData(JSONObject data) { string uidSeekios = string.Empty; string methodName = string.Empty; Tuple <int, int> batteryAndSignal = null; Tuple <double, double, double, double> location = null; DateTime date = DateTime.Now; int userCreditDebitAmount = 0; int seekiosCreditDebitAmount = 0; int idAlert = 0; int idMode = 0; if (!data.IsNull("uidSeekios")) { uidSeekios = data.Get("uidSeekios").ToString(); } string seekiosName = string.Empty; if (null != uidSeekios && !string.Empty.Equals(uidSeekios)) { var seekios = App.CurrentUserEnvironment.LsSeekios.FirstOrDefault(el => el.UIdSeekios == uidSeekios); if (seekios != null) { seekiosName = seekios.SeekiosName; } } if (!data.IsNull("batterySignal")) { batteryAndSignal = JsonConvert.DeserializeObject <Tuple <int, int> >(data.Get("batterySignal").ToString()); } if (!data.IsNull("location")) { location = JsonConvert.DeserializeObject <Tuple <double, double, double, double> >(data.Get("location").ToString()); } if (!data.IsNull("date")) { date = DateExtension.FormatJsonDateToDateTime(data.Get("date").ToString()); } if (!data.IsNull("userCreditDebitAmount")) { userCreditDebitAmount = JsonConvert.DeserializeObject <int>(data.Get("userCreditDebitAmount").ToString()); } if (!data.IsNull("seekiosCreditDebitAmount")) { seekiosCreditDebitAmount = JsonConvert.DeserializeObject <int>(data.Get("seekiosCreditDebitAmount").ToString()); } if (!data.IsNull("methodName")) { methodName = data.Get("methodName").ToString(); } if (!data.IsNull("idAlert")) { idAlert = JsonConvert.DeserializeObject <int>(data.Get("idAlert").ToString()); } if (!data.IsNull("idMode")) { idMode = JsonConvert.DeserializeObject <int>(data.Get("idMode").ToString()); } if (!string.IsNullOrEmpty(methodName)) { SeekiosDTO seekios = App.CurrentUserEnvironment.LsSeekios.FirstOrDefault(el => el.UIdSeekios == uidSeekios); switch (methodName) { case "RefreshCredits": App.Locator.ListSeekios.OnHasToRefreshCredits(uidSeekios, userCreditDebitAmount, seekiosCreditDebitAmount, date); break; case "RefreshPosition": if (batteryAndSignal != null && location != null) { App.Locator.BaseMap.OnDemandPositionReceived(uidSeekios, batteryAndSignal, location, date); } break; case "InstructionTaken": if (batteryAndSignal != null) { App.Locator.ListSeekios.SeekiosInstructionTaken(uidSeekios, batteryAndSignal, date); } break; case "NotifySeekiosOutOfZone": if (batteryAndSignal != null && location != null) { App.Locator.ModeZone.OnNotifySeekiosOutOfZone(uidSeekios, batteryAndSignal, location, date); } break; case "AddTrackingLocation": if (batteryAndSignal != null && location != null) { App.Locator.ModeTracking.OnAddTrackingLocation(uidSeekios, batteryAndSignal, location, date); } break; case "AddNewZoneTrackingLocation": if (batteryAndSignal != null && location != null) { App.Locator.ModeZone.OnNewZoneTrackingLocationAdded(uidSeekios, batteryAndSignal, location, date); } break; case "AddNewDontMoveTrackingLocation": if (batteryAndSignal != null && location != null) { App.Locator.ModeDontMove.OnNewDontMoveTrackingLocationAdded(uidSeekios, batteryAndSignal, location, date); } break; case "NotifySeekiosMoved": if (batteryAndSignal != null) { App.Locator.ModeDontMove.OnNotifySeekiosMoved(uidSeekios, batteryAndSignal, date); } break; case "SOSSent": if (seekios != null) { App.Locator.ListSeekios.OnSOSSentReceived(uidSeekios, batteryAndSignal, date); } break; case "SOSLocationSent": if (batteryAndSignal != null && location != null) { App.Locator.BaseMap.NotifySOSLocationReceived(uidSeekios, batteryAndSignal, location, date); } break; case "CriticalBattery": if (seekios != null) { App.Locator.ListSeekios.OnCriticalBatteryReceived(uidSeekios, batteryAndSignal, date); } break; case "PowerSavingDisabled": if (seekios != null) { App.Locator.ListSeekios.OnPowerSavingDisabledReceived(uidSeekios, batteryAndSignal, date); } break; } } }
private void SetData() { _user = new UserDTO() { DateLastConnection = DateTime.Now, DateLocation = DateTime.Now, DefaultTheme = 0, Email = "*****@*****.**", FirstName = "TestFirstName", GCMRegistrationToken = "noToken", IsValidate = true, LastName = "TestLastName", LocationLatitude = 0, LocationLongitude = 0, NumberView = 1, Password = "******", PhoneNumber = "33|64564866", RemainingRequest = 1000, SocialNetworkType = 0, SocialNetworkUserId = null, UserPicture = null }; DataService.Email = _user.Email; DataService.Pass = _user.Password; _seekios = new SeekiosDTO() { Idseekios = _idseekios, SeekiosName = "UnitTestSeekios", SeekiosPicture = null, SeekiosDateCreation = DateTime.Now, BatteryLife = 99, SignalQuality = 50, DateLastCommunication = DateTime.Now, LastKnownLocation_longitude = 0.0, LastKnownLocation_latitude = 0.0, LastKnownLocation_altitude = 0.0, LastKnownLocation_accuracy = 0.0, LastKnownLocation_dateLocationCreation = DateTime.Now, Subscription_idsubscription = 2, Category_idcategory = 1, User_iduser = _iduser, HasGetLastInstruction = true, IsAlertLowBattery = true, IsInPowerSaving = false, PowerSaving_hourStart = 0, PowerSaving_hourEnd = 0, AlertSOS_idalert = null, IsRefreshingBattery = false, FreeCredit = 100000000 }; _mode = new ModeDTO() { DateModeCreation = DateTime.Now, Trame = "1", NotificationPush = 0, CountOfTriggeredAlert = 0, LastTriggeredAlertDate = DateTime.Now, Seekios_idseekios = _idseekios, ModeDefinition_idmodeDefinition = (int)SeekiosApp.Enum.ModeDefinitionEnum.ModeTracking, StatusDefinition_idstatusDefinition = 1 }; alertes.Add(new AlertWithRecipientDTO() { IdAlertType = 1, Title = "Test", Content = "Test" }); _alert = new AlertDTO() { IdAlertType = 1, IdMode = _idmode, Title = "Test", Content = "Test" }; var recipients = new List <AlertRecipientDTO>(); recipients.Add(new AlertRecipientDTO() { Email = "*****@*****.**", DisplayName = "TestDisplayname", }); _alertwithrecipient = new AlertWithRecipientDTO() { IdAlert = _idalert, IdAlertType = 3, IdMode = _idmode, Title = "Test", Content = "Test", LsRecipients = recipients }; _listAlertWithRecipient.Add(_alertwithrecipient); }
public void RemoveSeekiosInDontMove(SeekiosDTO seekios) { }
/// <summary> /// Send a local notification on the phone /// </summary> public void SendNotification(SeekiosDTO seekios, string title, string message, bool isAlert = false, bool isLowBattery = false) { var context = AppCompatActivityBase.CurrentActivity; if (seekios == null) { throw new Exception("SendNotification: seekios can not be null"); } if (context == null) { throw new Exception("SendNotification: context can not be null"); } var intent = new Intent(context, typeof(DetailSeekiosActivity)); intent.AddFlags(ActivityFlags.ClearTop); using (var pendingIntent = PendingIntent.GetActivity(context, 0, intent, PendingIntentFlags.UpdateCurrent)) using (var builder = new NotificationCompat.Builder(context)) { Bitmap largeIcon = null; if (!string.IsNullOrEmpty(seekios.SeekiosPicture)) { try { var bytes = Convert.FromBase64String(seekios.SeekiosPicture); largeIcon = BitmapFactory.DecodeByteArray(bytes, 0, bytes.Length); } catch (System.Exception) { largeIcon = BitmapFactory.DecodeResource(context.Resources, Resource.Drawable.DefaultSeekios); } } else { largeIcon = BitmapFactory.DecodeResource(context.Resources, Resource.Drawable.DefaultSeekios); } if (isAlert) { largeIcon = BitmapFactory.DecodeResource(context.Resources, Resource.Drawable.AlertNotificationIcon); } // For Lollipop notification must be WHITE + TRANSPARENT if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { if (isLowBattery) { builder.SetSmallIcon(Resource.Drawable.BatteryWarning); } else { builder.SetSmallIcon(Resource.Drawable.IconTransparent); } } else { builder.SetSmallIcon(Resource.Drawable.Icon); } builder.SetLargeIcon(largeIcon) .SetContentTitle(title) .SetContentText(message) .SetAutoCancel(true) .SetColor(isLowBattery ? 14298670 : 8435503) .SetDefaults((int)NotificationDefaults.Sound | (int)NotificationDefaults.Vibrate); if (pendingIntent != null) { builder.SetContentIntent(pendingIntent); } ((NotificationManager)context.GetSystemService(Context.NotificationService)).Notify(1, builder.Build()); largeIcon.Dispose(); } }
private MKAnnotationView CreateSeekiosAnnotation(MKMapView mapView, IMKAnnotation annotation) { // queue for reuse the pin if it's already exist var annotationView = mapView.DequeueReusableAnnotation(_idSeekiosAnnotation); if (annotationView == null) { // not existing, we create a new one annotationView = new MKAnnotationView(annotation, _idSeekiosAnnotation); } // image of the annotation display on the map if (((SeekiosAnnotation)annotation).ImageName != null) { annotationView.Image = ((SeekiosAnnotation)annotation).ImageName; } else { annotationView.Image = UIImage.FromBundle("PinSeekiosGreen"); } annotationView.CanShowCallout = true; annotationView.CenterOffset = new CGPoint(0, -annotationView.Frame.Size.Height * 0.5);//-imageHeight / 2); SeekiosDTO seekios = null; if (((SeekiosAnnotation)annotation).IdSeekios != 0) { seekios = App.CurrentUserEnvironment.LsSeekios.FirstOrDefault(f => f.Idseekios == ((SeekiosAnnotation)annotation).IdSeekios); } else { return(null); } // image of the seekios inside the annotation var imageView = new UIImageView(); imageView.Frame = new CGRect(17.9, 4.2, 40, 40); imageView.Layer.CornerRadius = imageView.Frame.Size.Width / 2; imageView.ClipsToBounds = true; if (string.IsNullOrEmpty(seekios.SeekiosPicture)) { imageView.Image = UIImage.FromBundle("DefaultSeekios"); } else { using (var dataDecoded = new NSData(seekios.SeekiosPicture , NSDataBase64DecodingOptions.IgnoreUnknownCharacters)) { imageView.Image = new UIImage(dataDecoded); } } annotationView.AddSubview(imageView); // wrap all element in a view var customView = new UIView(); float xValue = 5f; if (App.Locator.ModeZone.IsActivityFocused) { customView.Frame = new RectangleF(0f, 0f, 160f, 75f); } else if (App.Locator.MapAllSeekios.HasRemovedButtonAnnotationView) { customView.Frame = new RectangleF(0f, 0f, 220f, 70f); customView.AddSubview(CreateMoreButton(10, seekios.LastKnownLocation_latitude, seekios.LastKnownLocation_longitude)); customView.AddSubview(CreateMoreLabel(0)); xValue = 65; } else { bool isAlert = ((SeekiosAnnotation)annotation).IsAlert; customView.Frame = new RectangleF(0f, 0f, 270f, 70f); customView.AddSubview(CreateRefreshButton(isAlert, seekios.IsInPowerSaving)); customView.AddSubview(CreateMoreButton(70 , seekios.LastKnownLocation_latitude , seekios.LastKnownLocation_longitude , isAlert)); customView.AddSubview(CreateRefreshLabel(isAlert)); customView.AddSubview(CreateMoreLabel(60, isAlert)); xValue = 115f; } customView.AddSubview(CreateSeekiosNameLabel(seekios.SeekiosName, xValue)); if (seekios.LastKnownLocation_dateLocationCreation.HasValue) { customView.AddSubview(CreateLastPositionLabel(seekios.LastKnownLocation_dateLocationCreation.Value.FormatDateFromNow(), xValue)); } else { customView.AddSubview(CreateLastPositionLabel(Application.LocalizedString("DateNotAvailable"), xValue)); } // add the view in the annotation view annotationView.LeftCalloutAccessoryView = customView; return(annotationView); }
public bool TryToStartFollowMe(SeekiosDTO seekios) { return(true); }