mirror of
https://github.com/bitwarden/android.git
synced 2025-01-11 18:57:39 +03:00
scan totp key
This commit is contained in:
parent
b5522c1b5e
commit
bfa336b72d
5 changed files with 60 additions and 7 deletions
|
@ -124,14 +124,34 @@
|
|||
Grid.Column="3"
|
||||
Grid.RowSpan="2" />
|
||||
</Grid>
|
||||
<StackLayout StyleClass="box-row">
|
||||
|
||||
<Grid StyleClass="box-row, box-row-input">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label
|
||||
Text="{u:I18n AuthenticatorKey}"
|
||||
StyleClass="box-label" />
|
||||
StyleClass="box-label"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0" />
|
||||
<controls:MonoEntry
|
||||
Text="{Binding Cipher.Login.Totp}"
|
||||
StyleClass="box-value" />
|
||||
</StackLayout>
|
||||
StyleClass="box-value"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0" />
|
||||
<controls:FaButton
|
||||
StyleClass="box-row-button, box-row-button-platform"
|
||||
Text=""
|
||||
Clicked="ScanTotp_Clicked"
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Grid.RowSpan="2" />
|
||||
</Grid>
|
||||
</StackLayout>
|
||||
<StackLayout IsVisible="{Binding IsCard}" Spacing="0" Padding="0">
|
||||
<StackLayout StyleClass="box-row, box-row-input">
|
||||
|
|
|
@ -157,5 +157,21 @@ namespace Bit.App.Pages
|
|||
await Navigation.PushModalAsync(new NavigationPage(page));
|
||||
}
|
||||
}
|
||||
|
||||
private async void ScanTotp_Clicked(object sender, System.EventArgs e)
|
||||
{
|
||||
if(DoOnce())
|
||||
{
|
||||
var page = new ScanPage(key =>
|
||||
{
|
||||
Device.BeginInvokeOnMainThread(async () =>
|
||||
{
|
||||
await Navigation.PopModalAsync();
|
||||
await _vm.UpdateTotpKeyAsync(key);
|
||||
});
|
||||
});
|
||||
await Navigation.PushModalAsync(new NavigationPage(page));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -576,6 +576,23 @@ namespace Bit.App.Pages
|
|||
ShowCardCode = !ShowCardCode;
|
||||
}
|
||||
|
||||
public async Task UpdateTotpKeyAsync(string key)
|
||||
{
|
||||
if(Cipher?.Login != null)
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(key))
|
||||
{
|
||||
Cipher.Login.Totp = key;
|
||||
TriggerCipherChanged();
|
||||
_platformUtilsService.ShowToast("info", null, AppResources.AuthenticatorKeyAdded);
|
||||
}
|
||||
else
|
||||
{
|
||||
await _platformUtilsService.ShowDialogAsync(AppResources.AuthenticatorKeyReadError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void TypeChanged()
|
||||
{
|
||||
if(Cipher != null && TypeSelectedIndex > -1)
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
Grid.Row="0"
|
||||
VerticalOptions="Center"
|
||||
HorizontalOptions="Center"
|
||||
BackgroundColor="White" />
|
||||
TextColor="White" />
|
||||
|
||||
<BoxView
|
||||
Grid.Column="0"
|
||||
|
@ -70,7 +70,7 @@
|
|||
Grid.Row="2"
|
||||
VerticalOptions="Center"
|
||||
HorizontalOptions="Center"
|
||||
BackgroundColor="White" />
|
||||
TextColor="White" />
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
|
|
|
@ -14,13 +14,13 @@ namespace Bit.App.Pages
|
|||
public ScanPage(Action<string> callback)
|
||||
{
|
||||
_callback = callback;
|
||||
InitializeComponent();
|
||||
_zxing.Options = new ZXing.Mobile.MobileBarcodeScanningOptions
|
||||
{
|
||||
UseNativeScanning = true,
|
||||
PossibleFormats = new List<ZXing.BarcodeFormat> { ZXing.BarcodeFormat.QR_CODE },
|
||||
AutoRotate = false,
|
||||
};
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnAppearing()
|
||||
|
|
Loading…
Reference in a new issue