Compare commits
149 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
2dc125e0ce | ||
![]() |
9c88ce213b | ||
![]() |
026de5dd4e | ||
![]() |
262897fbf6 | ||
![]() |
304a9d90d0 | ||
![]() |
91e1674833 | ||
![]() |
ee63946be2 | ||
![]() |
b1bcfacf35 | ||
![]() |
d4936e8eec | ||
![]() |
dbba098555 | ||
![]() |
b368e93061 | ||
![]() |
10b333ae48 | ||
![]() |
87c0345a6a | ||
![]() |
381510d213 | ||
![]() |
f5f99f5a04 | ||
![]() |
fcf1214f80 | ||
![]() |
7e122529d2 | ||
![]() |
600c3d21dc | ||
![]() |
135d7ebda5 | ||
![]() |
267d710c13 | ||
![]() |
5c9cf0a655 | ||
![]() |
337297e3e0 | ||
![]() |
26def9805f | ||
![]() |
5429876cde | ||
![]() |
6301b48b5d | ||
![]() |
5dea97cce2 | ||
![]() |
69b63bcb15 | ||
![]() |
d13b2d236b | ||
![]() |
9dce637d22 | ||
![]() |
dbb291fb86 | ||
![]() |
cefad66475 | ||
![]() |
726f4438d6 | ||
![]() |
880e75a91c | ||
![]() |
0f1fd0e367 | ||
![]() |
7a44cf6e26 | ||
![]() |
bc2dc1b2e9 | ||
![]() |
2d9429d688 | ||
![]() |
62f3ff1902 | ||
![]() |
36735cdfbe | ||
![]() |
f57db90d7b | ||
![]() |
97aec23384 | ||
![]() |
eb3bcf04ea | ||
![]() |
40626ba708 | ||
![]() |
882597365b | ||
![]() |
6b456c2f57 | ||
![]() |
515ae57e88 | ||
![]() |
9cc9d6ab66 | ||
![]() |
40b4fd210a | ||
![]() |
2ce2d0efab | ||
![]() |
97a863293d | ||
![]() |
d45426a4c1 | ||
![]() |
d5a49db782 | ||
![]() |
4b393f412c | ||
![]() |
8cc77fbe1d | ||
![]() |
673632bd92 | ||
![]() |
d2b9a5d1a9 | ||
![]() |
2bc46b0a0e | ||
![]() |
74200daf90 | ||
![]() |
b89c127df4 | ||
![]() |
67bbbb2097 | ||
![]() |
c6ddf0de87 | ||
![]() |
0ef73952b1 | ||
![]() |
0e02a3aeee | ||
![]() |
1558a7c386 | ||
![]() |
b72becd328 | ||
![]() |
df2ac8e203 | ||
![]() |
c6c230002c | ||
![]() |
885503b5fa | ||
![]() |
40fd91257e | ||
![]() |
02ece3cf41 | ||
![]() |
901c879647 | ||
![]() |
990a73f4a4 | ||
![]() |
73169d339d | ||
![]() |
265b86c031 | ||
![]() |
7c29c23015 | ||
![]() |
538e579477 | ||
![]() |
73db5f55e2 | ||
![]() |
31a9980343 | ||
![]() |
02c50f510f | ||
![]() |
3541ee0512 | ||
![]() |
e72821ba1e | ||
![]() |
3af00871a5 | ||
![]() |
22fe4ca790 | ||
![]() |
72d0570c15 | ||
![]() |
62e0cc0867 | ||
![]() |
8987480491 | ||
![]() |
70bb4c2478 | ||
![]() |
cf079a6be4 | ||
![]() |
f153cdcba1 | ||
![]() |
4e048240c5 | ||
![]() |
c098bb1ca0 | ||
![]() |
e02ded734c | ||
![]() |
e721f29f5a | ||
![]() |
f763d5f936 | ||
![]() |
a3368eb557 | ||
![]() |
b5758347c2 | ||
![]() |
775a6d92aa | ||
![]() |
2ab5995177 | ||
![]() |
f6e847d43f | ||
![]() |
cac2ca3d18 | ||
![]() |
d1e870cee0 | ||
![]() |
ca0f65767b | ||
![]() |
7968bfc262 | ||
![]() |
ed4bbe9814 | ||
![]() |
6e83eb6da2 | ||
![]() |
00949b6135 | ||
![]() |
f3a857f26f | ||
![]() |
4bd03372aa | ||
![]() |
dcc589c57a | ||
![]() |
3018ec8cf0 | ||
![]() |
c452a66a4f | ||
![]() |
7a860f8564 | ||
![]() |
94f6f4bdff | ||
![]() |
a627dac4b7 | ||
![]() |
848b6862be | ||
![]() |
d181575e93 | ||
![]() |
778775055f | ||
![]() |
22ccda8d34 | ||
![]() |
c5fc6fd72e | ||
![]() |
c8a4978b5f | ||
![]() |
9e88f8c884 | ||
![]() |
2e543bf4d3 | ||
![]() |
caf42d423f | ||
![]() |
dc39f874ac | ||
![]() |
d1c7a124cf | ||
![]() |
8ec17ce9a6 | ||
![]() |
012af35e87 | ||
![]() |
78bd1f4a5d | ||
![]() |
4477158182 | ||
![]() |
6e96021047 | ||
![]() |
48f57eea66 | ||
![]() |
4b6cfefaf3 | ||
![]() |
0e34cc7f26 | ||
![]() |
27fb2870ab | ||
![]() |
ee6b7c4fe0 | ||
![]() |
0464cecde5 | ||
![]() |
b237259599 | ||
![]() |
8c379739f0 | ||
![]() |
4fb8db982c | ||
![]() |
921b50b642 | ||
![]() |
031332e8ab | ||
![]() |
f03ccced8d | ||
![]() |
51973d225c | ||
![]() |
a59666e752 | ||
![]() |
8259191e50 | ||
![]() |
82f28bfc8c | ||
![]() |
a1d6347db3 | ||
![]() |
e66a8a0b21 | ||
![]() |
186fa35f70 |
6
crowdin.yml
Normal file
6
crowdin.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
files:
|
||||
- source: src/keepass2android/Resources/values/strings.xml
|
||||
translation: >-
|
||||
/src/keepass2android/Resources/values-%two_letters_code%/%original_file_name%
|
||||
translate_attributes: '0'
|
||||
content_segmentation: '0'
|
@@ -7,11 +7,12 @@ If you think something is missing in the documentation, please create an issue a
|
||||
If you store important information using Keepass2Android, you should know a little bit about what's going on:
|
||||
* Keepass2Android stores your password in an encrypted file. It is *your responsibility* to backup this file regularly and safely.
|
||||
* There is no way for anyone, including the app's author, to access the information stored in your password database without
|
||||
** having the database file
|
||||
** knowing the master password (and additional second factor if you chose one)
|
||||
This means that **if you forget the master password, your database is lost**! So make sure you remember the password. You might also want to think about:
|
||||
** What happens if I have an accident? Should any trusted person be able to access my database?
|
||||
** What happens if my phone gets lost or stolen? Do I know how to recover my database from a backup or the cloud?
|
||||
* having the database file
|
||||
* knowing the master password (and additional second factor if you chose one)
|
||||
This means that **if you forget the master password, your database is lost**! So make sure you remember the password and retain any second factor method (if one is used).
|
||||
* You might also want to think about:
|
||||
* What happens if I have an accident? Should any trusted person be able to access my database?
|
||||
* What happens if my phone gets lost or stolen? Do I know how to recover my database from a backup or the cloud?
|
||||
|
||||
|
||||
# Getting started
|
||||
|
@@ -4,28 +4,28 @@
|
||||
on how to set up a Keepass 2 database with Yubikey/OTP protection.<br>
|
||||
<br>
|
||||
After successful setup you should have the database file, e.g. yubi.kdbx, and the OTP auxiliary file, e.g. yubi.otp.xml, both in the same folder.<br>
|
||||
<a href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=keepass2android&DownloadId=767825"><img title="OTPAuxFile" src="http://download-codeplex.sec.s-msft.com/Download?ProjectName=keepass2android&DownloadId=767826" alt="OTPAuxFile" width="513" height="40" border="0" style="padding-top:0px; padding-left:0px; display:inline; padding-right:0px; border:0px"></a></p>
|
||||
<a href="How to use Keepass2Android with YubiKey NEO_OTPAuxFile_2.png"><img title="OTPAuxFile" src="How to use Keepass2Android with YubiKey NEO_OTPAuxFile_thumb.png" alt="OTPAuxFile" width="513" height="40" border="0" style="padding-top:0px; padding-left:0px; display:inline; padding-right:0px; border:0px"></a></p>
|
||||
<p>Make sure you make <strong>both files</strong> available to Keepass2Android, e.g. by placing them both in your Dropbox.</p>
|
||||
<p>Now you should check your NDEF setup of the Yubikey NEO. Therefore, go to the Tools menu in the Yubico Personalization Utility. Select the same slot as used for OTPs with Keepass 2. The default setting for NDEF type and payload should work. If you experience
|
||||
problems, you may use the configuration as shown in this screenshot or simply press the “Reset” button:</p>
|
||||
<p><a href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=keepass2android&DownloadId=767911"><img title="image" src="http://download-codeplex.sec.s-msft.com/Download?ProjectName=keepass2android&DownloadId=767912" alt="image" width="760" height="622" border="0" style="padding-top:0px; padding-left:0px; display:inline; padding-right:0px; border:0px"></a></p>
|
||||
<p><a href="How to use Keepass2Android with YubiKey NEO_image_2.png"><img title="image" src="How to use Keepass2Android with YubiKey NEO_image_thumb.png" alt="image" width="760" height="622" border="0" style="padding-top:0px; padding-left:0px; display:inline; padding-right:0px; border:0px"></a></p>
|
||||
<p><br>
|
||||
<br>
|
||||
In Keepass2Android, select "Open file" and locate your database file, e.g. yubi.kdbx.<br>
|
||||
<br>
|
||||
In the password screen under "Select master key type" select "Password + OTP".</p>
|
||||
<p><a href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=keepass2android&DownloadId=767913"><img title="Screenshot_2013-12-13-06-38-50" src="http://download-codeplex.sec.s-msft.com/Download?ProjectName=keepass2android&DownloadId=767914" alt="Screenshot_2013-12-13-06-38-50" width="204" height="360" border="0" style="padding-top:0px; padding-left:0px; display:inline; padding-right:0px; border:0px"></a></p>
|
||||
<p><a href="How to use Keepass2Android with YubiKey NEO_Screenshot_2013-12-13-06-38-50_2.png"><img title="Screenshot_2013-12-13-06-38-50" src="How to use Keepass2Android with YubiKey NEO_Screenshot_2013-12-13-06-38-50_thumb.png" alt="Screenshot_2013-12-13-06-38-50" width="204" height="360" border="0" style="padding-top:0px; padding-left:0px; display:inline; padding-right:0px; border:0px"></a></p>
|
||||
<p>Click "Load auxiliary OTP file". This is required to load the information how many OTPs must be entered. As loading the file might require user action in some cases, this is not performed automatically.<br>
|
||||
<a href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=keepass2android&DownloadId=767915"><img title="Screenshot_2013-12-13-06-38-12" src="http://download-codeplex.sec.s-msft.com/Download?ProjectName=keepass2android&DownloadId=767916" alt="Screenshot_2013-12-13-06-38-12" width="204" height="360" border="0" style="padding-top:0px; padding-left:0px; display:inline; padding-right:0px; border:0px"></a><br>
|
||||
<a href="How to use Keepass2Android with YubiKey NEO_Screenshot_2013-12-13-06-38-12_2.png"><img title="Screenshot_2013-12-13-06-38-12" src="How to use Keepass2Android with YubiKey NEO_Screenshot_2013-12-13-06-38-12_thumb.png" alt="Screenshot_2013-12-13-06-38-12" width="204" height="360" border="0" style="padding-top:0px; padding-left:0px; display:inline; padding-right:0px; border:0px"></a><br>
|
||||
After loading the OTP auxiliary file, you should see a few text fields for entering the OTPs. Now swipe your YubiKey NEO at the back of your Android device. If you have multiple apps which can handle NFC actions, you might be prompted to select which app to
|
||||
use. Select Keepass2Android in this case. Swipe your YubiKey again until all OTP fields are filled. Note: You don't need to select the next text field, this is done automatically!<br>
|
||||
<a href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=keepass2android&DownloadId=767917"><img title="Screenshot_2013-12-13-06-38-36" src="http://download-codeplex.sec.s-msft.com/Download?ProjectName=keepass2android&DownloadId=767918" alt="Screenshot_2013-12-13-06-38-36" width="204" height="360" border="0" style="padding-top:0px; padding-left:0px; display:inline; padding-right:0px; border:0px"></a><br>
|
||||
<a href="How to use Keepass2Android with YubiKey NEO_Screenshot_2013-12-13-06-38-36_2.png"><img title="Screenshot_2013-12-13-06-38-36" src="How to use Keepass2Android with YubiKey NEO_Screenshot_2013-12-13-06-38-36_thumb.png" alt="Screenshot_2013-12-13-06-38-36" width="204" height="360" border="0" style="padding-top:0px; padding-left:0px; display:inline; padding-right:0px; border:0px"></a><br>
|
||||
Don't forget to also enter your password and click OK. You will see the “Saving auxiliary OTP file…” dialog. Note that there is some encryption envolved which is probably fast on your PC but might take some time on your mobile device. You
|
||||
can reduce the look-ahead window length to speed this up.<br>
|
||||
<a href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=keepass2android&DownloadId=767919"><img title="Screenshot_2013-12-13-06-39-47" src="http://download-codeplex.sec.s-msft.com/Download?ProjectName=keepass2android&DownloadId=767920" alt="Screenshot_2013-12-13-06-39-47" width="204" height="360" border="0" style="padding-top:0px; padding-left:0px; display:inline; padding-right:0px; border:0px"></a></p>
|
||||
<a href="How to use Keepass2Android with YubiKey NEO_Screenshot_2013-12-13-06-39-47_2.png"><img title="Screenshot_2013-12-13-06-39-47" src="How to use Keepass2Android with YubiKey NEO_Screenshot_2013-12-13-06-39-47_thumb.png" alt="Screenshot_2013-12-13-06-39-47" width="204" height="360" border="0" style="padding-top:0px; padding-left:0px; display:inline; padding-right:0px; border:0px"></a></p>
|
||||
<h2> </h2>
|
||||
<h2>A note about offline access</h2>
|
||||
<p>If your database is stored in the cloud or on the web, you can still access it if you have enabled file caching (which is on by default). With OTPs, this becomes a little bit more complicated: If you repeatedly open your datbase while being offline, the
|
||||
OTP counter stored on the Yubikey will be increased. Don’t forget to synchronize the database (which will also synchronize the OTP auxiliary file) as soon as possible to avoid problems with accessing your database on other devices! If you often need
|
||||
to open the database while you’re offline, consider increasing the look-ahead window length!</p>
|
||||
</div><div class="ClearBoth"></div>
|
||||
</div><div class="ClearBoth"></div>
|
||||
|
BIN
graphics/launcher_icon/Logo-green-96.png
Normal file
BIN
graphics/launcher_icon/Logo-green-96.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
64
src/AdalBindings/AdalBindings.csproj
Normal file
64
src/AdalBindings/AdalBindings.csproj
Normal file
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{0B109C0E-0514-4340-8779-5BD6A0DDE84E}</ProjectGuid>
|
||||
<ProjectTypeGuids>{10368E6C-D01B-4462-8E8B-01FC667A7035};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>AdalBindings</RootNamespace>
|
||||
<AssemblyName>AdalBindings</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
|
||||
<TargetFrameworkVersion>v8.1</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Mono.Android" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Jars\AboutJars.txt" />
|
||||
<None Include="Additions\AboutAdditions.txt" />
|
||||
<LibraryProjectZip Include="Jars\adal-1.14.0.aar" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<TransformFile Include="Transforms\Metadata.xml" />
|
||||
<TransformFile Include="Transforms\EnumFields.xml" />
|
||||
<TransformFile Include="Transforms\EnumMethods.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedReferenceJar Include="Jars\gson-2.3.1.jar" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.Bindings.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.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
48
src/AdalBindings/Additions/AboutAdditions.txt
Normal file
48
src/AdalBindings/Additions/AboutAdditions.txt
Normal file
@@ -0,0 +1,48 @@
|
||||
Additions allow you to add arbitrary C# to the generated classes
|
||||
before they are compiled. This can be helpful for providing convenience
|
||||
methods or adding pure C# classes.
|
||||
|
||||
== Adding Methods to Generated Classes ==
|
||||
|
||||
Let's say the library being bound has a Rectangle class with a constructor
|
||||
that takes an x and y position, and a width and length size. It will look like
|
||||
this:
|
||||
|
||||
public partial class Rectangle
|
||||
{
|
||||
public Rectangle (int x, int y, int width, int height)
|
||||
{
|
||||
// JNI bindings
|
||||
}
|
||||
}
|
||||
|
||||
Imagine we want to add a constructor to this class that takes a Point and
|
||||
Size structure instead of 4 ints. We can add a new file called Rectangle.cs
|
||||
with a partial class containing our new method:
|
||||
|
||||
public partial class Rectangle
|
||||
{
|
||||
public Rectangle (Point location, Size size) :
|
||||
this (location.X, location.Y, size.Width, size.Height)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
At compile time, the additions class will be added to the generated class
|
||||
and the final assembly will a Rectangle class with both constructors.
|
||||
|
||||
|
||||
== Adding C# Classes ==
|
||||
|
||||
Another thing that can be done is adding fully C# managed classes to the
|
||||
generated library. In the above example, let's assume that there isn't a
|
||||
Point class available in Java or our library. The one we create doesn't need
|
||||
to interact with Java, so we'll create it like a normal class in C#.
|
||||
|
||||
By adding a Point.cs file with this class, it will end up in the binding library:
|
||||
|
||||
public class Point
|
||||
{
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
}
|
24
src/AdalBindings/Jars/AboutJars.txt
Normal file
24
src/AdalBindings/Jars/AboutJars.txt
Normal file
@@ -0,0 +1,24 @@
|
||||
This directory is for Android .jars.
|
||||
|
||||
There are 2 types of jars that are supported:
|
||||
|
||||
== Input Jar ==
|
||||
|
||||
This is the jar that bindings should be generated for.
|
||||
|
||||
For example, if you were binding the Google Maps library, this would
|
||||
be Google's "maps.jar".
|
||||
|
||||
Set the build action for these jars in the properties page to "InputJar".
|
||||
|
||||
|
||||
== Reference Jars ==
|
||||
|
||||
These are jars that are referenced by the input jar. C# bindings will
|
||||
not be created for these jars. These jars will be used to resolve
|
||||
types used by the input jar.
|
||||
|
||||
NOTE: Do not add "android.jar" as a reference jar. It will be added automatically
|
||||
based on the Target Framework selected.
|
||||
|
||||
Set the build action for these jars in the properties page to "ReferenceJar".
|
BIN
src/AdalBindings/Jars/gson-2.3.1.jar
Normal file
BIN
src/AdalBindings/Jars/gson-2.3.1.jar
Normal file
Binary file not shown.
30
src/AdalBindings/Properties/AssemblyInfo.cs
Normal file
30
src/AdalBindings/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using Android.App;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("AdalBindings")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("AdalBindings")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
14
src/AdalBindings/Transforms/EnumFields.xml
Normal file
14
src/AdalBindings/Transforms/EnumFields.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<enum-field-mappings>
|
||||
<!--
|
||||
This example converts the constants Fragment_id, Fragment_name,
|
||||
and Fragment_tag from android.support.v4.app.FragmentActivity.FragmentTag
|
||||
to an enum called Android.Support.V4.App.FragmentTagType with values
|
||||
Id, Name, and Tag.
|
||||
|
||||
<mapping jni-class="android/support/v4/app/FragmentActivity$FragmentTag" clr-enum-type="Android.Support.V4.App.FragmentTagType">
|
||||
<field jni-name="Fragment_name" clr-name="Name" value="0" />
|
||||
<field jni-name="Fragment_id" clr-name="Id" value="1" />
|
||||
<field jni-name="Fragment_tag" clr-name="Tag" value="2" />
|
||||
</mapping>
|
||||
-->
|
||||
</enum-field-mappings>
|
13
src/AdalBindings/Transforms/EnumMethods.xml
Normal file
13
src/AdalBindings/Transforms/EnumMethods.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<enum-method-mappings>
|
||||
<!--
|
||||
This example changes the Java method:
|
||||
android.support.v4.app.Fragment.SavedState.writeToParcel (int flags)
|
||||
to be:
|
||||
android.support.v4.app.Fragment.SavedState.writeToParcel (Android.OS.ParcelableWriteFlags flags)
|
||||
when bound in C#.
|
||||
|
||||
<mapping jni-class="android/support/v4/app/Fragment.SavedState">
|
||||
<method jni-name="writeToParcel" parameter="flags" clr-enum-type="Android.OS.ParcelableWriteFlags" />
|
||||
</mapping>
|
||||
-->
|
||||
</enum-method-mappings>
|
13
src/AdalBindings/Transforms/Metadata.xml
Normal file
13
src/AdalBindings/Transforms/Metadata.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<metadata>
|
||||
<!--
|
||||
This sample removes the class: android.support.v4.content.AsyncTaskLoader.LoadTask:
|
||||
<remove-node path="/api/package[@name='android.support.v4.content']/class[@name='AsyncTaskLoader.LoadTask']" />
|
||||
|
||||
This sample removes the method: android.support.v4.content.CursorLoader.loadInBackground:
|
||||
<remove-node path="/api/package[@name='android.support.v4.content']/class[@name='CursorLoader']/method[@name='loadInBackground']" />
|
||||
-->
|
||||
<remove-node path="/api/package[@name='com.microsoft.aad.adal']/class[@name='AuthenticationActivity']" />
|
||||
<remove-node path="/api/package[@name='com.microsoft.aad.adal']/class[@name='DateTimeAdapter']" />
|
||||
<remove-node path="/api/package[@name='com.microsoft.aad.adal']" />
|
||||
|
||||
</metadata>
|
@@ -26,6 +26,7 @@
|
||||
android:hint="@string/http_auth_dialog_password"
|
||||
android:inputType="textPassword"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="20dp" />
|
||||
android:paddingBottom="20dp"
|
||||
android:importantForAccessibility="no" />
|
||||
|
||||
</LinearLayout>
|
@@ -60,7 +60,6 @@
|
||||
</LibraryProjectZip>
|
||||
<None Include="Jars\AboutJars.txt" />
|
||||
<None Include="Additions\AboutAdditions.txt" />
|
||||
<LibraryProjectZip Include="Jars\adal-1.14.0.aar" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<TransformFile Include="Transforms\Metadata.xml" />
|
||||
@@ -81,6 +80,13 @@
|
||||
<Visible>False</Visible>
|
||||
</XamarinComponentReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AdalBindings\AdalBindings.csproj">
|
||||
<Project>{0b109c0e-0514-4340-8779-5bd6a0dde84e}</Project>
|
||||
<Name>AdalBindings</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\PCloudBindings\PCloudBindings.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedReferenceJar Include="Jars\okhttp-digest-1.7.jar" />
|
||||
</ItemGroup>
|
||||
|
@@ -11,6 +11,8 @@
|
||||
<remove-node path="/api/package[@name='com.jcraft.jsch.jcraft']" />
|
||||
<remove-node path="/api/package[@name='com.jcraft.jzlib']" />
|
||||
|
||||
<remove-node path="/api/package[@name='com.pcloud.sdk']" />
|
||||
|
||||
<remove-node path="/api/package[@name='com.dropbox.core']" />
|
||||
<remove-node path="/api/package[@name='com.dropbox.core.util']" />
|
||||
<remove-node path="/api/package[@name='com.dropbox.core.http']" />
|
||||
|
@@ -27,6 +27,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Net.FtpClient.Androi
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SamsungPass", "SamsungPass\Xamarin.SamsungPass\SamsungPass\SamsungPass.csproj", "{3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PCloudBindings", "PCloudBindings\PCloudBindings.csproj", "{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdalBindings", "AdalBindings\AdalBindings.csproj", "{0B109C0E-0514-4340-8779-5BD6A0DDE84E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -156,19 +160,25 @@ Global
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Debug|Win32.ActiveCfg = Debug|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Debug|Win32.Build.0 = Debug|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Release|Win32.Build.0 = Release|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.ReleaseNoNet|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.ReleaseNoNet|Any CPU.Build.0 = Release|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.Release|x64.Build.0 = Release|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.ReleaseNoNet|Any CPU.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.ReleaseNoNet|Any CPU.Build.0 = ReleaseNoNet|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.ReleaseNoNet|Mixed Platforms.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.ReleaseNoNet|Mixed Platforms.Build.0 = ReleaseNoNet|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.ReleaseNoNet|Win32.ActiveCfg = Release|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.ReleaseNoNet|x64.ActiveCfg = Release|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.ReleaseNoNet|Win32.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.ReleaseNoNet|Win32.Build.0 = ReleaseNoNet|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.ReleaseNoNet|x64.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{48574278-4779-4B3A-A9E4-9CF1BC285D0B}.ReleaseNoNet|x64.Build.0 = ReleaseNoNet|Any CPU
|
||||
{3C0F7FE5-639F-4422-A087-8B26CF862D1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3C0F7FE5-639F-4422-A087-8B26CF862D1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3C0F7FE5-639F-4422-A087-8B26CF862D1B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
@@ -283,6 +293,54 @@ Global
|
||||
{3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.ReleaseNoNet|Mixed Platforms.Build.0 = ReleaseNoNet|Any CPU
|
||||
{3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.ReleaseNoNet|Win32.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.ReleaseNoNet|x64.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Debug|Win32.ActiveCfg = Debug|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Debug|Win32.Build.0 = Debug|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Release|Win32.Build.0 = Release|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.Release|x64.Build.0 = Release|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.ReleaseNoNet|Any CPU.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.ReleaseNoNet|Any CPU.Build.0 = ReleaseNoNet|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.ReleaseNoNet|Mixed Platforms.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.ReleaseNoNet|Mixed Platforms.Build.0 = ReleaseNoNet|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.ReleaseNoNet|Win32.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.ReleaseNoNet|Win32.Build.0 = ReleaseNoNet|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.ReleaseNoNet|x64.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}.ReleaseNoNet|x64.Build.0 = ReleaseNoNet|Any CPU
|
||||
{0B109C0E-0514-4340-8779-5BD6A0DDE84E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0B109C0E-0514-4340-8779-5BD6A0DDE84E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0B109C0E-0514-4340-8779-5BD6A0DDE84E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{0B109C0E-0514-4340-8779-5BD6A0DDE84E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{0B109C0E-0514-4340-8779-5BD6A0DDE84E}.Debug|Win32.ActiveCfg = Debug|Any CPU
|
||||
{0B109C0E-0514-4340-8779-5BD6A0DDE84E}.Debug|Win32.Build.0 = Debug|Any CPU
|
||||
{0B109C0E-0514-4340-8779-5BD6A0DDE84E}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{0B109C0E-0514-4340-8779-5BD6A0DDE84E}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{0B109C0E-0514-4340-8779-5BD6A0DDE84E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0B109C0E-0514-4340-8779-5BD6A0DDE84E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0B109C0E-0514-4340-8779-5BD6A0DDE84E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{0B109C0E-0514-4340-8779-5BD6A0DDE84E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{0B109C0E-0514-4340-8779-5BD6A0DDE84E}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||
{0B109C0E-0514-4340-8779-5BD6A0DDE84E}.Release|Win32.Build.0 = Release|Any CPU
|
||||
{0B109C0E-0514-4340-8779-5BD6A0DDE84E}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{0B109C0E-0514-4340-8779-5BD6A0DDE84E}.Release|x64.Build.0 = Release|Any CPU
|
||||
{0B109C0E-0514-4340-8779-5BD6A0DDE84E}.ReleaseNoNet|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0B109C0E-0514-4340-8779-5BD6A0DDE84E}.ReleaseNoNet|Any CPU.Build.0 = Release|Any CPU
|
||||
{0B109C0E-0514-4340-8779-5BD6A0DDE84E}.ReleaseNoNet|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{0B109C0E-0514-4340-8779-5BD6A0DDE84E}.ReleaseNoNet|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{0B109C0E-0514-4340-8779-5BD6A0DDE84E}.ReleaseNoNet|Win32.ActiveCfg = Release|Any CPU
|
||||
{0B109C0E-0514-4340-8779-5BD6A0DDE84E}.ReleaseNoNet|Win32.Build.0 = Release|Any CPU
|
||||
{0B109C0E-0514-4340-8779-5BD6A0DDE84E}.ReleaseNoNet|x64.ActiveCfg = Release|Any CPU
|
||||
{0B109C0E-0514-4340-8779-5BD6A0DDE84E}.ReleaseNoNet|x64.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@@ -10,6 +10,7 @@ using Android.OS;
|
||||
using Android.Provider;
|
||||
using Java.IO;
|
||||
using KeePassLib.Serialization;
|
||||
using KeePassLib.Utility;
|
||||
using Console = System.Console;
|
||||
|
||||
namespace keepass2android.Io
|
||||
@@ -77,8 +78,9 @@ namespace keepass2android.Io
|
||||
|
||||
public string GetFilenameWithoutPathAndExt(IOConnectionInfo ioc)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return UrlUtil.StripExtension(
|
||||
UrlUtil.GetFileName(ioc.Path));
|
||||
}
|
||||
|
||||
public bool RequiresCredentials(IOConnectionInfo ioc)
|
||||
{
|
||||
|
@@ -345,57 +345,7 @@ namespace keepass2android.Io
|
||||
|
||||
private class CachedWriteTransaction: IWriteTransaction
|
||||
{
|
||||
private class CachedWriteMemoryStream : MemoryStream
|
||||
{
|
||||
private readonly IOConnectionInfo ioc;
|
||||
private readonly CachingFileStorage _cachingFileStorage;
|
||||
private readonly bool _useFileTransaction;
|
||||
private bool _closed;
|
||||
|
||||
public CachedWriteMemoryStream(IOConnectionInfo ioc, CachingFileStorage cachingFileStorage, bool useFileTransaction)
|
||||
{
|
||||
this.ioc = ioc;
|
||||
_cachingFileStorage = cachingFileStorage;
|
||||
_useFileTransaction = useFileTransaction;
|
||||
}
|
||||
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
if (_closed) return;
|
||||
|
||||
//write file to cache:
|
||||
//(note: this might overwrite local changes. It's assumed that a sync operation or check was performed before
|
||||
string hash;
|
||||
using (var hashingStream = new HashingStreamEx(File.Create(_cachingFileStorage.CachedFilePath(ioc)), true, new SHA256Managed()))
|
||||
{
|
||||
Position = 0;
|
||||
CopyTo(hashingStream);
|
||||
|
||||
hashingStream.Close();
|
||||
hash = MemUtil.ByteArrayToHexString(hashingStream.Hash);
|
||||
}
|
||||
|
||||
File.WriteAllText(_cachingFileStorage.VersionFilePath(ioc), hash);
|
||||
//update file on remote. This might overwrite changes there as well, see above.
|
||||
Position = 0;
|
||||
if (_cachingFileStorage.IsCached(ioc))
|
||||
{
|
||||
//if the file already is in the cache, it's ok if writing to remote fails.
|
||||
_cachingFileStorage.TryUpdateRemoteFile(this, ioc, _useFileTransaction, hash);
|
||||
}
|
||||
else
|
||||
{
|
||||
//if not, we don't accept a failure (e.g. invalid credentials would always remain a problem)
|
||||
_cachingFileStorage.UpdateRemoteFile(this, ioc, _useFileTransaction, hash);
|
||||
}
|
||||
|
||||
base.Close();
|
||||
|
||||
_closed = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private readonly IOConnectionInfo _ioc;
|
||||
private readonly bool _useFileTransaction;
|
||||
@@ -429,17 +379,48 @@ namespace keepass2android.Io
|
||||
|
||||
public Stream OpenFile()
|
||||
{
|
||||
_memoryStream = new CachedWriteMemoryStream(_ioc, _cachingFileStorage, _useFileTransaction);
|
||||
_memoryStream = new MemoryStream();
|
||||
return _memoryStream;
|
||||
}
|
||||
|
||||
public void CommitWrite()
|
||||
{
|
||||
//the transaction is committed in the stream's Close
|
||||
_committed = true;
|
||||
_memoryStream.Close();
|
||||
|
||||
//write file to cache:
|
||||
//(note: this might overwrite local changes. It's assumed that a sync operation or check was performed before
|
||||
|
||||
byte[] output = _memoryStream.ToArray();
|
||||
|
||||
string hash;
|
||||
using (var hashingStream = new HashingStreamEx(File.Create(_cachingFileStorage.CachedFilePath(_ioc)), true, new SHA256Managed()))
|
||||
{
|
||||
hashingStream.Write(output, 0, output.Length);
|
||||
|
||||
hashingStream.Close();
|
||||
hash = MemUtil.ByteArrayToHexString(hashingStream.Hash);
|
||||
}
|
||||
|
||||
File.WriteAllText(_cachingFileStorage.VersionFilePath(_ioc), hash);
|
||||
//create another memory stream which is open for reading again
|
||||
MemoryStream openMemStream = new MemoryStream(output);
|
||||
//update file on remote. This might overwrite changes there as well, see above.
|
||||
if (_cachingFileStorage.IsCached(_ioc))
|
||||
{
|
||||
//if the file already is in the cache, it's ok if writing to remote fails.
|
||||
_cachingFileStorage.TryUpdateRemoteFile(openMemStream, _ioc, _useFileTransaction, hash);
|
||||
}
|
||||
else
|
||||
{
|
||||
//if not, we don't accept a failure (e.g. invalid credentials would always remain a problem)
|
||||
_cachingFileStorage.UpdateRemoteFile(openMemStream, _ioc, _useFileTransaction, hash);
|
||||
}
|
||||
|
||||
openMemStream.Dispose();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public IWriteTransaction OpenWriteTransaction(IOConnectionInfo ioc, bool useFileTransaction)
|
||||
|
@@ -2,12 +2,12 @@ namespace keepass2android.Io
|
||||
{
|
||||
public partial class DropboxFileStorage
|
||||
{
|
||||
private const string AppKey = "";
|
||||
private const string AppSecret = "";
|
||||
private const string AppKey = "dummy";
|
||||
private const string AppSecret = "dummy";
|
||||
}
|
||||
public partial class DropboxAppFolderFileStorage
|
||||
{
|
||||
private const string AppKey = "";
|
||||
private const string AppSecret = "";
|
||||
private const string AppKey = "dummy";
|
||||
private const string AppSecret = "dummy";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
23
src/Kp2aBusinessLogic/Io/PCloudFileStorage.cs
Normal file
23
src/Kp2aBusinessLogic/Io/PCloudFileStorage.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Android.Content;
|
||||
#if !EXCLUDE_JAVAFILESTORAGE
|
||||
|
||||
namespace keepass2android.Io
|
||||
{
|
||||
public partial class PCloudFileStorage: JavaFileStorage
|
||||
{
|
||||
private const string ClientId = "CkRWTQXY6Lm";
|
||||
|
||||
public PCloudFileStorage(Context ctx, IKp2aApp app) :
|
||||
base(new Keepass2android.Javafilestorage.PCloudFileStorage(ctx, ClientId), app)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public override bool UserShouldBackup
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
@@ -5,8 +5,8 @@ namespace keepass2android.Io
|
||||
{
|
||||
public class SftpFileStorage: JavaFileStorage
|
||||
{
|
||||
public SftpFileStorage(IKp2aApp app) :
|
||||
base(new Keepass2android.Javafilestorage.SftpStorage(), app)
|
||||
public SftpFileStorage(Context ctx, IKp2aApp app) :
|
||||
base(new Keepass2android.Javafilestorage.SftpStorage(ctx.ApplicationContext), app)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -30,7 +30,8 @@ namespace keepass2android.Io
|
||||
yield return "http";
|
||||
yield return "https";
|
||||
yield return "owncloud";
|
||||
}
|
||||
yield return "nextcloud";
|
||||
}
|
||||
}
|
||||
|
||||
public override bool UserShouldBackup
|
||||
@@ -38,12 +39,15 @@ namespace keepass2android.Io
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public static string Owncloud2Webdav(string owncloudUrl)
|
||||
public static string owncloudPrefix = "owncloud://";
|
||||
public static string nextcloudPrefix = "nextcloud://";
|
||||
|
||||
public static string Owncloud2Webdav(string owncloudUrl, string prefix)
|
||||
{
|
||||
string owncloudPrefix = "owncloud://";
|
||||
if (owncloudUrl.StartsWith(owncloudPrefix))
|
||||
|
||||
if (owncloudUrl.StartsWith(prefix))
|
||||
{
|
||||
owncloudUrl = owncloudUrl.Substring(owncloudPrefix.Length);
|
||||
owncloudUrl = owncloudUrl.Substring(prefix.Length);
|
||||
}
|
||||
if (!owncloudUrl.Contains("://"))
|
||||
owncloudUrl = "https://" + owncloudUrl;
|
||||
|
@@ -117,6 +117,7 @@
|
||||
<Compile Include="Io\JavaFileStorage.cs" />
|
||||
<Compile Include="Io\NetFtpFileStorage.cs" />
|
||||
<Compile Include="Io\OfflineSwitchableFileStorage.cs" />
|
||||
<Compile Include="Io\PCloudFileStorage.cs" />
|
||||
<Compile Include="Io\SftpFileStorage.cs" />
|
||||
<Compile Include="Io\OneDriveFileStorage.cs" />
|
||||
<Compile Include="Io\WebDavFileStorage.cs" />
|
||||
@@ -128,15 +129,15 @@
|
||||
<Compile Include="database\edit\ActionOnFinish.cs" />
|
||||
<Compile Include="database\edit\AddEntry.cs" />
|
||||
<Compile Include="database\edit\AddGroup.cs" />
|
||||
<Compile Include="database\edit\CreateDb.cs" />
|
||||
<Compile Include="database\edit\CreateDB.cs" />
|
||||
<Compile Include="database\edit\DeleteEntry.cs" />
|
||||
<Compile Include="database\edit\DeleteGroup.cs" />
|
||||
<Compile Include="database\edit\DeleteRunnable.cs" />
|
||||
<Compile Include="database\edit\FileOnFinish.cs" />
|
||||
<Compile Include="database\edit\LoadDb.cs" />
|
||||
<Compile Include="database\edit\LoadDB.cs" />
|
||||
<Compile Include="database\edit\OnFinish.cs" />
|
||||
<Compile Include="database\edit\RunnableOnFinish.cs" />
|
||||
<Compile Include="database\edit\SaveDb.cs" />
|
||||
<Compile Include="database\edit\SaveDB.cs" />
|
||||
<Compile Include="database\edit\SetPassword.cs" />
|
||||
<Compile Include="database\edit\UpdateEntry.cs" />
|
||||
<Compile Include="IKp2aApp.cs" />
|
||||
@@ -155,6 +156,10 @@
|
||||
<Compile Include="Utils\Spr\SprEngine.PickChars.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AdalBindings\AdalBindings.csproj">
|
||||
<Project>{0b109c0e-0514-4340-8779-5bd6a0dde84e}</Project>
|
||||
<Name>AdalBindings</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\JavaFileStorageBindings\JavaFileStorageBindings.csproj">
|
||||
<Project>{48574278-4779-4b3a-a9e4-9cf1bc285d0b}</Project>
|
||||
<Name>JavaFileStorageBindings</Name>
|
||||
|
@@ -30,8 +30,12 @@ namespace keepass2android
|
||||
readonly IKp2aApp _app;
|
||||
private readonly Handler _handler;
|
||||
private string _message = "";
|
||||
private string _submessage;
|
||||
|
||||
public ProgressDialogStatusLogger() {
|
||||
public String SubMessage => _submessage;
|
||||
public String Message => _message;
|
||||
|
||||
public ProgressDialogStatusLogger() {
|
||||
|
||||
}
|
||||
|
||||
@@ -56,6 +60,7 @@ namespace keepass2android
|
||||
|
||||
public void UpdateSubMessage(String submessage)
|
||||
{
|
||||
_submessage = submessage;
|
||||
if (_app != null && _progressDialog != null && _handler != null)
|
||||
{
|
||||
_handler.Post(() =>
|
||||
|
@@ -25,39 +25,107 @@ namespace keepass2android
|
||||
/// <summary>
|
||||
/// Class to run a task while a progress dialog is shown
|
||||
/// </summary>
|
||||
public class ProgressTask {
|
||||
private readonly Handler _handler;
|
||||
public class ProgressTask
|
||||
{
|
||||
//for handling Activity recreation situations, we need access to the currently active task. It must hold that there is no more than one active task.
|
||||
private static ProgressTask _currentTask = null;
|
||||
|
||||
public static void SetNewActiveActivity(Activity activeActivity)
|
||||
{
|
||||
if (_currentTask != null)
|
||||
{
|
||||
_currentTask.ActiveActivity = activeActivity;
|
||||
}
|
||||
}
|
||||
public static void RemoveActiveActivity(Activity activity)
|
||||
{
|
||||
if ((_currentTask != null) && (_currentTask._activeActivity == activity))
|
||||
_currentTask.ActiveActivity = null;
|
||||
|
||||
}
|
||||
|
||||
public Activity ActiveActivity
|
||||
{
|
||||
get { return _activeActivity; }
|
||||
private set
|
||||
{
|
||||
_activeActivity = value;
|
||||
if (_task != null)
|
||||
_task.ActiveActivity = _activeActivity;
|
||||
if (_activeActivity != null)
|
||||
{
|
||||
SetupProgressDialog(_app);
|
||||
_progressDialog.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Handler _handler;
|
||||
private readonly RunnableOnFinish _task;
|
||||
private readonly IProgressDialog _progressDialog;
|
||||
private IProgressDialog _progressDialog;
|
||||
private readonly IKp2aApp _app;
|
||||
private Thread _thread;
|
||||
private Activity _activeActivity;
|
||||
private ProgressDialogStatusLogger _progressDialogStatusLogger;
|
||||
|
||||
public ProgressTask(IKp2aApp app, Context ctx, RunnableOnFinish task) {
|
||||
public ProgressTask(IKp2aApp app, Activity activity, RunnableOnFinish task)
|
||||
{
|
||||
_activeActivity = activity;
|
||||
_task = task;
|
||||
_handler = app.UiThreadHandler;
|
||||
_app = app;
|
||||
|
||||
// Show process dialog
|
||||
_progressDialog = app.CreateProgressDialog(ctx);
|
||||
_progressDialog.SetTitle(_app.GetResourceString(UiStringKey.progress_title));
|
||||
_progressDialog.SetMessage("Initializing...");
|
||||
|
||||
// Set code to run when this is finished
|
||||
_task.OnFinishToRun = new AfterTask(task.OnFinishToRun, _handler, _progressDialog);
|
||||
_task.SetStatusLogger(new ProgressDialogStatusLogger(_app, _handler, _progressDialog));
|
||||
SetupProgressDialog(app);
|
||||
|
||||
// Set code to run when this is finished
|
||||
_task.OnFinishToRun = new AfterTask(activity, task.OnFinishToRun, _handler, this);
|
||||
|
||||
_task.SetStatusLogger(_progressDialogStatusLogger);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void Run() {
|
||||
// Show process dialog
|
||||
_progressDialog.Show();
|
||||
|
||||
private void SetupProgressDialog(IKp2aApp app)
|
||||
{
|
||||
string currentMessage = "Initializing...";
|
||||
string currentSubmessage = "";
|
||||
|
||||
if (_progressDialogStatusLogger != null)
|
||||
{
|
||||
currentMessage = _progressDialogStatusLogger.Message;
|
||||
currentSubmessage = _progressDialogStatusLogger.SubMessage;
|
||||
}
|
||||
|
||||
if (_progressDialog != null)
|
||||
{
|
||||
var pd = _progressDialog;
|
||||
app.UiThreadHandler.Post(() =>
|
||||
{
|
||||
pd.Dismiss();
|
||||
});
|
||||
}
|
||||
|
||||
// Show process dialog
|
||||
_progressDialog = app.CreateProgressDialog(_activeActivity);
|
||||
_progressDialog.SetTitle(_app.GetResourceString(UiStringKey.progress_title));
|
||||
_progressDialogStatusLogger = new ProgressDialogStatusLogger(_app, _handler, _progressDialog);
|
||||
_progressDialogStatusLogger.UpdateMessage(currentMessage);
|
||||
_progressDialogStatusLogger.UpdateSubMessage(currentSubmessage);
|
||||
}
|
||||
|
||||
public void Run(bool allowOverwriteCurrentTask = false)
|
||||
{
|
||||
if ((!allowOverwriteCurrentTask) && (_currentTask != null))
|
||||
throw new Exception("Cannot start another ProgressTask while ProgressTask is already running! " + _task.GetType().Name + "/" + _currentTask._task.GetType().Name);
|
||||
_currentTask = this;
|
||||
|
||||
// Show process dialog
|
||||
_progressDialog.Show();
|
||||
|
||||
|
||||
// Start Thread to Run task
|
||||
_thread = new Thread(_task.Run);
|
||||
_thread.Start();
|
||||
|
||||
}
|
||||
|
||||
public void JoinWorkerThread()
|
||||
@@ -66,11 +134,11 @@ namespace keepass2android
|
||||
}
|
||||
|
||||
private class AfterTask : OnFinish {
|
||||
readonly IProgressDialog _progressDialog;
|
||||
readonly ProgressTask _progressTask;
|
||||
|
||||
public AfterTask (OnFinish finish, Handler handler, IProgressDialog pd): base(finish, handler)
|
||||
public AfterTask (Activity activity, OnFinish finish, Handler handler, ProgressTask pt): base(activity, finish, handler)
|
||||
{
|
||||
_progressDialog = pd;
|
||||
_progressTask = pt;
|
||||
}
|
||||
|
||||
public override void Run() {
|
||||
@@ -79,17 +147,22 @@ namespace keepass2android
|
||||
if (Handler != null) //can be null in tests
|
||||
{
|
||||
// Remove the progress dialog
|
||||
Handler.Post(delegate { _progressDialog.Dismiss(); });
|
||||
Handler.Post(delegate
|
||||
{
|
||||
_progressTask._progressDialog.Dismiss();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
_progressDialog.Dismiss();
|
||||
_progressTask._progressDialog.Dismiss();
|
||||
}
|
||||
_currentTask = null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -18,8 +18,8 @@ namespace keepass2android
|
||||
private readonly IKp2aApp _app;
|
||||
|
||||
|
||||
public CheckDatabaseForChanges(Context context, IKp2aApp app, OnFinish finish)
|
||||
: base(finish)
|
||||
public CheckDatabaseForChanges(Activity context, IKp2aApp app, OnFinish finish)
|
||||
: base(context, finish)
|
||||
{
|
||||
_context = context;
|
||||
_app = app;
|
||||
|
@@ -21,7 +21,6 @@ using System.IO;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Android.Content;
|
||||
using Java.Lang;
|
||||
using KeePassLib;
|
||||
using KeePassLib.Keys;
|
||||
@@ -218,7 +217,7 @@ namespace keepass2android
|
||||
}
|
||||
|
||||
|
||||
public void SaveData(Context ctx) {
|
||||
public void SaveData() {
|
||||
|
||||
KpDatabase.UseFileTransactions = _app.GetBooleanPreference(PreferenceKey.UseFileTransactions);
|
||||
using (IWriteTransaction trans = _app.GetFileStorage(Ioc).OpenWriteTransaction(Ioc, KpDatabase.UseFileTransactions))
|
||||
|
@@ -11,12 +11,12 @@ namespace keepass2android
|
||||
{
|
||||
public class SynchronizeCachedDatabase: RunnableOnFinish
|
||||
{
|
||||
private readonly Context _context;
|
||||
private readonly Activity _context;
|
||||
private readonly IKp2aApp _app;
|
||||
private SaveDb _saveDb;
|
||||
|
||||
public SynchronizeCachedDatabase(Context context, IKp2aApp app, OnFinish finish)
|
||||
: base(finish)
|
||||
public SynchronizeCachedDatabase(Activity context, IKp2aApp app, OnFinish finish)
|
||||
: base(context, finish)
|
||||
{
|
||||
_context = context;
|
||||
_app = app;
|
||||
@@ -59,7 +59,7 @@ namespace keepass2android
|
||||
if (cachingFileStorage.HasLocalChanges(ioc))
|
||||
{
|
||||
//conflict! need to merge
|
||||
_saveDb = new SaveDb(_context, _app, new ActionOnFinish((success, result) =>
|
||||
_saveDb = new SaveDb(_context, _app, new ActionOnFinish(ActiveActivity, (success, result, activity) =>
|
||||
{
|
||||
if (!success)
|
||||
{
|
||||
|
@@ -16,41 +16,37 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using Android.App;
|
||||
using Android.OS;
|
||||
|
||||
namespace keepass2android
|
||||
{
|
||||
public class ActionOnFinish: OnFinish
|
||||
{
|
||||
public delegate void ActionToPerformOnFinsh(bool success, String message);
|
||||
public delegate void ActionToPerformOnFinsh(bool success, String message, Activity activeActivity);
|
||||
|
||||
readonly ActionToPerformOnFinsh _actionToPerform;
|
||||
|
||||
public ActionOnFinish(ActionToPerformOnFinsh actionToPerform) : base(null, null)
|
||||
public ActionOnFinish(Activity activity, ActionToPerformOnFinsh actionToPerform) : base(activity, null, null)
|
||||
{
|
||||
_actionToPerform = actionToPerform;
|
||||
}
|
||||
|
||||
public ActionOnFinish(ActionToPerformOnFinsh actionToPerform, OnFinish finish) : base(finish)
|
||||
public ActionOnFinish(Activity activity, ActionToPerformOnFinsh actionToPerform, OnFinish finish) : base(activity, finish)
|
||||
{
|
||||
_actionToPerform = actionToPerform;
|
||||
}
|
||||
|
||||
public ActionOnFinish(ActionToPerformOnFinsh actionToPerform, Handler handler) : base(handler)
|
||||
{
|
||||
_actionToPerform = actionToPerform;
|
||||
}
|
||||
|
||||
|
||||
public override void Run()
|
||||
{
|
||||
if (Message == null)
|
||||
Message = "";
|
||||
if (Handler != null)
|
||||
{
|
||||
Handler.Post(() => {_actionToPerform(Success, Message);});
|
||||
Handler.Post(() => {_actionToPerform(Success, Message, ActiveActivity);});
|
||||
}
|
||||
else
|
||||
_actionToPerform(Success, Message);
|
||||
_actionToPerform(Success, Message, ActiveActivity);
|
||||
base.Run();
|
||||
}
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
|
||||
along with Keepass2Android. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using KeePassLib;
|
||||
|
||||
@@ -29,20 +30,20 @@ namespace keepass2android
|
||||
private readonly IKp2aApp _app;
|
||||
private readonly PwEntry _entry;
|
||||
private readonly PwGroup _parentGroup;
|
||||
private readonly Context _ctx;
|
||||
private readonly Activity _ctx;
|
||||
|
||||
public static AddEntry GetInstance(Context ctx, IKp2aApp app, PwEntry entry, PwGroup parentGroup, OnFinish finish) {
|
||||
public static AddEntry GetInstance(Activity ctx, IKp2aApp app, PwEntry entry, PwGroup parentGroup, OnFinish finish) {
|
||||
|
||||
return new AddEntry(ctx, app, entry, parentGroup, finish);
|
||||
}
|
||||
|
||||
protected AddEntry(Context ctx, IKp2aApp app, PwEntry entry, PwGroup parentGroup, OnFinish finish):base(finish) {
|
||||
protected AddEntry(Activity ctx, IKp2aApp app, PwEntry entry, PwGroup parentGroup, OnFinish finish):base(ctx, finish) {
|
||||
_ctx = ctx;
|
||||
_parentGroup = parentGroup;
|
||||
_app = app;
|
||||
_entry = entry;
|
||||
|
||||
_onFinishToRun = new AfterAdd(app.GetDb(), entry, OnFinishToRun);
|
||||
_onFinishToRun = new AfterAdd(ctx, app.GetDb(), entry, OnFinishToRun);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +69,7 @@ namespace keepass2android
|
||||
private readonly Database _db;
|
||||
private readonly PwEntry _entry;
|
||||
|
||||
public AfterAdd(Database db, PwEntry entry, OnFinish finish):base(finish) {
|
||||
public AfterAdd(Activity activity, Database db, PwEntry entry, OnFinish finish):base(activity, finish) {
|
||||
_db = db;
|
||||
_entry = entry;
|
||||
|
||||
|
@@ -16,6 +16,7 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
|
||||
*/
|
||||
|
||||
using System;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using KeePassLib;
|
||||
|
||||
@@ -34,16 +35,16 @@ namespace keepass2android
|
||||
internal PwGroup Group;
|
||||
internal PwGroup Parent;
|
||||
protected bool DontSave;
|
||||
readonly Context _ctx;
|
||||
readonly Activity _ctx;
|
||||
|
||||
|
||||
public static AddGroup GetInstance(Context ctx, IKp2aApp app, string name, int iconid, PwUuid groupCustomIconId, PwGroup parent, OnFinish finish, bool dontSave) {
|
||||
public static AddGroup GetInstance(Activity ctx, IKp2aApp app, string name, int iconid, PwUuid groupCustomIconId, PwGroup parent, OnFinish finish, bool dontSave) {
|
||||
return new AddGroup(ctx, app, name, iconid, groupCustomIconId, parent, finish, dontSave);
|
||||
}
|
||||
|
||||
|
||||
private AddGroup(Context ctx, IKp2aApp app, String name, int iconid, PwUuid groupCustomIconId, PwGroup parent, OnFinish finish, bool dontSave)
|
||||
: base(finish)
|
||||
private AddGroup(Activity ctx, IKp2aApp app, String name, int iconid, PwUuid groupCustomIconId, PwGroup parent, OnFinish finish, bool dontSave)
|
||||
: base(ctx, finish)
|
||||
{
|
||||
_ctx = ctx;
|
||||
_name = name;
|
||||
@@ -53,7 +54,7 @@ namespace keepass2android
|
||||
DontSave = dontSave;
|
||||
_app = app;
|
||||
|
||||
_onFinishToRun = new AfterAdd(this, OnFinishToRun);
|
||||
_onFinishToRun = new AfterAdd(ctx, this, OnFinishToRun);
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +77,7 @@ namespace keepass2android
|
||||
private class AfterAdd : OnFinish {
|
||||
readonly AddGroup _addGroup;
|
||||
|
||||
public AfterAdd(AddGroup addGroup,OnFinish finish): base(finish) {
|
||||
public AfterAdd(Activity activity, AddGroup addGroup,OnFinish finish): base(activity, finish) {
|
||||
_addGroup = addGroup;
|
||||
}
|
||||
|
||||
|
@@ -18,6 +18,7 @@ This file is part of Keepass2Android, Copyright 2016 Philipp Crocoll. This file
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using KeePassLib;
|
||||
using KeePassLib.Security;
|
||||
@@ -128,10 +129,10 @@ namespace keepass2android
|
||||
}
|
||||
|
||||
private readonly IKp2aApp _app;
|
||||
private readonly Context _ctx;
|
||||
private readonly Activity _ctx;
|
||||
|
||||
public AddTemplateEntries(Context ctx, IKp2aApp app, OnFinish finish)
|
||||
: base(finish)
|
||||
public AddTemplateEntries(Activity ctx, IKp2aApp app, OnFinish finish)
|
||||
: base(ctx, finish)
|
||||
{
|
||||
_ctx = ctx;
|
||||
_app = app;
|
||||
@@ -358,7 +359,7 @@ namespace keepass2android
|
||||
private readonly Database _db;
|
||||
private readonly List<PwEntry> _entries;
|
||||
|
||||
public AfterAdd(Database db, List<PwEntry> entries, OnFinish finish):base(finish) {
|
||||
public AfterAdd(Activity activity, Database db, List<PwEntry> entries, OnFinish finish):base(activity, finish) {
|
||||
_db = db;
|
||||
_entries = entries;
|
||||
|
||||
|
@@ -16,7 +16,7 @@ namespace keepass2android.database.edit
|
||||
{
|
||||
public class CopyEntry: AddEntry
|
||||
{
|
||||
public CopyEntry(Context ctx, IKp2aApp app, PwEntry entry, OnFinish finish)
|
||||
public CopyEntry(Activity ctx, IKp2aApp app, PwEntry entry, OnFinish finish)
|
||||
: base(ctx, app, CreateCopy(entry, app), entry.ParentGroup, finish)
|
||||
{
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using KeePassLib;
|
||||
using KeePassLib.Cryptography.KeyDerivation;
|
||||
@@ -31,19 +32,19 @@ namespace keepass2android
|
||||
|
||||
private readonly IOConnectionInfo _ioc;
|
||||
private readonly bool _dontSave;
|
||||
private readonly Context _ctx;
|
||||
private readonly Activity _ctx;
|
||||
private readonly IKp2aApp _app;
|
||||
private CompositeKey _key;
|
||||
|
||||
public CreateDb(IKp2aApp app, Context ctx, IOConnectionInfo ioc, OnFinish finish, bool dontSave): base(finish) {
|
||||
public CreateDb(IKp2aApp app, Activity ctx, IOConnectionInfo ioc, OnFinish finish, bool dontSave): base(ctx, finish) {
|
||||
_ctx = ctx;
|
||||
_ioc = ioc;
|
||||
_dontSave = dontSave;
|
||||
_app = app;
|
||||
}
|
||||
|
||||
public CreateDb(IKp2aApp app, Context ctx, IOConnectionInfo ioc, OnFinish finish, bool dontSave, CompositeKey key)
|
||||
: base(finish)
|
||||
public CreateDb(IKp2aApp app, Activity ctx, IOConnectionInfo ioc, OnFinish finish, bool dontSave, CompositeKey key)
|
||||
: base(ctx, finish)
|
||||
{
|
||||
_ctx = ctx;
|
||||
_ioc = ioc;
|
||||
|
@@ -17,6 +17,7 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using KeePassLib;
|
||||
using KeePassLib.Interfaces;
|
||||
@@ -28,8 +29,8 @@ namespace keepass2android
|
||||
private readonly PwEntry _entry;
|
||||
private UiStringKey _statusMessage;
|
||||
|
||||
public DeleteEntry(Context ctx, IKp2aApp app, PwEntry entry, OnFinish finish):base(finish, app) {
|
||||
Ctx = ctx;
|
||||
public DeleteEntry(Activity activiy, IKp2aApp app, PwEntry entry, OnFinish finish):base(activiy, finish, app) {
|
||||
Ctx = activiy;
|
||||
Db = app.GetDb();
|
||||
_entry = entry;
|
||||
|
||||
|
@@ -17,6 +17,7 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using KeePassLib;
|
||||
|
||||
@@ -28,10 +29,10 @@ namespace keepass2android
|
||||
private PwGroup _group;
|
||||
protected bool DontSave;
|
||||
|
||||
public DeleteGroup(Context ctx, IKp2aApp app, PwGroup group, OnFinish finish)
|
||||
: base(finish, app)
|
||||
public DeleteGroup(Activity activity, IKp2aApp app, PwGroup group, OnFinish finish)
|
||||
: base(activity, finish, app)
|
||||
{
|
||||
SetMembers(ctx, app, group, false);
|
||||
SetMembers(activity, app, group, false);
|
||||
}
|
||||
/*
|
||||
public DeleteGroup(Context ctx, Database db, PwGroup group, Activity act, OnFinish finish, bool dontSave)
|
||||
@@ -44,9 +45,9 @@ namespace keepass2android
|
||||
SetMembers(ctx, db, group, null, dontSave);
|
||||
}
|
||||
*/
|
||||
private void SetMembers(Context ctx, IKp2aApp app, PwGroup group, bool dontSave)
|
||||
private void SetMembers(Activity activity, IKp2aApp app, PwGroup group, bool dontSave)
|
||||
{
|
||||
base.SetMembers(ctx, app.GetDb());
|
||||
base.SetMembers(activity, app.GetDb());
|
||||
|
||||
_group = group;
|
||||
DontSave = dontSave;
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using KeePassLib;
|
||||
using KeePassLib.Interfaces;
|
||||
@@ -11,11 +12,11 @@ namespace keepass2android
|
||||
private readonly List<IStructureItem> _elementsToDelete;
|
||||
private readonly bool _canRecycle;
|
||||
|
||||
public DeleteMultipleItems(Context ctx, Database db, List<IStructureItem> elementsToDelete, OnFinish finish, IKp2aApp app)
|
||||
: base(finish, app)
|
||||
public DeleteMultipleItems(Activity activity, Database db, List<IStructureItem> elementsToDelete, OnFinish finish, IKp2aApp app)
|
||||
: base(activity, finish, app)
|
||||
{
|
||||
_elementsToDelete = elementsToDelete;
|
||||
SetMembers(ctx, db);
|
||||
SetMembers(activity, db);
|
||||
|
||||
//determine once. The property is queried for each delete operation, but might return false
|
||||
//after one entry/group is deleted (and thus in recycle bin and thus can't be recycled anymore)
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using KeePassLib;
|
||||
|
||||
@@ -7,8 +8,8 @@ namespace keepass2android
|
||||
{
|
||||
public abstract class DeleteRunnable : RunnableOnFinish
|
||||
{
|
||||
protected DeleteRunnable(OnFinish finish, IKp2aApp app)
|
||||
: base(finish)
|
||||
protected DeleteRunnable(Activity activity, OnFinish finish, IKp2aApp app)
|
||||
: base(activity, finish)
|
||||
{
|
||||
App = app;
|
||||
}
|
||||
@@ -17,11 +18,11 @@ namespace keepass2android
|
||||
|
||||
protected Database Db;
|
||||
|
||||
protected Context Ctx;
|
||||
protected Activity Ctx;
|
||||
|
||||
protected void SetMembers(Context ctx, Database db)
|
||||
protected void SetMembers(Activity activity, Database db)
|
||||
{
|
||||
Ctx = ctx;
|
||||
Ctx = activity;
|
||||
Db = db;
|
||||
}
|
||||
|
||||
@@ -209,7 +210,7 @@ namespace keepass2android
|
||||
Android.Util.Log.Debug("KP2A", "Calling PerformDelete..");
|
||||
PerformDelete(touchedGroups, permanentlyDeletedGroups);
|
||||
|
||||
_onFinishToRun = new ActionOnFinish((success, message) =>
|
||||
_onFinishToRun = new ActionOnFinish(ActiveActivity,(success, message, activity) =>
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
|
@@ -16,6 +16,7 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
|
||||
*/
|
||||
|
||||
using System;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using KeePassLib;
|
||||
|
||||
@@ -32,10 +33,10 @@ namespace keepass2android
|
||||
private readonly PwIcon _iconId;
|
||||
private readonly PwUuid _customIconId;
|
||||
internal PwGroup Group;
|
||||
readonly Context _ctx;
|
||||
readonly Activity _ctx;
|
||||
|
||||
public EditGroup(Context ctx, IKp2aApp app, String name, PwIcon iconid, PwUuid customIconId, PwGroup group, OnFinish finish)
|
||||
: base(finish)
|
||||
public EditGroup(Activity ctx, IKp2aApp app, String name, PwIcon iconid, PwUuid customIconId, PwGroup group, OnFinish finish)
|
||||
: base(ctx, finish)
|
||||
{
|
||||
_ctx = ctx;
|
||||
_name = name;
|
||||
@@ -44,7 +45,7 @@ namespace keepass2android
|
||||
_customIconId = customIconId;
|
||||
_app = app;
|
||||
|
||||
_onFinishToRun = new AfterEdit(this, OnFinishToRun);
|
||||
_onFinishToRun = new AfterEdit(ctx, this, OnFinishToRun);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,8 +65,8 @@ namespace keepass2android
|
||||
private class AfterEdit : OnFinish {
|
||||
readonly EditGroup _editGroup;
|
||||
|
||||
public AfterEdit(EditGroup editGroup, OnFinish finish)
|
||||
: base(finish)
|
||||
public AfterEdit(Activity ctx, EditGroup editGroup, OnFinish finish)
|
||||
: base(ctx, finish)
|
||||
{
|
||||
_editGroup = editGroup;
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
|
||||
*/
|
||||
|
||||
using System;
|
||||
using Android.App;
|
||||
|
||||
namespace keepass2android
|
||||
{
|
||||
@@ -23,7 +24,7 @@ namespace keepass2android
|
||||
public abstract class FileOnFinish : OnFinish {
|
||||
private String _filename = "";
|
||||
|
||||
protected FileOnFinish(FileOnFinish finish):base(finish) {
|
||||
protected FileOnFinish(Activity activity, FileOnFinish finish):base(activity, finish) {
|
||||
}
|
||||
|
||||
public string Filename
|
||||
|
@@ -20,6 +20,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Android.App;
|
||||
using KeePassLib;
|
||||
using KeePassLib.Keys;
|
||||
using KeePassLib.Serialization;
|
||||
@@ -35,7 +36,7 @@ namespace keepass2android
|
||||
private readonly bool _rememberKeyfile;
|
||||
IDatabaseFormat _format;
|
||||
|
||||
public LoadDb(IKp2aApp app, IOConnectionInfo ioc, Task<MemoryStream> databaseData, CompositeKey compositeKey, String keyfileOrProvider, OnFinish finish): base(finish)
|
||||
public LoadDb(Activity activity, IKp2aApp app, IOConnectionInfo ioc, Task<MemoryStream> databaseData, CompositeKey compositeKey, String keyfileOrProvider, OnFinish finish): base(activity, finish)
|
||||
{
|
||||
_app = app;
|
||||
_ioc = ioc;
|
||||
|
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using KeePassLib;
|
||||
using KeePassLib.Interfaces;
|
||||
@@ -12,10 +13,10 @@ namespace keepass2android.database.edit
|
||||
{
|
||||
private readonly List<IStructureItem> _elementsToMove;
|
||||
private readonly PwGroup _targetGroup;
|
||||
private readonly Context _ctx;
|
||||
private readonly Activity _ctx;
|
||||
private readonly IKp2aApp _app;
|
||||
|
||||
public MoveElements(List<IStructureItem> elementsToMove, PwGroup targetGroup, Context ctx, IKp2aApp app, OnFinish finish) : base(finish)
|
||||
public MoveElements(List<IStructureItem> elementsToMove, PwGroup targetGroup, Activity ctx, IKp2aApp app, OnFinish finish) : base(ctx, finish)
|
||||
{
|
||||
_elementsToMove = elementsToMove;
|
||||
_targetGroup = targetGroup;
|
||||
@@ -82,7 +83,7 @@ namespace keepass2android.database.edit
|
||||
}
|
||||
|
||||
|
||||
_onFinishToRun = new ActionOnFinish((success, message) =>
|
||||
_onFinishToRun = new ActionOnFinish(ActiveActivity, (success, message, activity) =>
|
||||
{
|
||||
if (!success)
|
||||
{ // Let's not bother recovering from a failure.
|
||||
|
@@ -16,6 +16,7 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
|
||||
*/
|
||||
|
||||
using System;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.OS;
|
||||
using Android.Widget;
|
||||
@@ -31,27 +32,47 @@ namespace keepass2android
|
||||
protected OnFinish BaseOnFinish;
|
||||
protected Handler Handler;
|
||||
private ProgressDialogStatusLogger _statusLogger = new ProgressDialogStatusLogger(); //default: no logging but not null -> can be used whenever desired
|
||||
|
||||
private Activity _activeActivity;
|
||||
|
||||
public ProgressDialogStatusLogger StatusLogger
|
||||
|
||||
public ProgressDialogStatusLogger StatusLogger
|
||||
{
|
||||
get { return _statusLogger; }
|
||||
set { _statusLogger = value; }
|
||||
}
|
||||
|
||||
public Activity ActiveActivity
|
||||
{
|
||||
get { return _activeActivity; }
|
||||
set
|
||||
{
|
||||
_activeActivity = value;
|
||||
if (BaseOnFinish != null)
|
||||
{
|
||||
BaseOnFinish.ActiveActivity = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected OnFinish(Handler handler) {
|
||||
|
||||
protected OnFinish(Activity activeActivity, Handler handler)
|
||||
{
|
||||
ActiveActivity = activeActivity;
|
||||
BaseOnFinish = null;
|
||||
Handler = handler;
|
||||
|
||||
}
|
||||
|
||||
protected OnFinish(OnFinish finish, Handler handler) {
|
||||
protected OnFinish(Activity activeActivity, OnFinish finish, Handler handler)
|
||||
{
|
||||
ActiveActivity = activeActivity;
|
||||
BaseOnFinish = finish;
|
||||
Handler = handler;
|
||||
}
|
||||
|
||||
protected OnFinish(OnFinish finish) {
|
||||
protected OnFinish(Activity activeActivity, OnFinish finish)
|
||||
{
|
||||
ActiveActivity = activeActivity;
|
||||
BaseOnFinish = finish;
|
||||
Handler = null;
|
||||
}
|
||||
@@ -86,7 +107,7 @@ namespace keepass2android
|
||||
{
|
||||
if ( !String.IsNullOrEmpty(message) ) {
|
||||
Kp2aLog.Log("OnFinish message: "+message);
|
||||
Toast.MakeText(ctx, message, ToastLength.Long).Show();
|
||||
Toast.MakeText(ctx ?? Application.Context, message, ToastLength.Long).Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -15,6 +15,8 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
|
||||
along with Keepass2Android. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
using System;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
|
||||
namespace keepass2android
|
||||
{
|
||||
@@ -23,8 +25,11 @@ namespace keepass2android
|
||||
|
||||
protected OnFinish _onFinishToRun;
|
||||
public ProgressDialogStatusLogger StatusLogger = new ProgressDialogStatusLogger(); //default: empty but not null
|
||||
private Activity _activeActivity;
|
||||
|
||||
protected RunnableOnFinish(OnFinish finish) {
|
||||
protected RunnableOnFinish(Activity activeActivity, OnFinish finish)
|
||||
{
|
||||
_activeActivity = activeActivity;
|
||||
_onFinishToRun = finish;
|
||||
}
|
||||
|
||||
@@ -34,7 +39,18 @@ namespace keepass2android
|
||||
set { _onFinishToRun = value; }
|
||||
}
|
||||
|
||||
protected void Finish(bool result, String message, Exception exception = null) {
|
||||
public Activity ActiveActivity
|
||||
{
|
||||
get { return _activeActivity; }
|
||||
set
|
||||
{
|
||||
_activeActivity = value;
|
||||
if (_onFinishToRun != null)
|
||||
_onFinishToRun.ActiveActivity = _activeActivity;
|
||||
}
|
||||
}
|
||||
|
||||
protected void Finish(bool result, String message, Exception exception = null) {
|
||||
if ( OnFinishToRun != null ) {
|
||||
OnFinishToRun.SetResult(result, message, exception);
|
||||
OnFinishToRun.Run();
|
||||
@@ -56,7 +72,7 @@ namespace keepass2android
|
||||
StatusLogger = status;
|
||||
}
|
||||
|
||||
abstract public void Run();
|
||||
public abstract void Run();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -18,6 +18,7 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.OS;
|
||||
using Java.Lang;
|
||||
@@ -42,8 +43,8 @@ namespace keepass2android
|
||||
private readonly Context _ctx;
|
||||
private Thread _workerThread;
|
||||
|
||||
public SaveDb(Context ctx, IKp2aApp app, OnFinish finish, bool dontSave)
|
||||
: base(finish)
|
||||
public SaveDb(Activity ctx, IKp2aApp app, OnFinish finish, bool dontSave)
|
||||
: base(ctx, finish)
|
||||
{
|
||||
_ctx = ctx;
|
||||
_app = app;
|
||||
@@ -58,8 +59,8 @@ namespace keepass2android
|
||||
/// <param name="finish"></param>
|
||||
/// <param name="dontSave"></param>
|
||||
/// <param name="streamForOrigFile">Stream for reading the data from the (changed) original location</param>
|
||||
public SaveDb(Context ctx, IKp2aApp app, OnFinish finish, bool dontSave, Stream streamForOrigFile)
|
||||
: base(finish)
|
||||
public SaveDb(Activity ctx, IKp2aApp app, OnFinish finish, bool dontSave, Stream streamForOrigFile)
|
||||
: base(ctx, finish)
|
||||
{
|
||||
_ctx = ctx;
|
||||
_app = app;
|
||||
@@ -67,8 +68,8 @@ namespace keepass2android
|
||||
_streamForOrigFile = streamForOrigFile;
|
||||
}
|
||||
|
||||
public SaveDb(Context ctx, IKp2aApp app, OnFinish finish)
|
||||
: base(finish)
|
||||
public SaveDb(Activity ctx, IKp2aApp app, OnFinish finish)
|
||||
: base(ctx, finish)
|
||||
{
|
||||
_ctx = ctx;
|
||||
_app = app;
|
||||
@@ -248,7 +249,7 @@ namespace keepass2android
|
||||
private void PerformSaveWithoutCheck(IFileStorage fileStorage, IOConnectionInfo ioc)
|
||||
{
|
||||
StatusLogger.UpdateSubMessage("");
|
||||
_app.GetDb().SaveData(_ctx);
|
||||
_app.GetDb().SaveData();
|
||||
_app.GetDb().LastFileVersion = fileStorage.GetCurrentFileVersionFast(ioc);
|
||||
}
|
||||
|
||||
|
@@ -15,6 +15,7 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
|
||||
along with Keepass2Android. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
using System;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using KeePassLib;
|
||||
using KeePassLib.Keys;
|
||||
@@ -27,9 +28,9 @@ namespace keepass2android
|
||||
private readonly String _keyfile;
|
||||
private readonly IKp2aApp _app;
|
||||
private readonly bool _dontSave;
|
||||
private readonly Context _ctx;
|
||||
private readonly Activity _ctx;
|
||||
|
||||
public SetPassword(Context ctx, IKp2aApp app, String password, String keyfile, OnFinish finish): base(finish) {
|
||||
public SetPassword(Activity ctx, IKp2aApp app, String password, String keyfile, OnFinish finish): base(ctx, finish) {
|
||||
_ctx = ctx;
|
||||
_app = app;
|
||||
_password = password;
|
||||
@@ -37,8 +38,8 @@ namespace keepass2android
|
||||
_dontSave = false;
|
||||
}
|
||||
|
||||
public SetPassword(Context ctx, IKp2aApp app, String password, String keyfile, OnFinish finish, bool dontSave)
|
||||
: base(finish)
|
||||
public SetPassword(Activity ctx, IKp2aApp app, String password, String keyfile, OnFinish finish, bool dontSave)
|
||||
: base(ctx, finish)
|
||||
{
|
||||
_ctx = ctx;
|
||||
_app = app;
|
||||
@@ -72,7 +73,7 @@ namespace keepass2android
|
||||
pm.MasterKey = newKey;
|
||||
|
||||
// Save Database
|
||||
_onFinishToRun = new AfterSave(previousKey, previousMasterKeyChanged, pm, OnFinishToRun);
|
||||
_onFinishToRun = new AfterSave(ActiveActivity, previousKey, previousMasterKeyChanged, pm, OnFinishToRun);
|
||||
SaveDb save = new SaveDb(_ctx, _app, OnFinishToRun, _dontSave);
|
||||
save.SetStatusLogger(StatusLogger);
|
||||
save.Run();
|
||||
@@ -83,7 +84,7 @@ namespace keepass2android
|
||||
private readonly DateTime _previousKeyChanged;
|
||||
private readonly PwDatabase _db;
|
||||
|
||||
public AfterSave(CompositeKey backup, DateTime previousKeyChanged, PwDatabase db, OnFinish finish): base(finish) {
|
||||
public AfterSave(Activity activity, CompositeKey backup, DateTime previousKeyChanged, PwDatabase db, OnFinish finish): base(activity, finish) {
|
||||
_previousKeyChanged = previousKeyChanged;
|
||||
_backup = backup;
|
||||
_db = db;
|
||||
|
@@ -15,6 +15,7 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
|
||||
along with Keepass2Android. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using KeePassLib;
|
||||
|
||||
@@ -23,13 +24,13 @@ namespace keepass2android
|
||||
|
||||
public class UpdateEntry : RunnableOnFinish {
|
||||
private readonly IKp2aApp _app;
|
||||
private readonly Context _ctx;
|
||||
private readonly Activity _ctx;
|
||||
|
||||
public UpdateEntry(Context ctx, IKp2aApp app, PwEntry oldE, PwEntry newE, OnFinish finish):base(finish) {
|
||||
public UpdateEntry(Activity ctx, IKp2aApp app, PwEntry oldE, PwEntry newE, OnFinish finish):base(ctx, finish) {
|
||||
_ctx = ctx;
|
||||
_app = app;
|
||||
|
||||
_onFinishToRun = new AfterUpdate(oldE, newE, app, finish);
|
||||
_onFinishToRun = new AfterUpdate(ctx, oldE, newE, app, finish);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +46,7 @@ namespace keepass2android
|
||||
private readonly PwEntry _updatedEntry;
|
||||
private readonly IKp2aApp _app;
|
||||
|
||||
public AfterUpdate(PwEntry backup, PwEntry updatedEntry, IKp2aApp app, OnFinish finish):base(finish) {
|
||||
public AfterUpdate(Activity activity, PwEntry backup, PwEntry updatedEntry, IKp2aApp app, OnFinish finish):base(activity, finish) {
|
||||
_backup = backup;
|
||||
_updatedEntry = updatedEntry;
|
||||
_app = app;
|
||||
|
@@ -63,8 +63,9 @@
|
||||
<TransformFile Include="Transforms\EnumMethods.xml" />
|
||||
<TransformFile Include="Transforms\Metadata.xml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.Bindings.targets" />
|
||||
<ItemGroup>
|
||||
<Folder Include="libs\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Novell\Xamarin.Android.Bindings.targets" />
|
||||
</Project>
|
||||
|
||||
</Project>
|
||||
|
48
src/PCloudBindings/Additions/AboutAdditions.txt
Normal file
48
src/PCloudBindings/Additions/AboutAdditions.txt
Normal file
@@ -0,0 +1,48 @@
|
||||
Additions allow you to add arbitrary C# to the generated classes
|
||||
before they are compiled. This can be helpful for providing convenience
|
||||
methods or adding pure C# classes.
|
||||
|
||||
== Adding Methods to Generated Classes ==
|
||||
|
||||
Let's say the library being bound has a Rectangle class with a constructor
|
||||
that takes an x and y position, and a width and length size. It will look like
|
||||
this:
|
||||
|
||||
public partial class Rectangle
|
||||
{
|
||||
public Rectangle (int x, int y, int width, int height)
|
||||
{
|
||||
// JNI bindings
|
||||
}
|
||||
}
|
||||
|
||||
Imagine we want to add a constructor to this class that takes a Point and
|
||||
Size structure instead of 4 ints. We can add a new file called Rectangle.cs
|
||||
with a partial class containing our new method:
|
||||
|
||||
public partial class Rectangle
|
||||
{
|
||||
public Rectangle (Point location, Size size) :
|
||||
this (location.X, location.Y, size.Width, size.Height)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
At compile time, the additions class will be added to the generated class
|
||||
and the final assembly will a Rectangle class with both constructors.
|
||||
|
||||
|
||||
== Adding C# Classes ==
|
||||
|
||||
Another thing that can be done is adding fully C# managed classes to the
|
||||
generated library. In the above example, let's assume that there isn't a
|
||||
Point class available in Java or our library. The one we create doesn't need
|
||||
to interact with Java, so we'll create it like a normal class in C#.
|
||||
|
||||
By adding a Point.cs file with this class, it will end up in the binding library:
|
||||
|
||||
public class Point
|
||||
{
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
}
|
24
src/PCloudBindings/Jars/AboutJars.txt
Normal file
24
src/PCloudBindings/Jars/AboutJars.txt
Normal file
@@ -0,0 +1,24 @@
|
||||
This directory is for Android .jars.
|
||||
|
||||
There are 2 types of jars that are supported:
|
||||
|
||||
== Input Jar ==
|
||||
|
||||
This is the jar that bindings should be generated for.
|
||||
|
||||
For example, if you were binding the Google Maps library, this would
|
||||
be Google's "maps.jar".
|
||||
|
||||
Set the build action for these jars in the properties page to "InputJar".
|
||||
|
||||
|
||||
== Reference Jars ==
|
||||
|
||||
These are jars that are referenced by the input jar. C# bindings will
|
||||
not be created for these jars. These jars will be used to resolve
|
||||
types used by the input jar.
|
||||
|
||||
NOTE: Do not add "android.jar" as a reference jar. It will be added automatically
|
||||
based on the Target Framework selected.
|
||||
|
||||
Set the build action for these jars in the properties page to "ReferenceJar".
|
BIN
src/PCloudBindings/Jars/pcloud-sdk-android-1.0.1.aar
Normal file
BIN
src/PCloudBindings/Jars/pcloud-sdk-android-1.0.1.aar
Normal file
Binary file not shown.
BIN
src/PCloudBindings/Jars/pcloud-sdk-java-core-1.0.1.jar
Normal file
BIN
src/PCloudBindings/Jars/pcloud-sdk-java-core-1.0.1.jar
Normal file
Binary file not shown.
90
src/PCloudBindings/PCloudBindings.csproj
Normal file
90
src/PCloudBindings/PCloudBindings.csproj
Normal file
@@ -0,0 +1,90 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}</ProjectGuid>
|
||||
|
||||
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{10368E6C-D01B-4462-8E8B-01FC667A7035};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
|
||||
|
||||
|
||||
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>PCloudBindings</RootNamespace>
|
||||
<AssemblyName>PCouldBindings</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
|
||||
<TargetFrameworkVersion>v8.1</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>0</WarningLevel>
|
||||
|
||||
<AndroidLinkMode>None</AndroidLinkMode>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
|
||||
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseNoNet|AnyCPU'">
|
||||
<OutputPath>bin\ReleaseNoNet\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Mono.Android" />
|
||||
<Reference Include="System" />
|
||||
|
||||
<Reference Include="System.Core" />
|
||||
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
|
||||
|
||||
|
||||
<None Include="Jars\AboutJars.txt" />
|
||||
<None Include="Additions\AboutAdditions.txt" />
|
||||
<LibraryProjectZip Include="Jars\pcloud-sdk-android-1.0.1.aar" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<TransformFile Include="Transforms\Metadata.xml" />
|
||||
<TransformFile Include="Transforms\EnumFields.xml" />
|
||||
<TransformFile Include="Transforms\EnumMethods.xml" />
|
||||
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.Bindings.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.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<ItemGroup>
|
||||
<EmbeddedReferenceJar Include="Jars\pcloud-sdk-java-core-1.0.1.jar" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
30
src/PCloudBindings/Properties/AssemblyInfo.cs
Normal file
30
src/PCloudBindings/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using Android.App;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("PCloudBindings")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("PCloudBindings")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2013")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
14
src/PCloudBindings/Transforms/EnumFields.xml
Normal file
14
src/PCloudBindings/Transforms/EnumFields.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<enum-field-mappings>
|
||||
<!--
|
||||
This example converts the constants Fragment_id, Fragment_name,
|
||||
and Fragment_tag from android.support.v4.app.FragmentActivity.FragmentTag
|
||||
to an enum called Android.Support.V4.App.FragmentTagType with values
|
||||
Id, Name, and Tag.
|
||||
|
||||
<mapping jni-class="android/support/v4/app/FragmentActivity$FragmentTag" clr-enum-type="Android.Support.V4.App.FragmentTagType">
|
||||
<field jni-name="Fragment_name" clr-name="Name" value="0" />
|
||||
<field jni-name="Fragment_id" clr-name="Id" value="1" />
|
||||
<field jni-name="Fragment_tag" clr-name="Tag" value="2" />
|
||||
</mapping>
|
||||
-->
|
||||
</enum-field-mappings>
|
13
src/PCloudBindings/Transforms/EnumMethods.xml
Normal file
13
src/PCloudBindings/Transforms/EnumMethods.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<enum-method-mappings>
|
||||
<!--
|
||||
This example changes the Java method:
|
||||
android.support.v4.app.Fragment.SavedState.writeToParcel (int flags)
|
||||
to be:
|
||||
android.support.v4.app.Fragment.SavedState.writeToParcel (Android.OS.ParcelableWriteFlags flags)
|
||||
when bound in C#.
|
||||
|
||||
<mapping jni-class="android/support/v4/app/Fragment.SavedState">
|
||||
<method jni-name="writeToParcel" parameter="flags" clr-enum-type="Android.OS.ParcelableWriteFlags" />
|
||||
</mapping>
|
||||
-->
|
||||
</enum-method-mappings>
|
10
src/PCloudBindings/Transforms/Metadata.xml
Normal file
10
src/PCloudBindings/Transforms/Metadata.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<metadata>
|
||||
<!--
|
||||
This sample removes the class: android.support.v4.content.AsyncTaskLoader.LoadTask:
|
||||
<remove-node path="/api/package[@name='android.support.v4.content']/class[@name='AsyncTaskLoader.LoadTask']" />
|
||||
|
||||
This sample removes the method: android.support.v4.content.CursorLoader.loadInBackground:
|
||||
<remove-node path="/api/package[@name='android.support.v4.content']/class[@name='CursorLoader']/method[@name='loadInBackground']" />
|
||||
-->
|
||||
<remove-node path="/api/package[@name='com.pcloud.sdk']" />
|
||||
</metadata>
|
20
src/build-scripts/build-all.sh
Executable file
20
src/build-scripts/build-all.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo '*****************************************'
|
||||
echo '********** Building Java parts **********'
|
||||
echo '*****************************************'
|
||||
./build-java.sh
|
||||
|
||||
echo '*****************************************'
|
||||
echo '******** Building Xamarin parts *********'
|
||||
echo '*****************************************'
|
||||
./build-xamarin.sh
|
||||
|
||||
echo '*****************************************'
|
||||
echo '************** Building APK *************'
|
||||
echo '*****************************************'
|
||||
./build-apk.sh
|
||||
|
||||
echo
|
||||
echo 'Congratulations! You you can find the target APK in src/keepass2android/bin/Debug/.'
|
8
src/build-scripts/build-apk.sh
Executable file
8
src/build-scripts/build-apk.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
pushd ../keepass2android
|
||||
|
||||
xabuild keepass2android.csproj /t:SignAndroidPackage "$@"
|
||||
|
||||
popd
|
18
src/build-scripts/build-java.sh
Executable file
18
src/build-scripts/build-java.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
pushd ../java/
|
||||
|
||||
pushd JavaFileStorageTest-AS
|
||||
./gradlew assemble
|
||||
popd
|
||||
|
||||
pushd KP2ASoftkeyboard_AS
|
||||
./gradlew assemble
|
||||
popd
|
||||
|
||||
pushd Keepass2AndroidPluginSDK2
|
||||
./gradlew assemble
|
||||
popd
|
||||
|
||||
popd
|
25
src/build-scripts/build-xamarin.sh
Executable file
25
src/build-scripts/build-xamarin.sh
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
pushd ..
|
||||
|
||||
pushd Kp2aBusinessLogic/Io
|
||||
|
||||
if [ -f "DropboxFileStorageKeys.cs" ]
|
||||
then
|
||||
echo "DropboxFileStorageKeys.cs found."
|
||||
else
|
||||
cp DropboxFileStorageKeysDummy.cs DropboxFileStorageKeys.cs
|
||||
fi
|
||||
|
||||
popd
|
||||
|
||||
pushd keepass2android
|
||||
./UseManifestDebug.sh
|
||||
popd
|
||||
|
||||
# call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86_amd64
|
||||
|
||||
xabuild KeePass.sln /target:keepass2android /p:BuildProjectReferences=true /p:Configuration="Debug" /p:Platform="Any CPU" "$@"
|
||||
|
||||
popd
|
55
src/build.readme.md
Normal file
55
src/build.readme.md
Normal file
@@ -0,0 +1,55 @@
|
||||
# How to build Keepass2Android
|
||||
|
||||
## Overview
|
||||
|
||||
Keepass2Android is a Mono for Android app. This means that you need Xamarin's Mono for Android to build it. However, it also uses several components written in Java, so there are also Android-Studio projects involved. To make things even worse, parts of the keyboard and kdb-library are written in native code.
|
||||
The current build-scripts assume that the native libraries are already built (they are included in the repo).
|
||||
|
||||
To build KP2A from scratch, make sure that you have Xamarin's Mono for Android installed and also install Android Studio. Make sure that both point to the same Android SDK location.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Install Xamarin.Android
|
||||
- Fetch all submodules (`git submodule init && git submodule update`)
|
||||
|
||||
## Build
|
||||
|
||||
### On Windows
|
||||
|
||||
```bat
|
||||
cd build-scripts
|
||||
build-java.bat
|
||||
build-xamarin.bat
|
||||
```
|
||||
|
||||
build-java.bat will call gradlew for several Java modules. build-xamarin.bat will first make sure that you have all files at their place. (There is a "secret" file for Dropbox SDK keys which is not in the repo, this is replaced with a dummy file. There are also different Android Manifest files depending on the configuration which is selected by calling the appropriate script.)
|
||||
|
||||
**Notes:**
|
||||
|
||||
- For building the java parts, it is suggested to keep a short name (e.g. "c:\projects\keepass2android") for the root project directory. Otherwise the Windows path length limit might be hit when building.
|
||||
- Before building the java parts, make sure you have set the ANDROID_HOME variable or create a local.properties file inside the directories with a gradlew file. It is recommended to use the same SDK location as that of the Xamarin build.
|
||||
|
||||
### On Linux
|
||||
|
||||
- Install [Mono](https://www.mono-project.com/)
|
||||
- Install Xamarin.Android
|
||||
- Option 1: Use the mono-project [CI builds](https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android-linux/lastSuccessfulBuild/Azure/)
|
||||
- Option 2: [Build it from source](https://github.com/xamarin/xamarin-android/blob/master/Documentation/README.md#building-from-source)
|
||||
- Setup your environment:
|
||||
- Add `xabuild` to your path: `export PATH=/path/to/xamarin.android-oss/bin/Release/bin/:$PATH`
|
||||
- Setup your `ANDROID_HOME` if it's not already: `export ANDROID_HOME=/path/to/android/`
|
||||
- Alternatively, you can set your `ANDROID_SDK_PATH` and `ANDROID_NDK_PATH`.
|
||||
- Build [jar2xml](https://github.com/xamarin/jar2xml) and copy `jar2xml.jar` to `/path/to/xamarin.android-oss/bin/Release/lib/xamarin.android/xbuild/Xamarin/Android/`
|
||||
- Install [libzip](https://libzip.org/) for your distribution.
|
||||
- Note: Xamarin seems to require `libzip4`, yet most distributions only ships `libzip5`. As a dirty workaround, it's possible to symlink `libzip.so.5` to `libzip.so.4`. Luckily, it appears to be working.
|
||||
- `sudo ln -s /usr/lib/libzip.so.5 /usr/lib/libzip.so.4`
|
||||
- Install NuGet dependencies:
|
||||
- `cd src/ && nuget restore KeePass.sln`
|
||||
- Build:
|
||||
- Option 1: `cd build-scripts && ./build-all.sh`
|
||||
- Option 2:
|
||||
- Build the Java parts: `cd build-scripts/ && ./build-java.sh`
|
||||
- Build the Xamarin parts: `./build-xamarin.sh`
|
||||
- Build the signed APK: `./build-apk.sh`
|
||||
- Enjoy:
|
||||
- `adb install ../keepass2android/bin/Debug/keepass2android.keepass2android_debug-Signed.apk`
|
@@ -1,23 +0,0 @@
|
||||
How to build Keepass2Android
|
||||
|
||||
* Overview *
|
||||
Keepass2Android is a Mono for Android app. This means that you need Xamarin's Mono for Android to build it. However, it also uses several components written in Java, so there are also Android-Studio projects involved. To make things even worse, parts of the keyboard and kdb-library are written in native code.
|
||||
The current build-scripts assume that the native libraries are already built (they are included in the repo).
|
||||
|
||||
To build KP2A from scratch, make sure that you have Xamarin's Mono for Android installed and also install Android Studio. Make sure that both point to the same Android SDK location.
|
||||
|
||||
On Windows you can use
|
||||
|
||||
cd build-scripts
|
||||
build-java.bat
|
||||
build-xamarin.bat
|
||||
|
||||
build-java.bat will call gradlew for several Java modules. build-xamarin.bat will first make sure that you have all files at their place. (There is a "secret" file for Dropbox SDK keys which is not in the repo, this is replaced with a dummy file. There are also different Android Manifest files depending on the configuration which is selected by calling the appropriate script.)
|
||||
|
||||
|
||||
* Notes *
|
||||
- Please don't forget to update the git submodules before building.
|
||||
- For building the java parts on Windows, it is suggested to keep a short name (e.g. "c:\projects\keepass2android") for the root project directory. Otherwise the Windows path length limit might be hit when building.
|
||||
- Before building the java parts, make sure you have set the ANDROID_HOME variable or create a local.properties file inside the directories with a gradlew file. It is recommended to use the same SDK location as that of the Xamarin build.
|
||||
|
||||
|
@@ -35,6 +35,8 @@ dependencies {
|
||||
compile('com.onedrive.sdk:onedrive-sdk-android:1.2.0') {
|
||||
transitive = false
|
||||
}
|
||||
compile 'com.pcloud.sdk:java-core:1.0.1'
|
||||
compile 'com.pcloud.sdk:android:1.0.1'
|
||||
compile 'com.google.code.gson:gson:2.3.1'
|
||||
compile 'com.microsoft.services.msa:msa-auth:0.8.6'
|
||||
compile 'com.microsoft.aad:adal:1.14.0'
|
||||
|
@@ -1,15 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="keepass2android.javafilestorage"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="8"
|
||||
android:targetSdkVersion="14" />
|
||||
|
||||
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
|
||||
</manifest>
|
||||
|
||||
<application>
|
||||
<activity
|
||||
android:name=".NotifSlave"
|
||||
android:label="Keepass2Android"></activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
@@ -312,6 +312,8 @@ public class GoogleDriveFileStorage extends JavaFileStorageBase {
|
||||
String driveId = path.getGDriveId();
|
||||
logDebug("id"+driveId);
|
||||
File file = driveService.files().get(driveId).execute();
|
||||
if (file.getLabels().getTrashed())
|
||||
throw new FileNotFoundException(path.getDisplayName() + " is trashed!");
|
||||
logDebug("...done.");
|
||||
return file;
|
||||
}
|
||||
|
@@ -132,7 +132,7 @@ public class FileEntry {
|
||||
|
||||
public boolean checkForFileChangeFast(String path, String previousFileVersion) throws Exception;
|
||||
|
||||
public String getCurrentFileVersionFast(String path);
|
||||
public String getCurrentFileVersionFast(String path) throws Exception;
|
||||
|
||||
public InputStream openFileForRead(String path) throws Exception;
|
||||
|
||||
@@ -157,4 +157,4 @@ public class FileEntry {
|
||||
public void onActivityResult(FileStorageSetupActivity activity, int requestCode, int resultCode, Intent data);
|
||||
public void onRequestPermissionsResult(FileStorageSetupActivity activity, int requestCode, String[] permissions, int[] grantResults);
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,169 @@
|
||||
package keepass2android.javafilestorage;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Message;
|
||||
import android.os.Messenger;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
//based on https://github.com/jwise/dumload/blob/master/src/com/joshuawise/dumload/NotifSlave.java
|
||||
public class NotifSlave extends Activity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
private void say(String s) {
|
||||
Toast.makeText(getApplicationContext(), s, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
private int _nextdialog = 0;
|
||||
private Dialog dialog = null;
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog(int id)
|
||||
{
|
||||
Log.e("KP2AJ.NotifSlave", "Create for dialog "+(Integer.toString(id)));
|
||||
if (id != _nextdialog)
|
||||
return null;
|
||||
return dialog;
|
||||
}
|
||||
|
||||
private void showDialog(Dialog d)
|
||||
{
|
||||
_nextdialog++;
|
||||
dialog = d;
|
||||
Log.e("KP2AJ.NotifSlave", "Attempting to show dialog "+(Integer.toString(_nextdialog)));
|
||||
showDialog(_nextdialog);
|
||||
}
|
||||
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
Intent i = getIntent(); /* i *am* not an intent! */
|
||||
final Activity thisact = this;
|
||||
|
||||
final Messenger m = (Messenger)i.getParcelableExtra("keepass2android.sftp.returnmessenger");
|
||||
String reqtype = i.getStringExtra("keepass2android.sftp.reqtype");
|
||||
String prompt = i.getStringExtra("keepass2android.sftp.prompt");
|
||||
|
||||
if (prompt == null || reqtype == null || m == null) /* i.e., we got called by a dummy notification */
|
||||
{
|
||||
this.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
if (reqtype.equals("yesno")) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("Keepass2Android");
|
||||
builder.setMessage(prompt);
|
||||
builder.setCancelable(false);
|
||||
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
Log.e("KP2AJ.NotifSlave", "Responding with a 1.");
|
||||
try {
|
||||
Message me = Message.obtain();
|
||||
me.arg1 = 1;
|
||||
m.send(me);
|
||||
} catch (Exception e) {
|
||||
Log.e("KP2AJ.NotifSlave", "Failed to send a message back to my buddy.");
|
||||
}
|
||||
dialog.cancel();
|
||||
thisact.finish();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
Log.e("KP2AJ.NotifSlave", "Responding with a 1.");
|
||||
try {
|
||||
Message me = Message.obtain();
|
||||
me.arg1 = 0;
|
||||
m.send(me);
|
||||
} catch (Exception e) {
|
||||
Log.e("KP2AJ.NotifSlave", "Failed to send a message back to my buddy.");
|
||||
}
|
||||
dialog.cancel();
|
||||
thisact.finish();
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
showDialog(alert);
|
||||
} else if (reqtype.equals("message")) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("Keepass2Android");
|
||||
builder.setMessage(prompt);
|
||||
builder.setCancelable(false);
|
||||
builder.setNeutralButton("OK", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
try {
|
||||
Message me = Message.obtain();
|
||||
m.send(me);
|
||||
} catch (Exception e) {
|
||||
Log.e("KP2AJ.NotifSlave", "Failed to send a message back to my buddy.");
|
||||
}
|
||||
dialog.cancel();
|
||||
thisact.finish();
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
showDialog(alert);
|
||||
} /*else if (reqtype.equals("password")) {
|
||||
final Dialog d = new Dialog(this);
|
||||
|
||||
d.setContentView(R.layout.notfif_slave);
|
||||
d.setTitle("Keepass2Android");
|
||||
d.setCancelable(false);
|
||||
|
||||
TextView text = (TextView) d.findViewById(R.id.prompt);
|
||||
text.setText(prompt);
|
||||
|
||||
Button ok = (Button) d.findViewById(R.id.ok);
|
||||
ok.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
try {
|
||||
Message me = Message.obtain();
|
||||
me.arg1 = 1;
|
||||
TextView entry = (TextView) d.findViewById(R.id.entry);
|
||||
Bundle b = new Bundle(1);
|
||||
b.putString("response", entry.getText().toString());
|
||||
me.setData(b);
|
||||
m.send(me);
|
||||
} catch (Exception e) {
|
||||
Log.e("KP2AJ.NotifSlave", "Failed to send a message back to my buddy.");
|
||||
}
|
||||
d.cancel();
|
||||
thisact.finish();
|
||||
}
|
||||
});
|
||||
|
||||
Button cancel = (Button) d.findViewById(R.id.cancel);
|
||||
cancel.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
try {
|
||||
Message me = Message.obtain();
|
||||
me.arg1 = 0;
|
||||
m.send(me);
|
||||
} catch (Exception e) {
|
||||
Log.e("KP2AJ.NotifSlave", "Failed to send a message back to my buddy.");
|
||||
}
|
||||
d.cancel();
|
||||
thisact.finish();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
showDialog(d);
|
||||
} */else {
|
||||
Log.e("KP2AJ.NotifSlave", "What's a "+reqtype+"?");
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,404 @@
|
||||
package keepass2android.javafilestorage;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.pcloud.sdk.ApiClient;
|
||||
import com.pcloud.sdk.ApiError;
|
||||
import com.pcloud.sdk.Authenticators;
|
||||
import com.pcloud.sdk.AuthorizationActivity;
|
||||
import com.pcloud.sdk.AuthorizationResult;
|
||||
import com.pcloud.sdk.Call;
|
||||
import com.pcloud.sdk.DataSource;
|
||||
import com.pcloud.sdk.PCloudSdk;
|
||||
import com.pcloud.sdk.RemoteEntry;
|
||||
import com.pcloud.sdk.RemoteFile;
|
||||
import com.pcloud.sdk.RemoteFolder;
|
||||
|
||||
/**
|
||||
* FileStorage implementation for PCloud provider.
|
||||
* https://www.pcloud.com/
|
||||
*/
|
||||
public class PCloudFileStorage extends JavaFileStorageBase
|
||||
{
|
||||
final static private int PCLOUD_AUTHORIZATION_REQUEST_CODE = 1001845497;
|
||||
|
||||
final static private String SHARED_PREF_NAME = "PCLOUD";
|
||||
final static private String SHARED_PREF_AUTH_TOKEN = "AUTH_TOKEN";
|
||||
|
||||
private final Context ctx;
|
||||
|
||||
private ApiClient apiClient;
|
||||
private String clientId;
|
||||
|
||||
public PCloudFileStorage(Context ctx, String clientId) {
|
||||
this.ctx = ctx;
|
||||
this.clientId = clientId;
|
||||
this.apiClient = createApiClientFromSharedPrefs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresSetup(String path) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startSelectFile(FileStorageSetupInitiatorActivity activity, boolean isForSave, int requestCode) {
|
||||
String path = getProtocolId() + "://";
|
||||
activity.startSelectFileProcess(path, isForSave, requestCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepareFileUsage(Context appContext, String path) throws Throwable {
|
||||
if (!isConnected()) {
|
||||
throw new UserInteractionRequiredException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepareFileUsage(FileStorageSetupInitiatorActivity activity, String path, int requestCode,
|
||||
boolean alwaysReturnSuccess) {
|
||||
if (this.isConnected()) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(EXTRA_PATH, path);
|
||||
activity.onImmediateResult(requestCode, RESULT_FILEUSAGE_PREPARED, intent);
|
||||
} else {
|
||||
activity.startFileUsageProcess(path, requestCode, alwaysReturnSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProtocolId() {
|
||||
return "pcloud";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName(String path) {
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFilename(String path) {
|
||||
return path.substring(path.lastIndexOf("/") + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkForFileChangeFast(String path, String previousFileVersion) throws Exception {
|
||||
if (previousFileVersion == null || "".equals(previousFileVersion)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
path = this.cleanPath(path);
|
||||
|
||||
RemoteFile remoteFile = this.getRemoteFileByPath(path);
|
||||
|
||||
return !remoteFile.hash().equals(previousFileVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrentFileVersionFast(String path) throws Exception {
|
||||
path = this.cleanPath(path);
|
||||
|
||||
RemoteFile remoteFile = this.getRemoteFileByPath(path);
|
||||
|
||||
return remoteFile.hash();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream openFileForRead(String path) throws Exception {
|
||||
path = this.cleanPath(path);
|
||||
|
||||
RemoteFile remoteFile = this.getRemoteFileByPath(path);
|
||||
|
||||
return remoteFile.byteStream();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadFile(String path, byte[] data, boolean writeTransactional) throws Exception {
|
||||
path = this.cleanPath(path);
|
||||
|
||||
DataSource dataSource = DataSource.create(data);
|
||||
String filename = path.substring(path.lastIndexOf("/") + 1);
|
||||
String filePath = path.substring(0, path.lastIndexOf("/") + 1);
|
||||
RemoteFolder remoteFolder = this.getRemoteFolderByPath(filePath);
|
||||
|
||||
try {
|
||||
this.apiClient.createFile(remoteFolder, filename, dataSource).execute();
|
||||
} catch (ApiError e) {
|
||||
throw convertApiError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createFolder(String parentPath, String newDirName) throws Exception {
|
||||
String parentPathWithoutProtocol = this.cleanPath(parentPath);
|
||||
|
||||
RemoteFolder remoteFolder = this.getRemoteFolderByPath(parentPathWithoutProtocol);
|
||||
|
||||
try {
|
||||
this.apiClient.createFolder(remoteFolder, newDirName).execute();
|
||||
} catch (ApiError e) {
|
||||
throw convertApiError(e);
|
||||
}
|
||||
|
||||
return this.createFilePath(parentPath, newDirName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createFilePath(String parentPath, String newFileName) throws Exception {
|
||||
return (
|
||||
this.getProtocolId() + "://" +
|
||||
this.cleanPath(parentPath) +
|
||||
("".equals(newFileName) ? "" : "/") +
|
||||
newFileName
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FileEntry> listFiles(String parentPath) throws Exception {
|
||||
parentPath = this.cleanPath(parentPath);
|
||||
|
||||
ArrayList<FileEntry> fileEntries = new ArrayList<>();
|
||||
|
||||
RemoteFolder remoteFolder = this.getRemoteFolderByPath(parentPath);
|
||||
|
||||
for (RemoteEntry remoteEntry : remoteFolder.children()) {
|
||||
fileEntries.add(this.convertRemoteEntryToFileEntry(remoteEntry, parentPath));
|
||||
}
|
||||
|
||||
return fileEntries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileEntry getFileEntry(String path) throws Exception {
|
||||
path = this.cleanPath(path);
|
||||
|
||||
RemoteEntry remoteEntry = this.getRemoteEntryByPath(path);
|
||||
|
||||
return this.convertRemoteEntryToFileEntry(
|
||||
remoteEntry,
|
||||
path.substring(0, path.lastIndexOf("/"))
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String path) throws Exception {
|
||||
path = this.cleanPath(path);
|
||||
|
||||
RemoteEntry remoteEntry = this.getRemoteFileByPath(path);
|
||||
|
||||
try {
|
||||
this.apiClient.delete(remoteEntry).execute();
|
||||
} catch (ApiError e) {
|
||||
throw convertApiError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(FileStorageSetupActivity activity, Bundle savedInstanceState) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(FileStorageSetupActivity activity) {
|
||||
if (activity.getProcessName().equals(PROCESS_NAME_SELECTFILE)) {
|
||||
activity.getState().putString(EXTRA_PATH, activity.getPath());
|
||||
}
|
||||
|
||||
if (this.isConnected()) {
|
||||
finishActivityWithSuccess(activity);
|
||||
} else if (!activity.getState().getBoolean("hasStartedAuth", false)) {
|
||||
Activity castedActivity = (Activity)activity;
|
||||
Intent authIntent = AuthorizationActivity.createIntent(castedActivity, this.clientId);
|
||||
castedActivity.startActivityForResult(authIntent, PCLOUD_AUTHORIZATION_REQUEST_CODE);
|
||||
activity.getState().putBoolean("hasStartedAuth", true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(FileStorageSetupActivity activity, int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == PCLOUD_AUTHORIZATION_REQUEST_CODE && data != null) {
|
||||
activity.getState().putBoolean("hasStartedAuth", false);
|
||||
AuthorizationResult result = (AuthorizationResult)(
|
||||
data.getSerializableExtra(AuthorizationActivity.KEY_AUTHORIZATION_RESULT)
|
||||
);
|
||||
this.handleAuthResult(activity, result, data);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleAuthResult(FileStorageSetupActivity activity, AuthorizationResult authorizationResult,
|
||||
Intent data) {
|
||||
if (authorizationResult == AuthorizationResult.ACCESS_GRANTED) {
|
||||
String authToken = data.getStringExtra(AuthorizationActivity.KEY_ACCESS_TOKEN);
|
||||
setAuthToken(authToken);
|
||||
finishActivityWithSuccess(activity);
|
||||
} else {
|
||||
Activity castedActivity = (Activity)activity;
|
||||
Intent resultData = new Intent();
|
||||
resultData.putExtra(EXTRA_ERROR_MESSAGE, "Authentication failed.");
|
||||
castedActivity.setResult(Activity.RESULT_CANCELED, resultData);
|
||||
castedActivity.finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart(FileStorageSetupActivity activity) {
|
||||
|
||||
}
|
||||
|
||||
private ApiClient createApiClientFromSharedPrefs() {
|
||||
SharedPreferences prefs = this.ctx.getSharedPreferences(SHARED_PREF_NAME, Context.MODE_PRIVATE);
|
||||
String authToken = prefs.getString(SHARED_PREF_AUTH_TOKEN, null);
|
||||
return this.createApiClient(authToken);
|
||||
}
|
||||
|
||||
private ApiClient createApiClient(String authToken) {
|
||||
if (authToken == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
PCloudSdk.newClientBuilder()
|
||||
.authenticator(Authenticators.newOAuthAuthenticator(authToken))
|
||||
.create()
|
||||
);
|
||||
}
|
||||
|
||||
private boolean isConnected() {
|
||||
return (this.apiClient != null);
|
||||
}
|
||||
|
||||
private void clearAuthToken() {
|
||||
this.apiClient = null;
|
||||
SharedPreferences prefs = this.ctx.getSharedPreferences(SHARED_PREF_NAME, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor edit = prefs.edit();
|
||||
edit.clear();
|
||||
edit.apply();
|
||||
}
|
||||
|
||||
private void setAuthToken(String authToken) {
|
||||
this.apiClient = this.createApiClient(authToken);
|
||||
SharedPreferences prefs = this.ctx.getSharedPreferences(SHARED_PREF_NAME, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor edit = prefs.edit();
|
||||
edit.putString(SHARED_PREF_AUTH_TOKEN, authToken);
|
||||
edit.apply();
|
||||
}
|
||||
|
||||
private String cleanPath(String path) {
|
||||
return (
|
||||
"/" + path.replaceAll("^(" + Pattern.quote(this.getProtocolId()) + "://)?/*", "")
|
||||
);
|
||||
}
|
||||
|
||||
private RemoteFile getRemoteFileByPath(String path) throws Exception {
|
||||
RemoteEntry remoteEntry = this.getRemoteEntryByPath(path);
|
||||
|
||||
try {
|
||||
return remoteEntry.asFile();
|
||||
} catch (IllegalStateException e) {
|
||||
throw new FileNotFoundException(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private RemoteFolder getRemoteFolderByPath(String path) throws Exception {
|
||||
RemoteEntry remoteEntry = this.getRemoteEntryByPath(path);
|
||||
|
||||
try {
|
||||
return remoteEntry.asFolder();
|
||||
} catch (IllegalStateException e) {
|
||||
throw new FileNotFoundException(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private RemoteEntry getRemoteEntryByPath(String path) throws Exception {
|
||||
Call<RemoteFolder> call = this.apiClient.listFolder(RemoteFolder.ROOT_FOLDER_ID, true);
|
||||
|
||||
RemoteFolder folder;
|
||||
try {
|
||||
folder = call.execute();
|
||||
} catch (ApiError apiError) {
|
||||
throw convertApiError(apiError);
|
||||
}
|
||||
|
||||
if ("/".equals(path)) {
|
||||
return folder;
|
||||
}
|
||||
|
||||
String[] fileNames = path.substring(1).split("/");
|
||||
RemoteFolder currentFolder = folder;
|
||||
Iterator<String> fileNamesIterator = Arrays.asList(fileNames).iterator();
|
||||
while (true) {
|
||||
String fileName = fileNamesIterator.next();
|
||||
|
||||
Iterator<RemoteEntry> entryIterator = currentFolder.children().iterator();
|
||||
while (true) {
|
||||
RemoteEntry remoteEntry;
|
||||
try {
|
||||
remoteEntry = entryIterator.next();
|
||||
} catch (NoSuchElementException e) {
|
||||
throw new FileNotFoundException(e.toString());
|
||||
}
|
||||
|
||||
if (currentFolder.folderId() == remoteEntry.parentFolderId() && fileName.equals(remoteEntry.name())) {
|
||||
if (!fileNamesIterator.hasNext()) {
|
||||
return remoteEntry;
|
||||
}
|
||||
|
||||
try {
|
||||
currentFolder = remoteEntry.asFolder();
|
||||
} catch (IllegalStateException e) {
|
||||
throw new FileNotFoundException(e.toString());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Exception convertApiError(ApiError e) {
|
||||
String strErrorCode = String.valueOf(e.errorCode());
|
||||
if (strErrorCode.startsWith("1") || "2000".equals(strErrorCode)) {
|
||||
this.clearAuthToken();
|
||||
return new UserInteractionRequiredException("Unlinked from PCloud! User must re-link.", e);
|
||||
} else if (strErrorCode.startsWith("2")) {
|
||||
return new FileNotFoundException(e.toString());
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
private FileEntry convertRemoteEntryToFileEntry(RemoteEntry remoteEntry, String parentPath) {
|
||||
FileEntry fileEntry = new FileEntry();
|
||||
fileEntry.canRead = true;
|
||||
fileEntry.canWrite = true;
|
||||
fileEntry.path = (
|
||||
this.getProtocolId() + "://" +
|
||||
("/".equals(parentPath) ? "" : parentPath) +
|
||||
"/" + remoteEntry.name()
|
||||
);
|
||||
fileEntry.displayName = remoteEntry.name();
|
||||
fileEntry.isDirectory = !remoteEntry.isFile();
|
||||
fileEntry.lastModifiedTime = remoteEntry.lastModified().getTime();
|
||||
|
||||
if (remoteEntry.isFile()) {
|
||||
fileEntry.sizeInBytes = remoteEntry.asFile().size();
|
||||
}
|
||||
|
||||
return fileEntry;
|
||||
}
|
||||
}
|
@@ -2,7 +2,9 @@ package keepass2android.javafilestorage;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
@@ -13,6 +15,7 @@ import com.jcraft.jsch.ChannelSftp;
|
||||
import com.jcraft.jsch.ChannelSftp.LsEntry;
|
||||
import com.jcraft.jsch.JSch;
|
||||
import com.jcraft.jsch.JSchException;
|
||||
import com.jcraft.jsch.KeyPair;
|
||||
import com.jcraft.jsch.Session;
|
||||
import com.jcraft.jsch.SftpATTRS;
|
||||
import com.jcraft.jsch.SftpException;
|
||||
@@ -21,6 +24,7 @@ import com.jcraft.jsch.UserInfo;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
public class SftpStorage extends JavaFileStorageBase {
|
||||
|
||||
@@ -35,8 +39,10 @@ public class SftpStorage extends JavaFileStorageBase {
|
||||
public String localPath;
|
||||
public int port;
|
||||
}
|
||||
Context _appContext;
|
||||
|
||||
public SftpStorage() {
|
||||
public SftpStorage(Context appContext) {
|
||||
_appContext = appContext;
|
||||
|
||||
}
|
||||
|
||||
@@ -318,10 +324,29 @@ public class SftpStorage extends JavaFileStorageBase {
|
||||
jsch = new JSch();
|
||||
ConnectionInfo ci = splitStringToConnectionInfo(filename);
|
||||
|
||||
String base_dir = getBaseDir();
|
||||
jsch.setKnownHosts(base_dir + "/known_hosts");
|
||||
|
||||
String key_filename = getKeyFileName();
|
||||
try{
|
||||
createKeyPair(key_filename);
|
||||
} catch (Exception ex) {
|
||||
System.out.println(ex);
|
||||
}
|
||||
|
||||
try {
|
||||
jsch.addIdentity(key_filename);
|
||||
} catch (java.lang.Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Session session = jsch.getSession(ci.username, ci.host, ci.port);
|
||||
UserInfo ui = new SftpUserInfo(ci.password);
|
||||
UserInfo ui = new SftpUserInfo(ci.password,_appContext);
|
||||
session.setUserInfo(ui);
|
||||
|
||||
session.setConfig("PreferredAuthentications", "publickey,password");
|
||||
|
||||
session.connect();
|
||||
|
||||
Channel channel = session.openChannel("sftp");
|
||||
@@ -333,6 +358,37 @@ public class SftpStorage extends JavaFileStorageBase {
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private String getBaseDir() {
|
||||
return _appContext.getFilesDir().getAbsolutePath();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private String getKeyFileName() {
|
||||
return getBaseDir() + "/id_kp2a_rsa";
|
||||
}
|
||||
|
||||
public String createKeyPair() throws IOException, JSchException {
|
||||
return createKeyPair(getKeyFileName());
|
||||
|
||||
}
|
||||
|
||||
private String createKeyPair(String key_filename) throws JSchException, IOException {
|
||||
String public_key_filename = key_filename + ".pub";
|
||||
File file = new File(key_filename);
|
||||
if (file.exists())
|
||||
return public_key_filename;
|
||||
int type = KeyPair.RSA;
|
||||
KeyPair kpair = KeyPair.genKeyPair(jsch, type, 2048);
|
||||
kpair.writePrivateKey(key_filename);
|
||||
|
||||
kpair.writePublicKey(public_key_filename, "generated by Keepass2Android");
|
||||
//ret = "Fingerprint: " + kpair.getFingerPrint();
|
||||
kpair.dispose();
|
||||
return public_key_filename;
|
||||
|
||||
}
|
||||
|
||||
public ConnectionInfo splitStringToConnectionInfo(String filename)
|
||||
throws UnsupportedEncodingException {
|
||||
ConnectionInfo ci = new ConnectionInfo();
|
||||
|
@@ -1,14 +1,119 @@
|
||||
package keepass2android.javafilestorage;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.Messenger;
|
||||
import android.os.SystemClock;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.util.Log;
|
||||
|
||||
import com.jcraft.jsch.UserInfo;
|
||||
|
||||
public class SftpUserInfo implements UserInfo {
|
||||
|
||||
private Object /* pick one type, and fixate on it */ dance(final String type, final String text) /* for inside the thread */
|
||||
{
|
||||
|
||||
final Message msg = Message.obtain();
|
||||
|
||||
/* t(*A*t) */
|
||||
Thread t = new Thread() {
|
||||
public void run() {
|
||||
Looper.prepare();
|
||||
int bogon = (int)SystemClock.elapsedRealtime();
|
||||
|
||||
NotificationManager mNotificationManager = (NotificationManager)_appContext.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(_appContext);
|
||||
builder.setContentText("SFTP prompt");
|
||||
builder.setSmallIcon(R.drawable.ic_logo_green_foreground);
|
||||
|
||||
|
||||
Handler h = new Handler() {
|
||||
public void handleMessage(Message M) {
|
||||
msg.copyFrom(M);
|
||||
Looper.myLooper().quit();
|
||||
}
|
||||
};
|
||||
Messenger m = new Messenger(h);
|
||||
|
||||
Intent intent = new Intent(_appContext, NotifSlave.class);
|
||||
|
||||
intent.setAction("keepass2android.sftp.NotifSlave");
|
||||
intent.putExtra("keepass2android.sftp.returnmessenger", m);
|
||||
intent.putExtra("keepass2android.sftp.reqtype", type);
|
||||
intent.putExtra("keepass2android.sftp.prompt", text);
|
||||
intent.setData((Uri.parse("suckit://"+SystemClock.elapsedRealtime())));
|
||||
|
||||
PendingIntent contentIntent = PendingIntent.getActivity(_appContext, 0, intent, 0);
|
||||
builder.setContentIntent(contentIntent);
|
||||
|
||||
{
|
||||
Intent directIntent = new Intent(_appContext, NotifSlave.class);
|
||||
directIntent.setAction("keepass2android.sftp.NotifSlave");
|
||||
directIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
directIntent.putExtra("keepass2android.sftp.returnmessenger", m);
|
||||
directIntent.putExtra("keepass2android.sftp.reqtype", type);
|
||||
directIntent.putExtra("keepass2android.sftp.prompt", text);
|
||||
directIntent.setData((Uri.parse("suckit://" + SystemClock.elapsedRealtime())));
|
||||
_appContext.startActivity(directIntent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log.e("KP2AJFS[thread]", "Notifying...");
|
||||
|
||||
mNotificationManager.notify(bogon, builder.build());
|
||||
|
||||
|
||||
|
||||
Log.e("KP2AJFS[thread]", "About to go to 'sleep'...");
|
||||
Looper.loop();
|
||||
Log.e("KP2AJFS[thread]", "And we're alive!");
|
||||
|
||||
Log.e("KP2AJFS[thread]", "result was: "+(Integer.toString(msg.arg1)));
|
||||
|
||||
mNotificationManager.cancel(bogon);
|
||||
}
|
||||
};
|
||||
|
||||
t.start();
|
||||
try {
|
||||
t.join();
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (type.equals("yesno"))
|
||||
return new Boolean(msg.arg1 == 1);
|
||||
else if (type.equals("message"))
|
||||
return null;
|
||||
else if (type.equals("password")) {
|
||||
if (msg.arg1 == 0)
|
||||
return null;
|
||||
Bundle b = msg.getData();
|
||||
return b.getString("response");
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Context _appContext;
|
||||
|
||||
String _password;
|
||||
|
||||
public SftpUserInfo(String password) {
|
||||
public SftpUserInfo(String password, Context appContext)
|
||||
{
|
||||
_password = password;
|
||||
_appContext = appContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -35,12 +140,15 @@ public class SftpUserInfo implements UserInfo {
|
||||
|
||||
@Override
|
||||
public boolean promptYesNo(String message) {
|
||||
return true; //continue all operations without user action
|
||||
return (Boolean)dance("yesno", message);
|
||||
|
||||
//test with https://www.sftp.net/public-online-sftp-servers?
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showMessage(String message) {
|
||||
Log.d("KP2AJ", message);
|
||||
public void showMessage(String message)
|
||||
{
|
||||
dance("message", message);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,4 @@
|
||||
<vector android:height="24dp" android:viewportHeight="800.0"
|
||||
android:viewportWidth="800.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#ffffff" android:fillType="evenOdd" android:pathData="m318.7,232c13.6,0 24.6,10.9 24.6,24.4 0,13.5 -11,24.4 -24.6,24.4 -13.6,0 -24.6,-10.9 -24.6,-24.4 0,-13.5 11,-24.4 24.6,-24.4zM453.5,256.4c0,13.5 11,24.4 24.6,24.4 13.6,0 24.6,-10.9 24.6,-24.4 0,-13.5 -11,-24.4 -24.6,-24.4 -13.6,0 -24.6,10.9 -24.6,24.4zM399.8,177.7M140.2,600.6v47h517.3v-47zM140.2,350.9v47h517.3v-47zM140.1,481.2h191.8c-0.8,-4.1 -1.2,-8.3 -1.2,-12.4 0,-12.4 3.4,-24.2 9.9,-34.6L140.1,434.2ZM657.5,481.2v-47L454.9,434.2c6.5,10.4 9.8,22.2 9.8,34.6 0,4.1 -0.4,8.3 -1.2,12.4zM140.1,517.4v47h186.6l14.3,-47zM454.3,517.4 L468.7,564.4h188.8v-47zM432.7,565.8 L411.7,496.9 414.4,495.3c10.3,-5.9 16.7,-16.9 16.7,-28.6 0,-18.2 -15,-33 -33.3,-33 -18.3,0 -33.3,14.8 -33.3,33 0,11.8 6.4,22.7 16.7,28.6l2.7,1.6 -21.1,68.9zM507.5,158.5 L507.7,158.2 543.3,106.9c2.4,-3.5 1.8,-8.1 -1.4,-10.3 -3.2,-2.2 -7.7,-1.1 -10.2,2.4l-37.2,53.5 -0.1,0.3c-29.3,-11.8 -62.1,-18.5 -96.8,-18.5 -35.2,0 -68.5,6.9 -98.1,19L261.8,99c-2.4,-3.5 -7,-4.6 -10.2,-2.4 -3.2,2.2 -3.8,6.8 -1.4,10.3l36.2,52.2c-66.8,32.2 -111.9,92.4 -111.9,161.3h42.9c0,-79.1 80.8,-143.5 180.1,-143.5 99.3,0 180.1,64.3 180.1,143.5h42.9c0.2,-69.3 -45.4,-129.8 -113,-161.9z"/>
|
||||
</vector>
|
0
src/java/JavaFileStorage/gradlew
vendored
Normal file → Executable file
0
src/java/JavaFileStorage/gradlew
vendored
Normal file → Executable file
@@ -135,7 +135,12 @@ package com.crocoapps.javafilestoragetest;
|
||||
import group.pals.android.lib.ui.filechooser.FileChooserActivity;
|
||||
import group.pals.android.lib.ui.filechooser.providers.BaseFileProviderUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -526,9 +531,9 @@ public class MainActivity extends Activity implements JavaFileStorage.FileStorag
|
||||
}
|
||||
|
||||
static JavaFileStorage createStorageToTest(Context ctx, Context appContext, boolean simulateRestart) {
|
||||
//storageToTest = new SftpStorage();
|
||||
storageToTest = new SftpStorage(ctx.getApplicationContext());
|
||||
//storageToTest = new SkyDriveFileStorage("000000004010C234", appContext);
|
||||
storageToTest = new OneDriveStorage(appContext, "000000004010C234");
|
||||
//storageToTest = new OneDriveStorage(appContext, "000000004010C234");
|
||||
//storageToTest = new GoogleDriveFileStorage();
|
||||
/*storageToTest = new WebDavStorage(new ICertificateErrorHandler() {
|
||||
@Override
|
||||
@@ -662,6 +667,20 @@ public class MainActivity extends Activity implements JavaFileStorage.FileStorag
|
||||
return this;
|
||||
}
|
||||
|
||||
public static String readStream(InputStream is) {
|
||||
StringBuilder sb = new StringBuilder(512);
|
||||
try {
|
||||
Reader r = new InputStreamReader(is, "UTF-8");
|
||||
int c = 0;
|
||||
while ((c = r.read()) != -1) {
|
||||
sb.append((char) c);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performManualFileSelect(boolean isForSave, final int requestCode,
|
||||
String protocolId)
|
||||
@@ -669,6 +688,30 @@ public class MainActivity extends Activity implements JavaFileStorage.FileStorag
|
||||
if (protocolId.equals("sftp"))
|
||||
{
|
||||
final View view = getLayoutInflater().inflate(R.layout.sftp_credentials, null);
|
||||
|
||||
view.findViewById(R.id.send_public_key).setOnClickListener(v -> {
|
||||
Intent sendIntent = new Intent();
|
||||
|
||||
|
||||
SftpStorage sftpStorage = (SftpStorage)storageToTest;
|
||||
try {
|
||||
String pub_filename = sftpStorage.createKeyPair();
|
||||
|
||||
sendIntent.setAction(Intent.ACTION_SEND);
|
||||
sendIntent.putExtra(Intent.EXTRA_TEXT, readStream(new FileInputStream(pub_filename)));
|
||||
|
||||
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Keepass2Android sftp public key");
|
||||
sendIntent.setType("text/plain");
|
||||
this.startActivity(Intent.createChooser(sendIntent, "Send public key to..."));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Toast.makeText(this,"Failed to create key pair: " + ex.getMessage(), Toast.LENGTH_LONG);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
new AlertDialog.Builder(this)
|
||||
.setView(view)
|
||||
.setTitle("Enter SFTP credentials")
|
||||
|
@@ -46,7 +46,8 @@
|
||||
android:inputType="textPassword"
|
||||
android:singleLine="true"
|
||||
android:text=""
|
||||
android:hint="@string/hint_pass" />
|
||||
android:hint="@string/hint_pass"
|
||||
android:importantForAccessibility="no" />
|
||||
|
||||
<TextView android:id="@+id/initial_dir"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -62,6 +63,9 @@
|
||||
android:singleLine="true"
|
||||
android:text="/home/philipp"
|
||||
/>
|
||||
|
||||
<Button android:id="@+id/send_public_key"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="send public key" />
|
||||
|
||||
</LinearLayout>
|
@@ -33,6 +33,7 @@
|
||||
android:inputType="textPassword"
|
||||
android:singleLine="true"
|
||||
android:text="$T3st17$"
|
||||
android:hint="@string/hint_pass" />
|
||||
android:hint="@string/hint_pass"
|
||||
android:importantForAccessibility="no" />
|
||||
|
||||
</LinearLayout>
|
0
src/java/JavaFileStorageTest-AS/gradlew
vendored
Normal file → Executable file
0
src/java/JavaFileStorageTest-AS/gradlew
vendored
Normal file → Executable file
@@ -18,5 +18,9 @@
|
||||
android:name="android.accessibilityservice"
|
||||
android:resource="@xml/accserviceconfig" />
|
||||
</service-->
|
||||
<activity android:excludeFromRecents="true"
|
||||
android:taskAffinity=""
|
||||
android:theme="@android:style/Theme.Dialog"
|
||||
android:name=".Kp2aDialog"></activity>
|
||||
</application>
|
||||
</manifest>
|
||||
|
@@ -10,20 +10,18 @@ public class KeyboardData
|
||||
public static List<StringForTyping> availableFields = new ArrayList<StringForTyping>();
|
||||
public static String entryName;
|
||||
public static String entryId;
|
||||
|
||||
public static int kp2aFieldIndex = 0;
|
||||
|
||||
public static boolean hasData()
|
||||
{
|
||||
return !TextUtils.isEmpty(entryId);
|
||||
}
|
||||
|
||||
public static boolean bla2()
|
||||
{
|
||||
return !TextUtils.isEmpty(entryId);
|
||||
}
|
||||
|
||||
public static void clear()
|
||||
{
|
||||
availableFields.clear();
|
||||
entryName = entryId = "";
|
||||
kp2aFieldIndex = 0;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,10 @@
|
||||
package keepass2android.kbbridge;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import keepass2android.softkeyboard.IKeyboardService;
|
||||
import keepass2android.softkeyboard.KP2AKeyboard;
|
||||
|
||||
public class KeyboardDataBuilder {
|
||||
private ArrayList<StringForTyping> availableFields = new ArrayList<StringForTyping>();
|
||||
|
||||
@@ -16,5 +20,8 @@ public class KeyboardDataBuilder {
|
||||
public void commit()
|
||||
{
|
||||
KeyboardData.availableFields = this.availableFields;
|
||||
KeyboardData.kp2aFieldIndex = 0;
|
||||
if (KP2AKeyboard.CurrentlyRunningService != null)
|
||||
KP2AKeyboard.CurrentlyRunningService.onNewData();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,9 @@
|
||||
package keepass2android.softkeyboard;
|
||||
|
||||
import keepass2android.kbbridge.StringForTyping;
|
||||
|
||||
public interface IKeyboardService
|
||||
{
|
||||
void commitStringForTyping(StringForTyping stringForTyping);
|
||||
void onNewData();
|
||||
}
|
@@ -17,6 +17,7 @@
|
||||
package keepass2android.softkeyboard;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
@@ -27,21 +28,26 @@ import android.content.SharedPreferences.Editor;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.XmlResourceParser;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.inputmethodservice.InputMethodService;
|
||||
import android.inputmethodservice.Keyboard;
|
||||
import android.media.AudioManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Debug;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.Settings;
|
||||
import android.text.ClipboardManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.util.PrintWriterPrinter;
|
||||
import android.util.Printer;
|
||||
import android.view.Gravity;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
@@ -54,7 +60,9 @@ import android.view.inputmethod.ExtractedTextRequest;
|
||||
import android.view.inputmethod.InputConnection;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.PopupWindow;
|
||||
|
||||
import keepass2android.kbbridge.KeyboardData;
|
||||
import keepass2android.kbbridge.StringForTyping;
|
||||
import keepass2android.softkeyboard.LatinIMEUtil.RingCharBuffer;
|
||||
|
||||
@@ -64,18 +72,24 @@ import java.io.FileDescriptor;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Input method implementation for Qwerty'ish keyboard.
|
||||
*/
|
||||
public class KP2AKeyboard extends InputMethodService
|
||||
implements LatinKeyboardBaseView.OnKeyboardActionListener,
|
||||
IKeyboardService,
|
||||
SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
public static IKeyboardService CurrentlyRunningService;
|
||||
|
||||
private static String get_KEEPASS2ANDROID_KEYBOARD_CLEARED(Context ctx)
|
||||
{
|
||||
return ctx.getPackageName()+".keyboard_cleared";
|
||||
@@ -311,6 +325,7 @@ public class KP2AKeyboard extends InputMethodService
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
CurrentlyRunningService = this;
|
||||
LatinImeLogger.init(this);
|
||||
KeyboardSwitcher.init(this);
|
||||
super.onCreate();
|
||||
@@ -330,6 +345,8 @@ public class KP2AKeyboard extends InputMethodService
|
||||
}
|
||||
mReCorrectionEnabled = prefs.getBoolean(PREF_RECORRECTION_ENABLED,
|
||||
getResources().getBoolean(R.bool.default_recorrection_enabled));
|
||||
|
||||
|
||||
|
||||
Log.d("KP2AK","finding plugin dicts...");
|
||||
PluginManager.getPluginDictionaries(getApplicationContext());
|
||||
@@ -358,7 +375,7 @@ public class KP2AKeyboard extends InputMethodService
|
||||
|
||||
// register to receive ringer mode changes for silent mode
|
||||
IntentFilter filter = new IntentFilter(AudioManager.RINGER_MODE_CHANGED_ACTION);
|
||||
registerReceiver(mReceiver, filter);
|
||||
registerReceiver(mSilentModeReceiver, filter);
|
||||
|
||||
prefs.registerOnSharedPreferenceChangeListener(this);
|
||||
|
||||
@@ -467,12 +484,14 @@ public class KP2AKeyboard extends InputMethodService
|
||||
if (mContactsDictionary != null) {
|
||||
mContactsDictionary.close();
|
||||
}*/
|
||||
unregisterReceiver(mReceiver);
|
||||
unregisterReceiver(mSilentModeReceiver);
|
||||
unregisterReceiver(mPluginManager);
|
||||
unregisterReceiver(mClearKeyboardReceiver);
|
||||
|
||||
LatinImeLogger.commit();
|
||||
LatinImeLogger.onDestroy();
|
||||
|
||||
CurrentlyRunningService = null;
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@@ -502,6 +521,7 @@ public class KP2AKeyboard extends InputMethodService
|
||||
mOrientation = conf.orientation;
|
||||
reloadKeyboards();
|
||||
}
|
||||
updateKp2aKeyLabels();
|
||||
mConfigurationChanging = true;
|
||||
super.onConfigurationChanged(conf);
|
||||
mConfigurationChanging = false;
|
||||
@@ -526,6 +546,7 @@ public class KP2AKeyboard extends InputMethodService
|
||||
mKeyboardSwitcher.setKeyboardMode(
|
||||
KeyboardSwitcher.MODE_TEXT, 0);
|
||||
}
|
||||
updateKp2aKeyLabels();
|
||||
|
||||
return mKeyboardSwitcher.getInputView();
|
||||
}
|
||||
@@ -687,6 +708,7 @@ public class KP2AKeyboard extends InputMethodService
|
||||
attribute.imeOptions);
|
||||
}
|
||||
}
|
||||
updateKp2aKeyLabels();
|
||||
}
|
||||
|
||||
private void updateShowKp2aMode() {
|
||||
@@ -1065,6 +1087,7 @@ public class KP2AKeyboard extends InputMethodService
|
||||
private void reloadKeyboards() {
|
||||
mKeyboardSwitcher.setLanguageSwitcher(mLanguageSwitcher);
|
||||
mKeyboardSwitcher.makeKeyboards(true);
|
||||
updateKp2aKeyLabels();
|
||||
}
|
||||
|
||||
private void commitTyped(InputConnection inputConnection) {
|
||||
@@ -1254,6 +1277,9 @@ public class KP2AKeyboard extends InputMethodService
|
||||
case LatinKeyboardView.KEYCODE_OPTIONS:
|
||||
onOptionKeyPressed();
|
||||
break;
|
||||
case LatinKeyboardView.KEYCODE_KP2A_NEXTFIELDS:
|
||||
onKp2aNextFieldsPressed();
|
||||
break;
|
||||
case LatinKeyboardView.KEYCODE_KP2A:
|
||||
onKp2aKeyPressed();
|
||||
break;
|
||||
@@ -1342,28 +1368,96 @@ public class KP2AKeyboard extends InputMethodService
|
||||
}
|
||||
|
||||
private void onKp2aPasswordKeyPressed() {
|
||||
commitStringForTyping(findStringForTyping("Password"));
|
||||
if (KeyboardData.availableFields.size() > KeyboardData.kp2aFieldIndex+1) //some entries may have only title, then there are no two buttons available
|
||||
commitStringForTyping(KeyboardData.availableFields.get(KeyboardData.kp2aFieldIndex+1));
|
||||
}
|
||||
|
||||
private StringForTyping findStringForTyping(String key) {
|
||||
|
||||
for (StringForTyping s: keepass2android.kbbridge.KeyboardData.availableFields)
|
||||
{
|
||||
if (key.equals(s.key))
|
||||
{
|
||||
return s;
|
||||
}
|
||||
}
|
||||
//found nothing: return empty struct:
|
||||
return new StringForTyping();
|
||||
}
|
||||
|
||||
private void onKp2aUserKeyPressed() {
|
||||
commitStringForTyping(findStringForTyping("UserName"));
|
||||
commitStringForTyping(KeyboardData.availableFields.get(KeyboardData.kp2aFieldIndex));
|
||||
|
||||
}
|
||||
|
||||
private void onKp2aKeyPressed() {
|
||||
|
||||
|
||||
private void onKp2aNextFieldsPressed()
|
||||
{
|
||||
|
||||
List<StringForTyping> availableFields = keepass2android.kbbridge.KeyboardData.availableFields;
|
||||
if (KeyboardData.kp2aFieldIndex >= availableFields.size()-2)
|
||||
{
|
||||
KeyboardData.kp2aFieldIndex = 0;
|
||||
}
|
||||
else if (KeyboardData.kp2aFieldIndex == availableFields.size()-3)
|
||||
{
|
||||
KeyboardData.kp2aFieldIndex++;
|
||||
}
|
||||
else
|
||||
KeyboardData.kp2aFieldIndex += 2;
|
||||
|
||||
updateKp2aKeyLabels();
|
||||
}
|
||||
|
||||
String makeShort(String input, int lineLength)
|
||||
{
|
||||
String result = input;
|
||||
if (input.length() > lineLength)
|
||||
{
|
||||
result = input.substring(0,lineLength-1)+"…";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void updateKp2aKeyLabels() {
|
||||
|
||||
if ((mKeyboardSwitcher.getInputView() != null)
|
||||
&& (mKeyboardSwitcher.getInputView().getKeyboard() != null))
|
||||
{
|
||||
for (Keyboard.Key key : mKeyboardSwitcher.getInputView().getKeyboard().getKeys()) {
|
||||
|
||||
boolean isFirstKey = false;
|
||||
boolean isSecondKey = false;
|
||||
for (int code : key.codes) {
|
||||
if (code == -201)
|
||||
isFirstKey = true;
|
||||
if (code == -202)
|
||||
isSecondKey = true;
|
||||
}
|
||||
|
||||
|
||||
int fieldIndex = -1;
|
||||
if (isFirstKey) {
|
||||
fieldIndex = KeyboardData.kp2aFieldIndex;
|
||||
}
|
||||
if (isSecondKey) {
|
||||
fieldIndex = KeyboardData.kp2aFieldIndex + 1;
|
||||
}
|
||||
|
||||
if (fieldIndex >= 0) {
|
||||
key.label = "";
|
||||
if (fieldIndex < KeyboardData.availableFields.size()) {
|
||||
String displayName = "";
|
||||
StringForTyping fieldData = KeyboardData.availableFields.get(fieldIndex);
|
||||
if (fieldData != null) {
|
||||
displayName = makeShort(fieldData.displayName, 10);
|
||||
|
||||
if ("Password".equals(fieldData.key))
|
||||
displayName = getString(R.string.kp2a_password); //might be a shorter variant
|
||||
if ("UserName".equals(fieldData.key))
|
||||
displayName = getString(R.string.kp2a_user); //might be a shorter variant
|
||||
}
|
||||
key.label = displayName;
|
||||
}
|
||||
}
|
||||
}
|
||||
mKeyboardSwitcher.getInputView().invalidateAllKeys();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void onKp2aKeyPressed() {
|
||||
|
||||
|
||||
if ((mKeyboardSwitcher.getKeyboardMode() == KeyboardSwitcher.MODE_KP2A)
|
||||
|| (!mKp2aEnableSimpleKeyboard)
|
||||
|| (!keepass2android.kbbridge.KeyboardData.hasData()))
|
||||
@@ -1376,132 +1470,149 @@ public class KP2AKeyboard extends InputMethodService
|
||||
setCandidatesViewShown(false);
|
||||
}
|
||||
|
||||
private void showKp2aDialog() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
String title = "Keepass2Android";
|
||||
List<StringForTyping> availableFields = keepass2android.kbbridge.KeyboardData.availableFields;
|
||||
|
||||
final EditorInfo attribute = getCurrentInputEditorInfo();
|
||||
Log.d("KP2AK", "hint: "+attribute.hintText);
|
||||
Log.d("KP2AK", "field name: "+attribute.fieldName);
|
||||
Log.d("KP2AK", "label: "+attribute.label);
|
||||
attribute.dump(new Printer() {
|
||||
|
||||
@Override
|
||||
public void println(String x) {
|
||||
Log.d("KP2AK", x);
|
||||
|
||||
}
|
||||
},"");
|
||||
final ArrayList<StringForTyping> items = new ArrayList<StringForTyping>();
|
||||
for (StringForTyping entry : availableFields)
|
||||
{
|
||||
Log.d("KP2AK", entry.displayName);
|
||||
items.add(entry.clone());
|
||||
}
|
||||
|
||||
|
||||
|
||||
StringForTyping openOrChangeEntry = new StringForTyping();
|
||||
if (keepass2android.kbbridge.KeyboardData.entryName == null)
|
||||
{
|
||||
openOrChangeEntry.displayName = openOrChangeEntry.key = getString(R.string.open_entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
openOrChangeEntry.displayName = openOrChangeEntry.key = getString(R.string.change_entry);
|
||||
}
|
||||
openOrChangeEntry.value = "KP2ASPECIAL_SelectEntryTask";
|
||||
items.add(openOrChangeEntry);
|
||||
|
||||
|
||||
final String clientPackageName = attribute.packageName;
|
||||
|
||||
if ((clientPackageName != null) && (clientPackageName != ""))
|
||||
{
|
||||
StringForTyping searchEntry = new StringForTyping();
|
||||
try
|
||||
{
|
||||
searchEntry.key = searchEntry.displayName
|
||||
= getString(R.string.open_entry_for_app, clientPackageName);
|
||||
}
|
||||
catch (java.util.FormatFlagsConversionMismatchException e) //buggy crowdin support for Arabic?
|
||||
{
|
||||
android.util.Log.e("KP2A", "Please report this error to crocoapps@gmail.com");
|
||||
android.util.Log.e("KP2A", e.toString());
|
||||
private void openOverlaySettings() {
|
||||
final Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
|
||||
Uri.parse("package:" + getPackageName()));
|
||||
try {
|
||||
startActivity(intent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Log.e(TAG, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
searchEntry.key = searchEntry.displayName
|
||||
= "Search entry for app";
|
||||
}
|
||||
|
||||
searchEntry.value = "KP2ASPECIAL_SearchUrlTask";
|
||||
items.add(searchEntry);
|
||||
}
|
||||
|
||||
|
||||
builder.setTitle(title);
|
||||
private void showKp2aDialog()
|
||||
{
|
||||
boolean androidP = android.os.Build.VERSION.SDK_INT >= 28;
|
||||
//due to a change in Android P, showing the dialog as dialog does not work (only visible
|
||||
// above the keyboard, not above the target application). Use an activity here.
|
||||
// However, this is not perfect as it has another behavior regarding which task is
|
||||
// in foreground, e.g. Chrome closes the IME when the activity is brought up which causes
|
||||
// trouble entering data. So we still use the dialog in previous android versions.
|
||||
if (androidP)
|
||||
{
|
||||
final EditorInfo attribute = getCurrentInputEditorInfo();
|
||||
final String clientPackageName = attribute.packageName;
|
||||
|
||||
CharSequence[] itemNames = new CharSequence[items.size()];
|
||||
int i=0;
|
||||
for (StringForTyping sft: items)
|
||||
itemNames[i++] = sft.displayName;
|
||||
|
||||
builder.setItems(itemNames,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int item) {
|
||||
Intent i = new Intent(this, Kp2aDialog.class);
|
||||
i.putExtra("clientPackageName", clientPackageName);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Log.d("KP2AK", "clicked item: " + items.get(item).key);
|
||||
|
||||
if (items.get(item).value.startsWith("KP2ASPECIAL")) {
|
||||
//change entry
|
||||
Log.d("KP2AK", "clicked item: " + items.get(item).value);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
String title = "Keepass2Android";
|
||||
List<StringForTyping> availableFields = keepass2android.kbbridge.KeyboardData.availableFields;
|
||||
|
||||
String packageName = getApplicationContext().getPackageName();
|
||||
Intent startKp2aIntent = getPackageManager().getLaunchIntentForPackage(packageName);
|
||||
if (startKp2aIntent != null)
|
||||
{
|
||||
startKp2aIntent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
startKp2aIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
String value = items.get(item).value;
|
||||
String taskName = value.substring("KP2ASPECIAL_".length());
|
||||
startKp2aIntent.putExtra("KP2A_APPTASK", taskName);
|
||||
if (taskName.equals("SearchUrlTask"))
|
||||
{
|
||||
startKp2aIntent.putExtra("UrlToSearch", "androidapp://"+clientPackageName);
|
||||
}
|
||||
startActivity(startKp2aIntent);
|
||||
} else Log.w("KP2AK", "didn't find intent for "+packageName);
|
||||
} else {
|
||||
|
||||
StringForTyping theItem = items.get(item);
|
||||
|
||||
commitStringForTyping(theItem);
|
||||
|
||||
}
|
||||
}
|
||||
final EditorInfo attribute = getCurrentInputEditorInfo();
|
||||
attribute.dump(new Printer() {
|
||||
|
||||
});
|
||||
@Override
|
||||
public void println(String x) {
|
||||
Log.d("KP2AK", x);
|
||||
|
||||
builder.setNegativeButton(android.R.string.cancel,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
// User cancelled the dialog
|
||||
}
|
||||
});
|
||||
}
|
||||
}, "");
|
||||
final ArrayList<StringForTyping> items = new ArrayList<StringForTyping>();
|
||||
for (StringForTyping entry : availableFields) {
|
||||
items.add(entry.clone());
|
||||
}
|
||||
|
||||
// Create the AlertDialog
|
||||
AlertDialog dialog = builder.create();
|
||||
Window window = dialog.getWindow();
|
||||
WindowManager.LayoutParams lp = window.getAttributes();
|
||||
LatinKeyboardView inputView = mKeyboardSwitcher.getInputView();
|
||||
lp.token = inputView.getWindowToken();
|
||||
lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
|
||||
window.setAttributes(lp);
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
|
||||
|
||||
dialog.show();
|
||||
StringForTyping openOrChangeEntry = new StringForTyping();
|
||||
if (keepass2android.kbbridge.KeyboardData.entryName == null) {
|
||||
openOrChangeEntry.displayName = openOrChangeEntry.key = getString(R.string.open_entry);
|
||||
} else {
|
||||
openOrChangeEntry.displayName = openOrChangeEntry.key = getString(R.string.change_entry);
|
||||
}
|
||||
openOrChangeEntry.value = "KP2ASPECIAL_SelectEntryTask";
|
||||
items.add(openOrChangeEntry);
|
||||
|
||||
|
||||
final String clientPackageName = attribute.packageName;
|
||||
|
||||
if ((clientPackageName != null) && (clientPackageName != "")) {
|
||||
StringForTyping searchEntry = new StringForTyping();
|
||||
try {
|
||||
searchEntry.key = searchEntry.displayName
|
||||
= getString(R.string.open_entry_for_app, new Object[]{clientPackageName});
|
||||
} catch (java.util.FormatFlagsConversionMismatchException e) //buggy crowdin support for Arabic?
|
||||
{
|
||||
android.util.Log.e("KP2A", "Please report this error to crocoapps@gmail.com");
|
||||
android.util.Log.e("KP2A", e.toString());
|
||||
|
||||
searchEntry.key = searchEntry.displayName
|
||||
= "Search entry for app";
|
||||
}
|
||||
|
||||
searchEntry.value = "KP2ASPECIAL_SearchUrlTask";
|
||||
items.add(searchEntry);
|
||||
}
|
||||
|
||||
|
||||
builder.setTitle(title);
|
||||
|
||||
CharSequence[] itemNames = new CharSequence[items.size()];
|
||||
int i = 0;
|
||||
for (StringForTyping sft : items)
|
||||
itemNames[i++] = sft.displayName;
|
||||
|
||||
builder.setItems(itemNames,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int item) {
|
||||
|
||||
|
||||
if (items.get(item).value.startsWith("KP2ASPECIAL")) {
|
||||
//change entry
|
||||
String packageName = getApplicationContext().getPackageName();
|
||||
Intent startKp2aIntent = getPackageManager().getLaunchIntentForPackage(packageName);
|
||||
if (startKp2aIntent != null) {
|
||||
startKp2aIntent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
startKp2aIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
String value = items.get(item).value;
|
||||
String taskName = value.substring("KP2ASPECIAL_".length());
|
||||
startKp2aIntent.putExtra("KP2A_APPTASK", taskName);
|
||||
if (taskName.equals("SearchUrlTask")) {
|
||||
startKp2aIntent.putExtra("UrlToSearch", "androidapp://" + clientPackageName);
|
||||
}
|
||||
startActivity(startKp2aIntent);
|
||||
} else Log.w("KP2AK", "didn't find intent for " + packageName);
|
||||
} else {
|
||||
|
||||
StringForTyping theItem = items.get(item);
|
||||
|
||||
commitStringForTyping(theItem);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
builder.setNegativeButton(android.R.string.cancel,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
// User cancelled the dialog
|
||||
}
|
||||
});
|
||||
|
||||
// Create the AlertDialog
|
||||
AlertDialog dialog = builder.create();
|
||||
Window window = dialog.getWindow();
|
||||
WindowManager.LayoutParams lp = window.getAttributes();
|
||||
LatinKeyboardView inputView = mKeyboardSwitcher.getInputView();
|
||||
lp.token = inputView.getWindowToken();
|
||||
lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
|
||||
window.setAttributes(lp);
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
|
||||
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
}
|
||||
private void commitStringForTyping(StringForTyping theItem) {
|
||||
public void commitStringForTyping(StringForTyping theItem) {
|
||||
|
||||
if ((mKp2aRememberAutoFill) && (!TextUtils.isEmpty(getCurrentInputEditorInfo().hintText)))
|
||||
{
|
||||
@@ -1517,12 +1628,17 @@ public class KP2AKeyboard extends InputMethodService
|
||||
|
||||
|
||||
|
||||
Log.d("KP2AK", "committing text for " + theItem.key);
|
||||
|
||||
commitKp2aString(theItem.value, getCurrentInputEditorInfo());
|
||||
}
|
||||
|
||||
|
||||
public void onText(CharSequence text) {
|
||||
@Override
|
||||
public void onNewData() {
|
||||
updateKp2aKeyLabels();
|
||||
}
|
||||
|
||||
|
||||
public void onText(CharSequence text) {
|
||||
InputConnection ic = getCurrentInputConnection();
|
||||
if (ic == null) return;
|
||||
if (text == null)
|
||||
@@ -1821,6 +1937,7 @@ public class KP2AKeyboard extends InputMethodService
|
||||
}
|
||||
setCandidatesViewShown(true);
|
||||
updateInputViewShown();
|
||||
updateKp2aKeyLabels();
|
||||
postUpdateSuggestions();
|
||||
}
|
||||
});
|
||||
@@ -2358,13 +2475,26 @@ public class KP2AKeyboard extends InputMethodService
|
||||
|
||||
|
||||
// receive ringer mode changes to detect silent mode
|
||||
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||
private BroadcastReceiver mSilentModeReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
updateRingerMode();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private BroadcastReceiver mCommitForTypingReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
StringForTyping stringForTyping = new StringForTyping();
|
||||
stringForTyping.key = intent.getStringExtra("key");
|
||||
stringForTyping.value = intent.getStringExtra("value");
|
||||
|
||||
KP2AKeyboard.this.commitStringForTyping(stringForTyping);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// update flags for silent mode
|
||||
private void updateRingerMode() {
|
||||
if (mAudioManager == null) {
|
||||
|
@@ -0,0 +1,129 @@
|
||||
package keepass2android.softkeyboard;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.util.Printer;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import keepass2android.kbbridge.StringForTyping;
|
||||
|
||||
public class Kp2aDialog extends Activity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
|
||||
|
||||
|
||||
setContentView(R.layout.activity_kp2a_dialog);
|
||||
ListView listview = ((ListView)findViewById(R.id.mylist));
|
||||
final String clientPackageName = getIntent().getStringExtra("clientPackageName");
|
||||
|
||||
final ArrayList<StringForTyping> items = new ArrayList<StringForTyping>();
|
||||
|
||||
|
||||
|
||||
|
||||
StringForTyping openOrChangeEntry = new StringForTyping();
|
||||
if (keepass2android.kbbridge.KeyboardData.entryName == null)
|
||||
{
|
||||
openOrChangeEntry.displayName = openOrChangeEntry.key = getString(R.string.open_entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
openOrChangeEntry.displayName = openOrChangeEntry.key = getString(R.string.change_entry);
|
||||
}
|
||||
openOrChangeEntry.value = "KP2ASPECIAL_SelectEntryTask";
|
||||
items.add(openOrChangeEntry);
|
||||
|
||||
|
||||
|
||||
|
||||
if ((clientPackageName != null) && (clientPackageName != ""))
|
||||
{
|
||||
StringForTyping searchEntry = new StringForTyping();
|
||||
try
|
||||
{
|
||||
searchEntry.key = searchEntry.displayName
|
||||
= getString(R.string.open_entry_for_app, new Object[]{clientPackageName});
|
||||
}
|
||||
catch (java.util.FormatFlagsConversionMismatchException e) //buggy crowdin support for Arabic?
|
||||
{
|
||||
android.util.Log.e("KP2A", "Please report this error to crocoapps@gmail.com");
|
||||
android.util.Log.e("KP2A", e.toString());
|
||||
|
||||
searchEntry.key = searchEntry.displayName
|
||||
= "Search entry for app";
|
||||
}
|
||||
|
||||
searchEntry.value = "KP2ASPECIAL_SearchUrlTask";
|
||||
items.add(searchEntry);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String[] itemNames = new String[items.size()];
|
||||
int i=0;
|
||||
for (StringForTyping sft: items)
|
||||
itemNames[i++] = sft.displayName;
|
||||
|
||||
listview.setAdapter(new ArrayAdapter<String>(this,
|
||||
R.layout.kp2a_textview,
|
||||
itemNames));
|
||||
listview.setClickable(true);
|
||||
listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int item, long l) {
|
||||
Log.d("KP2AK", "clicked item: " + items.get(item).key);
|
||||
|
||||
if (items.get(item).value.startsWith("KP2ASPECIAL")) {
|
||||
//change entry
|
||||
Log.d("KP2AK", "clicked item: " + items.get(item).value);
|
||||
|
||||
String packageName = getApplicationContext().getPackageName();
|
||||
Intent startKp2aIntent = getPackageManager().getLaunchIntentForPackage(packageName);
|
||||
if (startKp2aIntent != null)
|
||||
{
|
||||
startKp2aIntent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
startKp2aIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
String value = items.get(item).value;
|
||||
String taskName = value.substring("KP2ASPECIAL_".length());
|
||||
startKp2aIntent.putExtra("KP2A_APPTASK", taskName);
|
||||
if (taskName.equals("SearchUrlTask"))
|
||||
{
|
||||
startKp2aIntent.putExtra("UrlToSearch", "androidapp://"+clientPackageName);
|
||||
}
|
||||
startActivity(startKp2aIntent);
|
||||
} else Log.w("KP2AK", "didn't find intent for "+packageName);
|
||||
} else {
|
||||
|
||||
StringForTyping theItem = items.get(item);
|
||||
|
||||
KP2AKeyboard.CurrentlyRunningService.commitStringForTyping(theItem);
|
||||
|
||||
}
|
||||
Kp2aDialog.this.finish();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.button_cancel).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Kp2aDialog.this.finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@@ -43,6 +43,7 @@ public class LatinKeyboardView extends LatinKeyboardBaseView {
|
||||
static final int KEYCODE_KP2A_ALPHA = -203;
|
||||
static final int KEYCODE_KP2A_SWITCH = -204;
|
||||
static final int KEYCODE_KP2A_LOCK = -205;
|
||||
static final int KEYCODE_KP2A_NEXTFIELDS = -206;
|
||||
|
||||
private Keyboard mPhoneKeyboard;
|
||||
|
||||
|
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="12dp">
|
||||
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_cancel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginTop="19dp"
|
||||
android:text="@string/cancel" />
|
||||
|
||||
|
||||
<ListView
|
||||
android:id="@+id/mylist"
|
||||
android:layout_above="@id/button_cancel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentTop="true"
|
||||
tools:context="keepass2android.softkeyboard.Kp2aDialog">
|
||||
|
||||
|
||||
</ListView>
|
||||
|
||||
|
||||
</RelativeLayout>
|
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@android:id/text1"
|
||||
android:paddingTop="6dip"
|
||||
android:paddingBottom="6dip"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="20sp" />
|
@@ -8,7 +8,7 @@
|
||||
<string name="kp2a_password">密码</string>
|
||||
<string name="kp2a_prefs">输入凭据设置</string>
|
||||
<string name="kp2a_auto_fill">自动填充已启用</string>
|
||||
<string name="kp2a_auto_fill_summary">当进入一个空白字段时自动填充文字,如果 Keepass2Android 是激活键盘,且有一个相匹配字段的提示文本。</string>
|
||||
<string name="kp2a_auto_fill_summary">当填充区域为空白、键盘有待输入条目、且有字段匹配填充区域的提示文本时,自动将其填入。</string>
|
||||
<string name="kp2a_remember_auto_fill">记忆字段提示文本</string>
|
||||
<string name="kp2a_remember_auto_fill_summary">如果通过手动选择 Keepass2Android 填充字段,请记住哪个字段在对应字段中输入。该字段是后来由其提示文本重新检测到。</string>
|
||||
<string name="kp2a_simple_keyboard">简易键盘</string>
|
||||
|
@@ -35,6 +35,7 @@
|
||||
<integer name="key_kp2a_alpha">-203</integer>
|
||||
<integer name="key_kp2a_switch">-204</integer>
|
||||
<integer name="key_kp2a_lock">-205</integer>
|
||||
<integer name="key_kp2a_nextfields">-206</integer>
|
||||
|
||||
|
||||
</resources>
|
||||
|
@@ -376,6 +376,7 @@
|
||||
<!-- Title for Latin keyboard debug settings activity / dialog -->
|
||||
<string name="english_ime_debug_settings" translatable="false">Android keyboard Debug settings</string>
|
||||
<string name="prefs_debug_mode" translatable="false">Debug Mode</string>
|
||||
<string name="kp2a_nextfields"><![CDATA[>]]></string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
@@ -12,32 +12,37 @@
|
||||
<Key
|
||||
android:codes="@integer/key_kp2a_alpha"
|
||||
android:keyLabel="@string/label_alpha_key"
|
||||
android:keyWidth="12%p"
|
||||
android:keyWidth="10%p"
|
||||
android:isModifier="true"
|
||||
android:keyEdgeFlags="left" />
|
||||
<Key
|
||||
android:codes="@integer/key_kp2a_user"
|
||||
android:keyLabel="@string/kp2a_user"
|
||||
android:keyWidth="25%p"
|
||||
android:keyWidth="22%p"
|
||||
/>
|
||||
<Key
|
||||
android:codes="@integer/key_kp2a_pass"
|
||||
android:keyLabel="@string/kp2a_password"
|
||||
android:keyWidth="15%p"
|
||||
android:keyWidth="12%p"
|
||||
/>
|
||||
<Key
|
||||
android:codes="@integer/key_kp2a_nextfields"
|
||||
android:keyLabel="@string/kp2a_nextfields"
|
||||
android:keyWidth="8%p"
|
||||
/>
|
||||
<Key
|
||||
android:codes="@integer/key_kp2a"
|
||||
android:keyIcon="@drawable/sym_keyboard_kp2a"
|
||||
android:iconPreview="@drawable/sym_keyboard_feedback_kp2a"
|
||||
android:popupKeyboard="@xml/popup_kp2a"
|
||||
android:keyWidth="12%p"
|
||||
android:keyWidth="10%p"
|
||||
android:isModifier="true" />
|
||||
|
||||
<Key
|
||||
android:codes="@integer/key_delete"
|
||||
android:keyIcon="@drawable/sym_keyboard_delete"
|
||||
android:iconPreview="@drawable/sym_keyboard_feedback_delete"
|
||||
android:keyWidth="12%p"
|
||||
android:keyWidth="10%p"
|
||||
android:isModifier="true"
|
||||
android:isRepeatable="true"
|
||||
/>
|
||||
|
@@ -12,32 +12,37 @@
|
||||
<Key
|
||||
android:codes="@integer/key_kp2a_alpha"
|
||||
android:keyLabel="@string/label_alpha_key"
|
||||
android:keyWidth="12%p"
|
||||
android:keyWidth="10%p"
|
||||
android:isModifier="true"
|
||||
android:keyEdgeFlags="left" />
|
||||
<Key
|
||||
android:codes="@integer/key_kp2a_user"
|
||||
android:keyLabel="@string/kp2a_user"
|
||||
android:keyWidth="20%p"
|
||||
android:keyWidth="19%p"
|
||||
/>
|
||||
<Key
|
||||
android:codes="@integer/key_kp2a_pass"
|
||||
android:keyLabel="@string/kp2a_password"
|
||||
android:keyWidth="20%p"
|
||||
android:keyWidth="19%p"
|
||||
/>
|
||||
<Key
|
||||
android:codes="@integer/key_kp2a_nextfields"
|
||||
android:keyLabel="@string/kp2a_nextfields"
|
||||
android:keyWidth="8%p"
|
||||
/>
|
||||
<Key
|
||||
android:codes="@integer/key_kp2a"
|
||||
android:keyIcon="@drawable/sym_keyboard_kp2a"
|
||||
android:iconPreview="@drawable/sym_keyboard_feedback_kp2a"
|
||||
android:popupKeyboard="@xml/popup_kp2a"
|
||||
android:keyWidth="12%p"
|
||||
android:keyWidth="10%p"
|
||||
android:isModifier="true" />
|
||||
|
||||
<Key
|
||||
android:codes="@integer/key_delete"
|
||||
android:keyIcon="@drawable/sym_keyboard_delete"
|
||||
android:iconPreview="@drawable/sym_keyboard_feedback_delete"
|
||||
android:keyWidth="12%p"
|
||||
android:keyWidth="10%p"
|
||||
android:isModifier="true"
|
||||
android:isRepeatable="true"
|
||||
/>
|
||||
|
@@ -12,32 +12,37 @@
|
||||
<Key
|
||||
android:codes="@integer/key_kp2a_alpha"
|
||||
android:keyLabel="@string/label_alpha_key"
|
||||
android:keyWidth="12%p"
|
||||
android:keyWidth="10%p"
|
||||
android:isModifier="true"
|
||||
android:keyEdgeFlags="left" />
|
||||
<Key
|
||||
android:codes="@integer/key_kp2a_user"
|
||||
android:keyLabel="@string/kp2a_user"
|
||||
android:keyWidth="20%p"
|
||||
/>
|
||||
android:keyWidth="19%p"
|
||||
/>
|
||||
<Key
|
||||
android:codes="@integer/key_kp2a_pass"
|
||||
android:keyLabel="@string/kp2a_password"
|
||||
android:keyWidth="20%p"
|
||||
/>
|
||||
android:keyWidth="19%p"
|
||||
/>
|
||||
<Key
|
||||
android:codes="@integer/key_kp2a_nextfields"
|
||||
android:keyLabel="@string/kp2a_nextfields"
|
||||
android:keyWidth="8%p"
|
||||
/>
|
||||
<Key
|
||||
android:codes="@integer/key_kp2a"
|
||||
android:keyIcon="@drawable/sym_bkeyboard_kp2a"
|
||||
android:iconPreview="@drawable/sym_keyboard_feedback_kp2a"
|
||||
android:popupKeyboard="@xml/popup_kp2a"
|
||||
android:keyWidth="12%p"
|
||||
android:keyWidth="10%p"
|
||||
android:isModifier="true" />
|
||||
|
||||
<Key
|
||||
android:codes="@integer/key_delete"
|
||||
android:keyIcon="@drawable/sym_bkeyboard_delete"
|
||||
android:iconPreview="@drawable/sym_keyboard_feedback_delete"
|
||||
android:keyWidth="12%p"
|
||||
android:keyWidth="10%p"
|
||||
android:isRepeatable="true"
|
||||
/>
|
||||
<Key
|
||||
|
0
src/java/KP2ASoftkeyboard_AS/gradlew
vendored
Normal file → Executable file
0
src/java/KP2ASoftkeyboard_AS/gradlew
vendored
Normal file → Executable file
0
src/java/Keepass2AndroidPluginSDK2/gradlew
vendored
Normal file → Executable file
0
src/java/Keepass2AndroidPluginSDK2/gradlew
vendored
Normal file → Executable file
@@ -13,7 +13,7 @@
|
||||
<string name="afc_cmd_grid_view">Ruudukkonäkymä</string>
|
||||
<string name="afc_cmd_home">Etusivu</string>
|
||||
<string name="afc_cmd_list_view">Luettelonäkymä</string>
|
||||
<string name="afc_cmd_new_folder">Uusi kansio…</string>
|
||||
<string name="afc_cmd_new_folder">Uusi kansio</string>
|
||||
<string name="afc_cmd_select_all_files">Valitse kaikki tiedostot</string>
|
||||
<string name="afc_cmd_select_all_folders">Valitse kaikki kansiot</string>
|
||||
<string name="afc_cmd_sort">Lajittele…</string>
|
||||
@@ -23,8 +23,8 @@
|
||||
<string name="afc_hint_folder_name">kansion nimi</string>
|
||||
<string name="afc_hint_save_as_filename">tiedostonimi</string>
|
||||
<string name="afc_hint_search">haku</string>
|
||||
<string name="afc_msg_app_doesnot_have_permission_to_create_files">Sovelluksella ei ole oikeutta luoda tiedostoja/kansioita</string>
|
||||
<string name="afc_msg_app_doesnot_have_permission_to_delete_files">Sovelluksella ei ole oikeutta poistaa tiedostoja/kansioita</string>
|
||||
<string name="afc_msg_app_doesnot_have_permission_to_create_files">Sovelluksella ei ole oikeutta luoda tiedostoja / kansioita</string>
|
||||
<string name="afc_msg_app_doesnot_have_permission_to_delete_files">Sovelluksella ei ole oikeutta poistaa tiedostoja / kansioita</string>
|
||||
<string name="afc_msg_cancelled">Peruutettu</string>
|
||||
<string name="afc_msg_cannot_connect_to_file_provider_service">Ei voida yhdistää tiedoston tarjoavaan palveluun</string>
|
||||
<string name="afc_msg_cannot_create_new_folder_here">Uutta kansiota ei voi luoda tänne</string>
|
||||
@@ -46,7 +46,7 @@
|
||||
<string name="afc_pmsg_max_file_count_allowed">...liikaa tiedostoja, maksimimäärä on %1$,d</string>
|
||||
<string name="afc_pmsg_unknown_error">Tuntematon virhe: %1$s</string>
|
||||
<string name="afc_root">Juuri</string>
|
||||
<string name="afc_title_advanced_selection">Valitse...</string>
|
||||
<string name="afc_title_advanced_selection">Valitse</string>
|
||||
<string name="afc_title_confirmation">Vahvista</string>
|
||||
<string name="afc_title_date">Pvm.</string>
|
||||
<string name="afc_title_error">Virhe</string>
|
||||
|
@@ -22,8 +22,12 @@ namespace keepass2android
|
||||
{
|
||||
|
||||
public class CancelDialog : Dialog {
|
||||
public CancelDialog(Context context): base(context) {
|
||||
}
|
||||
protected readonly Activity _activity;
|
||||
|
||||
public CancelDialog(Activity activity): base(activity)
|
||||
{
|
||||
_activity = activity;
|
||||
}
|
||||
|
||||
public bool Canceled { get; private set; }
|
||||
|
||||
|
@@ -36,14 +36,13 @@ namespace keepass2android
|
||||
var chalIntent = Activity.TryGetYubichallengeIntentOrPrompt(challenge64, true);
|
||||
|
||||
if (chalIntent == null)
|
||||
throw new Exception("YubiChallenge not installed.");
|
||||
|
||||
Activity.StartActivityForResult(chalIntent, _requestCode);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{
|
||||
Error = Activity.GetString(Resource.String.NoChallengeApp);
|
||||
}
|
||||
else
|
||||
{
|
||||
Activity.StartActivityForResult(chalIntent, _requestCode);
|
||||
}
|
||||
|
||||
});
|
||||
while ((Response == null) && (Error == null))
|
||||
|
@@ -26,8 +26,9 @@ 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_1_05),
|
||||
|
||||
ctx.GetString(Resource.String.ChangeLog_1_06),
|
||||
ctx.GetString(Resource.String.ChangeLog_1_05),
|
||||
ctx.GetString(Resource.String.ChangeLog_1_04b),
|
||||
ctx.GetString(Resource.String.ChangeLog_1_04),
|
||||
ctx.GetString(Resource.String.ChangeLog_1_03),
|
||||
|
@@ -411,15 +411,15 @@ namespace keepass2android
|
||||
}
|
||||
else
|
||||
{
|
||||
var task = new CreateNewFilename(new ActionOnFinish((success, messageOrFilename) =>
|
||||
var task = new CreateNewFilename(this, new ActionOnFinish(this, (success, messageOrFilename, activity) =>
|
||||
{
|
||||
if (!success)
|
||||
{
|
||||
Toast.MakeText(this, messageOrFilename, ToastLength.Long).Show();
|
||||
Toast.MakeText(activity, messageOrFilename, ToastLength.Long).Show();
|
||||
return;
|
||||
}
|
||||
_ioc = new IOConnectionInfo { Path = ConvertFilenameToIocPath(messageOrFilename) };
|
||||
UpdateIocView();
|
||||
((CreateDatabaseActivity)activity)?.UpdateIocView();
|
||||
|
||||
}), filename);
|
||||
|
||||
@@ -471,7 +471,7 @@ namespace keepass2android
|
||||
private readonly IOConnectionInfo _ioc;
|
||||
|
||||
public LaunchGroupActivity(IOConnectionInfo ioc, CreateDatabaseActivity activity)
|
||||
: base(null)
|
||||
: base(activity, null)
|
||||
{
|
||||
_activity = activity;
|
||||
_ioc = ioc;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user