public OrderMapFragment(TouchableMap mapFragment, Resources resources, TaxiHailSetting settings)
        {
            _resources         = resources;
            _settings          = settings;
            _showVehicleNumber = settings.ShowAssignedVehicleNumberOnPin;

            InitDrawables();

            this.CreateBindingContext();

            Map = mapFragment.Map;
            Map.MyLocationEnabled = true;
            Map.UiSettings.MyLocationButtonEnabled = false;

            // NOTE: wasn't working on some devices, reverted to standard padding and moved the buttons up in the layout
            // add padding to the map to move the Google logo around
            // the padding must be the same for left/right and top/bottom for the pins to be correctly aligned
            Map.SetPadding(6.ToPixels(), 6.ToPixels(), 6.ToPixels(), 6.ToPixels());

            TouchableMap = mapFragment;

            InitializeOverlayIcons();

            this.DelayBind(InitializeBinding);

            CreatePins();
        }
Exemple #2
0
        public async Task Load()
        {
            //check if the cache has already something
            // We also verify if the application name is present to make sure the cached settings are in a valid state.
            var data = _cacheService.Get <TaxiHailSetting>(SettingsCacheKey);

            if (data != null && data.TaxiHail.ApplicationName.HasValue())
            {
                // Use cached settings until settings are done loading
                if (!data.CanChangeServiceUrl)
                {
                    // Always use service URL from file, not from cache in case it changes
                    var bundledServiceUrl = GetSettingFromFile("ServiceUrl");

                    data.ServiceUrl = bundledServiceUrl;
                }

                Data = data;

                // Update settings asynchronously. NB: ServiceUrl is never returned from the server settings
                Task.Run(() => RefreshSettingsFromServer());
            }
            else
            {
                // No settings in cache, need to load them synchronously
                await RefreshSettingsFromServer();
            }
        }
Exemple #3
0
        public AppSettingsService(ICacheService cacheService, ILogger logger, ICryptographyService cryptographyService)
        {
            _logger              = logger;
            _cacheService        = cacheService;
            _cryptographyService = cryptographyService;

            Data = new TaxiHailSetting();

            //bare minimum for the app to work (server url etc.)
            LoadSettingsFromFile();
        }
Exemple #4
0
        public OrderMapFragment(TouchableMap mapFragment, Resources resources, TaxiHailSetting settings)
        {
            _resources         = resources;
            _settings          = settings;
            _showVehicleNumber = settings.ShowAssignedVehicleNumberOnPin;

            this.CreateBindingContext();

            Map = mapFragment.Map;
            Map.MyLocationEnabled = true;

            TouchableMap = mapFragment;

            InitializeOverlayIcons();

            this.DelayBind(InitializeBinding);

            CreatePins();

            InitDrawables();
        }
Exemple #5
0
        public async Task ChangeServerUrl(string serverUrl, bool skipAppRestart = false)
        {
            // Reset cache
            Data = new TaxiHailSetting();
            LoadSettingsFromFile();
            Data.ServiceUrl = serverUrl;

            _cacheService.Clear(SettingsCacheKey);

            try
            {
                await RefreshSettingsFromServer(true);

                if (!skipAppRestart)
                {
                    // We are causing an intentional crash to force the app to exit.
#pragma warning disable 4014
                    Mvx.Resolve <IMessageService>()
                    .ShowMessage("Apps needs to restart", "Server url succesfully updated, press to quit the application")
                    .ContinueWith(async task =>
#pragma warning restore 4014
                    {
                        await task;
                        Mvx.Resolve <IQuitApplicationService>().Quit();
                    });
                }
            }
            catch
            {
                // server url probably not good, revert
                Mvx.Resolve <IMessageService>().ShowMessage("Error", "Server not found, reverting server url");

                Data = new TaxiHailSetting();
                LoadSettingsFromFile();

                _cacheService.Clear(SettingsCacheKey);

                RefreshSettingsFromServer();
            }
        }