Skip to content

Commit b2823a8

Browse files
committed
Release v3.1.10
1 parent ae4842e commit b2823a8

File tree

9 files changed

+73
-27
lines changed

9 files changed

+73
-27
lines changed

.github/ISSUE_TEMPLATE/bug_report.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ body:
3232
description: Specify the version of AdvancedSharpAdbClient you're using.
3333
options:
3434
- "Latest Source"
35+
- "3.1.10"
3536
- "3.0.9"
3637
- "2.5.8"
3738
- "2.5.7"
@@ -103,6 +104,7 @@ body:
103104
- "MonoDevelop 5.x"
104105
- "MonoDevelop 4.x"
105106
- "MonoDevelop 3.x"
107+
- "Rider 2024"
106108
- "Rider 2023"
107109
- "Rider 2022"
108110
- "Rider 2021"

AdvancedSharpAdbClient.Tests/AdvancedSharpAdbClient.Tests.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
</Choose>
2525

2626
<ItemGroup>
27-
<PackageReference Include="coverlet.msbuild" Version="6.0.0" PrivateAssets="all">
27+
<PackageReference Include="coverlet.msbuild" Version="6.0.1" PrivateAssets="all">
2828
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2929
</PackageReference>
3030
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
3131
<PackageReference Include="NSubstitute" Version="5.1.0" />
32-
<PackageReference Include="xunit" Version="2.6.6" />
33-
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6" PrivateAssets="all">
32+
<PackageReference Include="xunit" Version="2.7.0" />
33+
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7" PrivateAssets="all">
3434
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3535
</PackageReference>
3636
</ItemGroup>

AdvancedSharpAdbClient/DeviceCommands/DeviceClient.Async.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,32 @@ public async Task SendTextAsync(string text, CancellationToken cancellationToken
458458
}
459459
}
460460

461+
/// <summary>
462+
/// Asynchronously clear the input text. The input should be in focus. Use <see cref="Element.ClearInputAsync(int, CancellationToken)"/> if the element isn't focused.
463+
/// </summary>
464+
/// <param name="charCount">The length of text to clear.</param>
465+
/// <param name="cancellationToken">A <see cref="CancellationToken"/> which can be used to cancel the asynchronous operation.</param>
466+
/// <returns>A <see cref="Task"/> which represents the asynchronous operation.</returns>
467+
public async Task ClearInputAsync(int charCount, CancellationToken cancellationToken = default)
468+
{
469+
await SendKeyEventAsync("KEYCODE_MOVE_END", cancellationToken).ConfigureAwait(false);
470+
await SendKeyEventAsync(StringExtensions.Join(" ", Enumerable.Repeat<string?>("KEYCODE_DEL", charCount)), cancellationToken).ConfigureAwait(false);
471+
}
472+
473+
/// <summary>
474+
/// Asynchronously click BACK button.
475+
/// </summary>
476+
/// <param name="cancellationToken">A <see cref="CancellationToken"/> which can be used to cancel the asynchronous operation.</param>
477+
/// <returns>A <see cref="Task"/> which represents the asynchronous operation.</returns>
478+
public Task ClickBackButtonAsync(CancellationToken cancellationToken = default) => SendKeyEventAsync("KEYCODE_BACK", cancellationToken);
479+
480+
/// <summary>
481+
/// Asynchronously click HOME button.
482+
/// </summary>
483+
/// <param name="cancellationToken">A <see cref="CancellationToken"/> which can be used to cancel the asynchronous operation.</param>
484+
/// <returns>A <see cref="Task"/> which represents the asynchronous operation.</returns>
485+
public Task ClickHomeButtonAsync(CancellationToken cancellationToken = default) => SendKeyEventAsync("KEYCODE_HOME", cancellationToken);
486+
461487
/// <summary>
462488
/// Start an Android application on device asynchronously.
463489
/// </summary>

AdvancedSharpAdbClient/DeviceCommands/DeviceClient.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,26 @@ public void SendText(string text)
378378
}
379379
}
380380

381+
/// <summary>
382+
/// Clear the input text. The input should be in focus. Use <see cref="Element.ClearInput(int)"/> if the element isn't focused.
383+
/// </summary>
384+
/// <param name="charCount">The length of text to clear.</param>
385+
public void ClearInput(int charCount)
386+
{
387+
SendKeyEvent("KEYCODE_MOVE_END");
388+
SendKeyEvent(StringExtensions.Join(" ", Enumerable.Repeat<string?>("KEYCODE_DEL", charCount)));
389+
}
390+
391+
/// <summary>
392+
/// Click BACK button.
393+
/// </summary>
394+
public void ClickBackButton() => SendKeyEvent("KEYCODE_BACK");
395+
396+
/// <summary>
397+
/// Click HOME button.
398+
/// </summary>
399+
public void ClickHomeButton() => SendKeyEvent("KEYCODE_HOME");
400+
381401
/// <summary>
382402
/// Start an Android application on device.
383403
/// </summary>

