mirror of
https://github.com/moparisthebest/keepass2android
synced 2025-01-30 14:40:21 -05:00
Merge branch '1.0.0e'
Conflicts: src/java/JavaFileStorage/app/app.iml src/keepass2android/CreateDatabaseActivity.cs src/keepass2android/Properties/AndroidManifest_net.xml
This commit is contained in:
commit
f5d3aed721
@ -103,15 +103,7 @@ namespace keepass2android
|
||||
if (_restoringInstanceState)
|
||||
return;
|
||||
|
||||
string defaulFilename = _keyfileFilename;
|
||||
if (_keyfileFilename == null)
|
||||
{
|
||||
defaulFilename = _keyfileFilename = SdDir + "keyfile.txt";
|
||||
if (defaulFilename.StartsWith("file://") == false)
|
||||
defaulFilename = "file://" + defaulFilename;
|
||||
}
|
||||
|
||||
new FileSelectHelper(this, false, RequestCodeKeyFile).StartFileChooser(defaulFilename);
|
||||
Util.ShowBrowseDialog(this, RequestCodeKeyFile, false, true);
|
||||
|
||||
}
|
||||
else
|
||||
@ -193,7 +185,13 @@ namespace keepass2android
|
||||
{
|
||||
try
|
||||
{
|
||||
newKey.AddUserKey(new KcpKeyFile(_keyfileFilename));
|
||||
var ioc = IOConnectionInfo.FromPath(_keyfileFilename);
|
||||
using (var stream = App.Kp2a.GetFileStorage(ioc).OpenFileForRead(ioc))
|
||||
{
|
||||
byte[] keyfileData = Util.StreamToMemoryStream(stream).ToArray();
|
||||
newKey.AddUserKey(new KcpKeyFile(keyfileData, ioc, true));
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@ -343,14 +341,38 @@ namespace keepass2android
|
||||
{
|
||||
if (requestCode == RequestCodeKeyFile)
|
||||
{
|
||||
string filename = Util.IntentToFilename(data, this);
|
||||
if (filename != null)
|
||||
if (data.Data.Scheme == "content")
|
||||
{
|
||||
if ((int)Build.VERSION.SdkInt >= 19)
|
||||
{
|
||||
//try to take persistable permissions
|
||||
try
|
||||
{
|
||||
Kp2aLog.Log("TakePersistableUriPermission");
|
||||
var takeFlags = data.Flags
|
||||
& (ActivityFlags.GrantReadUriPermission
|
||||
| ActivityFlags.GrantWriteUriPermission);
|
||||
this.ContentResolver.TakePersistableUriPermission(data.Data, takeFlags);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string filename = Util.IntentToFilename(data, this);
|
||||
if (filename == null)
|
||||
filename = data.DataString;
|
||||
|
||||
|
||||
_keyfileFilename = ConvertFilenameToIocPath(filename);
|
||||
FindViewById<TextView>(Resource.Id.keyfile_filename).Text = _keyfileFilename;
|
||||
FindViewById(Resource.Id.keyfile_filename).Visibility = ViewStates.Visible;
|
||||
|
||||
}
|
||||
}
|
||||
if (requestCode == RequestCodeDbFilename)
|
||||
{
|
||||
|
||||
|
@ -1390,10 +1390,16 @@ namespace keepass2android
|
||||
private void PerformLoadDatabaseWithCompositeKey(CompositeKey compositeKey)
|
||||
{
|
||||
CheckBox cbQuickUnlock = (CheckBox) FindViewById(Resource.Id.enable_quickunlock);
|
||||
if (cbQuickUnlock == null)
|
||||
throw new NullPointerException("cpQuickUnlock");
|
||||
App.Kp2a.SetQuickUnlockEnabled(cbQuickUnlock.Checked);
|
||||
|
||||
if (App.Kp2a.OfflineMode != _loadDbTaskOffline)
|
||||
{
|
||||
if (_loadDbTask == null)
|
||||
throw new NullPointerException("_loadDbTask");
|
||||
if (App.Kp2a == null)
|
||||
throw new NullPointerException("App.Kp2a");
|
||||
//keep the loading result if we loaded in online-mode (now offline) and the task is completed
|
||||
if (!App.Kp2a.OfflineMode || !_loadDbTask.IsCompleted)
|
||||
{
|
||||
@ -1532,11 +1538,11 @@ namespace keepass2android
|
||||
|
||||
protected override void OnPause()
|
||||
{
|
||||
base.OnPause();
|
||||
if (_fingerprintDec != null)
|
||||
{
|
||||
_fingerprintDec.StopListening();
|
||||
}
|
||||
base.OnPause();
|
||||
}
|
||||
|
||||
private void SetPasswordTypeface(TextView textView)
|
||||
@ -1607,21 +1613,7 @@ namespace keepass2android
|
||||
|
||||
private static MemoryStream StreamToMemoryStream(Stream stream)
|
||||
{
|
||||
var memoryStream = stream as MemoryStream;
|
||||
if (memoryStream == null)
|
||||
{
|
||||
// Read the stream into memory
|
||||
int capacity = 4096; // Default initial capacity, if stream can't report it.
|
||||
if (stream.CanSeek)
|
||||
{
|
||||
capacity = (int) stream.Length;
|
||||
}
|
||||
memoryStream = new MemoryStream(capacity);
|
||||
stream.CopyTo(memoryStream);
|
||||
stream.Close();
|
||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||
}
|
||||
return memoryStream;
|
||||
return Util.StreamToMemoryStream(stream);
|
||||
}
|
||||
|
||||
protected override void OnSaveInstanceState(Bundle outState)
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:versionCode="83"
|
||||
android:versionCode="84"
|
||||
android:versionName="1.01-pre2"
|
||||
package="keepass2android.keepass2android"
|
||||
android:installLocation="auto">
|
||||
|
@ -361,12 +361,13 @@ namespace keepass2android
|
||||
|
||||
protected override void OnPause()
|
||||
{
|
||||
base.OnPause();
|
||||
if (_fingerprintIdentifier != null)
|
||||
{
|
||||
Kp2aLog.Log("FP: Stop listening");
|
||||
_fingerprintIdentifier.StopListening();
|
||||
}
|
||||
|
||||
base.OnPause();
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
|
@ -482,6 +482,27 @@ namespace keepass2android
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static MemoryStream StreamToMemoryStream(Stream stream)
|
||||
{
|
||||
|
||||
var memoryStream = stream as MemoryStream;
|
||||
if (memoryStream == null)
|
||||
{
|
||||
// Read the stream into memory
|
||||
int capacity = 4096; // Default initial capacity, if stream can't report it.
|
||||
if (stream.CanSeek)
|
||||
{
|
||||
capacity = (int) stream.Length;
|
||||
}
|
||||
memoryStream = new MemoryStream(capacity);
|
||||
stream.CopyTo(memoryStream);
|
||||
stream.Close();
|
||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||
}
|
||||
return memoryStream;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user