Skip to content

Feature: Only show Google Drive under cloud drives #14041

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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