protected void SetupFileSystem()
        {
            var MockFile1 = A.Fake <Java.IO.File>();

            A.CallTo(() => MockFile1.AbsolutePath).Returns(PATH1);
            var MockFile2 = A.Fake <Java.IO.File>();

            A.CallTo(() => MockFile2.AbsolutePath).Returns(PATH2);

            Java.IO.File[] files = new Java.IO.File[]  {
                MockFile1,
                MockFile2
            };
            A.CallTo(() => MockFileSystemHelper.GetApplicationExternalFilesDirs()).Returns(files);

            A.CallTo(() => MockFileSystemHelper.GetAvailableFileSystemSizeInBytes(PATH1)).Returns(100 * BYTES_PER_MB);
            A.CallTo(() => MockFileSystemHelper.GetTotalFileSystemSizeInBytes(PATH1)).Returns(200 * BYTES_PER_MB);
            A.CallTo(() => MockFileSystemHelper.GetAvailableFileSystemSizeInBytes(PATH2)).Returns(2000 * BYTES_PER_MB);
            A.CallTo(() => MockFileSystemHelper.GetTotalFileSystemSizeInBytes(PATH2)).Returns(4000L * BYTES_PER_MB);
        }
Exemplo n.º 2
0
        private void AddFileSystem(string absolutePath)
        {
            long freeBytes  = FileSystemHelper.GetAvailableFileSystemSizeInBytes(absolutePath);
            long totalBytes = FileSystemHelper.GetTotalFileSystemSizeInBytes(absolutePath);
            long usedBytes  = totalBytes - freeBytes;

            string[] freeSize  = DisplayFormatter.RenderFileSize(freeBytes).Split(' ');
            string[] totalSize = DisplayFormatter.RenderFileSize(totalBytes).Split(' ');

            var view = DriveVolumeInfoViewFactory.GetNewView(ApplicationContext);

            view.Title = ConvertPathToTitle(absolutePath);
            view.SetSpace(
                Convert.ToInt32(ByteConverter.BytesToMegabytes(usedBytes)),
                Convert.ToInt32(ByteConverter.BytesToMegabytes(totalBytes)),
                freeSize[0], freeSize[1],
                totalSize[0], totalSize[1]);

            Observables?.AddInfoView?.Invoke(this, view.GetView());
        }
Exemplo n.º 3
0
        private ReadOnlyControlFile OpenControlFile(Android.Net.Uri uri)
        {
            try
            {
                ContentResolver resolver = Application.ContentResolver;
                var             stream   = resolver.OpenInputStream(uri);
                var             xml      = new XmlDocument();
                xml.Load(stream);
                var control  = new ReadOnlyControlFile(xml);
                var podcasts = control.GetPodcasts();
                int count    = 0;
                foreach (var item in podcasts)
                {
                    count++;
                }
                NoOfFeeds = count;

                AndroidApplication.Logger.Debug(() => $"MainActivity:Control Podcasts {control.GetSourceRoot()}");
                AndroidApplication.Logger.Debug(() => $"MainActivity:Control Podcasts {count}");

                SetTextViewText(Resource.Id.txtConfigFilePath, $"{uri.ToString()}");

                freeBytesNet      = GetFreeBytes(control.GetSourceRoot());
                freeBytesAndroid  = FileSystemHelper.GetAvailableFileSystemSizeInBytes(control.GetSourceRoot());
                totalBytesAndroid = FileSystemHelper.GetTotalFileSystemSizeInBytes(control.GetSourceRoot());
                var output = $"{count}, {control.GetSourceRoot()}\nFree space (Net): {DisplayFormatter.RenderFileSize(freeBytesNet)}\nFree/total space (Android): {DisplayFormatter.RenderFileSize(freeBytesAndroid)}/{DisplayFormatter.RenderFileSize(totalBytesAndroid)}";
                SetTextViewText(Resource.Id.txtOutput, output);
                return(control);
            }
            catch (Exception ex)
            {
                AndroidApplication.Logger.LogException(() => $"MainActivity: OpenConfigFile", ex);
                SetTextViewText(Resource.Id.txtConfigFilePath, $"Error {ex.Message}");
                return(null);
            }
        }