mirror of
https://github.com/bitwarden/android.git
synced 2024-12-25 18:38:27 +03:00
PM-3165 Finish task completion source when cancelling the dialog tapping on the background. (#2647)
This commit is contained in:
parent
ea81acb3bf
commit
9eda015371
1 changed files with 17 additions and 6 deletions
|
@ -3,7 +3,6 @@ using System.Threading.Tasks;
|
||||||
using Android.App;
|
using Android.App;
|
||||||
using Android.Content;
|
using Android.Content;
|
||||||
using Android.Content.PM;
|
using Android.Content.PM;
|
||||||
using Android.Media;
|
|
||||||
using Android.Nfc;
|
using Android.Nfc;
|
||||||
using Android.OS;
|
using Android.OS;
|
||||||
using Android.Provider;
|
using Android.Provider;
|
||||||
|
@ -18,14 +17,9 @@ using Bit.App.Utilities;
|
||||||
using Bit.App.Utilities.Prompts;
|
using Bit.App.Utilities.Prompts;
|
||||||
using Bit.Core.Abstractions;
|
using Bit.Core.Abstractions;
|
||||||
using Bit.Core.Enums;
|
using Bit.Core.Enums;
|
||||||
using Bit.Core.Utilities;
|
|
||||||
using Bit.Droid.Utilities;
|
using Bit.Droid.Utilities;
|
||||||
using Plugin.CurrentActivity;
|
using Plugin.CurrentActivity;
|
||||||
using Xamarin.Forms.Platform.Android;
|
using Xamarin.Forms.Platform.Android;
|
||||||
using static Android.Icu.Text.CaseMap;
|
|
||||||
using static Android.Renderscripts.ScriptGroup;
|
|
||||||
using static Android.Util.EventLogTags;
|
|
||||||
using static Bit.App.Pages.SettingsPageViewModel;
|
|
||||||
|
|
||||||
namespace Bit.Droid.Services
|
namespace Bit.Droid.Services
|
||||||
{
|
{
|
||||||
|
@ -267,6 +261,7 @@ namespace Bit.Droid.Services
|
||||||
|
|
||||||
var result = new TaskCompletionSource<ValidatablePromptResponse?>();
|
var result = new TaskCompletionSource<ValidatablePromptResponse?>();
|
||||||
|
|
||||||
|
alertBuilder.SetOnCancelListener(new BasicDialogWithResultCancelListener(result));
|
||||||
alertBuilder.SetPositiveButton(config.OkButtonText ?? AppResources.Ok, listener: null);
|
alertBuilder.SetPositiveButton(config.OkButtonText ?? AppResources.Ok, listener: null);
|
||||||
alertBuilder.SetNegativeButton(config.CancelButtonText ?? AppResources.Cancel, (sender, args) => result.TrySetResult(null));
|
alertBuilder.SetNegativeButton(config.CancelButtonText ?? AppResources.Cancel, (sender, args) => result.TrySetResult(null));
|
||||||
if (!string.IsNullOrEmpty(config.ThirdButtonText))
|
if (!string.IsNullOrEmpty(config.ThirdButtonText))
|
||||||
|
@ -614,4 +609,20 @@ namespace Bit.Droid.Services
|
||||||
#pragma warning restore CS0618 // Type or member is obsolete
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class BasicDialogWithResultCancelListener : Java.Lang.Object, IDialogInterfaceOnCancelListener
|
||||||
|
{
|
||||||
|
private readonly TaskCompletionSource<ValidatablePromptResponse?> _taskCompletionSource;
|
||||||
|
|
||||||
|
public BasicDialogWithResultCancelListener(TaskCompletionSource<ValidatablePromptResponse?> taskCompletionSource)
|
||||||
|
{
|
||||||
|
_taskCompletionSource = taskCompletionSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnCancel(IDialogInterface dialog)
|
||||||
|
{
|
||||||
|
_taskCompletionSource?.TrySetResult(null);
|
||||||
|
dialog?.Dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue