1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-25 12:43:39 +00:00

add/edit/delete custom fields. remove field page.

This commit is contained in:
Kyle Spearrin
2018-03-05 15:15:20 -05:00
parent c3f4d56d1e
commit 1f21a2ecc7
14 changed files with 459 additions and 304 deletions

View File

@@ -24,6 +24,7 @@ using Bit.Android.Autofill;
using System.Linq;
using Plugin.Settings.Abstractions;
using Android.Views.InputMethods;
using Android.Widget;
namespace Bit.Android.Services
{
@@ -469,5 +470,44 @@ namespace Bit.Android.Services
_progressDialog.Dispose();
_progressDialog = null;
}
public Task<string> DisplayPromptAync(string title = null, string description = null, string text = null)
{
var activity = (MainActivity)CurrentContext;
var alertBuilder = new AlertDialog.Builder(activity);
alertBuilder.SetTitle(title);
alertBuilder.SetMessage(description);
var input = new EditText(activity)
{
InputType = global::Android.Text.InputTypes.ClassText
};
if(text != null)
{
input.Text = text;
input.SetSelection(text.Length);
}
else
{
input.FocusedByDefault = true;
}
alertBuilder.SetView(input);
var result = new TaskCompletionSource<string>();
alertBuilder.SetPositiveButton(AppResources.Ok, (sender, args) =>
{
result.TrySetResult(input.Text ?? string.Empty);
});
alertBuilder.SetNegativeButton(AppResources.Cancel, (sender, args) =>
{
result.TrySetResult(null);
});
var alert = alertBuilder.Create();
alert.Window.SetSoftInputMode(global::Android.Views.SoftInput.StateVisible);
alert.Show();
return result.Task;
}
}
}