update file storage selection to use icon from https://developers.google.com/drive/api/v3/branding

This commit is contained in:
Philipp Crocoll
2022-01-12 08:28:09 +01:00
parent fe57c05579
commit 952aaa76ff
5 changed files with 22 additions and 44 deletions

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 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="500dp"
android:numColumns="1"
android:columnWidth="90dp"
android:numColumns="auto_fit"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:stretchMode="columnWidth"

View File

@@ -454,6 +454,7 @@
<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" />
@@ -1074,6 +1075,9 @@
<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>
@@ -1914,9 +1918,6 @@
<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.