mirror of
https://github.com/bitwarden/android.git
synced 2024-12-24 01:48:25 +03:00
select URI match option from action sheet
This commit is contained in:
parent
0bccc8f0d5
commit
fb6e488339
7 changed files with 154 additions and 12 deletions
33
src/Android/Resources/Resource.Designer.cs
generated
33
src/Android/Resources/Resource.Designer.cs
generated
|
@ -6475,17 +6475,17 @@ namespace Bit.Android
|
|||
// aapt resource value: 0x7f090051
|
||||
public const int ApplicationName = 2131296337;
|
||||
|
||||
// aapt resource value: 0x7f0900ab
|
||||
public const int AutoFillServiceDescription = 2131296427;
|
||||
// aapt resource value: 0x7f0900b2
|
||||
public const int AutoFillServiceDescription = 2131296434;
|
||||
|
||||
// aapt resource value: 0x7f0900aa
|
||||
public const int AutoFillServiceSummary = 2131296426;
|
||||
// aapt resource value: 0x7f0900b1
|
||||
public const int AutoFillServiceSummary = 2131296433;
|
||||
|
||||
// aapt resource value: 0x7f090050
|
||||
public const int Hello = 2131296336;
|
||||
|
||||
// aapt resource value: 0x7f0900ac
|
||||
public const int MyVault = 2131296428;
|
||||
// aapt resource value: 0x7f0900b3
|
||||
public const int MyVault = 2131296435;
|
||||
|
||||
// aapt resource value: 0x7f090027
|
||||
public const int abc_action_bar_home_description = 2131296295;
|
||||
|
@ -6640,6 +6640,27 @@ namespace Bit.Android
|
|||
// aapt resource value: 0x7f09000f
|
||||
public const int common_signin_button_text_long = 2131296271;
|
||||
|
||||
// aapt resource value: 0x7f0900ac
|
||||
public const int default_web_client_id = 2131296428;
|
||||
|
||||
// aapt resource value: 0x7f0900ad
|
||||
public const int firebase_database_url = 2131296429;
|
||||
|
||||
// aapt resource value: 0x7f0900aa
|
||||
public const int gcm_defaultSenderId = 2131296426;
|
||||
|
||||
// aapt resource value: 0x7f0900ae
|
||||
public const int google_api_key = 2131296430;
|
||||
|
||||
// aapt resource value: 0x7f0900ab
|
||||
public const int google_app_id = 2131296427;
|
||||
|
||||
// aapt resource value: 0x7f0900af
|
||||
public const int google_crash_reporting_api_key = 2131296431;
|
||||
|
||||
// aapt resource value: 0x7f0900b0
|
||||
public const int google_storage_bucket = 2131296432;
|
||||
|
||||
// aapt resource value: 0x7f090052
|
||||
public const int hockeyapp_crash_dialog_app_name_fallback = 2131296338;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using Bit.App.Abstractions;
|
||||
using FFImageLoading.Forms;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Xamarin.Forms;
|
||||
using XLabs.Ioc;
|
||||
|
||||
|
@ -150,6 +151,7 @@ namespace Bit.App.Controls
|
|||
}
|
||||
}
|
||||
}
|
||||
public Dictionary<string, object> MetaData { get; set; }
|
||||
|
||||
public void InitEvents()
|
||||
{
|
||||
|
|
|
@ -452,7 +452,7 @@ namespace Bit.App.Pages
|
|||
TextColor = Colors.Primary
|
||||
};
|
||||
UrisSection.Add(AddUriCell);
|
||||
UrisSection.Insert(0, Helpers.MakeUriCell(string.Empty, UrisSection));
|
||||
UrisSection.Insert(0, Helpers.MakeUriCell(string.Empty, null, UrisSection, this));
|
||||
}
|
||||
else if(_type == CipherType.Card)
|
||||
{
|
||||
|
@ -833,7 +833,7 @@ namespace Bit.App.Pages
|
|||
|
||||
private void AddUriCell_Tapped(object sender, EventArgs e)
|
||||
{
|
||||
var cell = Helpers.MakeUriCell(string.Empty, UrisSection);
|
||||
var cell = Helpers.MakeUriCell(string.Empty, null, UrisSection, this);
|
||||
if(cell != null)
|
||||
{
|
||||
UrisSection.Insert(UrisSection.Count - 1, cell);
|
||||
|
|
|
@ -223,7 +223,8 @@ namespace Bit.App.Pages
|
|||
foreach(var uri in Cipher.Login.Uris)
|
||||
{
|
||||
var value = uri.Uri?.Decrypt(Cipher.OrganizationId);
|
||||
UrisSection.Insert(UrisSection.Count - 1, Helpers.MakeUriCell(value, UrisSection));
|
||||
UrisSection.Insert(UrisSection.Count - 1,
|
||||
Helpers.MakeUriCell(value, uri.Match, UrisSection, this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -930,7 +931,7 @@ namespace Bit.App.Pages
|
|||
|
||||
private void AddUriCell_Tapped(object sender, EventArgs e)
|
||||
{
|
||||
var cell = Helpers.MakeUriCell(string.Empty, UrisSection);
|
||||
var cell = Helpers.MakeUriCell(string.Empty, null, UrisSection, this);
|
||||
if(cell != null)
|
||||
{
|
||||
UrisSection.Insert(UrisSection.Count - 1, cell);
|
||||
|
|
63
src/App/Resources/AppResources.Designer.cs
generated
63
src/App/Resources/AppResources.Designer.cs
generated
|
@ -420,6 +420,15 @@ namespace Bit.App.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Base Domain.
|
||||
/// </summary>
|
||||
public static string BaseDomain {
|
||||
get {
|
||||
return ResourceManager.GetString("BaseDomain", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Beta.
|
||||
/// </summary>
|
||||
|
@ -924,6 +933,15 @@ namespace Bit.App.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Default.
|
||||
/// </summary>
|
||||
public static string Default {
|
||||
get {
|
||||
return ResourceManager.GetString("Default", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Delete.
|
||||
/// </summary>
|
||||
|
@ -1158,6 +1176,15 @@ namespace Bit.App.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Exact.
|
||||
/// </summary>
|
||||
public static string Exact {
|
||||
get {
|
||||
return ResourceManager.GetString("Exact", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Re-enable App Extension.
|
||||
/// </summary>
|
||||
|
@ -1554,6 +1581,15 @@ namespace Bit.App.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Host.
|
||||
/// </summary>
|
||||
public static string Host {
|
||||
get {
|
||||
return ResourceManager.GetString("Host", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Icons.
|
||||
/// </summary>
|
||||
|
@ -2472,6 +2508,15 @@ namespace Bit.App.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Regular expression.
|
||||
/// </summary>
|
||||
public static string RegEx {
|
||||
get {
|
||||
return ResourceManager.GetString("RegEx", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Remember me.
|
||||
/// </summary>
|
||||
|
@ -2706,6 +2751,15 @@ namespace Bit.App.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Starts with.
|
||||
/// </summary>
|
||||
public static string StartsWith {
|
||||
get {
|
||||
return ResourceManager.GetString("StartsWith", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to State / Province.
|
||||
/// </summary>
|
||||
|
@ -2949,6 +3003,15 @@ namespace Bit.App.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to URI Match Detection.
|
||||
/// </summary>
|
||||
public static string URIMatchDetection {
|
||||
get {
|
||||
return ResourceManager.GetString("URIMatchDetection", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to URI {0}.
|
||||
/// </summary>
|
||||
|
|
|
@ -1256,4 +1256,27 @@
|
|||
<value>URI {0}</value>
|
||||
<comment>Label for a uri/url with position. i.e. URI 1, URI 2, etc</comment>
|
||||
</data>
|
||||
<data name="BaseDomain" xml:space="preserve">
|
||||
<value>Base Domain</value>
|
||||
</data>
|
||||
<data name="Default" xml:space="preserve">
|
||||
<value>Default</value>
|
||||
</data>
|
||||
<data name="Exact" xml:space="preserve">
|
||||
<value>Exact</value>
|
||||
</data>
|
||||
<data name="Host" xml:space="preserve">
|
||||
<value>Host</value>
|
||||
<comment>A URL's host value. For example, the host of https://sub.domain.com:443 is 'sub.domain.com:443'.</comment>
|
||||
</data>
|
||||
<data name="RegEx" xml:space="preserve">
|
||||
<value>Regular expression</value>
|
||||
<comment>A programming term, also known as 'RegEx'.</comment>
|
||||
</data>
|
||||
<data name="StartsWith" xml:space="preserve">
|
||||
<value>Starts with</value>
|
||||
</data>
|
||||
<data name="URIMatchDetection" xml:space="preserve">
|
||||
<value>URI Match Detection</value>
|
||||
</data>
|
||||
</root>
|
|
@ -18,6 +18,15 @@ namespace Bit.App.Utilities
|
|||
public static class Helpers
|
||||
{
|
||||
public static readonly DateTime Epoc = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
public static IDictionary<UriMatchType?, string> UriMatchOptionsMap = new Dictionary<UriMatchType?, string>
|
||||
{
|
||||
[UriMatchType.Domain] = AppResources.BaseDomain,
|
||||
[UriMatchType.Host] = AppResources.Host,
|
||||
[UriMatchType.StartsWith] = AppResources.StartsWith,
|
||||
[UriMatchType.RegularExpression] = AppResources.RegEx,
|
||||
[UriMatchType.Exact] = AppResources.Exact,
|
||||
[UriMatchType.Never] = AppResources.Never
|
||||
};
|
||||
|
||||
public static long EpocUtcNow()
|
||||
{
|
||||
|
@ -374,13 +383,14 @@ namespace Bit.App.Utilities
|
|||
}
|
||||
}
|
||||
|
||||
public static FormEntryCell MakeUriCell(string value, TableSection urisSection)
|
||||
public static FormEntryCell MakeUriCell(string value, UriMatchType? match, TableSection urisSection, Page page)
|
||||
{
|
||||
var label = string.Format(AppResources.URIPosition, urisSection.Count);
|
||||
var cell = new FormEntryCell(label, entryKeyboard: Keyboard.Url);
|
||||
cell.Entry.Text = value;
|
||||
cell.Entry.DisableAutocapitalize = true;
|
||||
cell.Entry.Autocorrect = false;
|
||||
cell.MetaData = new Dictionary<string, object> { ["match"] = match };
|
||||
|
||||
var deleteAction = new MenuItem { Text = AppResources.Remove, IsDestructive = true };
|
||||
deleteAction.Clicked += (sender, e) =>
|
||||
|
@ -407,7 +417,28 @@ namespace Bit.App.Utilities
|
|||
var optionsAction = new MenuItem { Text = AppResources.Options };
|
||||
optionsAction.Clicked += async (sender, e) =>
|
||||
{
|
||||
var options = UriMatchOptionsMap.Select(v => v.Value).ToList();
|
||||
options.Insert(0, AppResources.Default);
|
||||
var exactingMatchVal = cell.MetaData["match"] as UriMatchType?;
|
||||
|
||||
var matchIndex = exactingMatchVal.HasValue ?
|
||||
Array.IndexOf(UriMatchOptionsMap.Keys.ToArray(), exactingMatchVal) + 1 : 0;
|
||||
options[matchIndex] = $"✓ {options[matchIndex]}";
|
||||
|
||||
var optionsArr = options.ToArray();
|
||||
var val = await page.DisplayActionSheet(AppResources.URIMatchDetection, AppResources.Cancel,
|
||||
null, options.ToArray());
|
||||
|
||||
UriMatchType? selectedVal = null;
|
||||
if(val == AppResources.Cancel)
|
||||
{
|
||||
selectedVal = exactingMatchVal;
|
||||
}
|
||||
else if(val != AppResources.Default)
|
||||
{
|
||||
selectedVal = UriMatchOptionsMap.ElementAt(Array.IndexOf(optionsArr, val) - 1).Key;
|
||||
}
|
||||
cell.MetaData["match"] = selectedVal;
|
||||
};
|
||||
|
||||
cell.ContextActions.Add(optionsAction);
|
||||
|
@ -424,10 +455,11 @@ namespace Bit.App.Utilities
|
|||
{
|
||||
if(cell is FormEntryCell entryCell && !string.IsNullOrWhiteSpace(entryCell.Entry.Text))
|
||||
{
|
||||
var match = entryCell?.MetaData["match"] as UriMatchType?;
|
||||
uris.Add(new LoginUri
|
||||
{
|
||||
Uri = entryCell.Entry.Text.Encrypt(cipher.OrganizationId),
|
||||
Match = null
|
||||
Match = match
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue