mirror of
https://github.com/bitwarden/android.git
synced 2025-01-11 18:57:39 +03:00
stub native cipher view cell for android
This commit is contained in:
parent
d199c83a61
commit
d7bfc64840
5 changed files with 553 additions and 433 deletions
|
@ -117,6 +117,7 @@
|
||||||
<Compile Include="Receivers\ClearClipboardAlarmReceiver.cs" />
|
<Compile Include="Receivers\ClearClipboardAlarmReceiver.cs" />
|
||||||
<Compile Include="Receivers\LockAlarmReceiver.cs" />
|
<Compile Include="Receivers\LockAlarmReceiver.cs" />
|
||||||
<Compile Include="Receivers\PackageReplacedReceiver.cs" />
|
<Compile Include="Receivers\PackageReplacedReceiver.cs" />
|
||||||
|
<Compile Include="Renderers\CipherViewCellRenderer.cs" />
|
||||||
<Compile Include="Renderers\ExtendedSliderRenderer.cs" />
|
<Compile Include="Renderers\ExtendedSliderRenderer.cs" />
|
||||||
<Compile Include="Renderers\CustomEditorRenderer.cs" />
|
<Compile Include="Renderers\CustomEditorRenderer.cs" />
|
||||||
<Compile Include="Renderers\CustomPickerRenderer.cs" />
|
<Compile Include="Renderers\CustomPickerRenderer.cs" />
|
||||||
|
@ -552,5 +553,11 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AndroidResource Include="Resources\drawable-xxxhdpi\refresh_sm.png" />
|
<AndroidResource Include="Resources\drawable-xxxhdpi\refresh_sm.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<AndroidResource Include="Resources\layout\CipherViewCell.axml">
|
||||||
|
<Generator>MSBuild:UpdateGeneratedFiles</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</AndroidResource>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
61
src/Android/Renderers/CipherViewCellRenderer.cs
Normal file
61
src/Android/Renderers/CipherViewCellRenderer.cs
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
using Android.App;
|
||||||
|
using Android.Content;
|
||||||
|
using Android.Views.InputMethods;
|
||||||
|
using Android.Widget;
|
||||||
|
using Bit.App.Controls;
|
||||||
|
using Bit.Droid.Renderers;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
using Xamarin.Forms.Platform.Android;
|
||||||
|
|
||||||
|
[assembly: ExportRenderer(typeof(CipherViewCell), typeof(CipherViewCellRenderer))]
|
||||||
|
namespace Bit.Droid.Renderers
|
||||||
|
{
|
||||||
|
public class CipherViewCellRenderer : ViewCellRenderer
|
||||||
|
{
|
||||||
|
protected override Android.Views.View GetCellCore(Cell item, Android.Views.View convertView,
|
||||||
|
Android.Views.ViewGroup parent, Context context)
|
||||||
|
{
|
||||||
|
var cipherCell = item as CipherViewCell;
|
||||||
|
if(!(convertView is AndroidCipherCell cell))
|
||||||
|
{
|
||||||
|
cell = new AndroidCipherCell(context, cipherCell);
|
||||||
|
}
|
||||||
|
cell.CipherViewCell.PropertyChanged += CellPropertyChanged;
|
||||||
|
cell.CipherViewCell = cipherCell;
|
||||||
|
cell.CipherViewCell.PropertyChanged -= CellPropertyChanged;
|
||||||
|
cell.UpdateCell();
|
||||||
|
return cell;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CellPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
var nativeCell = sender as AndroidCipherCell;
|
||||||
|
if(e.PropertyName == CipherViewCell.CipherProperty.PropertyName)
|
||||||
|
{
|
||||||
|
nativeCell.UpdateCell();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AndroidCipherCell : LinearLayout, INativeElementView
|
||||||
|
{
|
||||||
|
public AndroidCipherCell(Context context, CipherViewCell cipherCell)
|
||||||
|
: base(context)
|
||||||
|
{
|
||||||
|
var view = (context as Activity).LayoutInflater.Inflate(Resource.Layout.CipherViewCell, null);
|
||||||
|
CipherViewCell = cipherCell;
|
||||||
|
Title = view.FindViewById<TextView>(Resource.Id.CipherCellTitle);
|
||||||
|
AddView(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CipherViewCell CipherViewCell { get; set; }
|
||||||
|
public Element Element => CipherViewCell;
|
||||||
|
public TextView Title { get; set; }
|
||||||
|
|
||||||
|
public void UpdateCell()
|
||||||
|
{
|
||||||
|
Title.Text = CipherViewCell.Cipher.Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
726
src/Android/Resources/Resource.designer.cs
generated
726
src/Android/Resources/Resource.designer.cs
generated
File diff suppressed because it is too large
Load diff
38
src/Android/Resources/layout/CipherViewCell.axml
Normal file
38
src/Android/Resources/layout/CipherViewCell.axml
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:minHeight="44dp"
|
||||||
|
android:paddingLeft="15dp"
|
||||||
|
android:paddingRight="15dp"
|
||||||
|
android:paddingTop="8dp"
|
||||||
|
android:paddingBottom="8dp">
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/CipherCellContent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_toLeftOf="@+id/CipherCellButton"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/CipherCellTitle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="left"
|
||||||
|
android:paddingRight="6dp"
|
||||||
|
android:layout_gravity="left|center_vertical" />
|
||||||
|
</LinearLayout>
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/CipherCellButton"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingLeft="5dp"
|
||||||
|
android:gravity="center_vertical" />
|
||||||
|
</RelativeLayout>
|
|
@ -5,86 +5,88 @@
|
||||||
xmlns:controls="clr-namespace:Bit.App.Controls"
|
xmlns:controls="clr-namespace:Bit.App.Controls"
|
||||||
xmlns:ff="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms">
|
xmlns:ff="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms">
|
||||||
<ViewCell.View>
|
<ViewCell.View>
|
||||||
|
<OnPlatform x:TypeArguments="View">
|
||||||
|
<On Platform="iOS">
|
||||||
|
<Grid x:Name="_grid"
|
||||||
|
StyleClass="list-row, list-row-platform"
|
||||||
|
RowSpacing="0"
|
||||||
|
ColumnSpacing="0"
|
||||||
|
x:DataType="controls:CipherViewCellViewModel">
|
||||||
|
|
||||||
<Grid x:Name="_grid"
|
<Grid.BindingContext>
|
||||||
StyleClass="list-row, list-row-platform"
|
<controls:CipherViewCellViewModel />
|
||||||
RowSpacing="0"
|
</Grid.BindingContext>
|
||||||
ColumnSpacing="0"
|
|
||||||
x:DataType="controls:CipherViewCellViewModel">
|
|
||||||
|
|
||||||
<Grid.BindingContext>
|
<Grid.RowDefinitions>
|
||||||
<controls:CipherViewCellViewModel />
|
<RowDefinition Height="*" />
|
||||||
</Grid.BindingContext>
|
<RowDefinition Height="*" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="40" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="60" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<Grid.RowDefinitions>
|
<controls:FaLabel x:Name="_icon"
|
||||||
<RowDefinition Height="*" />
|
Grid.Column="0"
|
||||||
<RowDefinition Height="*" />
|
Grid.Row="0"
|
||||||
</Grid.RowDefinitions>
|
Grid.RowSpan="2"
|
||||||
<Grid.ColumnDefinitions>
|
HorizontalOptions="Center"
|
||||||
<ColumnDefinition Width="40" />
|
VerticalOptions="Center"
|
||||||
<ColumnDefinition Width="Auto" />
|
StyleClass="list-icon" />
|
||||||
<ColumnDefinition Width="Auto" />
|
<ff:CachedImage x:Name="_image"
|
||||||
<ColumnDefinition Width="*" />
|
Grid.Column="0"
|
||||||
<ColumnDefinition Width="60" />
|
Grid.Row="0"
|
||||||
</Grid.ColumnDefinitions>
|
Grid.RowSpan="2"
|
||||||
|
BitmapOptimizations="True"
|
||||||
|
ErrorPlaceholder="login.png"
|
||||||
|
HorizontalOptions="Center"
|
||||||
|
VerticalOptions="Center"
|
||||||
|
WidthRequest="22"
|
||||||
|
HeightRequest="22"
|
||||||
|
IsVisible="False"/>
|
||||||
|
<Label LineBreakMode="TailTruncation"
|
||||||
|
Grid.Column="1"
|
||||||
|
Grid.Row="0"
|
||||||
|
StyleClass="list-title, list-title-platform"
|
||||||
|
Text="{Binding Cipher.Name, Mode=OneWay}" />
|
||||||
|
<Label LineBreakMode="TailTruncation"
|
||||||
|
Grid.Column="1"
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.ColumnSpan="3"
|
||||||
|
StyleClass="list-subtitle, list-subtitle-platform"
|
||||||
|
Text="{Binding Cipher.SubTitle, Mode=OneWay}" />
|
||||||
|
|
||||||
<controls:FaLabel x:Name="_icon"
|
<controls:FaLabel
|
||||||
Grid.Column="0"
|
Grid.Column="2"
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
Grid.RowSpan="2"
|
HorizontalOptions="Start"
|
||||||
HorizontalOptions="Center"
|
VerticalOptions="Center"
|
||||||
VerticalOptions="Center"
|
StyleClass="list-title-icon"
|
||||||
StyleClass="list-icon" />
|
Margin="5, 0, 0, 0"
|
||||||
<ff:CachedImage x:Name="_image"
|
Text=""
|
||||||
Grid.Column="0"
|
IsVisible="{Binding Cipher.Shared, Mode=OneWay}" />
|
||||||
Grid.Row="0"
|
<controls:FaLabel
|
||||||
Grid.RowSpan="2"
|
Grid.Column="3"
|
||||||
BitmapOptimizations="True"
|
Grid.Row="0"
|
||||||
ErrorPlaceholder="login.png"
|
HorizontalOptions="Start"
|
||||||
HorizontalOptions="Center"
|
VerticalOptions="Center"
|
||||||
VerticalOptions="Center"
|
StyleClass="list-title-icon"
|
||||||
WidthRequest="22"
|
Margin="5, 0, 0, 0"
|
||||||
HeightRequest="22"
|
Text=""
|
||||||
IsVisible="False"/>
|
IsVisible="{Binding Cipher.HasAttachments, Mode=OneWay}" />
|
||||||
<Label LineBreakMode="TailTruncation"
|
|
||||||
Grid.Column="1"
|
|
||||||
Grid.Row="0"
|
|
||||||
StyleClass="list-title, list-title-platform"
|
|
||||||
Text="{Binding Cipher.Name, Mode=OneWay}" />
|
|
||||||
<Label LineBreakMode="TailTruncation"
|
|
||||||
Grid.Column="1"
|
|
||||||
Grid.Row="1"
|
|
||||||
Grid.ColumnSpan="3"
|
|
||||||
StyleClass="list-subtitle, list-subtitle-platform"
|
|
||||||
Text="{Binding Cipher.SubTitle, Mode=OneWay}" />
|
|
||||||
|
|
||||||
<controls:FaLabel
|
|
||||||
Grid.Column="2"
|
|
||||||
Grid.Row="0"
|
|
||||||
HorizontalOptions="Start"
|
|
||||||
VerticalOptions="Center"
|
|
||||||
StyleClass="list-title-icon"
|
|
||||||
Margin="5, 0, 0, 0"
|
|
||||||
Text=""
|
|
||||||
IsVisible="{Binding Cipher.Shared, Mode=OneWay}" />
|
|
||||||
<controls:FaLabel
|
|
||||||
Grid.Column="3"
|
|
||||||
Grid.Row="0"
|
|
||||||
HorizontalOptions="Start"
|
|
||||||
VerticalOptions="Center"
|
|
||||||
StyleClass="list-title-icon"
|
|
||||||
Margin="5, 0, 0, 0"
|
|
||||||
Text=""
|
|
||||||
IsVisible="{Binding Cipher.HasAttachments, Mode=OneWay}" />
|
|
||||||
|
|
||||||
<controls:MiButton
|
|
||||||
Text=""
|
|
||||||
StyleClass="list-row-button, list-row-button-platform, btn-disabled"
|
|
||||||
Clicked="ImageButton_Clicked"
|
|
||||||
Grid.Column="4"
|
|
||||||
Grid.Row="0"
|
|
||||||
Grid.RowSpan="2" />
|
|
||||||
</Grid>
|
|
||||||
|
|
||||||
|
<controls:MiButton
|
||||||
|
Text=""
|
||||||
|
StyleClass="list-row-button, list-row-button-platform, btn-disabled"
|
||||||
|
Clicked="ImageButton_Clicked"
|
||||||
|
Grid.Column="4"
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.RowSpan="2" />
|
||||||
|
</Grid>
|
||||||
|
</On>
|
||||||
|
</OnPlatform>
|
||||||
</ViewCell.View>
|
</ViewCell.View>
|
||||||
</ViewCell>
|
</ViewCell>
|
||||||
|
|
Loading…
Reference in a new issue