private void InitialiseSeekiosInformation()
        {
            if (null == _seekiosSelected)
            {
                return;
            }
            // Seekios name
            SeekiosNameTextView.Text = _seekiosSelected.SeekiosName;
            SeekiosNameTextView.SetTextColor(Resources.GetColor(Resource.Color.primary));

            // Seekios image
            if (!string.IsNullOrEmpty(_seekiosSelected.SeekiosPicture))
            {
                var bytes       = Convert.FromBase64String(_seekiosSelected.SeekiosPicture);
                var imageBitmap = BitmapFactory.DecodeByteArray(bytes, 0, bytes.Length);
                SeekiosRoundedImageView.SetImageBitmap(imageBitmap);
                imageBitmap.Dispose();
            }
            else
            {
                SeekiosRoundedImageView.SetImageResource(Resource.Drawable.DefaultSeekios);
            }

            // Seekios need update ?
            if (App.CurrentUserEnvironment.LastVersionEmbedded != null &&
                _seekiosSelected.VersionEmbedded_idversionEmbedded != App.CurrentUserEnvironment.LastVersionEmbedded.IdVersionEmbedded &&
                !App.CurrentUserEnvironment.LastVersionEmbedded.IsBetaVersion)
            {
                if (_seekiosSelected.IsInPowerSaving)
                {
                    FirmwareUpdateSvgImageView.TranslationY = (-AccessResources.Instance.SizeOf30Dip());
                }
                FirmwareUpdateSvgImageView.Visibility = ViewStates.Visible;
            }

            // Display or not power saving picture
            if (_seekiosSelected.IsInPowerSaving)
            {
                PowerSavingImageView.Visibility = ViewStates.Visible;
                PowerSavingImageView.BringToFront();
            }
            else
            {
                PowerSavingImageView.Visibility = ViewStates.Gone;
            }

            if (_seekiosSelected.LastKnownLocation_latitude == App.DefaultLatitude && _seekiosSelected.LastKnownLocation_longitude == App.DefaultLongitude)
            {
                // Display statement to say there is no position
                LastLocationTextView.Text = Resources.GetString(Resource.String.listSeekios_lastPositionNone);
            }
            else
            {
                if (_seekiosSelected.LastKnownLocation_dateLocationCreation.HasValue &&
                    _seekiosSelected.LastKnownLocation_dateLocationCreation.Value.Year != 1)
                {
                    if (_seekiosSelected.IsOnDemand)
                    {
                        // Display on refresh state (OnDemand)
                        var textToDisplay    = Resources.GetString(Resource.String.listSeekios_refreshPosition);
                        var _seekiosOnDemand = App.Locator.Map.LsSeekiosOnDemand.FirstOrDefault(x => x.Seekios.Idseekios == _seekiosSelected.Idseekios);
                        if (_seekiosOnDemand != null)
                        {
                            int minutes = (int)_seekiosOnDemand.Timer.CountDown / 60;
                            int seconds = (int)_seekiosOnDemand.Timer.CountDown - (minutes * 60);
                            LastLocationTextView.Text       = textToDisplay + string.Format(" {00:00}:{01:00}", minutes, seconds);
                            _seekiosOnDemand.Timer.UpdateUI = () =>
                            {
                                minutes = (int)_seekiosOnDemand.Timer.CountDown / 60;
                                seconds = (int)_seekiosOnDemand.Timer.CountDown - (minutes * 60);
                                LastLocationTextView.Text = textToDisplay + string.Format(" {00:00}:{01:00}", minutes, seconds);
                            };
                            // Hidden the count down, specific UI when it's the first location
                            _seekiosOnDemand.Timer.Stopped = () =>
                            {
                                LastLocationTextView.Text = App.CurrentUserEnvironment.LsSeekios.FirstOrDefault(f => f.UIdSeekios == App.Locator.DetailSeekios.SeekiosSelected.UIdSeekios).LastKnownLocation_dateLocationCreation.Value.FormatDateFromNow();
                            };
                        }
                        else
                        {
                            LastLocationTextView.Text = Resources.GetString(Resource.String.listSeekios_refreshPosition);
                        }
                    }
                    else
                    {
                        LastLocationTextView.Text = _seekiosSelected.LastKnownLocation_dateLocationCreation.Value.FormatDateFromNow();
                    }
                }
                else
                {
                    LastLocationTextView.Text = Resources.GetString(Resource.String.listSeekios_lastPositionNone);
                }
            }
            LastLocationTextView.SetTextColor(Resources.GetColor(Resource.Color.textColorTitle));

            // Mode name and image
            var mode = App.CurrentUserEnvironment.LsMode.FirstOrDefault(el => el.Seekios_idseekios == _seekiosSelected.Idseekios);

            ModeTitleTextView.SetTextColor(Resources.GetColor(Resource.Color.textColorTitle));

            // Update alert layout && low battery layout
            AlertSeekiosLayout.Visibility = ViewStates.Gone;
            if (_seekiosSelected.BatteryLife <= 20 && _seekiosSelected.LastKnownLocation_dateLocationCreation.HasValue)
            {
                AlertSvgImageView.SetSvg(this, Resource.Drawable.CriticalBattery);
                AlertTextView.Text            = _seekiosSelected.BatteryLife + "%";
                AlertSeekiosLayout.Visibility = ViewStates.Visible;
            }
            else if (!_seekiosSelected.IsLastSOSRead)
            {
                AlertSvgImageView.SetSvg(this, Resource.Drawable.SOS, "2FAD62=da2e2e");
                AlertTextView.Text            = GetString(Resource.String.detailSeekios_sos);
                AlertSeekiosLayout.Visibility = ViewStates.Visible;
            }

            if (mode != null)
            {
                ModeLayout.Visibility = ViewStates.Visible;
                if (!_seekiosSelected.HasGetLastInstruction &&
                    !App.Locator.Map.LsSeekiosOnDemand.Any(x => x.Seekios.Idseekios == _seekiosSelected.Idseekios) &&
                    mode.StatusDefinition_idstatusDefinition == (int)StatutDefinitionEnum.RAS &&
                    !_seekiosSelected.IsRefreshingBattery ||
                    !mode.DateModeActivation.HasValue)
                {
                    if (_seekiosSelected.IsInPowerSaving)
                    {
                        if (mode.ModeDefinition_idmodeDefinition == (int)ModeDefinitionEnum.ModeTracking)
                        {
                            ModeSvgImageView.SetSvg(this, Resource.Drawable.ModeTracking, "62da73=c8c8c8");
                        }
                        if (mode.ModeDefinition_idmodeDefinition == (int)ModeDefinitionEnum.ModeDontMove)
                        {
                            ModeSvgImageView.SetSvg(this, Resource.Drawable.ModeDontMove, "62da73=c8c8c8");
                        }
                        else if (mode.ModeDefinition_idmodeDefinition == (int)ModeDefinitionEnum.ModeZone)
                        {
                            ModeSvgImageView.SetSvg(this, Resource.Drawable.ModeZone, "62da73=c8c8c8");
                        }
                        ModeTitleTextView.Text = string.Format(GetString(Resource.String.listSeekios_nextNoon), DateHelper.TimeLeftUntilNextNoon());
                    }
                    else
                    {
                        ModeSvgImageView.SetSvg(this, Resource.Drawable.CloudSync);
                        ModeTitleTextView.SetText(Resource.String.listSeekios_synchr);
                    }
                }
                // The seekios has moved or is out of the area
                else if (mode.StatusDefinition_idstatusDefinition != 1)
                {
                    switch (mode.ModeDefinition_idmodeDefinition)
                    {
                    case (int)ModeDefinitionEnum.ModeDontMove:
                        if (mode.StatusDefinition_idstatusDefinition == 3)
                        {
                            LastLocationTextView.SetText(Resource.String.modeDontMove_seekiosMoved);
                            ModeTitleTextView.SetText(Resource.String.detailSeekios_dontMove);
                            ModeSvgImageView.SetSvg(this, Resource.Drawable.ModeDontMove, "62da73=da2e2e");
                        }
                        break;

                    case (int)ModeDefinitionEnum.ModeZone:
                        if (mode.StatusDefinition_idstatusDefinition == 2)
                        {
                            LastLocationTextView.SetText(Resource.String.modeZone_seekiosOutOfZone);
                            ModeTitleTextView.SetText(Resource.String.detailSeekios_zone);
                            ModeSvgImageView.SetSvg(this, Resource.Drawable.ModeZone, "62da73=da2e2e");
                        }
                        break;

                    default:
                        break;
                    }
                    var colorRed = Resources.GetColor(Resource.Color.color_red);
                    ModeTitleTextView.SetTextColor(colorRed);
                    SeekiosNameTextView.SetTextColor(colorRed);
                    LastLocationTextView.SetTextColor(colorRed);
                }
                // Seekios is in a mode
                else
                {
                    // Configuration of the mode layout
                    switch (mode.ModeDefinition_idmodeDefinition)
                    {
                    case 3:
                        ModeSvgImageView.SetSvg(this, Resource.Drawable.ModeTracking);
                        ModeTitleTextView.SetText(Resource.String.listSeekios_modeTracking);
                        break;

                    case 4:
                        ModeSvgImageView.SetSvg(this, Resource.Drawable.ModeDontMove);
                        ModeTitleTextView.SetText(Resource.String.listSeekios_modeDontMove);
                        break;

                    case 5:
                        ModeSvgImageView.SetSvg(this, Resource.Drawable.ModeZone);
                        ModeTitleTextView.SetText(Resource.String.listSeekios_modeZone);
                        break;
                    }
                }
            }
            else if (_seekiosSelected.IsLastSOSRead)
            {
                ModeLayout.Visibility = ViewStates.Invisible;
            }
        }
