prototype implementation using the "Sign in with Google" button

This commit is contained in:
Philipp Crocoll
2022-01-12 08:11:18 +01:00
parent 309fd9f4d1
commit fe57c05579
6 changed files with 44 additions and 23 deletions

View File

@@ -117,20 +117,34 @@ namespace keepass2android
Button btn;
if (convertView == null)
var protocolId = _displayedProtocolIds[position];
string firstProtocolInList = protocolId.Split(",").First();
String title =
protocolId == "kp2a" ? App.Kp2a.GetResourceString("get_regular_version")
:
App.Kp2a.GetStorageMainTypeDisplayName(firstProtocolInList);
if (convertView == null)
{ // if it's not recycled, initialize some attributes
btn = new Button(_context);
btn.LayoutParameters = new GridView.LayoutParams((int)convertDpToPixel(90, _context), (int)convertDpToPixel(110, _context));
btn.SetBackgroundResource(Resource.Drawable.storagetype_button_bg);
btn.SetPadding((int)convertDpToPixel(4, _context),
(int)convertDpToPixel(20, _context),
btn.LayoutParameters = new GridView.LayoutParams((int)convertDpToPixel(250, _context), (int)convertDpToPixel(45, _context));
btn.SetBackgroundColor(Color.White);
if (title == "Google Drive")
btn.SetPadding((int)convertDpToPixel(0, _context),
(int)convertDpToPixel(0, _context),
(int)convertDpToPixel(0, _context),
(int)convertDpToPixel(0, _context));
else
btn.SetPadding((int)convertDpToPixel(12, _context),
(int)convertDpToPixel(12, _context),
(int)convertDpToPixel(4, _context),
(int)convertDpToPixel(4, _context));
btn.SetTextSize(ComplexUnitType.Sp, 11);
btn.SetTextSize(ComplexUnitType.Sp, 14);
btn.SetTextColor(new Color(115, 115, 115));
btn.SetSingleLine(false);
btn.Gravity = GravityFlags.Center;
btn.SetSingleLine(true);
btn.Gravity = GravityFlags.Left;
btn.Click += (sender, args) => _context.OnItemSelected( (string) ((Button)sender).Tag);
}
else
@@ -138,23 +152,32 @@ namespace keepass2android
btn = (Button)convertView;
}
var protocolId = _displayedProtocolIds[position];
btn.Tag = protocolId;
string firstProtocolInList = protocolId.Split(",").First();
Drawable drawable = App.Kp2a.GetStorageIcon(firstProtocolInList);
String title =
protocolId == "kp2a" ? App.Kp2a.GetResourceString("get_regular_version")
:
App.Kp2a.GetStorageMainTypeDisplayName(firstProtocolInList);
var str = new SpannableString(title);
bool isdrive = (title == "Google Drive");
if (title == "Google Drive")
title = "";
var str = new SpannableString(" " + title);
btn.TextFormatted = str;
//var drawable = ContextCompat.GetDrawable(context, Resource.Drawable.Icon);
btn.SetCompoundDrawablesWithIntrinsicBounds(null, drawable, null, null);
if (!isdrive)
{
drawable.SetBounds(0, 0, 75, 75);
btn.SetCompoundDrawables(drawable, null, null, null);
}
else
btn.SetCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
return btn;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -26,8 +26,8 @@
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
android:layout_marginTop="0dp"
android:columnWidth="90dp"
android:numColumns="auto_fit"
android:columnWidth="500dp"
android:numColumns="1"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:stretchMode="columnWidth"

View File

@@ -594,7 +594,6 @@
<string name="filestoragename_dropboxKP2A">Dropbox (KP2A folder)</string>
<string name="filestoragehelp_dropboxKP2A">If you do not want to give KP2A access to your full Dropbox, you may select this option. It will request only access to the folder Apps/Keepass2Android. This is especially suited when creating a new database. If you already have a database, select this option to create the folder, then place your file inside the folder (from your PC) and then select this option again for opening the file.</string>
<string name="filestoragename_gdrive">Google Drive</string>
<string name="filestoragehelp_gdrive">Please note: I have requested verification of the app by Google, but nothing has happened since months. If you see a message saying that the app is blocked because it is not verified, please use Android filebrowser - Google Drive instead of this option.</string>
<string name="filestoragename_pcloud">PCloud</string>
<string name="filestoragehelp_pcloud">This storage type will only request access to the pCloud folder "Applications/Keepass2Android". If you want to use an existing database from your pCloud account, please make sure the file is placed in this pCloud folder.</string>
<string name="filestoragename_onedrive">OneDrive</string>

View File

@@ -454,7 +454,6 @@
<AndroidResource Include="Resources\drawable-mdpi\ic_storage_file.png" />
<AndroidResource Include="Resources\drawable-mdpi\ic_storage_ftp.png" />
<AndroidResource Include="Resources\drawable-mdpi\ic_storage_ftps.png" />
<AndroidResource Include="Resources\drawable-mdpi\ic_storage_gdrive.png" />
<AndroidResource Include="Resources\drawable-mdpi\ic_storage_http.png" />
<AndroidResource Include="Resources\drawable-mdpi\ic_storage_https.png" />
<AndroidResource Include="Resources\drawable-mdpi\ic_storage_owncloud.png" />
@@ -1075,9 +1074,6 @@
<ItemGroup>
<AndroidResource Include="Resources\drawable-xhdpi\ic_storage_ftps.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable-xhdpi\ic_storage_gdrive.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable-xhdpi\ic_storage_http.png" />
</ItemGroup>
@@ -1918,6 +1914,9 @@
<Name>ZlibAndroid</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable-xhdpi\ic_storage_gdrive.png" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.