mirror of
https://github.com/bitwarden/mobile
synced 2025-12-17 16:53:26 +00:00
stub native cipher view cell for android
This commit is contained in:
@@ -117,6 +117,7 @@
|
||||
<Compile Include="Receivers\ClearClipboardAlarmReceiver.cs" />
|
||||
<Compile Include="Receivers\LockAlarmReceiver.cs" />
|
||||
<Compile Include="Receivers\PackageReplacedReceiver.cs" />
|
||||
<Compile Include="Renderers\CipherViewCellRenderer.cs" />
|
||||
<Compile Include="Renderers\ExtendedSliderRenderer.cs" />
|
||||
<Compile Include="Renderers\CustomEditorRenderer.cs" />
|
||||
<Compile Include="Renderers\CustomPickerRenderer.cs" />
|
||||
@@ -552,5 +553,11 @@
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable-xxxhdpi\refresh_sm.png" />
|
||||
</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" />
|
||||
</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>
|
||||
Reference in New Issue
Block a user