mirror of
https://github.com/moparisthebest/keepass2android
synced 2025-02-07 02:10:10 -05:00
Allow to add new custom icons
ChangeLog/Manifest 0.9.9-pre1
This commit is contained in:
parent
1bca643c3f
commit
2bff468242
@ -26,6 +26,7 @@ namespace keepass2android
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(ctx, Android.Resource.Style.ThemeHoloLightDialog));
|
||||
builder.SetTitle(ctx.GetString(Resource.String.ChangeLog_title));
|
||||
List<string> changeLog = new List<string>{
|
||||
ctx.GetString(Resource.String.ChangeLog_0_9_9),
|
||||
ctx.GetString(Resource.String.ChangeLog_0_9_8c),
|
||||
ctx.GetString(Resource.String.ChangeLog_0_9_8b),
|
||||
ctx.GetString(Resource.String.ChangeLog_0_9_8),
|
||||
|
@ -16,6 +16,7 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.Graphics;
|
||||
@ -24,6 +25,8 @@ using Android.Views;
|
||||
using Android.Widget;
|
||||
using KeePassLib;
|
||||
using KeePassLib.Utility;
|
||||
using FileNotFoundException = Java.IO.FileNotFoundException;
|
||||
using IOException = Java.IO.IOException;
|
||||
|
||||
namespace keepass2android
|
||||
{
|
||||
@ -67,8 +70,86 @@ namespace keepass2android
|
||||
Finish();
|
||||
};
|
||||
}
|
||||
|
||||
public class ImageAdapter : BaseAdapter
|
||||
|
||||
private const int AddCustomIconId = 1;
|
||||
private const int RequestCodePickImage = 2;
|
||||
|
||||
public override bool OnCreateOptionsMenu(IMenu menu)
|
||||
{
|
||||
|
||||
base.OnCreateOptionsMenu(menu);
|
||||
|
||||
menu.Add(0, AddCustomIconId, 0, GetString(Resource.String.AddCustomIcon));
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public override bool OnOptionsItemSelected(IMenuItem item)
|
||||
{
|
||||
if (item.ItemId == AddCustomIconId)
|
||||
{
|
||||
Intent intent = new Intent();
|
||||
intent.SetType("image/*");
|
||||
intent.SetAction(Intent.ActionGetContent);
|
||||
intent.AddCategory(Intent.CategoryOpenable);
|
||||
StartActivityForResult(intent, RequestCodePickImage);
|
||||
}
|
||||
|
||||
return base.OnOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
|
||||
{
|
||||
|
||||
base.OnActivityResult(requestCode, resultCode, data);
|
||||
|
||||
if (requestCode == RequestCodePickImage && resultCode == Result.Ok)
|
||||
try
|
||||
{
|
||||
var stream = ContentResolver.OpenInputStream(data.Data);
|
||||
var bitmap = BitmapFactory.DecodeStream(stream);
|
||||
|
||||
stream.Close();
|
||||
|
||||
float maxSize = 128;
|
||||
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
if ((bitmap.Width > maxSize) || (bitmap.Height > maxSize))
|
||||
{
|
||||
float scale = Math.Min(maxSize / bitmap.Width, maxSize / bitmap.Height);
|
||||
var scaleWidth = (int)(bitmap.Width * scale);
|
||||
var scaleHeight = (int)(bitmap.Height * scale);
|
||||
var scaledBitmap = Bitmap.CreateScaledBitmap(bitmap, scaleWidth, scaleHeight, true);
|
||||
Bitmap newRectBitmap = Bitmap.CreateBitmap((int)maxSize, (int)maxSize, Bitmap.Config.Argb8888);
|
||||
|
||||
Canvas c = new Canvas(newRectBitmap);
|
||||
c.DrawBitmap(scaledBitmap, (maxSize - scaledBitmap.Width)/2.0f, (maxSize - scaledBitmap.Height)/2.0f, null);
|
||||
bitmap = newRectBitmap;
|
||||
}
|
||||
;
|
||||
bitmap.Compress(Bitmap.CompressFormat.Png, 90, ms);
|
||||
PwCustomIcon pwci = new PwCustomIcon(new PwUuid(true), ms.ToArray());
|
||||
|
||||
App.Kp2a.GetDb().KpDatabase.CustomIcons.Add(pwci);
|
||||
|
||||
}
|
||||
var gridView = ((GridView)FindViewById(Resource.Id.IconGridView));
|
||||
((BaseAdapter)gridView.Adapter).NotifyDataSetInvalidated();
|
||||
gridView.SmoothScrollToPosition(((BaseAdapter)gridView.Adapter).Count-1);
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
e.PrintStackTrace();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.PrintStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public class ImageAdapter : BaseAdapter
|
||||
{
|
||||
readonly IconPickerActivity _act;
|
||||
private readonly PwDatabase _db;
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:versionCode="60"
|
||||
android:versionName="0.9.8c"
|
||||
android:versionCode="61"
|
||||
android:versionName="0.9.9-pre1"
|
||||
package="keepass2android.keepass2android"
|
||||
android:installLocation="auto">
|
||||
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21" />
|
||||
|
@ -531,6 +531,8 @@
|
||||
<string name="CopyFileRequiredForEditing">To edit it, you must copy the file to another location.</string>
|
||||
<string name="ClickOkToSelectLocation">Click OK to select a location where the file should be copied.</string>
|
||||
<string name="CancelReadOnly">Cancel, open read-only.</string>
|
||||
|
||||
<string name="AddCustomIcon">Add icon from file...</string>
|
||||
|
||||
<string name="CopyingFile">Copying file...</string>
|
||||
|
||||
@ -547,6 +549,16 @@
|
||||
* Bug fix: Previous release contained two input methods (one crashing)\n
|
||||
</string>
|
||||
|
||||
<string name="ChangeLog_0_9_9">
|
||||
Version 0.9.9\n
|
||||
* Complete UI redesign. Thanks a lot to Stefano Pignataro (http://www.spstudio.at) for his support!\n
|
||||
* Support for Multi Window mode on Samsung devices\n
|
||||
* Increased default number of encryption rounds for new databases\n
|
||||
* Check for duplicate keys of additional fields to avoid losing data\n
|
||||
* Allow to add custom icons
|
||||
</string>
|
||||
|
||||
|
||||
<string name="ChangeLog_0_9_8b">
|
||||
Version 0.9.8b\n
|
||||
* Bug fixes (Saving failed for some databases, exporting to local device not working, selecting some preference options crashed the app)\n
|
||||
|
Loading…
Reference in New Issue
Block a user