Skip to content

Commit

Permalink
Feature: Only show Google Drive under cloud drives (files-community#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
yaira2 authored Nov 23, 2023
1 parent 432b47c commit bd78721
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/Files.App/Data/Models/AppModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,15 @@ public bool ForceProcessTermination
get => forceProcessTermination;
set => SetProperty(ref forceProcessTermination, value);
}

private string googleDrivePath = string.Empty;
/// <summary>
/// Gets or sets a value indicating the path for Google Drive.
/// </summary>
public string GoogleDrivePath
{
get => googleDrivePath;
set => SetProperty(ref googleDrivePath, value);
}
}
}
5 changes: 5 additions & 0 deletions src/Files.App/Services/RemovableDrivesService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public IStorageDeviceWatcher CreateWatcher()
public async IAsyncEnumerable<ILocatableFolder> GetDrivesAsync()
{
var list = DriveInfo.GetDrives();
var googleDrivePath = App.AppModel.GoogleDrivePath;

foreach (var drive in list)
{
Expand All @@ -41,6 +42,10 @@ public async IAsyncEnumerable<ILocatableFolder> GetDrivesAsync()
var label = DriveHelpers.GetExtendedDriveLabel(drive);
var driveItem = await DriveItem.CreateFromPropertiesAsync(res.Result, drive.Name.TrimEnd('\\'), label, type, thumbnail);

// Don't add here because Google Drive is already displayed under cloud drives
if (drive.Name == googleDrivePath)
continue;

App.Logger.LogInformation($"Drive added: {driveItem.Path}, {driveItem.Type}");

yield return driveItem;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.Core.Utils.Cloud;
using Microsoft.Data.Sqlite;
using System.IO;
using Windows.Storage;
Expand Down Expand Up @@ -57,6 +56,8 @@ await FilesystemTasks.Wrap(() => StorageFile.GetFileFromPathAsync(Path.Combine(a
var folder = await StorageFolder.GetFolderFromPathAsync(path);
string title = reader["title"]?.ToString() ?? folder.Name;

App.AppModel.GoogleDrivePath = path;

yield return new CloudProvider(CloudProviders.GoogleDrive)
{
Name = $"Google Drive ({title})",
Expand All @@ -77,6 +78,8 @@ await FilesystemTasks.Wrap(() => StorageFile.GetFileFromPathAsync(Path.Combine(a
string title = reader["name"]?.ToString() ?? folder.Name;
string iconPath = Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles"), "Google", "Drive File Stream", "drive_fs.ico");

App.AppModel.GoogleDrivePath = path;

StorageFile iconFile = await FilesystemTasks.Wrap(() => StorageFile.GetFileFromPathAsync(iconPath).AsTask());

yield return new CloudProvider(CloudProviders.GoogleDrive)
Expand Down
2 changes: 0 additions & 2 deletions src/Files.Core/Services/Settings/IAppSettingsService.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using System.ComponentModel;

namespace Files.Core.Services.Settings
{
public interface IAppSettingsService : IBaseSettingsService, INotifyPropertyChanged
Expand Down

0 comments on commit bd78721

Please sign in to comment.