Skip to content

Commit

Permalink
Merge pull request #9 from IeuanWalker/Accessibility-WorkWithPhysical…
Browse files Browse the repository at this point in the history
…Keyboard
  • Loading branch information
IeuanWalker authored Feb 25, 2022
2 parents 84c6739 + 5a13e4e commit cbbe8e7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions Src/Switch.Android/CustomSwitchRenderer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.ComponentModel;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Views.Accessibility;
using Java.Lang;
Expand Down Expand Up @@ -73,5 +74,17 @@ private string GetStateDescription()
{
return _a11YSwitch.Checked ? _a11YSwitch.TextOn : _a11YSwitch.TextOff;
}

public override bool OnKeyUp([GeneratedEnum] Keycode keyCode, KeyEvent e)
{
if (keyCode == Keycode.Space || keyCode == Keycode.Enter)
{
CustomSwitch customSwitch = Element as CustomSwitch;

customSwitch.IsToggled = !customSwitch.IsToggled;
}

return base.OnKeyUp(keyCode, e);
}
}
}
2 changes: 1 addition & 1 deletion Src/Switch.Android/Resources/Resource.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Src/Switch.Android/Switch.Droid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AdvancedFrameRenderer.cs" />
<Compile Include="CustomSwitchRenderer.cs" />
<Compile Include="Resources\Resource.designer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand All @@ -64,6 +65,12 @@
<Version>5.0.0.2012</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Switch\Switch.csproj">
<Project>{3de1ce08-2c75-4e8e-abf3-3e6a44f46820}</Project>
<Name>Switch</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down

0 comments on commit cbbe8e7

Please sign in to comment.