Detect if all Drives are indexed and show a warning if they aren't (#5015)

* opens new settings search options

* Catching file not found exception

* removed unnecessary header files

* Added display strings and cleaned up code

* reduced the number of max results to 30

* added log statement for exception

* Added drive detection to settings ui but still doesn't reflect on toggling it

* added getter setter for DriveDetectionWarning

* Got UI and backend to work as expected

* Reading value from registry working as expected

* Added test for settings

* Added tests for drive detection

* rename drive detection

* Localized indexer string

* formatting

* resolving merge conflict

* Added theme aware warning icon

* changed text for the warning

* Added the warning images to the installer
This commit is contained in:
Alekhya
2020-07-20 17:50:42 -07:00
committed by GitHub
parent c85cd4ac24
commit 96cd135f82
23 changed files with 289 additions and 68 deletions

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Plugin.Indexer.DriveDetection;
using Microsoft.Plugin.Indexer.Interface;
namespace Microsoft.Plugin.Indexer.DriveDetection
{
public class IndexerDriveDetection
{
private bool IsEnhancedModeEnabled { get; set; } = false;
private IRegistryWrapper _registryHelper;
public bool IsDriveDetectionWarningCheckBoxSelected { get; set; } = false;
public IndexerDriveDetection(IRegistryWrapper registryHelper)
{
_registryHelper = registryHelper;
GetEnhancedModeStatus();
}
// To display the results if either enhanced mode is on or if the disable drive detection checkbox is checked
public bool DisplayResults()
{
return IsDriveDetectionWarningCheckBoxSelected || IsEnhancedModeEnabled;
}
// To look up the registry entry for
private void GetEnhancedModeStatus()
{
string registryLocation = @"Software\Microsoft\Windows Search\Gather\Windows\SystemIndex";
string valueName = "EnableFindMyFiles";
IsEnhancedModeEnabled = _registryHelper.GetHKLMRegistryValue(registryLocation, valueName) == 0 ? false : true;
}
}
}

View File

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Input;
using Microsoft.Plugin.Indexer.Interface;
using Microsoft.Win32;
namespace Microsoft.Plugin.Indexer.DriveDetection
{
public class RegistryWrapper : IRegistryWrapper
{
// Given the registrypath and the name of the value, to retrieve the data corresponding to that registry key
public int GetHKLMRegistryValue(string registryLocation, string valueName)
{
using (RegistryKey regKey = Registry.LocalMachine.OpenSubKey(registryLocation))
{
if(regKey != null)
{
Object value = regKey.GetValue(valueName);
if(value != null)
{
return (int)value;
}
}
}
return 0;
}
}
}