AdvancedSharpAdbClient/DeviceCommands/DeviceExtensions.Async.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,8 @@ public static Task SendTextAsync(this IAdbClient client, DeviceData device, stri
150150
/// <param name="charCount">The length of text to clear.</param>
151151
/// <param name="cancellationToken">A <see cref="CancellationToken"/> which can be used to cancel the asynchronous operation.</param>
152152
/// <returns>A <see cref="Task"/> which represents the asynchronous operation.</returns>
153-
public static async Task ClearInputAsync(this IAdbClient client, DeviceData device, int charCount, CancellationToken cancellationToken = default)
154-
{
155-
DeviceClient deviceClient = new(client, device);
156-
await deviceClient.SendKeyEventAsync("KEYCODE_MOVE_END", cancellationToken).ConfigureAwait(false);
157-
await deviceClient.SendKeyEventAsync(StringExtensions.Join(" ", Enumerable.Repeat<string?>("KEYCODE_DEL", charCount)), cancellationToken).ConfigureAwait(false);
158-
}
153+
public static Task ClearInputAsync(this IAdbClient client, DeviceData device, int charCount, CancellationToken cancellationToken = default) =>
154+
new DeviceClient(client, device).ClearInputAsync(charCount, cancellationToken);
159155

160156
/// <summary>
161157
/// Asynchronously click BACK button.
@@ -165,7 +161,7 @@ public static async Task ClearInputAsync(this IAdbClient client, DeviceData devi
165161
/// <param name="cancellationToken">A <see cref="CancellationToken"/> which can be used to cancel the asynchronous operation.</param>
166162
/// <returns>A <see cref="Task"/> which represents the asynchronous operation.</returns>
167163
public static Task ClickBackButtonAsync(this IAdbClient client, DeviceData device, CancellationToken cancellationToken = default) =>
168-
new DeviceClient(client, device).SendKeyEventAsync("KEYCODE_BACK", cancellationToken);
164+
new DeviceClient(client, device).ClickBackButtonAsync(cancellationToken);
169165

170166
/// <summary>
171167
/// Asynchronously click HOME button.
@@ -175,7 +171,7 @@ public static Task ClickBackButtonAsync(this IAdbClient client, DeviceData devic
175171
/// <param name="cancellationToken">A <see cref="CancellationToken"/> which can be used to cancel the asynchronous operation.</param>
176172
/// <returns>A <see cref="Task"/> which represents the asynchronous operation.</returns>
177173
public static Task ClickHomeButtonAsync(this IAdbClient client, DeviceData device, CancellationToken cancellationToken = default) =>
178-
new DeviceClient(client, device).SendKeyEventAsync("KEYCODE_HOME", cancellationToken);
174+
new DeviceClient(client, device).ClickHomeButtonAsync(cancellationToken);
179175

180176
/// <summary>
181177
/// Asynchronously start an Android application on device.

AdvancedSharpAdbClient/DeviceCommands/DeviceExtensions.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,28 +133,24 @@ public static void SendText(this IAdbClient client, DeviceData device, string te
133133
/// <param name="client">An instance of a class that implements the <see cref="IAdbClient"/> interface.</param>
134134
/// <param name="device">The device on which to clear the input text.</param>
135135
/// <param name="charCount">The length of text to clear.</param>
136-
public static void ClearInput(this IAdbClient client, DeviceData device, int charCount)
137-
{
138-
DeviceClient deviceClient = new(client, device);
139-
deviceClient.SendKeyEvent("KEYCODE_MOVE_END");
140-
deviceClient.SendKeyEvent(StringExtensions.Join(" ", Enumerable.Repeat<string?>("KEYCODE_DEL", charCount)));
141-
}
136+
public static void ClearInput(this IAdbClient client, DeviceData device, int charCount)=>
137+
new DeviceClient(client, device).ClearInput(charCount);
142138

143139
/// <summary>
144140
/// Click BACK button.
145141
/// </summary>
146142
/// <param name="client">An instance of a class that implements the <see cref="IAdbClient"/> interface.</param>
147143
/// <param name="device">The device on which to click BACK button.</param>
148144
public static void ClickBackButton(this IAdbClient client, DeviceData device) =>
149-
new DeviceClient(client, device).SendKeyEvent("KEYCODE_BACK");
145+
new DeviceClient(client, device).ClickBackButton();
150146

151147
/// <summary>
152148
/// Click HOME button.
153149
/// </summary>
154150
/// <param name="client">An instance of a class that implements the <see cref="IAdbClient"/> interface.</param>
155151
/// <param name="device">The device on which to click HOME button.</param>
156152
public static void ClickHomeButton(this IAdbClient client, DeviceData device) =>
157-
new DeviceClient(client, device).SendKeyEvent("KEYCODE_HOME");
153+
new DeviceClient(client, device).ClickHomeButton();
158154

159155
/// <summary>
160156
/// Start an Android application on device.

AdvancedSharpAdbClient/DeviceCommands/Models/Element.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,13 @@ public void SendText(string text)
268268
}
269269

270270
/// <summary>
271-
/// Clear the input text. Use <see cref="DeviceExtensions.ClearInput(IAdbClient, DeviceData, int)"/> if the element is focused.
271+
/// Clear the input text. Use <see cref="DeviceClient.ClearInput(int)"/> if the element is focused.
272272
/// </summary>
273273
[MemberNotNull(nameof(Text))]
274274
public void ClearInput() => ClearInput(Text!.Length);
275275

276276
/// <summary>
277-
/// Clear the input text. Use <see cref="DeviceExtensions.ClearInput(IAdbClient, DeviceData, int)"/> if the element is focused.
277+
/// Clear the input text. Use <see cref="DeviceClient.ClearInput(int)"/> if the element is focused.
278278
/// </summary>
279279
/// <param name="charCount">The length of text to clear.</param>
280280
public void ClearInput(int charCount)
@@ -331,7 +331,7 @@ public async Task SendTextAsync(string text, CancellationToken cancellationToken
331331
}
332332

333333
/// <summary>
334-
/// Asynchronously clear the input text. Use <see cref="DeviceExtensions.ClearInputAsync(IAdbClient, DeviceData, int, CancellationToken)"/> if the element is focused.
334+
/// Asynchronously clear the input text. Use <see cref="DeviceClient.ClearInputAsync(int, CancellationToken)"/> if the element is focused.
335335
/// </summary>
336336
/// <param name="cancellationToken">A <see cref="CancellationToken"/> which can be used to cancel the asynchronous operation.</param>
337337
/// <returns>A <see cref="Task"/> which represents the asynchronous operation.</returns>
@@ -340,7 +340,7 @@ public Task ClearInputAsync(CancellationToken cancellationToken = default) =>
340340
ClearInputAsync(Text!.Length, cancellationToken);
341341

342342
/// <summary>
343-
/// Asynchronously clear the input text. Use <see cref="DeviceExtensions.ClearInputAsync(IAdbClient, DeviceData, int, CancellationToken)"/> if the element is focused.
343+
/// Asynchronously clear the input text. Use <see cref="DeviceClient.ClearInputAsync(int, CancellationToken)"/> if the element is focused.
344344
/// </summary>
345345
/// <param name="charCount">The length of text to clear.</param>
346346
/// <param name="cancellationToken">A <see cref="CancellationToken"/> which can be used to cancel the asynchronous operation.</param>

AdvancedSharpAdbClient/Models/InstallProgress.EventArgs.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System;
66
using System.Collections.Generic;
77
using System.Diagnostics;
8+
using System.Runtime.InteropServices;
89
using System.Text;
910

1011
namespace AdvancedSharpAdbClient.Models
@@ -87,7 +88,12 @@ public override string ToString()
8788
split.Add(c);
8889
}
8990

90-
StringBuilder builder = new(new string(split.ToArray()));
91+
StringBuilder builder =
92+
#if NET
93+
new StringBuilder().Append(CollectionsMarshal.AsSpan(split));
94+
#else
95+
new(new string(split.ToArray()));
96+
#endif
9197

9298
if (PackageRequired > 0)
9399
{

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ The text field should be in focus
246246
static void Main(string[] args)
247247
{
248248
...
249-
adbClient.ClearInput(deviceData, 25); // The second argument is to specify the maximum number of characters to be erased
249+
deviceClient.ClearInput(25); // The argument is to specify the maximum number of characters to be erased
250250
...
251251
}
252252
```
@@ -294,9 +294,9 @@ catch (Exception ex)
294294
static void Main(string[] args)
295295
{
296296
...
297-
adbClient.ClickBackButton(device); // Click Back button
297+
deviceClient.ClickBackButton(); // Click Back button
298298
...
299-
adbClient.ClickHomeButton(device); // Click Home button
299+
deviceClient.ClickHomeButton(); // Click Home button
300300
...
301301
}
302302
```

0 commit comments

Comments
 (0)