예제 #2
0
        private void InitialiseSeekiosInformation()
        {
            if (null == _seekiosSelected)
            {
                return;
            }
            // seekios name
            SeekiosNameTextView.Text = _seekiosSelected.SeekiosName;
            SeekiosNameTextView.SetTextColor(Resources.GetColor(Resource.Color.primary));

            // seekios image
            if (!string.IsNullOrEmpty(_seekiosSelected.SeekiosPicture))
            {
                var bytes       = Convert.FromBase64String(_seekiosSelected.SeekiosPicture);
                var imageBitmap = BitmapFactory.DecodeByteArray(bytes, 0, bytes.Length);
                SeekiosRoundedImageView.SetImageBitmap(imageBitmap);
                imageBitmap.Dispose();
            }
            else
            {
                SeekiosRoundedImageView.SetImageResource(Resource.Drawable.DefaultSeekios);
            }

            // Power saving and firmware update images
            if (_seekiosSelected.IsInPowerSaving)
            {
                PowerSavingImageView.Visibility = ViewStates.Visible;
            }
            else
            {
                PowerSavingImageView.Visibility = ViewStates.Gone;
            }

            if (_seekiosSelected.VersionEmbedded_idversionEmbedded != App.CurrentUserEnvironment.LastVersionEmbedded.IdVersionEmbedded)
            {
                FirmwareUpdateSvgImageView.Visibility = ViewStates.Visible;
                if (_seekiosSelected.IsInPowerSaving)
                {
                    RelativeLayout.LayoutParams rl = (RelativeLayout.LayoutParams)FirmwareUpdateSvgImageView.LayoutParameters;
                    rl.TopMargin -= 25;
                    FirmwareUpdateSvgImageView.LayoutParameters = rl;
                }
            }
            else
            {
                FirmwareUpdateSvgImageView.Visibility = ViewStates.Gone;
            }

            if (_seekiosSelected.LastKnownLocation_latitude == App.DefaultLatitude && _seekiosSelected.LastKnownLocation_longitude == App.DefaultLongitude)
            {
                // display statement to say there is no position
                LastLocationTextView.Text = Resources.GetString(Resource.String.listSeekios_lastPositionNone);
            }
            else
            {
                if (_seekiosSelected.LastKnownLocation_dateLocationCreation.HasValue &&
                    _seekiosSelected.LastKnownLocation_dateLocationCreation.Value.Year != 1)
                {
                    if (_seekiosSelected.IsOnDemand)
                    {
                        // display on refresh state (OnDemand)
                        var textToDisplay    = Resources.GetString(Resource.String.listSeekios_refreshPosition);
                        var _seekiosOnDemand = App.Locator.Map.LsSeekiosOnDemand.FirstOrDefault(x => x.Seekios.Idseekios == _seekiosSelected.Idseekios);
                        if (_seekiosOnDemand != null)
                        {
                            int minutes = (int)_seekiosOnDemand.Timer.CountDown / 60;
                            int seconds = (int)_seekiosOnDemand.Timer.CountDown - (minutes * 60);
                            LastLocationTextView.Text       = textToDisplay + string.Format(" {00:00}:{01:00}", minutes, seconds);
                            _seekiosOnDemand.Timer.UpdateUI = () =>
                            {
                                minutes = (int)_seekiosOnDemand.Timer.CountDown / 60;
                                seconds = (int)_seekiosOnDemand.Timer.CountDown - (minutes * 60);
                                LastLocationTextView.Text = textToDisplay + string.Format(" {00:00}:{01:00}", minutes, seconds);
                            };
                            // hidden the count down, specific UI when it's the first location
                            _seekiosOnDemand.Timer.Stopped = () =>
                            {
                                LastLocationTextView.Text = App.CurrentUserEnvironment.LsSeekios.FirstOrDefault(f => f.UIdSeekios == App.Locator.DetailSeekios.SeekiosSelected.UIdSeekios).LastKnownLocation_dateLocationCreation.Value.FormatDateFromNow();
                            };
                        }
                        else
                        {
                            LastLocationTextView.Text = Resources.GetString(Resource.String.listSeekios_refreshPosition);
                        }
                    }
                    else
                    {
                        // display date of the last position
                        LastLocationTextView.Text = _seekiosSelected.LastKnownLocation_dateLocationCreation.Value.FormatDateFromNow();
                    }
                }
                else
                {
                    // display no position
                    LastLocationTextView.Text = Resources.GetString(Resource.String.listSeekios_lastPositionNone);
                }
            }
            LastLocationTextView.SetTextColor(Resources.GetColor(Resource.Color.textColorTitle));

            // mode name and image
            var mode = App.CurrentUserEnvironment.LsMode.FirstOrDefault(el => el.Seekios_idseekios == _seekiosSelected.Idseekios);

            ModeTitleTextView.SetTextColor(Resources.GetColor(Resource.Color.textColorTitle));

            //update alert layout && low battery layout
            if (_seekiosSelected.BatteryLife <= 20)
            {
                AlertSvgImageView.SetSvg(this, Resource.Drawable.CriticalBattery);
                AlertTextView.Text            = _seekiosSelected.BatteryLife + "%";
                AlertSeekiosLayout.Visibility = ViewStates.Visible;
            }
            if (!_seekiosSelected.IsLastSOSRead)
            {
                AlertSvgImageView.SetSvg(this, Resource.Drawable.SOS, "2FAD62=da2e2e");
                AlertTextView.Text            = GetString(Resource.String.detailSeekios_sos);
                AlertSeekiosLayout.Visibility = ViewStates.Visible;
            }
            else if (_seekiosSelected.BatteryLife > 20 && _seekiosSelected.IsLastSOSRead)
            {
                AlertSeekiosLayout.Visibility = ViewStates.Gone;
            }

            if (mode != null)
            {
                ModeLayout.Visibility = ViewStates.Visible;
                if (!_seekiosSelected.HasGetLastInstruction)
                {
                    ModeSvgImageView.SetSvg(this, Resource.Drawable.CloudSync);
                    ModeTitleTextView.SetText(Resource.String.listSeekios_synchr);
                    //AlertSeekiosLayout.Visibility = ViewStates.Gone;
                }
                else
                {
                    //configuration of the mode layout
                    switch (mode.ModeDefinition_idmodeDefinition)
                    {
                    case 3:
                        ModeSvgImageView.SetSvg(this, Resource.Drawable.ModeTracking);
                        ModeTitleTextView.SetText(Resource.String.listSeekios_modeTracking);
                        break;

                    case 4:
                        ModeSvgImageView.SetSvg(this, Resource.Drawable.ModeDontMove);
                        ModeTitleTextView.SetText(Resource.String.listSeekios_modeDontMove);
                        break;

                    case 5:
                        ModeSvgImageView.SetSvg(this, Resource.Drawable.ModeZone);
                        ModeTitleTextView.SetText(Resource.String.listSeekios_modeZone);
                        break;

                    default:
                        //ButtonRightLayout.Visibility = ViewStates.Gone;
                        break;
                    }
                }

                if (mode.StatusDefinition_idstatusDefinition != 1)
                {
                    switch (mode.ModeDefinition_idmodeDefinition)
                    {
                    case (int)ModeDefinitionEnum.ModeDontMove:
                        if (mode.StatusDefinition_idstatusDefinition == 3)
                        {
                            LastLocationTextView.SetText(Resource.String.modeDontMove_seekiosMoved);
                            ModeTitleTextView.SetText(Resource.String.detailSeekios_dontMove);
                            ModeSvgImageView.SetSvg(this, Resource.Drawable.ModeDontMove, "62da73=da2e2e");
                        }
                        break;

                    case (int)ModeDefinitionEnum.ModeZone:
                        if (mode.StatusDefinition_idstatusDefinition == 2)
                        {
                            LastLocationTextView.SetText(Resource.String.modeZone_seekiosOutOfZone);
                            ModeTitleTextView.SetText(Resource.String.detailSeekios_zone);
                            ModeSvgImageView.SetSvg(this, Resource.Drawable.ModeZone, "62da73=da2e2e");
                        }
                        break;

                    default:
                        break;
                    }
                    var colorRed = Resources.GetColor(Resource.Color.color_red);
                    ModeTitleTextView.SetTextColor(colorRed);
                    SeekiosNameTextView.SetTextColor(colorRed);
                    LastLocationTextView.SetTextColor(colorRed);
                }
            }
            else
            {
                ModeLayout.Visibility = ViewStates.Invisible;
            }
        }