コード例 #1
0
        public async void StartDialog()
        {
            PermissionManager permissions = new PermissionManager();
            var taskPermissionRead        = await permissions.CheckAndRequestStorageReadPermission();

            if (taskPermissionRead.HasFlag(Xamarin.Essentials.PermissionStatus.Granted))
            {
                ImagesCacheDbManager imagesCache      = new ImagesCacheDbManager(new ImageManager(), DateTime.Now.AddDays(90), DateTime.Now);
                ParameterManager     parameterManager = new ParameterManager();
                _initDCIMDirectory = string.Empty;
                if (!parameterManager.Get("CameraDirectoryFullPath", out _initDCIMDirectory))
                {
                    //параметр заполняется при старте индексации, уже должен быть заполнен
                    _initDCIMDirectory = imagesCache.GetPublicDirectoryDcim();
                }

                PathToDefaultDCIM = imagesCache.GetPublicDirectoryDcim();
                PathToCustomDCIM  = _initDCIMDirectory;
                IsUsageMainMemory = _initDCIMDirectory.Equals(PathToDefaultDCIM);

                await Task.Run(() =>
                {
                    MediaFileManager mediaFileManager = new MediaFileManager();
                    CountOfPhotoDefaultDCIM           = mediaFileManager.GetMediaFilesFromDirectory(new DirectoryInfo(PathToDefaultDCIM)).Count();
                    _pathToImagesDir       = _initDCIMDirectory;
                    CountOfPhotoCustomDCIM = mediaFileManager.GetMediaFilesFromDirectory(new DirectoryInfo(_initDCIMDirectory)).Count();
                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("CountOfPhotoDefaultDCIM"));
                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("CountOfPhotoCustomDCIM"));
                    updateDirContent(new DirectoryInfo(_pathToImagesDir));
                });
            }
        }
コード例 #2
0
        private bool isGuestMode()
        {
            ParameterManager par            = new ParameterManager();
            string           guestModeParam = string.Empty;

            par.Get("GuestMode", out guestModeParam);

            return(!string.IsNullOrEmpty(guestModeParam) && guestModeParam.Equals("1"));
        }
コード例 #3
0
        private async Task <string> getDataByKey(string keyName)
        {
            string datavalue = string.Empty;

            try
            {
                datavalue = await SecureStorage.GetAsync(keyName);
            }
            catch (Exception e)
            {
                HandleError.Process("TokenStoreService", "GetAuthTokenAsync", e, false);
            }

            //если значение не было сохранено в безопасное хранилище, ищем его в небезопасном - Android 4.4.2
            if (string.IsNullOrEmpty(datavalue))
            {
                ParameterManager par = new ParameterManager();
                par.Get(keyName, out datavalue);
            }

            return(datavalue);
        }
コード例 #4
0
        public App()
        {
            Xamarin.Forms.Device.SetFlags(new string[] { "Shapes_Experimental" });
            Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("");

            InitializeComponent();
            _log = App.Container.Resolve <ITextfileLogger>();

            _log.NewFile();
            Analytics.TrackEvent("Start app");
            Application.Current.Properties.Remove("SyncStatus");
            Application.Current.Properties.Remove("WorkInRoaming");
            ParameterManager par            = new ParameterManager();
            string           showOnboarding = string.Empty;

            if (!par.Get("NeedShowOnboarding", out showOnboarding))
            {
                MainPage = new SplashWizardPage();
            }
            else
            {
                MainPage = new View.MainPage();
            }
        }
コード例 #5
0
        private async void startIndexGalleryCommand(object obj)
        {
            PermissionManager permissions = new PermissionManager();
            var taskPermissionRead        = await permissions.CheckAndRequestStorageReadPermission();

            if (taskPermissionRead.HasFlag(Xamarin.Essentials.PermissionStatus.Granted))
            {
                Device.BeginInvokeOnMainThread(async() =>
                {
                    var statusReadExtStorage = await Permissions.CheckStatusAsync <Permissions.StorageRead>().ConfigureAwait(false);
                    if (statusReadExtStorage != Xamarin.Essentials.PermissionStatus.Granted)
                    {
                        await Permissions.RequestAsync <Permissions.StorageRead>().ConfigureAwait(false);
                    }
                });

                ImagesCacheDbManager imagesCache     = new ImagesCacheDbManager(new ImageManager(), PeriodRouteBegin, PeriodRouteEnd);
                string           pathToDCIMDirectory = string.Empty;
                ParameterManager parameterManager    = new ParameterManager();

                if (!parameterManager.Get("CameraDirectoryFullPath", out pathToDCIMDirectory))
                {
                    pathToDCIMDirectory = imagesCache.GetPathToCameraDirectory();
                    parameterManager.Set("CameraDirectoryFullPath", pathToDCIMDirectory);
                    MainThread.BeginInvokeOnMainThread(() =>
                    {
                        UserDialogs.Instance.Alert(CommonResource.AutoRoutes_WarningDefaultImagePath, CommonResource.CommonMsg_FirstStartDetected, "Ок");
                    });
                }

                PathToImageDirectory = pathToDCIMDirectory;

                await Task.Factory.StartNew(() =>
                {
                    int maxCountFilesForShowModalDialog = 20; //кол-во файлов которое считаем большим и достаточным для отображения диалога обработки
                    var listFilesForIndexing            = imagesCache.GetFilenamesForIndexing(PathToImageDirectory);
                    IsShowModalDialog     = false;
                    int countFiles        = listFilesForIndexing.Count;
                    IsGalleryIndexed      = !(countFiles > 0);
                    IsRouteMaking         = countFiles > maxCountFilesForShowModalDialog;
                    MaxCountProgressItems = countFiles;
                    attachReceiverMessagesForProgress();
                    imagesCache.UpdateFilenames(listFilesForIndexing, PathToImageDirectory);
                    detachReceiverMessagesForProgress();
                    CurrentProgressIndex = 0;
                });

                await Task.Factory.StartNew(() => {
                    _countImagesForToday   = imagesCache.GetCountImagesForDaysAgo(0, PathToImageDirectory);
                    _countImagesFor1Day    = imagesCache.GetCountImagesForDaysAgo(1, PathToImageDirectory);
                    _countImagesFor7Day    = imagesCache.GetCountImagesForDaysAgo(7, PathToImageDirectory);
                    int days               = 7300;
                    _countImagesForAllDays = imagesCache.GetCountImagesForDaysAgo(days, PathToImageDirectory);
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("CountImagesForToday"));
                        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("CountImagesFor1Day"));
                        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("CountImagesFor7Day"));
                        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("CountImagesForAllDays"));
                        IsRouteMaking = false;
                    });
                });

                Device.BeginInvokeOnMainThread(() =>
                {
                    MinRangeDate              = _localFileCacheManager.GetMinDate(PathToImageDirectory);
                    MaxRangeDate              = _localFileCacheManager.GetMaxDate(PathToImageDirectory);
                    IsGalleryIndexed          = true;
                    CurrentMonthChart         = DateTime.Now;
                    IsShowWarningNeedIndexing = false;
                });
            }
        }