1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-09 20:13:18 +00:00

EC-295 Fixed Android swipe and added vibration when cipher username/password gets copied

This commit is contained in:
Federico Andrés Maccaroni
2022-07-25 15:40:57 -03:00
parent 9e7c462153
commit 3878ea4e09
5 changed files with 36 additions and 21 deletions

View File

@@ -12,6 +12,7 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>

View File

@@ -14,7 +14,7 @@ namespace Bit.Droid.Renderers
protected override void OnElementChanged(ElementChangedEventArgs<View> elementChangedEvent)
{
base.OnElementChanged(elementChangedEvent);
if (elementChangedEvent.NewElement != null)
if (elementChangedEvent.NewElement is ExtendedGrid extGrid && extGrid.ApplyRipple)
{
SetBackgroundResource(Resource.Drawable.list_item_bg);
}

View File

@@ -4,5 +4,6 @@ namespace Bit.App.Controls
{
public class ExtendedGrid : Grid
{
public bool ApplyRipple { get; set; } = true;
}
}

View File

@@ -53,41 +53,39 @@
WebsiteIconsEnabled="{Binding BindingContext.WebsiteIconsEnabled, Source={x:Reference _page}}" />
</DataTemplate>
<!--Threshold="{Binding Source={x:Reference _page}, Path=SwipeThreshold}"-->
<DataTemplate x:Key="loginCipherTemplate"
x:DataType="pages:GroupingsPageListItem">
<SwipeView Threshold="{Binding Source={x:Reference _page}, Path=SwipeThreshold}">
<SwipeView>
<SwipeView.LeftItems>
<SwipeItems Mode="Execute">
<SwipeItem Text="{u:I18n CopyUsername}"
BackgroundColor="{DynamicResource PrimaryColor}"
Command="{Binding Source={x:Reference _page}, Path=BindingContext.CopyUsernameItemCommand}"
CommandParameter="{Binding .}">
<SwipeItem.IconImageSource>
<controls:IconFontImageSource
Glyph="{Binding Source={x:Static core:BitwardenIcons.Clone}}"
Color="{DynamicResource TextColor}"/>
</SwipeItem.IconImageSource>
</SwipeItem>
</SwipeItems>
</SwipeView.LeftItems>
<SwipeView.RightItems>
<SwipeItems Mode="Execute">
<SwipeItem Text="{u:I18n CopyPassword}"
<SwipeItems>
<SwipeItem
BackgroundColor="{DynamicResource PrimaryColor}"
Command="{Binding Source={x:Reference _page}, Path=BindingContext.CopyPasswordItemCommand}"
CommandParameter="{Binding .}">
<SwipeItem.IconImageSource>
<controls:IconFontImageSource
Glyph="{Binding Source={x:Static core:BitwardenIcons.Clone}}"
Glyph="{Binding Source={x:Static core:BitwardenIcons.Key}}"
Color="{DynamicResource TextColor}" />
</SwipeItem.IconImageSource>
</SwipeItem>
<SwipeItem
BackgroundColor="{DynamicResource InfoColor}"
Command="{Binding Source={x:Reference _page}, Path=BindingContext.CopyUsernameItemCommand}"
CommandParameter="{Binding .}">
<SwipeItem.IconImageSource>
<controls:IconFontImageSource
Glyph="{Binding Source={x:Static core:BitwardenIcons.User}}"
Color="{DynamicResource TextColor}"/>
</SwipeItem.IconImageSource>
</SwipeItem>
</SwipeItems>
</SwipeView.RightItems>
</SwipeView.LeftItems>
<controls:CipherViewCell
Cipher="{Binding Cipher}"
ButtonCommand="{Binding BindingContext.CipherOptionsCommand, Source={x:Reference _page}}"
WebsiteIconsEnabled="{Binding BindingContext.WebsiteIconsEnabled, Source={x:Reference _page}}"
ApplyRipple="False"
BackgroundColor="{DynamicResource BackgroundColor}"/>
</SwipeView>
</DataTemplate>

View File

@@ -5,7 +5,6 @@ using System.Threading.Tasks;
using Bit.App.Abstractions;
using Bit.App.Controls;
using Bit.App.Resources;
using Bit.App.Utilities;
using Bit.App.Utilities.Helpers;
using Bit.Core.Abstractions;
using Bit.Core.Enums;
@@ -645,6 +644,14 @@ namespace Bit.App.Pages
if (listItem is GroupingsPageListItem groupPageListItem && groupPageListItem.Cipher?.Type == CipherType.Login)
{
await _cipherHelper.CopyUsernameAsync(groupPageListItem.Cipher);
try
{
Xamarin.Essentials.Vibration.Vibrate();
}
catch (Xamarin.Essentials.FeatureNotSupportedException)
{
}
}
}
@@ -653,6 +660,14 @@ namespace Bit.App.Pages
if (listItem is GroupingsPageListItem groupPageListItem && groupPageListItem.Cipher?.Type == CipherType.Login)
{
await _cipherHelper.CopyPasswordAsync(groupPageListItem.Cipher);
try
{
Xamarin.Essentials.Vibration.Vibrate();
}
catch (Xamarin.Essentials.FeatureNotSupportedException)
{
}
}
}
}