Compare commits
402 Commits
2.5.0.0bet
...
2.5.0.0bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
88ac2ecf98 | ||
|
|
227cb078a5 | ||
|
|
a17582bf6d | ||
|
|
e8ba5dc6e2 | ||
|
|
f37d3324e6 | ||
|
|
fcb06c8c22 | ||
|
|
d8bdf4500a | ||
|
|
69ea4d5414 | ||
|
|
7e9f99e5c8 | ||
|
|
95541d99c4 | ||
|
|
05ca7e6d69 | ||
|
|
644a4a4886 | ||
|
|
7eb82ddbea | ||
|
|
e721d4ca9e | ||
|
|
c72582b679 | ||
|
|
217f0a82b5 | ||
|
|
1efd172b42 | ||
|
|
e8d0d03ad9 | ||
|
|
6cb97de793 | ||
|
|
77dbdc235a | ||
|
|
a9c87ea2b8 | ||
|
|
232829526c | ||
|
|
b5d8b2f14c | ||
|
|
c2673a627c | ||
|
|
bb49256188 | ||
|
|
1b6a284dd6 | ||
|
|
36b35b907e | ||
|
|
f61b310ff2 | ||
|
|
c1e84b3bf1 | ||
|
|
9971d27ef3 | ||
|
|
3c0835f725 | ||
|
|
023aba2b60 | ||
|
|
abc0a14dda | ||
|
|
dc23c6a445 | ||
|
|
161a0ffc59 | ||
|
|
b96436c906 | ||
|
|
cee7419208 | ||
|
|
9ff6e7a080 | ||
|
|
9112a568d9 | ||
|
|
8d0c9bc894 | ||
|
|
e7b4e4501e | ||
|
|
df80084822 | ||
|
|
4df2891b1a | ||
|
|
d0560677fa | ||
|
|
9130a3851f | ||
|
|
bb3fb26847 | ||
|
|
8406264138 | ||
|
|
e51f48ebe0 | ||
|
|
a0a2aa4c5d | ||
|
|
65cea7b5ec | ||
|
|
fb589419de | ||
|
|
ae9844d5a1 | ||
|
|
645ea21581 | ||
|
|
60fd675dff | ||
|
|
48903da446 | ||
|
|
5399df134c | ||
|
|
a858040ace | ||
|
|
d792b7d5ae | ||
|
|
8b3ed1a7dc | ||
|
|
47004857ea | ||
|
|
82a6b8d7ef | ||
|
|
a30bcf1fa7 | ||
|
|
febe978fa1 | ||
|
|
1eeefcf495 | ||
|
|
ff6b0eee6c | ||
|
|
a7c8eaa937 | ||
|
|
55545e31e8 | ||
|
|
34132c6da7 | ||
|
|
fbafa99a3b | ||
|
|
bd63805611 | ||
|
|
ae8398a434 | ||
|
|
0b9318de88 | ||
|
|
55e4bbf9db | ||
|
|
f33a572751 | ||
|
|
2849cedbd8 | ||
|
|
041d1b29d1 | ||
|
|
cdcdc2fee1 | ||
|
|
8e35d5bc8d | ||
|
|
f12e368707 | ||
|
|
f01895c7a7 | ||
|
|
4ce0c067e1 | ||
|
|
728a2cbfae | ||
|
|
a4aab3b933 | ||
|
|
11ee0d6544 | ||
|
|
2b80dad47c | ||
|
|
7bb13ec1c2 | ||
|
|
344010d2bb | ||
|
|
ef37ecddc6 | ||
|
|
91a38e205e | ||
|
|
bd4de382e4 | ||
|
|
623244c3bd | ||
|
|
7a06ff6dec | ||
|
|
6d735e24ff | ||
|
|
5c30d544fa | ||
|
|
54a3876288 | ||
|
|
57f71afb98 | ||
|
|
d8ec198f6f | ||
|
|
faa6d7c9f6 | ||
|
|
d79a5b17a5 | ||
|
|
34deea5d32 | ||
|
|
edc7324c1d | ||
|
|
b9190e8254 | ||
|
|
534878ae99 | ||
|
|
99bfd21ecc | ||
|
|
cb5c324c9d | ||
|
|
55dc504f26 | ||
|
|
ecb0138c90 | ||
|
|
0860eeb87f | ||
|
|
f08bff61cf | ||
|
|
432aca6465 | ||
|
|
7cdb8db146 | ||
|
|
6ba9dedcb8 | ||
|
|
6d603608f4 | ||
|
|
64f4d9fb84 | ||
|
|
60ccc450ae | ||
|
|
ddb5f327a3 | ||
|
|
df90ea42eb | ||
|
|
a062d648b3 | ||
|
|
a59ae820b5 | ||
|
|
228831acdd | ||
|
|
bf15ee43da | ||
|
|
608f45677c | ||
|
|
1cb15f214b | ||
|
|
cd4a9e9b03 | ||
|
|
d6eae56d4f | ||
|
|
b5a87a63dc | ||
|
|
1eb17c4f34 | ||
|
|
8a6ce1f711 | ||
|
|
0f22f8af45 | ||
|
|
b2e81e6fd9 | ||
|
|
f82eab942d | ||
|
|
aa29aec40f | ||
|
|
181def52ab | ||
|
|
96d2bd63cc | ||
|
|
194021a957 | ||
|
|
9e307f94ea | ||
|
|
155b2de138 | ||
|
|
c76c3fd2be | ||
|
|
01c5554944 | ||
|
|
542cf65b41 | ||
|
|
f037561a67 | ||
|
|
379263a6d3 | ||
|
|
c420ca01f6 | ||
|
|
a1f9db6eee | ||
|
|
c9212174c4 | ||
|
|
0065336377 | ||
|
|
4f9625a3e1 | ||
|
|
7688ebd29b | ||
|
|
3f2a7f1eb3 | ||
|
|
b3d067d0c8 | ||
|
|
a3b4ad5ac1 | ||
|
|
e3b329d27f | ||
|
|
7d10c43822 | ||
|
|
fcb0d45d39 | ||
|
|
5492db0223 | ||
|
|
2207b05f5f | ||
|
|
f15a0c2591 | ||
|
|
92fb22129c | ||
|
|
ccca9c4400 | ||
|
|
0597cb4416 | ||
|
|
0602174e50 | ||
|
|
6fddc92ce7 | ||
|
|
aa30df6454 | ||
|
|
f6c61ab407 | ||
|
|
2ab81ed77c | ||
|
|
0ade035f43 | ||
|
|
73b62035d8 | ||
|
|
28837db308 | ||
|
|
85befef260 | ||
|
|
e7bbb47422 | ||
|
|
846bc7edb1 | ||
|
|
99a9842a1f | ||
|
|
33009138c3 | ||
|
|
c74b82ebd8 | ||
|
|
49ea92a4a5 | ||
|
|
6cc4eeaa30 | ||
|
|
1b89f79888 | ||
|
|
07d99de3ea | ||
|
|
ae757affa1 | ||
|
|
482b6296fc | ||
|
|
d37ce729f0 | ||
|
|
e92ce232bc | ||
|
|
78ae44b160 | ||
|
|
49ce87a8e0 | ||
|
|
d2fe5ce884 | ||
|
|
5e695756de | ||
|
|
0506a75417 | ||
|
|
34e1316144 | ||
|
|
18dffa6c75 | ||
|
|
03621c378e | ||
|
|
aff9312419 | ||
|
|
4651b1be96 | ||
|
|
32497a22d2 | ||
|
|
3b5ef56c16 | ||
|
|
d4cc3a58d8 | ||
|
|
afedbb38b2 | ||
|
|
fe70bf3877 | ||
|
|
f14ee6cf1c | ||
|
|
1791b15f85 | ||
|
|
6c5b3b3a0d | ||
|
|
6ea2287679 | ||
|
|
cad4ec22b4 | ||
|
|
f277983caf | ||
|
|
5e561e5321 | ||
|
|
ef83dbcae2 | ||
|
|
ab6c69adcb | ||
|
|
1c90747476 | ||
|
|
c3b3d8482c | ||
|
|
86b4d92599 | ||
|
|
1f6786b1f8 | ||
|
|
4cd2b153f4 | ||
|
|
27b0810688 | ||
|
|
94c72a4cf6 | ||
|
|
e634116e71 | ||
|
|
9021cb5bc8 | ||
|
|
3674900a54 | ||
|
|
9855ae79c3 | ||
|
|
fe1a4985f1 | ||
|
|
015a368a1d | ||
|
|
07f59e071d | ||
|
|
670e2bfe33 | ||
|
|
992b6382a3 | ||
|
|
c3ac550c93 | ||
|
|
acba7fc5de | ||
|
|
ccb500fdf4 | ||
|
|
44111507e7 | ||
|
|
5f14596ed2 | ||
|
|
4ad65c8f4a | ||
|
|
b4b215fe30 | ||
|
|
d8a8005d70 | ||
|
|
37ca15b77c | ||
|
|
6c18fe5591 | ||
|
|
fdcb05467c | ||
|
|
ef8db46ae7 | ||
|
|
14f56c77e8 | ||
|
|
44e21084e4 | ||
|
|
b7f1275789 | ||
|
|
b1be05db4d | ||
|
|
09c776fd7e | ||
|
|
e8a24790a5 | ||
|
|
8b3be79266 | ||
|
|
e5f0572c1c | ||
|
|
68df3bc6c3 | ||
|
|
a3da960c26 | ||
|
|
d9490f9840 | ||
|
|
3b24f9d821 | ||
|
|
bf35897e92 | ||
|
|
977705b42d | ||
|
|
459bc40515 | ||
|
|
eb8ca9355c | ||
|
|
31f7b0d5be | ||
|
|
7c54946c4b | ||
|
|
5aaf2c222a | ||
|
|
9424feefce | ||
|
|
a3917ccab6 | ||
|
|
5286a60142 | ||
|
|
d4459de49b | ||
|
|
05dba6668c | ||
|
|
c15a1c6eaa | ||
|
|
fe8c962f73 | ||
|
|
4192cf2403 | ||
|
|
1817f1aa9e | ||
|
|
afacf352ed | ||
|
|
d3ebbba2a1 | ||
|
|
460edf1745 | ||
|
|
dacb19d412 | ||
|
|
fe8158db85 | ||
|
|
a36e4fbcd0 | ||
|
|
9442c7ef07 | ||
|
|
d4a0b59eb1 | ||
|
|
07600949ab | ||
|
|
7efaad1818 | ||
|
|
e32b0d1c25 | ||
|
|
0fdcc29aa2 | ||
|
|
37bedbffc9 | ||
|
|
46505150c4 | ||
|
|
e18c5c90cc | ||
|
|
1f5649d9d2 | ||
|
|
7bbd55a9fd | ||
|
|
92eeccf84e | ||
|
|
7bcc289518 | ||
|
|
507f758c0d | ||
|
|
6afffb7245 | ||
|
|
c62f4ae0b3 | ||
|
|
ee80c614e0 | ||
|
|
fea7af6910 | ||
|
|
c72aa0e97d | ||
|
|
3dd60b5392 | ||
|
|
a357267552 | ||
|
|
1badeb2eef | ||
|
|
0bb8d2a417 | ||
|
|
4a215db83c | ||
|
|
512e55a170 | ||
|
|
1ebe8dc022 | ||
|
|
cafeabdbc3 | ||
|
|
b342b26409 | ||
|
|
938c3a07af | ||
|
|
16288f98f7 | ||
|
|
a932156e85 | ||
|
|
64e9b9fb6d | ||
|
|
7af28550da | ||
|
|
60e2d786dd | ||
|
|
ec08f3430d | ||
|
|
a50aa0fb95 | ||
|
|
cf026e8eaa | ||
|
|
77614d0c4a | ||
|
|
e8d71039d7 | ||
|
|
4164b5bd37 | ||
|
|
3c66ec82b5 | ||
|
|
b796c16877 | ||
|
|
42d34d8f0c | ||
|
|
5fbb37df82 | ||
|
|
52e12d7cbd | ||
|
|
5cf5719e8e | ||
|
|
af3a80143e | ||
|
|
90db27c3fe | ||
|
|
3d584b76f7 | ||
|
|
fbf3dec421 | ||
|
|
1d36683128 | ||
|
|
cefc546c0a | ||
|
|
7aeb51813c | ||
|
|
d6fc29ec79 | ||
|
|
9af182e0c3 | ||
|
|
c7120b997f | ||
|
|
e61571fcec | ||
|
|
9a900b32b2 | ||
|
|
1033dd78b0 | ||
|
|
4aaae3f59e | ||
|
|
1424633a58 | ||
|
|
c9b98094e5 | ||
|
|
5707026985 | ||
|
|
bfcfb842fb | ||
|
|
8fe2230891 | ||
|
|
41cc0b1a5a | ||
|
|
cc8c525dab | ||
|
|
92bc3c2838 | ||
|
|
1d065e7bc5 | ||
|
|
fb1b90a281 | ||
|
|
268f716104 | ||
|
|
b7328875f1 | ||
|
|
02ee58efa7 | ||
|
|
6754881847 | ||
|
|
6e4c5d8c26 | ||
|
|
544648c2eb | ||
|
|
e62f8bf56b | ||
|
|
7f5138b08b | ||
|
|
a367aeaf12 | ||
|
|
fc6453beba | ||
|
|
8a981b7a79 | ||
|
|
d7f9a02699 | ||
|
|
7c9153ea04 | ||
|
|
2c16fe3335 | ||
|
|
eb14d27ca5 | ||
|
|
7024178069 | ||
|
|
c85ce3e0e8 | ||
|
|
067c5ff1cf | ||
|
|
429bd99f1c | ||
|
|
7b5bb0fd97 | ||
|
|
ae50f424d3 | ||
|
|
53cc1ad673 | ||
|
|
ceb80c6cac | ||
|
|
71bd3ab780 | ||
|
|
8a40a4b3ae | ||
|
|
7772db17ae | ||
|
|
11738d807c | ||
|
|
80b9a8fa50 | ||
|
|
d619f6581e | ||
|
|
697e9aa923 | ||
|
|
15c843fbb9 | ||
|
|
b6b7e61cfb | ||
|
|
d5b0ee9371 | ||
|
|
e86807c3d3 | ||
|
|
08fcb119a9 | ||
|
|
edff33afd1 | ||
|
|
bdfa963bed | ||
|
|
4eff247865 | ||
|
|
3e3d5bd7d8 | ||
|
|
5a74d1be8f | ||
|
|
812eccfe0e | ||
|
|
d00c337382 | ||
|
|
54dbcc95ab | ||
|
|
2e5ddd80ff | ||
|
|
2c44a4d760 | ||
|
|
f8561222d5 | ||
|
|
2c8e3e9c8e | ||
|
|
ccbc6c07ed | ||
|
|
47e820e3d8 | ||
|
|
13dea4b567 | ||
|
|
70d1ce715e | ||
|
|
cc41545c0a | ||
|
|
aded8fab0a | ||
|
|
9cb4d28ad8 | ||
|
|
a1b2235fb3 | ||
|
|
ed7f6e4b68 | ||
|
|
1ebba9d8be | ||
|
|
347522b9a6 | ||
|
|
918f563faa | ||
|
|
041f3eb568 | ||
|
|
4a1d97a622 | ||
|
|
cd0d712f56 | ||
|
|
761d9a1883 | ||
|
|
2c9a6d7c26 |
1
.gitignore
vendored
@@ -71,6 +71,7 @@ app/app.iml
|
||||
# Art
|
||||
art/screen*.png
|
||||
art/logo_512.png
|
||||
art/store_screens/
|
||||
|
||||
# Dir linux
|
||||
.directory
|
||||
|
||||
66
CHANGELOG
@@ -1,3 +1,69 @@
|
||||
KeepassDX (2.5.0.0beta18)
|
||||
* New recent databases views
|
||||
* New information dialog
|
||||
* Custom fields for the Magikeyboard
|
||||
* Timeout for the Magikeyboard
|
||||
* Long press for keyboard selection
|
||||
* Fix memory when opening the database
|
||||
* Memory management for attachments
|
||||
|
||||
KeepassDX (2.5.0.0beta17)
|
||||
* Fix font and search
|
||||
|
||||
KeepassDX (2.5.0.0beta16)
|
||||
* New search in a single fragment
|
||||
* Search suggestions
|
||||
* Added the display of usernames
|
||||
* Added translations
|
||||
* Fix read-only mode
|
||||
* Fix parcelable / toolbar / back
|
||||
|
||||
KeepassDX (2.5.0.0beta15)
|
||||
* Read only mode
|
||||
* Best group recovery for the navigation fragment
|
||||
* Fix copies in notifications
|
||||
* Fix orientation
|
||||
* Added translations
|
||||
|
||||
KeepassDX (2.5.0.0beta14)
|
||||
* Optimize all the memory with parcelables / fix search
|
||||
|
||||
KeepassDX (2.5.0.0beta13)
|
||||
* Fix memory issue with parcelable (crash in beta12 version)
|
||||
|
||||
KeepassDX (2.5.0.0beta12)
|
||||
* Added the Magikeyboard to fill the forms (settings still in development)
|
||||
* Added move and copy for groups and entries
|
||||
* New navigation in a single screen / new animations between activities
|
||||
* New icons for the material pack / vectorization
|
||||
* New adaptive launcher icon
|
||||
* Icons depends now of setting of list items
|
||||
* Added a setting to disable the open button when no password is identified
|
||||
* Added a setting to disable the education screens
|
||||
* Added a setting to disable the copy of protected custom fields
|
||||
* Fix the fingerprint recognition (WARNING : The keystore is reinit, you must delete the old keys)
|
||||
* Fix small bugs
|
||||
|
||||
KeepassDX (2.5.0.0beta11)
|
||||
* Fix crash in beta10 version
|
||||
|
||||
KeepassDX (2.5.0.0beta10)
|
||||
* Dynamically change Algorithm and Key Derivation Function in settings
|
||||
* Upgrade translations
|
||||
* New red volcano theme, fix classic dark theme
|
||||
* Add Material Icon Pack to the Free version
|
||||
* Update fingerprint state with checkbox
|
||||
* Fix bugs
|
||||
|
||||
KeepassDX (2.5.0.0beta9)
|
||||
* Education Screens to learn how to use the app
|
||||
* New designs
|
||||
* New custom font for character visibility
|
||||
* New themes
|
||||
* New icon pack
|
||||
* Change setting organisation
|
||||
* Pro version
|
||||
|
||||
KeepassDX (2.5.0.0beta8)
|
||||
* Hide custom entries protected
|
||||
* Best management of field references (https://keepass.info/help/base/fieldrefs.html)
|
||||
|
||||
396
LICENSES/LICENSE-FONT-AWESOME
Normal file
@@ -0,0 +1,396 @@
|
||||
Attribution 4.0 International
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons Corporation ("Creative Commons") is not a law firm and
|
||||
does not provide legal services or legal advice. Distribution of
|
||||
Creative Commons public licenses does not create a lawyer-client or
|
||||
other relationship. Creative Commons makes its licenses and related
|
||||
information available on an "as-is" basis. Creative Commons gives no
|
||||
warranties regarding its licenses, any material licensed under their
|
||||
terms and conditions, or any related information. Creative Commons
|
||||
disclaims all liability for damages resulting from their use to the
|
||||
fullest extent possible.
|
||||
|
||||
Using Creative Commons Public Licenses
|
||||
|
||||
Creative Commons public licenses provide a standard set of terms and
|
||||
conditions that creators and other rights holders may use to share
|
||||
original works of authorship and other material subject to copyright
|
||||
and certain other rights specified in the public license below. The
|
||||
following considerations are for informational purposes only, are not
|
||||
exhaustive, and do not form part of our licenses.
|
||||
|
||||
Considerations for licensors: Our public licenses are
|
||||
intended for use by those authorized to give the public
|
||||
permission to use material in ways otherwise restricted by
|
||||
copyright and certain other rights. Our licenses are
|
||||
irrevocable. Licensors should read and understand the terms
|
||||
and conditions of the license they choose before applying it.
|
||||
Licensors should also secure all rights necessary before
|
||||
applying our licenses so that the public can reuse the
|
||||
material as expected. Licensors should clearly mark any
|
||||
material not subject to the license. This includes other CC-
|
||||
licensed material, or material used under an exception or
|
||||
limitation to copyright. More considerations for licensors:
|
||||
wiki.creativecommons.org/Considerations_for_licensors
|
||||
|
||||
Considerations for the public: By using one of our public
|
||||
licenses, a licensor grants the public permission to use the
|
||||
licensed material under specified terms and conditions. If
|
||||
the licensor's permission is not necessary for any reason--for
|
||||
example, because of any applicable exception or limitation to
|
||||
copyright--then that use is not regulated by the license. Our
|
||||
licenses grant only permissions under copyright and certain
|
||||
other rights that a licensor has authority to grant. Use of
|
||||
the licensed material may still be restricted for other
|
||||
reasons, including because others have copyright or other
|
||||
rights in the material. A licensor may make special requests,
|
||||
such as asking that all changes be marked or described.
|
||||
Although not required by our licenses, you are encouraged to
|
||||
respect those requests where reasonable. More considerations
|
||||
for the public:
|
||||
wiki.creativecommons.org/Considerations_for_licensees
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons Attribution 4.0 International Public License
|
||||
|
||||
By exercising the Licensed Rights (defined below), You accept and agree
|
||||
to be bound by the terms and conditions of this Creative Commons
|
||||
Attribution 4.0 International Public License ("Public License"). To the
|
||||
extent this Public License may be interpreted as a contract, You are
|
||||
granted the Licensed Rights in consideration of Your acceptance of
|
||||
these terms and conditions, and the Licensor grants You such rights in
|
||||
consideration of benefits the Licensor receives from making the
|
||||
Licensed Material available under these terms and conditions.
|
||||
|
||||
|
||||
Section 1 -- Definitions.
|
||||
|
||||
a. Adapted Material means material subject to Copyright and Similar
|
||||
Rights that is derived from or based upon the Licensed Material
|
||||
and in which the Licensed Material is translated, altered,
|
||||
arranged, transformed, or otherwise modified in a manner requiring
|
||||
permission under the Copyright and Similar Rights held by the
|
||||
Licensor. For purposes of this Public License, where the Licensed
|
||||
Material is a musical work, performance, or sound recording,
|
||||
Adapted Material is always produced where the Licensed Material is
|
||||
synched in timed relation with a moving image.
|
||||
|
||||
b. Adapter's License means the license You apply to Your Copyright
|
||||
and Similar Rights in Your contributions to Adapted Material in
|
||||
accordance with the terms and conditions of this Public License.
|
||||
|
||||
c. Copyright and Similar Rights means copyright and/or similar rights
|
||||
closely related to copyright including, without limitation,
|
||||
performance, broadcast, sound recording, and Sui Generis Database
|
||||
Rights, without regard to how the rights are labeled or
|
||||
categorized. For purposes of this Public License, the rights
|
||||
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
||||
Rights.
|
||||
|
||||
d. Effective Technological Measures means those measures that, in the
|
||||
absence of proper authority, may not be circumvented under laws
|
||||
fulfilling obligations under Article 11 of the WIPO Copyright
|
||||
Treaty adopted on December 20, 1996, and/or similar international
|
||||
agreements.
|
||||
|
||||
e. Exceptions and Limitations means fair use, fair dealing, and/or
|
||||
any other exception or limitation to Copyright and Similar Rights
|
||||
that applies to Your use of the Licensed Material.
|
||||
|
||||
f. Licensed Material means the artistic or literary work, database,
|
||||
or other material to which the Licensor applied this Public
|
||||
License.
|
||||
|
||||
g. Licensed Rights means the rights granted to You subject to the
|
||||
terms and conditions of this Public License, which are limited to
|
||||
all Copyright and Similar Rights that apply to Your use of the
|
||||
Licensed Material and that the Licensor has authority to license.
|
||||
|
||||
h. Licensor means the individual(s) or entity(ies) granting rights
|
||||
under this Public License.
|
||||
|
||||
i. Share means to provide material to the public by any means or
|
||||
process that requires permission under the Licensed Rights, such
|
||||
as reproduction, public display, public performance, distribution,
|
||||
dissemination, communication, or importation, and to make material
|
||||
available to the public including in ways that members of the
|
||||
public may access the material from a place and at a time
|
||||
individually chosen by them.
|
||||
|
||||
j. Sui Generis Database Rights means rights other than copyright
|
||||
resulting from Directive 96/9/EC of the European Parliament and of
|
||||
the Council of 11 March 1996 on the legal protection of databases,
|
||||
as amended and/or succeeded, as well as other essentially
|
||||
equivalent rights anywhere in the world.
|
||||
|
||||
k. You means the individual or entity exercising the Licensed Rights
|
||||
under this Public License. Your has a corresponding meaning.
|
||||
|
||||
|
||||
Section 2 -- Scope.
|
||||
|
||||
a. License grant.
|
||||
|
||||
1. Subject to the terms and conditions of this Public License,
|
||||
the Licensor hereby grants You a worldwide, royalty-free,
|
||||
non-sublicensable, non-exclusive, irrevocable license to
|
||||
exercise the Licensed Rights in the Licensed Material to:
|
||||
|
||||
a. reproduce and Share the Licensed Material, in whole or
|
||||
in part; and
|
||||
|
||||
b. produce, reproduce, and Share Adapted Material.
|
||||
|
||||
2. Exceptions and Limitations. For the avoidance of doubt, where
|
||||
Exceptions and Limitations apply to Your use, this Public
|
||||
License does not apply, and You do not need to comply with
|
||||
its terms and conditions.
|
||||
|
||||
3. Term. The term of this Public License is specified in Section
|
||||
6(a).
|
||||
|
||||
4. Media and formats; technical modifications allowed. The
|
||||
Licensor authorizes You to exercise the Licensed Rights in
|
||||
all media and formats whether now known or hereafter created,
|
||||
and to make technical modifications necessary to do so. The
|
||||
Licensor waives and/or agrees not to assert any right or
|
||||
authority to forbid You from making technical modifications
|
||||
necessary to exercise the Licensed Rights, including
|
||||
technical modifications necessary to circumvent Effective
|
||||
Technological Measures. For purposes of this Public License,
|
||||
simply making modifications authorized by this Section 2(a)
|
||||
(4) never produces Adapted Material.
|
||||
|
||||
5. Downstream recipients.
|
||||
|
||||
a. Offer from the Licensor -- Licensed Material. Every
|
||||
recipient of the Licensed Material automatically
|
||||
receives an offer from the Licensor to exercise the
|
||||
Licensed Rights under the terms and conditions of this
|
||||
Public License.
|
||||
|
||||
b. No downstream restrictions. You may not offer or impose
|
||||
any additional or different terms or conditions on, or
|
||||
apply any Effective Technological Measures to, the
|
||||
Licensed Material if doing so restricts exercise of the
|
||||
Licensed Rights by any recipient of the Licensed
|
||||
Material.
|
||||
|
||||
6. No endorsement. Nothing in this Public License constitutes or
|
||||
may be construed as permission to assert or imply that You
|
||||
are, or that Your use of the Licensed Material is, connected
|
||||
with, or sponsored, endorsed, or granted official status by,
|
||||
the Licensor or others designated to receive attribution as
|
||||
provided in Section 3(a)(1)(A)(i).
|
||||
|
||||
b. Other rights.
|
||||
|
||||
1. Moral rights, such as the right of integrity, are not
|
||||
licensed under this Public License, nor are publicity,
|
||||
privacy, and/or other similar personality rights; however, to
|
||||
the extent possible, the Licensor waives and/or agrees not to
|
||||
assert any such rights held by the Licensor to the limited
|
||||
extent necessary to allow You to exercise the Licensed
|
||||
Rights, but not otherwise.
|
||||
|
||||
2. Patent and trademark rights are not licensed under this
|
||||
Public License.
|
||||
|
||||
3. To the extent possible, the Licensor waives any right to
|
||||
collect royalties from You for the exercise of the Licensed
|
||||
Rights, whether directly or through a collecting society
|
||||
under any voluntary or waivable statutory or compulsory
|
||||
licensing scheme. In all other cases the Licensor expressly
|
||||
reserves any right to collect such royalties.
|
||||
|
||||
|
||||
Section 3 -- License Conditions.
|
||||
|
||||
Your exercise of the Licensed Rights is expressly made subject to the
|
||||
following conditions.
|
||||
|
||||
a. Attribution.
|
||||
|
||||
1. If You Share the Licensed Material (including in modified
|
||||
form), You must:
|
||||
|
||||
a. retain the following if it is supplied by the Licensor
|
||||
with the Licensed Material:
|
||||
|
||||
i. identification of the creator(s) of the Licensed
|
||||
Material and any others designated to receive
|
||||
attribution, in any reasonable manner requested by
|
||||
the Licensor (including by pseudonym if
|
||||
designated);
|
||||
|
||||
ii. a copyright notice;
|
||||
|
||||
iii. a notice that refers to this Public License;
|
||||
|
||||
iv. a notice that refers to the disclaimer of
|
||||
warranties;
|
||||
|
||||
v. a URI or hyperlink to the Licensed Material to the
|
||||
extent reasonably practicable;
|
||||
|
||||
b. indicate if You modified the Licensed Material and
|
||||
retain an indication of any previous modifications; and
|
||||
|
||||
c. indicate the Licensed Material is licensed under this
|
||||
Public License, and include the text of, or the URI or
|
||||
hyperlink to, this Public License.
|
||||
|
||||
2. You may satisfy the conditions in Section 3(a)(1) in any
|
||||
reasonable manner based on the medium, means, and context in
|
||||
which You Share the Licensed Material. For example, it may be
|
||||
reasonable to satisfy the conditions by providing a URI or
|
||||
hyperlink to a resource that includes the required
|
||||
information.
|
||||
|
||||
3. If requested by the Licensor, You must remove any of the
|
||||
information required by Section 3(a)(1)(A) to the extent
|
||||
reasonably practicable.
|
||||
|
||||
4. If You Share Adapted Material You produce, the Adapter's
|
||||
License You apply must not prevent recipients of the Adapted
|
||||
Material from complying with this Public License.
|
||||
|
||||
|
||||
Section 4 -- Sui Generis Database Rights.
|
||||
|
||||
Where the Licensed Rights include Sui Generis Database Rights that
|
||||
apply to Your use of the Licensed Material:
|
||||
|
||||
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
||||
to extract, reuse, reproduce, and Share all or a substantial
|
||||
portion of the contents of the database;
|
||||
|
||||
b. if You include all or a substantial portion of the database
|
||||
contents in a database in which You have Sui Generis Database
|
||||
Rights, then the database in which You have Sui Generis Database
|
||||
Rights (but not its individual contents) is Adapted Material; and
|
||||
|
||||
c. You must comply with the conditions in Section 3(a) if You Share
|
||||
all or a substantial portion of the contents of the database.
|
||||
|
||||
For the avoidance of doubt, this Section 4 supplements and does not
|
||||
replace Your obligations under this Public License where the Licensed
|
||||
Rights include other Copyright and Similar Rights.
|
||||
|
||||
|
||||
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
|
||||
|
||||
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
|
||||
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
|
||||
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
|
||||
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
|
||||
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
|
||||
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
|
||||
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
|
||||
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
|
||||
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
|
||||
|
||||
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
|
||||
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
|
||||
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
|
||||
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
|
||||
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
|
||||
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
|
||||
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
|
||||
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
|
||||
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
|
||||
|
||||
c. The disclaimer of warranties and limitation of liability provided
|
||||
above shall be interpreted in a manner that, to the extent
|
||||
possible, most closely approximates an absolute disclaimer and
|
||||
waiver of all liability.
|
||||
|
||||
|
||||
Section 6 -- Term and Termination.
|
||||
|
||||
a. This Public License applies for the term of the Copyright and
|
||||
Similar Rights licensed here. However, if You fail to comply with
|
||||
this Public License, then Your rights under this Public License
|
||||
terminate automatically.
|
||||
|
||||
b. Where Your right to use the Licensed Material has terminated under
|
||||
Section 6(a), it reinstates:
|
||||
|
||||
1. automatically as of the date the violation is cured, provided
|
||||
it is cured within 30 days of Your discovery of the
|
||||
violation; or
|
||||
|
||||
2. upon express reinstatement by the Licensor.
|
||||
|
||||
For the avoidance of doubt, this Section 6(b) does not affect any
|
||||
right the Licensor may have to seek remedies for Your violations
|
||||
of this Public License.
|
||||
|
||||
c. For the avoidance of doubt, the Licensor may also offer the
|
||||
Licensed Material under separate terms or conditions or stop
|
||||
distributing the Licensed Material at any time; however, doing so
|
||||
will not terminate this Public License.
|
||||
|
||||
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
|
||||
License.
|
||||
|
||||
|
||||
Section 7 -- Other Terms and Conditions.
|
||||
|
||||
a. The Licensor shall not be bound by any additional or different
|
||||
terms or conditions communicated by You unless expressly agreed.
|
||||
|
||||
b. Any arrangements, understandings, or agreements regarding the
|
||||
Licensed Material not stated herein are separate from and
|
||||
independent of the terms and conditions of this Public License.
|
||||
|
||||
|
||||
Section 8 -- Interpretation.
|
||||
|
||||
a. For the avoidance of doubt, this Public License does not, and
|
||||
shall not be interpreted to, reduce, limit, restrict, or impose
|
||||
conditions on any use of the Licensed Material that could lawfully
|
||||
be made without permission under this Public License.
|
||||
|
||||
b. To the extent possible, if any provision of this Public License is
|
||||
deemed unenforceable, it shall be automatically reformed to the
|
||||
minimum extent necessary to make it enforceable. If the provision
|
||||
cannot be reformed, it shall be severed from this Public License
|
||||
without affecting the enforceability of the remaining terms and
|
||||
conditions.
|
||||
|
||||
c. No term or condition of this Public License will be waived and no
|
||||
failure to comply consented to unless expressly agreed to by the
|
||||
Licensor.
|
||||
|
||||
d. Nothing in this Public License constitutes or may be interpreted
|
||||
as a limitation upon, or waiver of, any privileges and immunities
|
||||
that apply to the Licensor or You, including from the legal
|
||||
processes of any jurisdiction or authority.
|
||||
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons is not a party to its public
|
||||
licenses. Notwithstanding, Creative Commons may elect to apply one of
|
||||
its public licenses to material it publishes and in those instances
|
||||
will be considered the “Licensor.” The text of the Creative Commons
|
||||
public licenses is dedicated to the public domain under the CC0 Public
|
||||
Domain Dedication. Except for the limited purpose of indicating that
|
||||
material is shared under a Creative Commons public license or as
|
||||
otherwise permitted by the Creative Commons policies published at
|
||||
creativecommons.org/policies, Creative Commons does not authorize the
|
||||
use of the trademark "Creative Commons" or any other trademark or logo
|
||||
of Creative Commons without its prior written consent including,
|
||||
without limitation, in connection with any unauthorized modifications
|
||||
to any of its public licenses or any other arrangements,
|
||||
understandings, or agreements concerning use of licensed material. For
|
||||
the avoidance of doubt, this paragraph does not form part of the
|
||||
public licenses.
|
||||
|
||||
Creative Commons may be contacted at creativecommons.org.
|
||||
|
||||
201
LICENSES/LICENSE_FONT_DROID_SANS_MONO.txt
Normal file
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
63
ReadMe.md
@@ -1,43 +1,48 @@
|
||||
# Android Keepass DX
|
||||
|
||||
<img src="https://raw.githubusercontent.com/Kunzisoft/KeePassDX/master/fastlane/metadata/android/en-US/images/icon.png"> Keepass DX is a material design Keepass Client for manage keys and passwords in crypt database for your android device.
|
||||
<img src="https://raw.githubusercontent.com/Kunzisoft/KeePassDX/master/art/icon.png"> Keepass DX is a **multi-format KeePass manager for Android devices**. The application allows to create keys and passwords in a secure way by integrating with the Android design standards.
|
||||
|
||||
<img src="https://raw.githubusercontent.com/Kunzisoft/KeePassDX/master/art/screen.jpg" width="220">
|
||||
|
||||
### Features
|
||||
|
||||
* Create database files / entries and groups
|
||||
* Support for .kdb and .kdbx files (version 1 to 4)
|
||||
* Open database, copy username / password, open URI / URL
|
||||
* Fingerprint for fast unlocking
|
||||
* Material design with themes
|
||||
* AutoFill and Integration (Development in progress)
|
||||
* Precise management of settings
|
||||
* Create database files / entries and groups
|
||||
* Support for **.kdb** and **.kdbx** files (version 1 to 4) with AES - Twofish - ChaCha20 - Argon2 algorithm
|
||||
* **Compatible** with the majority of alternative programs (KeePass, KeePassX, KeePass XC...)
|
||||
* Allows **fast copy** of fields and opening of URI / URL
|
||||
* **Fingerprint** for fast unlocking
|
||||
* Material design with **themes**
|
||||
* **AutoFill** and Integration
|
||||
* Field filling **keyboard**
|
||||
* Precise management of **settings**
|
||||
|
||||
<img src="https://raw.githubusercontent.com/Kunzisoft/KeePassDX/master/fastlane/metadata/android/en-US/images/phoneScreenshots/screen1.jpg" width="220">
|
||||
<img src="https://raw.githubusercontent.com/Kunzisoft/KeePassDX/master/fastlane/metadata/android/en-US/images/phoneScreenshots/screen2.jpg" width="220">
|
||||
Keepass DX is **open source** and **ad-free**.
|
||||
|
||||
## What is KeePass?
|
||||
## What is KeePass DX?
|
||||
|
||||
Today you need to remember many passwords. You need a password for the Windows network logon, your e-mail account, your website's FTP password, online passwords (like website member account), etc. etc. etc. The list is endless. Also, you should use different passwords for each account. Because if you use only one password everywhere and someone gets this password you have a problem... A serious problem. The thief would have access to your e-mail account, website, etc. Unimaginable.
|
||||
Today you need to remember many passwords. You need a password for your e-mail account, your website's FTP password, online passwords (like website member account), etc. etc. etc. The list is endless. Also, you **should use different passwords for each account**. Because if you use only one password everywhere and someone gets this password you have a problem... A serious problem. The thief would have access to your e-mail account, website, etc. Unimaginable.
|
||||
|
||||
KeePass is a free open source password manager, which helps you to manage your passwords in a secure way. You can put all your passwords in one database, which is locked with one master key or a key file. So you only have to remember one single master password or select the key file to unlock the whole database. The databases are encrypted using the best and most secure encryption algorithms currently known (AES and Twofish). For more information, see the features page.
|
||||
KeePass DX is a **free open source password manager for Android**, which helps you to **manage your passwords in a secure way**. You can put all your passwords in one database, which is locked with one **master key** or a **key file**. So you **only have to remember one single master password or select the key file** to unlock the whole database. The databases are encrypted using the best and **most secure encryption algorithms** currently known.
|
||||
|
||||
## Is it really free?
|
||||
|
||||
Yes, KeePass is really free, and more than that: it is open source (OSI certified). You can have a look at its full source and check whether the encryption algorithms are implemented correctly.
|
||||
Yes, KeePass DX is under **free license (OSI certified)** and **without advertising**. You can have a look at its full source and check whether the encryption algorithms are implemented correctly.
|
||||
|
||||
## Donation
|
||||
*Note : If you access the application from a store, visual features may not be available to incentivize the contribution to the work of open source projects. These optional visuals are accessible after a donation (and a small congratulation message :) or the purchase of an extended version, but do not worry, the main features remain completely free. If you contribute to the project and you do not have access to the themes, do not hesitate to contact me at [contact@kunzisoft.com](contact@kunzisoft.com), I will give you the procedure.*
|
||||
|
||||
Even if the application is free, to maintain the application, you can make donations.
|
||||
## Contributions
|
||||
|
||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KM6QMDAXZM3UU "Kunzisoft Paypal Donation")
|
||||
You can contribute in different ways to help us on our work.
|
||||
|
||||
[](https://liberapay.com/Kunzisoft/donate "Kunzisoft Liberapay Donation")
|
||||
|
||||
<img src="https://raw.githubusercontent.com/Kunzisoft/KeePassDX/master/fastlane/metadata/android/en-US/images/phoneScreenshots/screen4.jpg" width="220">
|
||||
<img src="https://raw.githubusercontent.com/Kunzisoft/KeePassDX/master/fastlane/metadata/android/en-US/images/phoneScreenshots/screen5.jpg" width="220">
|
||||
* Add features by a **[pull request](https://help.github.com/articles/about-pull-requests/)**.
|
||||
* Help to **[translate](https://hosted.weblate.org/projects/keepass-dx/strings/)** into your language (By using [Weblate](https://hosted.weblate.org/projects/keepass-dx/) or with a manual [pull request](https://help.github.com/articles/about-pull-requests/))
|
||||
* **[Donate](https://www.kunzisoft.com/donation)** 人◕ ‿‿ ◕人Y for a better service and a quick development of your features.
|
||||
* Buy the **[Pro version](https://play.google.com/store/apps/details?id=com.kunzisoft.keepass.pro)** of KeePass DX
|
||||
|
||||
## Download
|
||||
|
||||
*We recommend the installation from [F-Droid](https://f-droid.org/en/packages/com.kunzisoft.keepass.libre/) which verifies that all libraries and application code are open source.*
|
||||
|
||||
[<img src="https://f-droid.org/badge/get-it-on.png"
|
||||
alt="Get it on F-Droid"
|
||||
height="80">](https://f-droid.org/en/packages/com.kunzisoft.keepass.libre/)
|
||||
@@ -46,13 +51,23 @@ Even if the application is free, to maintain the application, you can make donat
|
||||
alt="Get it on Google Play"
|
||||
height="80">](https://play.google.com/store/apps/details?id=com.kunzisoft.keepass.free)
|
||||
|
||||
## F.A.Q.
|
||||
|
||||
Other questions? You can read the [F.A.Q.](https://www.keepassdx.com/FAQ)
|
||||
|
||||
## Other devices
|
||||
|
||||
- [KeePass XC](https://keepassxc.org/) (https://keepassxc.org/) works with **GNU/Linux**, **Mac** and **Windows**, is updated regularly and under the terms of the GNU General Public License. This is the recommended version for computers.
|
||||
|
||||
- [KeePass](https://keepass.info/) (https://keepass.info/) is the historical project, with good technical documentation for standardized database files but only running on **Windows**.
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) 2017 Jeremy Jamet / Kunzisoft.
|
||||
Copyright (c) 2017 Jeremy Jamet / [Kunzisoft](https://www.kunzisoft.com).
|
||||
|
||||
This file is part of KeePass DX.
|
||||
|
||||
KeePass DX is free software: you can redistribute it and/or modify
|
||||
[KeePass DX](https://www.keepassdx.com) is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
@@ -65,4 +80,4 @@ Even if the application is free, to maintain the application, you can make donat
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with KeePass DX. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
This project is a fork of [KeepassDroid](https://github.com/bpellin/keepassdroid) by bpellin.
|
||||
*This project is a fork of [KeepassDroid](https://github.com/bpellin/keepassdroid) by bpellin.*
|
||||
|
||||
@@ -1,24 +1,21 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion = 27
|
||||
buildToolsVersion = '27.0.3'
|
||||
compileSdkVersion 27
|
||||
buildToolsVersion '28.0.2'
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.kunzisoft.keepass"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 27
|
||||
versionCode = 8
|
||||
versionName = "2.5.0.0beta8"
|
||||
versionCode = 18
|
||||
versionName = "2.5.0.0beta18"
|
||||
multiDexEnabled true
|
||||
|
||||
testApplicationId = "com.kunzisoft.keepass.tests"
|
||||
testInstrumentationRunner = "android.test.InstrumentationTestRunner"
|
||||
|
||||
ndk {
|
||||
abiFilters 'x86', 'x86_64', 'armeabi', 'armeabi-v7a',
|
||||
'arm64-v8a', 'mips', 'mips64'
|
||||
}
|
||||
buildConfigField "String[]", "ICON_PACKS", "{\"classic\",\"material\"}"
|
||||
}
|
||||
|
||||
externalNativeBuild {
|
||||
@@ -42,30 +39,44 @@ android {
|
||||
productFlavors {
|
||||
libre {
|
||||
applicationIdSuffix = ".libre"
|
||||
versionNameSuffix "-libre"
|
||||
buildConfigField "String", "BUILD_VERSION", "\"libre\""
|
||||
buildConfigField "boolean", "FULL_VERSION", "true"
|
||||
buildConfigField "boolean", "GOOGLE_PLAY_VERSION", "false"
|
||||
buildConfigField "boolean", "CLOSED_STORE", "false"
|
||||
buildConfigField "String[]", "STYLES_DISABLED", "{\"KeepassDXStyle_Dark\",\"KeepassDXStyle_Red\",\"KeepassDXStyle_Purple\"}"
|
||||
buildConfigField "String[]", "ICON_PACKS_DISABLED", "{}"
|
||||
|
||||
}
|
||||
pro_google {
|
||||
pro {
|
||||
applicationIdSuffix = ".pro"
|
||||
versionNameSuffix "-pro"
|
||||
buildConfigField "String", "BUILD_VERSION", "\"pro\""
|
||||
buildConfigField "boolean", "FULL_VERSION", "true"
|
||||
buildConfigField "boolean", "GOOGLE_PLAY_VERSION", "true"
|
||||
buildConfigField "boolean", "CLOSED_STORE", "true"
|
||||
buildConfigField "String[]", "STYLES_DISABLED", "{}"
|
||||
buildConfigField "String[]", "ICON_PACKS_DISABLED", "{}"
|
||||
}
|
||||
free_google {
|
||||
free {
|
||||
applicationIdSuffix = ".free"
|
||||
versionNameSuffix "-free"
|
||||
buildConfigField "String", "BUILD_VERSION", "\"free\""
|
||||
buildConfigField "boolean", "FULL_VERSION", "false"
|
||||
buildConfigField "boolean", "GOOGLE_PLAY_VERSION", "true"
|
||||
buildConfigField "boolean", "CLOSED_STORE", "true"
|
||||
buildConfigField "String[]", "STYLES_DISABLED", "{\"KeepassDXStyle_Dark\",\"KeepassDXStyle_Blue\",\"KeepassDXStyle_Red\",\"KeepassDXStyle_Purple\"}"
|
||||
buildConfigField "String[]", "ICON_PACKS_DISABLED", "{}"
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
libre.res.srcDir 'src/libre/res'
|
||||
pro.res.srcDir 'src/pro/res'
|
||||
free.res.srcDir 'src/free/res'
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
targetCompatibility 1.8
|
||||
sourceCompatibility 1.8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
|
||||
def supportVersion = "27.1.0"
|
||||
def supportVersion = "27.1.1"
|
||||
def spongycastleVersion = "1.58.0.0"
|
||||
def permissionDispatcherVersion = "3.1.0"
|
||||
|
||||
@@ -77,20 +88,29 @@ dependencies {
|
||||
implementation "com.android.support:cardview-v7:$supportVersion"
|
||||
implementation "com.madgag.spongycastle:core:$spongycastleVersion"
|
||||
implementation "com.madgag.spongycastle:prov:$spongycastleVersion"
|
||||
// Expandable view
|
||||
implementation 'net.cachapa.expandablelayout:expandablelayout:2.9.2'
|
||||
// Time
|
||||
implementation "joda-time:joda-time:2.9.9"
|
||||
implementation "org.sufficientlysecure:html-textview:3.5"
|
||||
implementation "com.nononsenseapps:filepicker:4.1.0"
|
||||
implementation 'joda-time:joda-time:2.9.9'
|
||||
implementation 'org.sufficientlysecure:html-textview:3.5'
|
||||
implementation 'com.nononsenseapps:filepicker:4.1.0'
|
||||
implementation 'com.getkeepsafe.taptargetview:taptargetview:1.12.0'
|
||||
// Permissions
|
||||
implementation ("com.github.hotchemi:permissionsdispatcher:$permissionDispatcherVersion") {
|
||||
implementation("com.github.hotchemi:permissionsdispatcher:$permissionDispatcherVersion") {
|
||||
// if you don't use android.app.Fragment you can exclude support for them
|
||||
exclude module: "support-v13"
|
||||
}
|
||||
// Apache Commons Collections
|
||||
implementation group: 'commons-collections', name: 'commons-collections', version: '3.2.1'
|
||||
// Base64
|
||||
compile group: 'biz.source_code', name: 'base64coder', version: '2010-12-19'
|
||||
annotationProcessor "com.github.hotchemi:permissionsdispatcher-processor:$permissionDispatcherVersion"
|
||||
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.1'
|
||||
implementation group: 'com.google.guava', name: 'guava', version: '23.0-android'
|
||||
// Apache Commons Collections
|
||||
implementation 'commons-collections:commons-collections:3.2.1'
|
||||
implementation 'org.apache.commons:commons-io:1.3.2'
|
||||
// Base64
|
||||
implementation 'biz.source_code:base64coder:2010-12-19'
|
||||
// IO-Extras
|
||||
implementation 'com.github.davidmoten:io-extras:0.1'
|
||||
implementation 'com.google.code.gson:gson:2.8.4'
|
||||
implementation 'com.google.guava:guava:23.0-android'
|
||||
// Icon pack
|
||||
implementation project(path: ':icon-pack-classic')
|
||||
implementation project(path: ':icon-pack-material')
|
||||
}
|
||||
|
||||
@@ -45,10 +45,10 @@ public class PwEntryTestV4 extends TestCase {
|
||||
|
||||
entry.setBackgroupColor("blue");
|
||||
entry.putProtectedBinary("key1", new ProtectedBinary(false, new byte[] {0,1}));
|
||||
entry.setCustomIcon(new PwIconCustom(UUID.randomUUID(), new byte[0]));
|
||||
entry.setIconCustom(new PwIconCustom(UUID.randomUUID(), new byte[0]));
|
||||
entry.setForegroundColor("red");
|
||||
entry.addToHistory(new PwEntryV4());
|
||||
entry.setIcon(new PwIconStandard(5));
|
||||
entry.setIconStandard(new PwIconStandard(5));
|
||||
entry.setOverrideURL("override");
|
||||
entry.setParent(new PwGroupV4());
|
||||
entry.addExtraField("key2", new ProtectedString(false, "value2"));
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.tests.database;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.content.Context;
|
||||
import android.test.AndroidTestCase;
|
||||
|
||||
@@ -30,8 +28,10 @@ import com.kunzisoft.keepass.database.PwDatabaseV3;
|
||||
import com.kunzisoft.keepass.database.PwEntry;
|
||||
import com.kunzisoft.keepass.database.PwEntryV3;
|
||||
import com.kunzisoft.keepass.database.PwGroup;
|
||||
import com.kunzisoft.keepass.database.edit.DeleteGroup;
|
||||
import com.kunzisoft.keepass.search.SearchDbHelper;
|
||||
import com.kunzisoft.keepass.database.action.node.DeleteGroupRunnable;
|
||||
import com.kunzisoft.keepass.database.search.SearchDbHelper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DeleteEntry extends AndroidTestCase {
|
||||
private static final String GROUP1_NAME = "Group1";
|
||||
@@ -60,7 +60,7 @@ public class DeleteEntry extends AndroidTestCase {
|
||||
assertNotNull("Could not find group1", group1);
|
||||
|
||||
// Delete the group
|
||||
DeleteGroup task = new DeleteGroup(db, group1, null, true);
|
||||
DeleteGroupRunnable task = new DeleteGroupRunnable(null, db, group1, null, true);
|
||||
task.run();
|
||||
|
||||
// Verify the entries were deleted
|
||||
@@ -72,8 +72,8 @@ public class DeleteEntry extends AndroidTestCase {
|
||||
|
||||
// Verify the entries were removed from the search index
|
||||
SearchDbHelper dbHelp = new SearchDbHelper(ctx);
|
||||
PwGroup results1 = dbHelp.search(db.getPwDatabase(), ENTRY1_NAME);
|
||||
PwGroup results2 = dbHelp.search(db.getPwDatabase(), ENTRY2_NAME);
|
||||
PwGroup results1 = dbHelp.search(db.getPwDatabase(), ENTRY1_NAME, 100);
|
||||
PwGroup results2 = dbHelp.search(db.getPwDatabase(), ENTRY2_NAME, 100);
|
||||
|
||||
assertEquals("Entry1 was not removed from the search results", 0, results1.numbersOfChildEntries());
|
||||
assertEquals("Entry2 was not removed from the search results", 0, results2.numbersOfChildEntries());
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.tests.database;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.kunzisoft.keepass.database.PwDatabaseV4;
|
||||
import com.kunzisoft.keepass.database.PwEntryV4;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class EntryV4 extends TestCase {
|
||||
|
||||
public void testBackup() {
|
||||
@@ -46,7 +46,7 @@ public class EntryV4 extends TestCase {
|
||||
entry.createBackup(db);
|
||||
|
||||
PwEntryV4 backup = entry.getHistory().get(0);
|
||||
entry.endToManageFieldReferences();
|
||||
entry.stopToManageFieldReferences();
|
||||
assertEquals("Title2", backup.getTitle());
|
||||
assertEquals("User2", backup.getUsername());
|
||||
}
|
||||
|
||||
50
app/src/free/res/drawable-v24/ic_launcher_foreground.xml
Normal file
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108"
|
||||
android:width="108dp"
|
||||
android:height="108dp">
|
||||
<group
|
||||
android:translateY="-332">
|
||||
<group
|
||||
android:translateY="332">
|
||||
<path
|
||||
android:pathData="M65.728516 32.791016L58.052734 35.904297 56.173828 48.380859 35.306641 69.267578 35.238281 73.759766 69.478516 108 108 108 108 70.810547 73.09375 35.904297 65.728516 32.791016Z"
|
||||
android:fillColor="@color/long_shadow"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeLineCap="round"
|
||||
android:strokeMiterLimit="4" />
|
||||
</group>
|
||||
<group
|
||||
android:scaleX="0.3939503"
|
||||
android:scaleY="0.3939503"
|
||||
android:translateX="33.66343"
|
||||
android:translateY="233.998">
|
||||
<path
|
||||
android:pathData="M88.76953 339.91602L4.1718754 424.59766 4.0000004 436 15.400391 435.82813 27.240234 424 40 424l0 -12 12 0 0 -12.73438 34.01172 -33.97656A8 8 0 0 1 84 360a8 8 0 0 1 8 -8 8 8 0 0 1 5.296882 2.01367l2.787098 -2.7832 -11.31445 -11.31445z"
|
||||
android:fillColor="#eaeaea"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#58000000" />
|
||||
</group>
|
||||
<group
|
||||
android:scaleX="0.3939503"
|
||||
android:scaleY="0.3939503"
|
||||
android:translateX="33.66343"
|
||||
android:translateY="233.998">
|
||||
<path
|
||||
android:pathData="M4.0000004 340L4.1718754 351.40137 88.59863 435.82812 100 436 99.828122 424.59863 15.401367 340.17188Z"
|
||||
android:fillColor="#81c784" />
|
||||
</group>
|
||||
<group
|
||||
android:scaleX="0.3939503"
|
||||
android:scaleY="0.3939503"
|
||||
android:translateX="33.66343"
|
||||
android:translateY="233.998">
|
||||
<path
|
||||
android:pathData="M81.39454 332.00195a27 27 0 0 0 -19.48634 7.90625 27 27 0 0 0 0 38.1836 27 27 0 0 0 38.1836 0 27 27 0 0 0 0 -38.1836 27 27 0 0 0 -18.69726 -7.90625zM92 352a8 8 0 0 1 8 8 8 8 0 0 1 -8 8 8 8 0 0 1 -8 -8 8 8 0 0 1 8 -8z"
|
||||
android:fillColor="#eaeaea"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#58000000" />
|
||||
</group>
|
||||
</group>
|
||||
</vector>
|
||||
5
app/src/free/res/mipmap-anydpi-v26/ic_launcher.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/green" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
5
app/src/free/res/mipmap-anydpi-v26/ic_launcher_round.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/green" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
BIN
app/src/free/res/mipmap-hdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
app/src/free/res/mipmap-hdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
app/src/free/res/mipmap-ldpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
app/src/free/res/mipmap-ldpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
app/src/free/res/mipmap-mdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
app/src/free/res/mipmap-mdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
app/src/free/res/mipmap-xhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 5.6 KiB |
BIN
app/src/free/res/mipmap-xhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 7.3 KiB |
BIN
app/src/free/res/mipmap-xxhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 9.5 KiB |
BIN
app/src/free/res/mipmap-xxhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
app/src/free/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
app/src/free/res/mipmap-xxxhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
50
app/src/libre/res/drawable-v24/ic_launcher_foreground.xml
Normal file
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108"
|
||||
android:width="108dp"
|
||||
android:height="108dp">
|
||||
<group
|
||||
android:translateY="-332">
|
||||
<group
|
||||
android:translateY="332">
|
||||
<path
|
||||
android:pathData="M65.728516 32.791016L58.052734 35.904297 56.173828 48.380859 35.306641 69.267578 35.238281 73.759766 69.478516 108 108 108 108 70.810547 73.09375 35.904297 65.728516 32.791016Z"
|
||||
android:fillColor="@color/long_shadow"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeLineCap="round"
|
||||
android:strokeMiterLimit="4" />
|
||||
</group>
|
||||
<group
|
||||
android:scaleX="0.3939503"
|
||||
android:scaleY="0.3939503"
|
||||
android:translateX="33.66343"
|
||||
android:translateY="233.998">
|
||||
<path
|
||||
android:pathData="M88.76953 339.91602L4.1718754 424.59766 4.0000004 436 15.400391 435.82813 27.240234 424 40 424l0 -12 12 0 0 -12.73438 34.01172 -33.97656A8 8 0 0 1 84 360a8 8 0 0 1 8 -8 8 8 0 0 1 5.296882 2.01367l2.787098 -2.7832 -11.31445 -11.31445z"
|
||||
android:fillColor="#eaeaea"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#58000000"/>
|
||||
</group>
|
||||
<group
|
||||
android:scaleX="0.3939503"
|
||||
android:scaleY="0.3939503"
|
||||
android:translateX="33.66343"
|
||||
android:translateY="233.998">
|
||||
<path
|
||||
android:pathData="M4.0000004 340L4.1718754 351.40137 88.59863 435.82812 100 436 99.828122 424.59863 15.401367 340.17188Z"
|
||||
android:fillColor="#64b5f6" />
|
||||
</group>
|
||||
<group
|
||||
android:scaleX="0.3939503"
|
||||
android:scaleY="0.3939503"
|
||||
android:translateX="33.66343"
|
||||
android:translateY="233.998">
|
||||
<path
|
||||
android:pathData="M81.39454 332.00195a27 27 0 0 0 -19.48634 7.90625 27 27 0 0 0 0 38.1836 27 27 0 0 0 38.1836 0 27 27 0 0 0 0 -38.1836 27 27 0 0 0 -18.69726 -7.90625zM92 352a8 8 0 0 1 8 8 8 8 0 0 1 -8 8 8 8 0 0 1 -8 -8 8 8 0 0 1 8 -8z"
|
||||
android:fillColor="#eaeaea"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#58000000" />
|
||||
</group>
|
||||
</group>
|
||||
</vector>
|
||||
5
app/src/libre/res/mipmap-anydpi-v26/ic_launcher.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/green" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/green" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
BIN
app/src/libre/res/mipmap-hdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
app/src/libre/res/mipmap-hdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
app/src/libre/res/mipmap-ldpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
app/src/libre/res/mipmap-ldpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
app/src/libre/res/mipmap-mdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
app/src/libre/res/mipmap-mdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
app/src/libre/res/mipmap-xhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
BIN
app/src/libre/res/mipmap-xhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 7.3 KiB |
BIN
app/src/libre/res/mipmap-xxhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 9.6 KiB |
BIN
app/src/libre/res/mipmap-xxhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
app/src/libre/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
app/src/libre/res/mipmap-xxxhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
@@ -20,47 +20,27 @@
|
||||
android:allowBackup="true"
|
||||
android:fullBackupContent="@xml/backup"
|
||||
android:backupAgent="com.kunzisoft.keepass.backup.SettingsBackupAgent"
|
||||
android:theme="@style/KeepassDXStyle.Light"
|
||||
tools:replace="android:theme">
|
||||
android:theme="@style/KeepassDXStyle.Night">
|
||||
<!-- TODO backup API Key -->
|
||||
<meta-data
|
||||
android:name="com.google.android.backup.api_key"
|
||||
android:value="" />
|
||||
|
||||
<!-- Folder picker -->
|
||||
<provider
|
||||
android:name="android.support.v4.content.FileProvider"
|
||||
android:authorities="${applicationId}.provider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/nnf_provider_paths" />
|
||||
</provider>
|
||||
<activity
|
||||
android:name="com.kunzisoft.keepass.fileselect.FilePickerStylishActivity"
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.GET_CONTENT" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".KeePass"
|
||||
android:label="@string/app_name">
|
||||
android:name="com.kunzisoft.keepass.fileselect.FileSelectActivity"
|
||||
android:theme="@style/KeepassDXStyle.SplashScreen"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleTop"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:windowSoftInputMode="stateHidden" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name="com.kunzisoft.keepass.fileselect.FileSelectActivity"
|
||||
android:launchMode="singleInstance"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:windowSoftInputMode="stateHidden" />
|
||||
<activity
|
||||
android:name="com.kunzisoft.keepass.activities.AboutActivity"
|
||||
android:launchMode="singleInstance"
|
||||
android:launchMode="singleTask"
|
||||
android:label="@string/menu_about" />
|
||||
<activity
|
||||
android:name="com.kunzisoft.keepass.password.PasswordActivity"
|
||||
@@ -102,14 +82,40 @@
|
||||
<data android:mimeType="application/octet-stream"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<!-- Folder picker -->
|
||||
<provider
|
||||
android:name="android.support.v4.content.FileProvider"
|
||||
android:authorities="${applicationId}.provider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/nnf_provider_paths" />
|
||||
</provider>
|
||||
<activity
|
||||
android:name="com.kunzisoft.keepass.fileselect.FilePickerStylishActivity"
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.GET_CONTENT" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name="com.kunzisoft.keepass.activities.GroupActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:windowSoftInputMode="adjustPan">
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
android:launchMode="singleTop">
|
||||
<meta-data
|
||||
android:name="android.app.default_searchable"
|
||||
android:value="com.kunzisoft.keepass.search.SearchResults"
|
||||
android:exported="false"/>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEARCH" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<meta-data
|
||||
android:name="android.app.searchable"
|
||||
android:resource="@xml/searchable" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name="com.kunzisoft.keepass.activities.EntryActivity"
|
||||
@@ -119,27 +125,33 @@
|
||||
android:name="com.kunzisoft.keepass.activities.EntryEditActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:windowSoftInputMode="stateHidden" />
|
||||
<activity
|
||||
android:name="com.kunzisoft.keepass.search.SearchResultsActivity"
|
||||
android:launchMode="standard">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEARCH" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<meta-data
|
||||
android:name="android.app.searchable"
|
||||
android:resource="@xml/searchable" />
|
||||
</activity>
|
||||
<activity android:name="com.kunzisoft.keepass.settings.SettingsActivity" />
|
||||
<activity android:name="com.kunzisoft.keepass.autofill.AutoFillAuthActivity"
|
||||
android:configChanges="orientation|keyboardHidden" />
|
||||
<activity android:name="com.kunzisoft.keepass.selection.EntrySelectionAuthActivity"
|
||||
android:configChanges="orientation|keyboardHidden" />
|
||||
<activity android:name="com.kunzisoft.keepass.settings.SettingsAutofillActivity" />
|
||||
<activity android:name="com.kunzisoft.keepass.magikeyboard.EntryRetrieverActivity"
|
||||
android:label="@string/keyboard_name">
|
||||
</activity>
|
||||
<activity android:name="com.kunzisoft.keepass.settings.MagikIMESettings"
|
||||
android:label="@string/keyboard_setting_label">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<service android:name="com.kunzisoft.keepass.timeout.TimeoutService" />
|
||||
|
||||
<!-- Receiver for Keyboard -->
|
||||
<receiver
|
||||
android:name="com.kunzisoft.keepass.magikeyboard.receiver.NotificationDeleteBroadcastReceiver"
|
||||
android:exported="false" >
|
||||
</receiver>
|
||||
<service
|
||||
android:name="com.kunzisoft.keepass.notifications.NotificationCopyingService"
|
||||
android:enabled="true"
|
||||
android:exported="false" />
|
||||
<!-- Receiver for Autofill -->
|
||||
<service
|
||||
android:name="com.kunzisoft.keepass.autofill.KeeAutofillService"
|
||||
android:label="@string/autofill_service_name"
|
||||
@@ -147,11 +159,22 @@
|
||||
<meta-data
|
||||
android:name="android.autofill"
|
||||
android:resource="@xml/dataset_service" />
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.service.autofill.AutofillService" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name="com.kunzisoft.keepass.magikeyboard.MagikIME"
|
||||
android:label="@string/keyboard_label"
|
||||
android:permission="android.permission.BIND_INPUT_METHOD" >
|
||||
<meta-data android:name="android.view.im"
|
||||
android:resource="@xml/keyboard_method"/>
|
||||
<intent-filter>
|
||||
<action android:name="android.view.InputMethod" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service android:name="com.kunzisoft.keepass.magikeyboard.KeyboardEntryNotificationService" />
|
||||
|
||||
<meta-data android:name="com.sec.android.support.multiwindow" android:value="true" />
|
||||
</application>
|
||||
</manifest>
|
||||
BIN
app/src/main/assets/fonts/DroidSansMonoSlashed.ttf
Normal file
@@ -19,7 +19,6 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.activities;
|
||||
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
@@ -27,6 +26,7 @@ import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.kunzisoft.keepass.BuildConfig;
|
||||
import com.kunzisoft.keepass.R;
|
||||
import com.kunzisoft.keepass.stylish.StylishActivity;
|
||||
|
||||
@@ -40,7 +40,7 @@ public class AboutActivity extends StylishActivity {
|
||||
|
||||
setContentView(R.layout.about);
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
toolbar.setTitle(getString(R.string.menu_about));
|
||||
setSupportActionBar(toolbar);
|
||||
assert getSupportActionBar() != null;
|
||||
@@ -48,18 +48,25 @@ public class AboutActivity extends StylishActivity {
|
||||
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||
|
||||
String version;
|
||||
String build;
|
||||
try {
|
||||
PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
|
||||
version = packageInfo.versionName;
|
||||
version = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
|
||||
build = BuildConfig.BUILD_VERSION;
|
||||
} catch (NameNotFoundException e) {
|
||||
Log.w(getClass().getSimpleName(), "Unable to get application version", e);
|
||||
version = "Unable to get application version.";
|
||||
Log.w(getClass().getSimpleName(), "Unable to get the app or the build version", e);
|
||||
version = "Unable to get the app version";
|
||||
build = "Unable to get the build version";
|
||||
}
|
||||
version = getString(R.string.version_label) + " " + version;
|
||||
TextView versionText = (TextView) findViewById(R.id.activity_about_version);
|
||||
versionText.setText(version);
|
||||
version = getString(R.string.version_label, version);
|
||||
TextView versionTextView = findViewById(R.id.activity_about_version);
|
||||
versionTextView.setText(version);
|
||||
|
||||
TextView disclaimerText = (TextView) findViewById(R.id.disclaimer);
|
||||
build = getString(R.string.build_label, build);
|
||||
TextView buildTextView = findViewById(R.id.activity_about_build);
|
||||
buildTextView.setText(build);
|
||||
|
||||
|
||||
TextView disclaimerText = findViewById(R.id.disclaimer);
|
||||
disclaimerText.setText(getString(R.string.disclaimer_formal, new DateTime().getYear()));
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,12 @@ package com.kunzisoft.keepass.activities;
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
@@ -34,6 +38,8 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.getkeepsafe.taptargetview.TapTarget;
|
||||
import com.getkeepsafe.taptargetview.TapTargetView;
|
||||
import com.kunzisoft.keepass.R;
|
||||
import com.kunzisoft.keepass.app.App;
|
||||
import com.kunzisoft.keepass.database.Database;
|
||||
@@ -41,9 +47,12 @@ import com.kunzisoft.keepass.database.ExtraFields;
|
||||
import com.kunzisoft.keepass.database.PwDatabase;
|
||||
import com.kunzisoft.keepass.database.PwEntry;
|
||||
import com.kunzisoft.keepass.database.security.ProtectedString;
|
||||
import com.kunzisoft.keepass.lock.LockingActivity;
|
||||
import com.kunzisoft.keepass.lock.LockingHideActivity;
|
||||
import com.kunzisoft.keepass.notifications.NotificationCopyingService;
|
||||
import com.kunzisoft.keepass.notifications.NotificationField;
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil;
|
||||
import com.kunzisoft.keepass.settings.SettingsAutofillActivity;
|
||||
import com.kunzisoft.keepass.timeout.ClipboardHelper;
|
||||
import com.kunzisoft.keepass.utils.EmptyUtils;
|
||||
import com.kunzisoft.keepass.utils.MenuUtil;
|
||||
@@ -56,6 +65,7 @@ import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.kunzisoft.keepass.settings.PreferencesUtil.isClipboardNotificationsEnable;
|
||||
import static com.kunzisoft.keepass.settings.PreferencesUtil.isFirstTimeAskAllowCopyPasswordAndProtectedFields;
|
||||
|
||||
public class EntryActivity extends LockingHideActivity {
|
||||
private final static String TAG = EntryActivity.class.getName();
|
||||
@@ -65,18 +75,21 @@ public class EntryActivity extends LockingHideActivity {
|
||||
private ImageView titleIconView;
|
||||
private TextView titleView;
|
||||
private EntryContentsView entryContentsView;
|
||||
private Toolbar toolbar;
|
||||
|
||||
protected PwEntry mEntry;
|
||||
private boolean mShowPassword;
|
||||
protected boolean readOnly = false;
|
||||
|
||||
private ClipboardHelper clipboardHelper;
|
||||
private boolean firstLaunchOfActivity;
|
||||
|
||||
public static void launch(Activity act, PwEntry pw) {
|
||||
private int iconColor;
|
||||
|
||||
public static void launch(Activity act, PwEntry pw, boolean readOnly) {
|
||||
if (LockingActivity.checkTimeIsAllowedOrFinish(act)) {
|
||||
Intent intent = new Intent(act, EntryActivity.class);
|
||||
intent.putExtra(KEY_ENTRY, Types.UUIDtoBytes(pw.getUUID()));
|
||||
ReadOnlyHelper.putReadOnlyInIntent(intent, readOnly);
|
||||
act.startActivityForResult(intent, EntryEditActivity.ADD_OR_UPDATE_ENTRY_REQUEST_CODE);
|
||||
}
|
||||
}
|
||||
@@ -87,7 +100,7 @@ public class EntryActivity extends LockingHideActivity {
|
||||
|
||||
setContentView(R.layout.entry_view);
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
assert getSupportActionBar() != null;
|
||||
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_close_white_24dp);
|
||||
@@ -100,7 +113,7 @@ public class EntryActivity extends LockingHideActivity {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
readOnly = db.isReadOnly();
|
||||
readOnly = db.isReadOnly() || readOnly;
|
||||
|
||||
mShowPassword = !PreferencesUtil.isPasswordMask(this);
|
||||
|
||||
@@ -114,6 +127,11 @@ public class EntryActivity extends LockingHideActivity {
|
||||
return;
|
||||
}
|
||||
|
||||
// Retrieve the textColor to tint the icon
|
||||
int[] attrs = {R.attr.textColorInverse};
|
||||
TypedArray ta = getTheme().obtainStyledAttributes(attrs);
|
||||
iconColor = ta.getColor(0, Color.WHITE);
|
||||
|
||||
// Refresh Menu contents in case onCreateMenuOptions was called before mEntry was set
|
||||
invalidateOptionsMenu();
|
||||
|
||||
@@ -142,12 +160,28 @@ public class EntryActivity extends LockingHideActivity {
|
||||
// Start to manage field reference to copy a value from ref
|
||||
mEntry.startToManageFieldReferences(App.getDB().getPwDatabase());
|
||||
|
||||
boolean containsUsernameToCopy =
|
||||
mEntry.getUsername().length() > 0;
|
||||
boolean containsPasswordToCopy =
|
||||
(mEntry.getPassword().length() > 0
|
||||
&& PreferencesUtil.allowCopyPasswordAndProtectedFields(this));
|
||||
boolean containsExtraFieldToCopy =
|
||||
(mEntry.allowExtraFields()
|
||||
&& ((mEntry.containsCustomFields()
|
||||
&& mEntry.containsCustomFieldsNotProtected())
|
||||
|| (mEntry.containsCustomFields()
|
||||
&& mEntry.containsCustomFieldsProtected()
|
||||
&& PreferencesUtil.allowCopyPasswordAndProtectedFields(this))
|
||||
)
|
||||
);
|
||||
|
||||
// If notifications enabled in settings
|
||||
// Don't if application timeout
|
||||
if (firstLaunchOfActivity && !App.isShutdown() && isClipboardNotificationsEnable(getApplicationContext())) {
|
||||
if (mEntry.getUsername().length() > 0
|
||||
|| (mEntry.getPassword().length() > 0 && PreferencesUtil.allowCopyPassword(this))
|
||||
|| mEntry.containsCustomFields()) {
|
||||
if (containsUsernameToCopy
|
||||
|| containsPasswordToCopy
|
||||
|| containsExtraFieldToCopy
|
||||
) {
|
||||
// username already copied, waiting for user's action before copy password.
|
||||
Intent intent = new Intent(this, NotificationCopyingService.class);
|
||||
intent.setAction(NotificationCopyingService.ACTION_NEW_NOTIFICATION);
|
||||
@@ -156,15 +190,14 @@ public class EntryActivity extends LockingHideActivity {
|
||||
// Construct notification fields
|
||||
ArrayList<NotificationField> notificationFields = new ArrayList<>();
|
||||
// Add username if exists to notifications
|
||||
if (mEntry.getUsername().length() > 0)
|
||||
if (containsUsernameToCopy)
|
||||
notificationFields.add(
|
||||
new NotificationField(
|
||||
NotificationField.NotificationFieldId.USERNAME,
|
||||
mEntry.getUsername(),
|
||||
getResources()));
|
||||
// Add password to notifications
|
||||
if (PreferencesUtil.allowCopyPassword(this)) {
|
||||
if (mEntry.getPassword().length() > 0)
|
||||
if (containsPasswordToCopy) {
|
||||
notificationFields.add(
|
||||
new NotificationField(
|
||||
NotificationField.NotificationFieldId.PASSWORD,
|
||||
@@ -172,12 +205,14 @@ public class EntryActivity extends LockingHideActivity {
|
||||
getResources()));
|
||||
}
|
||||
// Add extra fields
|
||||
if (mEntry.allowExtraFields()) {
|
||||
if (containsExtraFieldToCopy) {
|
||||
try {
|
||||
mEntry.getFields().doActionToAllCustomProtectedField(new ExtraFields.ActionProtected() {
|
||||
private int anonymousFieldNumber = 0;
|
||||
@Override
|
||||
public void doAction(String key, ProtectedString value) {
|
||||
//If value is not protected or allowed
|
||||
if (!value.isProtected() || PreferencesUtil.allowCopyPasswordAndProtectedFields(EntryActivity.this)) {
|
||||
notificationFields.add(
|
||||
new NotificationField(
|
||||
NotificationField.NotificationFieldId.getAnonymousFieldId()[anonymousFieldNumber],
|
||||
@@ -186,6 +221,7 @@ public class EntryActivity extends LockingHideActivity {
|
||||
getResources()));
|
||||
anonymousFieldNumber++;
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
Log.w(TAG, "Only " + NotificationField.NotificationFieldId.getAnonymousFieldId().length +
|
||||
@@ -197,14 +233,82 @@ public class EntryActivity extends LockingHideActivity {
|
||||
|
||||
startService(intent);
|
||||
}
|
||||
mEntry.endToManageFieldReferences();
|
||||
mEntry.stopToManageFieldReferences();
|
||||
}
|
||||
firstLaunchOfActivity = false;
|
||||
}
|
||||
|
||||
private void populateTitle(Drawable drawIcon, String text) {
|
||||
titleIconView.setImageDrawable(drawIcon);
|
||||
titleView.setText(text);
|
||||
/**
|
||||
* Check and display learning views
|
||||
* Displays the explanation for copying a field and editing an entry
|
||||
*/
|
||||
private void checkAndPerformedEducation(Menu menu) {
|
||||
if (PreferencesUtil.isEducationScreensEnabled(this)) {
|
||||
|
||||
if (entryContentsView != null && entryContentsView.isUserNamePresent()
|
||||
&& !PreferencesUtil.isEducationCopyUsernamePerformed(this)) {
|
||||
TapTargetView.showFor(this,
|
||||
TapTarget.forView(findViewById(R.id.entry_user_name_action_image),
|
||||
getString(R.string.education_field_copy_title),
|
||||
getString(R.string.education_field_copy_summary))
|
||||
.textColorInt(Color.WHITE)
|
||||
.tintTarget(false)
|
||||
.cancelable(true),
|
||||
new TapTargetView.Listener() {
|
||||
@Override
|
||||
public void onTargetClick(TapTargetView view) {
|
||||
super.onTargetClick(view);
|
||||
clipboardHelper.timeoutCopyToClipboard(mEntry.getUsername(),
|
||||
getString(R.string.copy_field, getString(R.string.entry_user_name)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOuterCircleClick(TapTargetView view) {
|
||||
super.onOuterCircleClick(view);
|
||||
view.dismiss(false);
|
||||
// Launch autofill settings
|
||||
startActivity(new Intent(EntryActivity.this, SettingsAutofillActivity.class));
|
||||
}
|
||||
});
|
||||
PreferencesUtil.saveEducationPreference(this,
|
||||
R.string.education_copy_username_key);
|
||||
|
||||
} else if (!PreferencesUtil.isEducationEntryEditPerformed(this)) {
|
||||
|
||||
try {
|
||||
TapTargetView.showFor(this,
|
||||
TapTarget.forToolbarMenuItem(toolbar, R.id.menu_edit,
|
||||
getString(R.string.education_entry_edit_title),
|
||||
getString(R.string.education_entry_edit_summary))
|
||||
.textColorInt(Color.WHITE)
|
||||
.tintTarget(true)
|
||||
.cancelable(true),
|
||||
new TapTargetView.Listener() {
|
||||
@Override
|
||||
public void onTargetClick(TapTargetView view) {
|
||||
super.onTargetClick(view);
|
||||
MenuItem editItem = menu.findItem(R.id.menu_edit);
|
||||
onOptionsItemSelected(editItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOuterCircleClick(TapTargetView view) {
|
||||
super.onOuterCircleClick(view);
|
||||
view.dismiss(false);
|
||||
// Open Keepass doc to create field references
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW,
|
||||
Uri.parse(getString(R.string.field_references_url)));
|
||||
startActivity(browserIntent);
|
||||
}
|
||||
});
|
||||
PreferencesUtil.saveEducationPreference(this,
|
||||
R.string.education_entry_edit_key);
|
||||
} catch (Exception e) {
|
||||
// If icon not visible
|
||||
Log.w(TAG, "Can't performed education for entry's edition");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void fillData() {
|
||||
@@ -213,9 +317,11 @@ public class EntryActivity extends LockingHideActivity {
|
||||
|
||||
mEntry.startToManageFieldReferences(pm);
|
||||
|
||||
// Assign title
|
||||
populateTitle(db.getDrawFactory().getIconDrawable(getResources(), mEntry.getIcon()),
|
||||
mEntry.getTitle());
|
||||
// Assign title icon
|
||||
db.getDrawFactory().assignDatabaseIconTo(this, titleIconView, mEntry.getIcon(), iconColor);
|
||||
|
||||
// Assign title text
|
||||
titleView.setText(mEntry.getVisualTitle());
|
||||
|
||||
// Assign basic fields
|
||||
entryContentsView.assignUserName(mEntry.getUsername());
|
||||
@@ -224,12 +330,39 @@ public class EntryActivity extends LockingHideActivity {
|
||||
getString(R.string.copy_field, getString(R.string.entry_user_name)))
|
||||
);
|
||||
|
||||
entryContentsView.assignPassword(mEntry.getPassword());
|
||||
if (PreferencesUtil.allowCopyPassword(this)) {
|
||||
boolean allowCopyPassword = PreferencesUtil.allowCopyPasswordAndProtectedFields(this);
|
||||
entryContentsView.assignPassword(mEntry.getPassword(), allowCopyPassword);
|
||||
if (allowCopyPassword) {
|
||||
entryContentsView.assignPasswordCopyListener(view ->
|
||||
clipboardHelper.timeoutCopyToClipboard(mEntry.getPassword(),
|
||||
getString(R.string.copy_field, getString(R.string.entry_password)))
|
||||
);
|
||||
} else {
|
||||
// If dialog not already shown
|
||||
if (isFirstTimeAskAllowCopyPasswordAndProtectedFields(this)) {
|
||||
entryContentsView.assignPasswordCopyListener(v -> {
|
||||
String message = getString(R.string.allow_copy_password_warning) +
|
||||
"\n\n" +
|
||||
getString(R.string.clipboard_warning);
|
||||
AlertDialog warningDialog = new AlertDialog.Builder(EntryActivity.this)
|
||||
.setMessage(message).create();
|
||||
warningDialog.setButton(AlertDialog.BUTTON1, getText(android.R.string.ok),
|
||||
(dialog, which) -> {
|
||||
PreferencesUtil.setAllowCopyPasswordAndProtectedFields(EntryActivity.this, true);
|
||||
dialog.dismiss();
|
||||
fillData();
|
||||
});
|
||||
warningDialog.setButton(AlertDialog.BUTTON2, getText(android.R.string.cancel),
|
||||
(dialog, which) -> {
|
||||
PreferencesUtil.setAllowCopyPasswordAndProtectedFields(EntryActivity.this, false);
|
||||
dialog.dismiss();
|
||||
fillData();
|
||||
});
|
||||
warningDialog.show();
|
||||
});
|
||||
} else {
|
||||
entryContentsView.assignPasswordCopyListener(null);
|
||||
}
|
||||
}
|
||||
|
||||
entryContentsView.assignURL(mEntry.getUrl());
|
||||
@@ -241,14 +374,15 @@ public class EntryActivity extends LockingHideActivity {
|
||||
if (mEntry.allowExtraFields()) {
|
||||
entryContentsView.clearExtraFields();
|
||||
|
||||
mEntry.getFields().doActionToAllCustomProtectedField((label, value) ->
|
||||
|
||||
entryContentsView.addExtraField(label, value, view ->
|
||||
mEntry.getFields().doActionToAllCustomProtectedField((label, value) -> {
|
||||
boolean showAction = (!value.isProtected() || PreferencesUtil.allowCopyPasswordAndProtectedFields(EntryActivity.this));
|
||||
entryContentsView.addExtraField(label, value, showAction, view ->
|
||||
clipboardHelper.timeoutCopyToClipboard(
|
||||
value.toString(),
|
||||
getString(R.string.copy_field, label)
|
||||
)
|
||||
));
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// Assign dates
|
||||
@@ -262,7 +396,7 @@ public class EntryActivity extends LockingHideActivity {
|
||||
entryContentsView.assignExpiresDate(getString(R.string.never));
|
||||
}
|
||||
|
||||
mEntry.endToManageFieldReferences();
|
||||
mEntry.stopToManageFieldReferences();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -290,7 +424,7 @@ public class EntryActivity extends LockingHideActivity {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
MenuUtil.donationMenuInflater(inflater, menu);
|
||||
MenuUtil.contributionMenuInflater(inflater, menu);
|
||||
inflater.inflate(R.menu.entry, menu);
|
||||
inflater.inflate(R.menu.database_lock, menu);
|
||||
|
||||
@@ -324,14 +458,17 @@ public class EntryActivity extends LockingHideActivity {
|
||||
}
|
||||
}
|
||||
|
||||
// Show education views
|
||||
new Handler().post(() -> checkAndPerformedEducation(menu));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch ( item.getItemId() ) {
|
||||
case R.id.menu_donate:
|
||||
return MenuUtil.onDonationItemSelected(this);
|
||||
case R.id.menu_contribute:
|
||||
return MenuUtil.onContributionItemSelected(this);
|
||||
|
||||
case R.id.menu_toggle_pass:
|
||||
mShowPassword = !mShowPassword;
|
||||
|
||||
@@ -21,8 +21,9 @@ package com.kunzisoft.keepass.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
@@ -31,11 +32,13 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.getkeepsafe.taptargetview.TapTarget;
|
||||
import com.getkeepsafe.taptargetview.TapTargetView;
|
||||
import com.kunzisoft.keepass.R;
|
||||
import com.kunzisoft.keepass.app.App;
|
||||
import com.kunzisoft.keepass.database.Database;
|
||||
@@ -45,16 +48,19 @@ import com.kunzisoft.keepass.database.PwEntry;
|
||||
import com.kunzisoft.keepass.database.PwGroup;
|
||||
import com.kunzisoft.keepass.database.PwGroupId;
|
||||
import com.kunzisoft.keepass.database.PwIconStandard;
|
||||
import com.kunzisoft.keepass.database.edit.AddEntry;
|
||||
import com.kunzisoft.keepass.database.edit.OnFinish;
|
||||
import com.kunzisoft.keepass.database.edit.RunnableOnFinish;
|
||||
import com.kunzisoft.keepass.database.edit.UpdateEntry;
|
||||
import com.kunzisoft.keepass.database.PwNode;
|
||||
import com.kunzisoft.keepass.database.action.RunnableOnFinish;
|
||||
import com.kunzisoft.keepass.database.action.node.AddEntryRunnable;
|
||||
import com.kunzisoft.keepass.database.action.node.AfterActionNodeOnFinish;
|
||||
import com.kunzisoft.keepass.database.action.node.UpdateEntryRunnable;
|
||||
import com.kunzisoft.keepass.database.security.ProtectedString;
|
||||
import com.kunzisoft.keepass.dialogs.GeneratePasswordDialogFragment;
|
||||
import com.kunzisoft.keepass.dialogs.IconPickerDialogFragment;
|
||||
import com.kunzisoft.keepass.icons.Icons;
|
||||
import com.kunzisoft.keepass.lock.LockingActivity;
|
||||
import com.kunzisoft.keepass.lock.LockingHideActivity;
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil;
|
||||
import com.kunzisoft.keepass.tasks.ProgressTask;
|
||||
import com.kunzisoft.keepass.tasks.SaveDatabaseProgressTaskDialogFragment;
|
||||
import com.kunzisoft.keepass.tasks.UpdateProgressTaskStatus;
|
||||
import com.kunzisoft.keepass.utils.MenuUtil;
|
||||
import com.kunzisoft.keepass.utils.Types;
|
||||
import com.kunzisoft.keepass.utils.Util;
|
||||
@@ -62,6 +68,10 @@ import com.kunzisoft.keepass.view.EntryEditCustomField;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.kunzisoft.keepass.dialogs.IconPickerDialogFragment.KEY_ICON_STANDARD;
|
||||
|
||||
public class EntryEditActivity extends LockingHideActivity
|
||||
implements IconPickerDialogFragment.IconPickerListener,
|
||||
GeneratePasswordDialogFragment.GeneratePasswordListener {
|
||||
@@ -78,23 +88,31 @@ public class EntryEditActivity extends LockingHideActivity
|
||||
public static final int ADD_OR_UPDATE_ENTRY_REQUEST_CODE = 7129;
|
||||
public static final String ADD_OR_UPDATE_ENTRY_KEY = "ADD_OR_UPDATE_ENTRY_KEY";
|
||||
|
||||
private Database database;
|
||||
|
||||
protected PwEntry mEntry;
|
||||
protected PwEntry mCallbackNewEntry;
|
||||
protected boolean mIsNew;
|
||||
protected int mSelectedIconID = -1;
|
||||
protected PwIconStandard mSelectedIconStandard;
|
||||
|
||||
// Views
|
||||
private ScrollView scrollView;
|
||||
private EditText entryTitleView;
|
||||
private ImageView entryIconView;
|
||||
private EditText entryUserNameView;
|
||||
private EditText entryUrlView;
|
||||
private EditText entryPasswordView;
|
||||
private EditText entryConfirmationPasswordView;
|
||||
private View generatePasswordView;
|
||||
private EditText entryCommentView;
|
||||
private ViewGroup entryExtraFieldsContainer;
|
||||
private View addNewFieldView;
|
||||
private View saveView;
|
||||
private int iconColor;
|
||||
|
||||
/**
|
||||
* launch EntryEditActivity to update an existing entry
|
||||
* Launch EntryEditActivity to update an existing entry
|
||||
*
|
||||
* @param act from activity
|
||||
* @param pw Entry to update
|
||||
*/
|
||||
@@ -107,7 +125,8 @@ public class EntryEditActivity extends LockingHideActivity
|
||||
}
|
||||
|
||||
/**
|
||||
* launch EntryEditActivity to add a new entry
|
||||
* Launch EntryEditActivity to add a new entry
|
||||
*
|
||||
* @param act from activity
|
||||
* @param pwGroup Group who will contains new entry
|
||||
*/
|
||||
@@ -125,7 +144,6 @@ public class EntryEditActivity extends LockingHideActivity
|
||||
setContentView(R.layout.entry_edit);
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
toolbar.setTitle(getString(R.string.app_name));
|
||||
setSupportActionBar(toolbar);
|
||||
assert getSupportActionBar() != null;
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
@@ -135,6 +153,7 @@ public class EntryEditActivity extends LockingHideActivity
|
||||
scrollView.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET);
|
||||
|
||||
entryTitleView = findViewById(R.id.entry_title);
|
||||
entryIconView = findViewById(R.id.icon_button);
|
||||
entryUserNameView = findViewById(R.id.entry_user_name);
|
||||
entryUrlView = findViewById(R.id.entry_url);
|
||||
entryPasswordView = findViewById(R.id.entry_password);
|
||||
@@ -143,8 +162,8 @@ public class EntryEditActivity extends LockingHideActivity
|
||||
entryExtraFieldsContainer = findViewById(R.id.advanced_container);
|
||||
|
||||
// Likely the app has been killed exit the activity
|
||||
Database db = App.getDB();
|
||||
if ( ! db.getLoaded() ) {
|
||||
database = App.getDB();
|
||||
if ( ! database.getLoaded() ) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
@@ -152,12 +171,21 @@ public class EntryEditActivity extends LockingHideActivity
|
||||
Intent intent = getIntent();
|
||||
byte[] uuidBytes = intent.getByteArrayExtra(KEY_ENTRY);
|
||||
|
||||
PwDatabase pm = db.getPwDatabase();
|
||||
// Retrieve the textColor to tint the icon
|
||||
int[] attrs = {android.R.attr.textColorPrimary};
|
||||
TypedArray ta = getTheme().obtainStyledAttributes(attrs);
|
||||
iconColor = ta.getColor(0, Color.WHITE);
|
||||
|
||||
mSelectedIconStandard = database.getPwDatabase().getIconFactory().getUnknownIcon();
|
||||
|
||||
PwDatabase pm = database.getPwDatabase();
|
||||
if ( uuidBytes == null ) {
|
||||
PwGroupId parentId = (PwGroupId) intent.getSerializableExtra(KEY_PARENT);
|
||||
PwGroupId parentId = intent.getParcelableExtra(KEY_PARENT);
|
||||
PwGroup parent = pm.getGroupByGroupId(parentId);
|
||||
mEntry = PwEntry.getInstance(parent);
|
||||
mEntry = database.createEntry(parent);
|
||||
mIsNew = true;
|
||||
// Add the default icon
|
||||
database.getDrawFactory().assignDefaultDatabaseIconTo(this, entryIconView, iconColor);
|
||||
} else {
|
||||
UUID uuid = Types.bytestoUUID(uuidBytes);
|
||||
mEntry = pm.getEntryByUUIDId(uuid);
|
||||
@@ -165,66 +193,182 @@ public class EntryEditActivity extends LockingHideActivity
|
||||
fillData();
|
||||
}
|
||||
|
||||
View iconButton = findViewById(R.id.icon_button);
|
||||
iconButton.setOnClickListener(v ->
|
||||
// Assign title
|
||||
setTitle((mIsNew) ? getString(R.string.add_entry) : getString(R.string.edit_entry));
|
||||
|
||||
// Retrieve the icon after an orientation change
|
||||
if (savedInstanceState != null
|
||||
&& savedInstanceState.containsKey(KEY_ICON_STANDARD)) {
|
||||
iconPicked(savedInstanceState);
|
||||
}
|
||||
|
||||
// Add listener to the icon
|
||||
entryIconView.setOnClickListener(v ->
|
||||
IconPickerDialogFragment.launch(EntryEditActivity.this));
|
||||
|
||||
// Generate password button
|
||||
View generatePassword = findViewById(R.id.generate_button);
|
||||
generatePassword.setOnClickListener(v -> {
|
||||
GeneratePasswordDialogFragment generatePasswordDialogFragment = new GeneratePasswordDialogFragment();
|
||||
generatePasswordDialogFragment.show(getSupportFragmentManager(), "PasswordGeneratorFragment");
|
||||
});
|
||||
generatePasswordView = findViewById(R.id.generate_button);
|
||||
generatePasswordView.setOnClickListener(v -> openPasswordGenerator());
|
||||
|
||||
// Save button
|
||||
View save = findViewById(R.id.entry_save);
|
||||
save.setOnClickListener(v -> {
|
||||
saveView = findViewById(R.id.entry_save);
|
||||
saveView.setOnClickListener(v -> saveEntry());
|
||||
|
||||
|
||||
if (mEntry.allowExtraFields()) {
|
||||
addNewFieldView = findViewById(R.id.add_new_field);
|
||||
addNewFieldView.setVisibility(View.VISIBLE);
|
||||
addNewFieldView.setOnClickListener(v -> addNewCustomField());
|
||||
}
|
||||
|
||||
// Verify the education views
|
||||
checkAndPerformedEducation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the password generator fragment
|
||||
*/
|
||||
private void openPasswordGenerator() {
|
||||
GeneratePasswordDialogFragment generatePasswordDialogFragment = new GeneratePasswordDialogFragment();
|
||||
generatePasswordDialogFragment.show(getSupportFragmentManager(), "PasswordGeneratorFragment");
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new view to fill in the information of the customized field
|
||||
*/
|
||||
private void addNewCustomField() {
|
||||
EntryEditCustomField entryEditCustomField = new EntryEditCustomField(EntryEditActivity.this);
|
||||
entryEditCustomField.setData("", new ProtectedString(false, ""));
|
||||
boolean visibilityFontActivated = PreferencesUtil.fieldFontIsInVisibility(this);
|
||||
entryEditCustomField.setFontVisibility(visibilityFontActivated);
|
||||
entryExtraFieldsContainer.addView(entryEditCustomField);
|
||||
|
||||
// Scroll bottom
|
||||
scrollView.post(() -> scrollView.fullScroll(ScrollView.FOCUS_DOWN));
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the new entry or update an existing entry in the database
|
||||
*/
|
||||
private void saveEntry() {
|
||||
if (!validateBeforeSaving()) {
|
||||
return;
|
||||
}
|
||||
mCallbackNewEntry = populateNewEntry();
|
||||
|
||||
OnFinish onFinish = new AfterSave();
|
||||
// Open a progress dialog and save entry
|
||||
AfterActionNodeOnFinish onFinish = new AfterSave();
|
||||
EntryEditActivity act = EntryEditActivity.this;
|
||||
RunnableOnFinish task;
|
||||
if ( mIsNew ) {
|
||||
task = new AddEntry(act, App.getDB(), mCallbackNewEntry, onFinish);
|
||||
task = new AddEntryRunnable(act, database, mCallbackNewEntry, onFinish);
|
||||
} else {
|
||||
task = new UpdateEntry(act, App.getDB(), mEntry, mCallbackNewEntry, onFinish);
|
||||
task = new UpdateEntryRunnable(act, database, mEntry, mCallbackNewEntry, onFinish);
|
||||
}
|
||||
task.setUpdateProgressTaskStatus(
|
||||
new UpdateProgressTaskStatus(this,
|
||||
SaveDatabaseProgressTaskDialogFragment.start(
|
||||
getSupportFragmentManager())
|
||||
));
|
||||
new Thread(task).start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check and display learning views
|
||||
* Displays the explanation for the icon selection, the password generator and for a new field
|
||||
*/
|
||||
private void checkAndPerformedEducation() {
|
||||
if (PreferencesUtil.isEducationScreensEnabled(this)) {
|
||||
// TODO Show icon
|
||||
|
||||
if (!PreferencesUtil.isEducationPasswordGeneratorPerformed(this)) {
|
||||
TapTargetView.showFor(this,
|
||||
TapTarget.forView(generatePasswordView,
|
||||
getString(R.string.education_generate_password_title),
|
||||
getString(R.string.education_generate_password_summary))
|
||||
.textColorInt(Color.WHITE)
|
||||
.tintTarget(false)
|
||||
.cancelable(true),
|
||||
new TapTargetView.Listener() {
|
||||
@Override
|
||||
public void onTargetClick(TapTargetView view) {
|
||||
super.onTargetClick(view);
|
||||
openPasswordGenerator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOuterCircleClick(TapTargetView view) {
|
||||
super.onOuterCircleClick(view);
|
||||
view.dismiss(false);
|
||||
}
|
||||
ProgressTask pt = new ProgressTask(act, task, R.string.saving_database);
|
||||
pt.run();
|
||||
});
|
||||
PreferencesUtil.saveEducationPreference(this,
|
||||
R.string.education_password_generator_key);
|
||||
} else if (mEntry.allowExtraFields()
|
||||
&& !mEntry.containsCustomFields()
|
||||
&& !PreferencesUtil.isEducationEntryNewFieldPerformed(this)) {
|
||||
TapTargetView.showFor(this,
|
||||
TapTarget.forView(addNewFieldView,
|
||||
getString(R.string.education_entry_new_field_title),
|
||||
getString(R.string.education_entry_new_field_summary))
|
||||
.textColorInt(Color.WHITE)
|
||||
.tintTarget(false)
|
||||
.cancelable(true),
|
||||
new TapTargetView.Listener() {
|
||||
@Override
|
||||
public void onTargetClick(TapTargetView view) {
|
||||
super.onTargetClick(view);
|
||||
addNewCustomField();
|
||||
}
|
||||
|
||||
|
||||
if (mEntry.allowExtraFields()) {
|
||||
View add = findViewById(R.id.add_new_field);
|
||||
add.setVisibility(View.VISIBLE);
|
||||
add.setOnClickListener(v -> {
|
||||
EntryEditCustomField ees = new EntryEditCustomField(EntryEditActivity.this);
|
||||
ees.setData("", new ProtectedString(false, ""));
|
||||
entryExtraFieldsContainer.addView(ees);
|
||||
|
||||
// Scroll bottom
|
||||
scrollView.post(() -> scrollView.fullScroll(ScrollView.FOCUS_DOWN));
|
||||
@Override
|
||||
public void onOuterCircleClick(TapTargetView view) {
|
||||
super.onOuterCircleClick(view);
|
||||
view.dismiss(false);
|
||||
}
|
||||
});
|
||||
PreferencesUtil.saveEducationPreference(this,
|
||||
R.string.education_entry_new_field_key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean validateBeforeSaving() {
|
||||
/**
|
||||
* Utility class to retrieve a validation or an error with a message
|
||||
*/
|
||||
private class ErrorValidation {
|
||||
static final int unknownMessage = -1;
|
||||
|
||||
boolean isValidate = false;
|
||||
int messageId = unknownMessage;
|
||||
|
||||
void showValidationErrorIfNeeded() {
|
||||
if (!isValidate && messageId != unknownMessage)
|
||||
Toast.makeText(EntryEditActivity.this, messageId, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate or not the entry form
|
||||
*
|
||||
* @return ErrorValidation An error with a message or a validation without message
|
||||
*/
|
||||
protected ErrorValidation validate() {
|
||||
ErrorValidation errorValidation = new ErrorValidation();
|
||||
|
||||
// Require title
|
||||
String title = entryTitleView.getText().toString();
|
||||
if ( title.length() == 0 ) {
|
||||
Toast.makeText(this, R.string.error_title_required, Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
errorValidation.messageId = R.string.error_title_required;
|
||||
return errorValidation;
|
||||
}
|
||||
|
||||
// Validate password
|
||||
String pass = entryPasswordView.getText().toString();
|
||||
String conf = entryConfirmationPasswordView.getText().toString();
|
||||
if ( ! pass.equals(conf) ) {
|
||||
Toast.makeText(this, R.string.error_pass_match, Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
errorValidation.messageId = R.string.error_pass_match;
|
||||
return errorValidation;
|
||||
}
|
||||
|
||||
// Validate extra fields
|
||||
@@ -233,13 +377,25 @@ public class EntryEditActivity extends LockingHideActivity
|
||||
EntryEditCustomField entryEditCustomField = (EntryEditCustomField) entryExtraFieldsContainer.getChildAt(i);
|
||||
String key = entryEditCustomField.getLabel();
|
||||
if (key == null || key.length() == 0) {
|
||||
Toast.makeText(this, R.string.error_string_key, Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
errorValidation.messageId = R.string.error_string_key;
|
||||
return errorValidation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
errorValidation.isValidate = true;
|
||||
return errorValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch a validation with {@link #validate()} and show the error if present
|
||||
*
|
||||
* @return true if the form was validate or false if not
|
||||
*/
|
||||
protected boolean validateBeforeSaving() {
|
||||
ErrorValidation errorValidation = validate();
|
||||
errorValidation.showValidationErrorIfNeeded();
|
||||
return errorValidation.isValidate;
|
||||
}
|
||||
|
||||
protected PwEntry populateNewEntry() {
|
||||
@@ -255,18 +411,8 @@ public class EntryEditActivity extends LockingHideActivity
|
||||
newEntry.setLastModificationTime(new PwDate());
|
||||
|
||||
newEntry.setTitle(entryTitleView.getText().toString());
|
||||
if(mSelectedIconID != -1)
|
||||
// or TODO icon factory newEntry.setIcon(App.getDB().pm.iconFactory.getIcon(mSelectedIconID));
|
||||
newEntry.setIcon(new PwIconStandard(mSelectedIconID));
|
||||
else {
|
||||
if (mIsNew) {
|
||||
newEntry.setIcon(App.getDB().getPwDatabase().getIconFactory().getFirstIcon());
|
||||
}
|
||||
else {
|
||||
// Keep previous icon, if no new one was selected
|
||||
newEntry.setIcon(mEntry.getIconStandard());
|
||||
}
|
||||
}
|
||||
newEntry.setIconStandard(retrieveIcon());
|
||||
|
||||
newEntry.setUrl(entryUrlView.getText().toString());
|
||||
newEntry.setUsername(entryUserNameView.getText().toString());
|
||||
newEntry.setNotes(entryCommentView.getText().toString());
|
||||
@@ -285,26 +431,44 @@ public class EntryEditActivity extends LockingHideActivity
|
||||
}
|
||||
}
|
||||
|
||||
newEntry.endToManageFieldReferences();
|
||||
newEntry.stopToManageFieldReferences();
|
||||
|
||||
return newEntry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the icon by the selection, or the first icon in the list if the entry is new or the last one
|
||||
*/
|
||||
private PwIconStandard retrieveIcon() {
|
||||
|
||||
if (!mSelectedIconStandard.isUnknown())
|
||||
return mSelectedIconStandard;
|
||||
else {
|
||||
if (mIsNew) {
|
||||
return database.getPwDatabase().getIconFactory().getKeyIcon();
|
||||
}
|
||||
else {
|
||||
// Keep previous icon, if no new one was selected
|
||||
return mEntry.getIconStandard();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
MenuUtil.donationMenuInflater(inflater, menu);
|
||||
MenuUtil.contributionMenuInflater(inflater, menu);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch ( item.getItemId() ) {
|
||||
case R.id.menu_donate:
|
||||
return MenuUtil.onDonationItemSelected(this);
|
||||
case R.id.menu_contribute:
|
||||
return MenuUtil.onContributionItemSelected(this);
|
||||
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
@@ -313,12 +477,21 @@ public class EntryEditActivity extends LockingHideActivity
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void assignIconView() {
|
||||
database.getDrawFactory()
|
||||
.assignDatabaseIconTo(
|
||||
this,
|
||||
entryIconView,
|
||||
mEntry.getIcon(),
|
||||
iconColor);
|
||||
}
|
||||
|
||||
protected void fillData() {
|
||||
ImageButton currIconButton = findViewById(R.id.icon_button);
|
||||
App.getDB().getDrawFactory().assignDrawableTo(currIconButton, getResources(), mEntry.getIcon());
|
||||
|
||||
assignIconView();
|
||||
|
||||
// Don't start the field reference manager, we want to see the raw ref
|
||||
mEntry.endToManageFieldReferences();
|
||||
mEntry.stopToManageFieldReferences();
|
||||
|
||||
entryTitleView.setText(mEntry.getTitle());
|
||||
entryUserNameView.setText(mEntry.getUsername());
|
||||
@@ -330,10 +503,10 @@ public class EntryEditActivity extends LockingHideActivity
|
||||
|
||||
boolean visibilityFontActivated = PreferencesUtil.fieldFontIsInVisibility(this);
|
||||
if (visibilityFontActivated) {
|
||||
Util.applyFontVisibilityTo(entryUserNameView);
|
||||
Util.applyFontVisibilityTo(entryPasswordView);
|
||||
Util.applyFontVisibilityTo(entryConfirmationPasswordView);
|
||||
Util.applyFontVisibilityTo(entryCommentView);
|
||||
Util.applyFontVisibilityTo(this, entryUserNameView);
|
||||
Util.applyFontVisibilityTo(this, entryPasswordView);
|
||||
Util.applyFontVisibilityTo(this, entryConfirmationPasswordView);
|
||||
Util.applyFontVisibilityTo(this, entryCommentView);
|
||||
}
|
||||
|
||||
if (mEntry.allowExtraFields()) {
|
||||
@@ -349,9 +522,17 @@ public class EntryEditActivity extends LockingHideActivity
|
||||
|
||||
@Override
|
||||
public void iconPicked(Bundle bundle) {
|
||||
mSelectedIconID = bundle.getInt(IconPickerDialogFragment.KEY_ICON_ID);
|
||||
ImageButton currIconButton = findViewById(R.id.icon_button);
|
||||
currIconButton.setImageResource(Icons.iconToResId(mSelectedIconID));
|
||||
mSelectedIconStandard = bundle.getParcelable(KEY_ICON_STANDARD);
|
||||
mEntry.setIconStandard(mSelectedIconStandard);
|
||||
assignIconView();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
if (!mSelectedIconStandard.isUnknown()) {
|
||||
outState.putParcelable(KEY_ICON_STANDARD, mSelectedIconStandard);
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -359,6 +540,8 @@ public class EntryEditActivity extends LockingHideActivity
|
||||
String generatedPassword = bundle.getString(GeneratePasswordDialogFragment.KEY_PASSWORD_ID);
|
||||
entryPasswordView.setText(generatedPassword);
|
||||
entryConfirmationPasswordView.setText(generatedPassword);
|
||||
|
||||
checkAndPerformedEducation();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -373,7 +556,7 @@ public class EntryEditActivity extends LockingHideActivity
|
||||
if (mCallbackNewEntry != null) {
|
||||
Bundle bundle = new Bundle();
|
||||
Intent intentEntry = new Intent();
|
||||
bundle.putSerializable(ADD_OR_UPDATE_ENTRY_KEY, mCallbackNewEntry);
|
||||
bundle.putParcelable(ADD_OR_UPDATE_ENTRY_KEY, mCallbackNewEntry);
|
||||
intentEntry.putExtras(bundle);
|
||||
if (mIsNew) {
|
||||
setResult(ADD_ENTRY_RESULT_CODE, intentEntry);
|
||||
@@ -388,19 +571,19 @@ public class EntryEditActivity extends LockingHideActivity
|
||||
}
|
||||
}
|
||||
|
||||
private final class AfterSave extends OnFinish {
|
||||
|
||||
AfterSave() {
|
||||
super(new Handler());
|
||||
}
|
||||
private final class AfterSave extends AfterActionNodeOnFinish {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
public void run(@Nullable PwNode oldNode, @Nullable PwNode newNode) {
|
||||
runOnUiThread(() -> {
|
||||
if ( mSuccess ) {
|
||||
finish();
|
||||
} else {
|
||||
displayMessage(EntryEditActivity.this);
|
||||
}
|
||||
|
||||
SaveDatabaseProgressTaskDialogFragment.stop(EntryEditActivity.this);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.kunzisoft.keepass.activities;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
public interface IntentBuildLauncher {
|
||||
void startActivityForResult(Intent intent);
|
||||
}
|
||||
@@ -1,353 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017 Brian Pellin, Jeremy Jamet / Kunzisoft.
|
||||
*
|
||||
* This file is part of KeePass DX.
|
||||
*
|
||||
* KeePass DX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* KeePass DX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with KeePass DX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.kunzisoft.keepass.activities;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.assist.AssistStructure;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.kunzisoft.keepass.R;
|
||||
import com.kunzisoft.keepass.adapters.NodeAdapter;
|
||||
import com.kunzisoft.keepass.app.App;
|
||||
import com.kunzisoft.keepass.autofill.AutofillHelper;
|
||||
import com.kunzisoft.keepass.compat.EditorCompat;
|
||||
import com.kunzisoft.keepass.database.Database;
|
||||
import com.kunzisoft.keepass.database.PwDatabase;
|
||||
import com.kunzisoft.keepass.database.PwEntry;
|
||||
import com.kunzisoft.keepass.database.PwGroup;
|
||||
import com.kunzisoft.keepass.database.PwNode;
|
||||
import com.kunzisoft.keepass.database.SortNodeEnum;
|
||||
import com.kunzisoft.keepass.database.edit.AfterAddNodeOnFinish;
|
||||
import com.kunzisoft.keepass.database.edit.OnFinish;
|
||||
import com.kunzisoft.keepass.dialogs.AssignMasterKeyDialogFragment;
|
||||
import com.kunzisoft.keepass.dialogs.SortDialogFragment;
|
||||
import com.kunzisoft.keepass.password.AssignPasswordHelper;
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil;
|
||||
import com.kunzisoft.keepass.tasks.UIToastTask;
|
||||
import com.kunzisoft.keepass.utils.MenuUtil;
|
||||
|
||||
public abstract class ListNodesActivity extends LockingActivity
|
||||
implements AssignMasterKeyDialogFragment.AssignPasswordDialogListener,
|
||||
NodeAdapter.OnNodeClickCallback,
|
||||
SortDialogFragment.SortSelectionListener {
|
||||
|
||||
protected PwGroup mCurrentGroup;
|
||||
protected NodeAdapter mAdapter;
|
||||
|
||||
private SharedPreferences prefs;
|
||||
|
||||
protected AutofillHelper autofillHelper;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if ( isFinishing() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Likely the app has been killed exit the activity
|
||||
if ( ! App.getDB().getLoaded() ) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
invalidateOptionsMenu();
|
||||
|
||||
// TODO Move in search
|
||||
setContentView(R.layout.list_nodes);
|
||||
|
||||
mCurrentGroup = initCurrentGroup();
|
||||
|
||||
mAdapter = new NodeAdapter(this);
|
||||
addOptionsToAdapter(mAdapter);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
autofillHelper = new AutofillHelper();
|
||||
autofillHelper.retrieveAssistStructure(getIntent());
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract PwGroup initCurrentGroup();
|
||||
|
||||
protected abstract RecyclerView defineNodeList();
|
||||
|
||||
protected void addOptionsToAdapter(NodeAdapter nodeAdapter) {
|
||||
mAdapter.setOnNodeClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
// Add elements to the list
|
||||
mAdapter.rebuildList(mCurrentGroup);
|
||||
assignListToNodeAdapter(defineNodeList());
|
||||
}
|
||||
|
||||
protected void setGroupTitle() {
|
||||
if ( mCurrentGroup != null ) {
|
||||
String name = mCurrentGroup.getName();
|
||||
TextView tv = findViewById(R.id.group_name);
|
||||
if ( name != null && name.length() > 0 ) {
|
||||
if ( tv != null ) {
|
||||
tv.setText(name);
|
||||
}
|
||||
} else {
|
||||
if ( tv != null ) {
|
||||
tv.setText(getText(R.string.root));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void assignListToNodeAdapter(RecyclerView recyclerView) {
|
||||
recyclerView.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
recyclerView.setAdapter(mAdapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNodeClick(PwNode node) {
|
||||
|
||||
mAdapter.registerANodeToUpdate(node);
|
||||
|
||||
// Add event when we have Autofill
|
||||
AssistStructure assistStructure = null;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
assistStructure = autofillHelper.getAssistStructure();
|
||||
if (assistStructure != null) {
|
||||
switch (node.getType()) {
|
||||
case GROUP:
|
||||
GroupActivity.launch(this, (PwGroup) node, assistStructure);
|
||||
break;
|
||||
case ENTRY:
|
||||
// Build response with the entry selected
|
||||
autofillHelper.buildResponseWhenEntrySelected(this, (PwEntry) node);
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( assistStructure == null ){
|
||||
switch (node.getType()) {
|
||||
case GROUP:
|
||||
GroupActivity.launch(this, (PwGroup) node);
|
||||
break;
|
||||
case ENTRY:
|
||||
EntryActivity.launch(this, (PwEntry) node);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
MenuUtil.donationMenuInflater(inflater, menu);
|
||||
inflater.inflate(R.menu.tree, menu);
|
||||
inflater.inflate(R.menu.default_menu, menu);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSortSelected(SortNodeEnum sortNodeEnum, boolean ascending, boolean groupsBefore, boolean recycleBinBottom) {
|
||||
// Toggle setting
|
||||
Editor editor = prefs.edit();
|
||||
editor.putString(getString(R.string.sort_node_key), sortNodeEnum.name());
|
||||
editor.putBoolean(getString(R.string.sort_ascending_key), ascending);
|
||||
editor.putBoolean(getString(R.string.sort_group_before_key), groupsBefore);
|
||||
editor.putBoolean(getString(R.string.sort_recycle_bin_bottom_key), recycleBinBottom);
|
||||
EditorCompat.apply(editor);
|
||||
|
||||
// Tell the adapter to refresh it's list
|
||||
mAdapter.notifyChangeSort(sortNodeEnum, ascending, groupsBefore);
|
||||
mAdapter.rebuildList(mCurrentGroup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch ( item.getItemId() ) {
|
||||
|
||||
case R.id.menu_sort:
|
||||
SortDialogFragment sortDialogFragment;
|
||||
|
||||
PwDatabase database = App.getDB().getPwDatabase();
|
||||
/*
|
||||
// TODO Recycle bin bottom
|
||||
if (database.isRecycleBinAvailable() && database.isRecycleBinEnabled()) {
|
||||
sortDialogFragment =
|
||||
SortDialogFragment.getInstance(
|
||||
PrefsUtil.getListSort(this),
|
||||
PrefsUtil.getAscendingSort(this),
|
||||
PrefsUtil.getGroupsBeforeSort(this),
|
||||
PrefsUtil.getRecycleBinBottomSort(this));
|
||||
} else {
|
||||
*/
|
||||
sortDialogFragment =
|
||||
SortDialogFragment.getInstance(
|
||||
PreferencesUtil.getListSort(this),
|
||||
PreferencesUtil.getAscendingSort(this),
|
||||
PreferencesUtil.getGroupsBeforeSort(this));
|
||||
//}
|
||||
|
||||
sortDialogFragment.show(getSupportFragmentManager(), "sortDialog");
|
||||
return true;
|
||||
|
||||
default:
|
||||
// Check the time lock before launching settings
|
||||
MenuUtil.onDefaultMenuOptionsItemSelected(this, item, true);
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAssignKeyDialogPositiveClick(
|
||||
boolean masterPasswordChecked, String masterPassword,
|
||||
boolean keyFileChecked, Uri keyFile) {
|
||||
|
||||
AssignPasswordHelper assignPasswordHelper =
|
||||
new AssignPasswordHelper(this,
|
||||
masterPassword, keyFile);
|
||||
assignPasswordHelper.assignPasswordInDatabase(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAssignKeyDialogNegativeClick(
|
||||
boolean masterPasswordChecked, String masterPassword,
|
||||
boolean keyFileChecked, Uri keyFile) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
switch (requestCode) {
|
||||
case EntryEditActivity.ADD_OR_UPDATE_ENTRY_REQUEST_CODE:
|
||||
if (resultCode == EntryEditActivity.ADD_ENTRY_RESULT_CODE ||
|
||||
resultCode == EntryEditActivity.UPDATE_ENTRY_RESULT_CODE) {
|
||||
PwNode newNode = (PwNode) data.getSerializableExtra(EntryEditActivity.ADD_OR_UPDATE_ENTRY_KEY);
|
||||
if (newNode != null) {
|
||||
if (resultCode == EntryEditActivity.ADD_ENTRY_RESULT_CODE)
|
||||
mAdapter.addNode(newNode);
|
||||
if (resultCode == EntryEditActivity.UPDATE_ENTRY_RESULT_CODE) {
|
||||
//mAdapter.updateLastNodeRegister(newNode);
|
||||
mAdapter.rebuildList(mCurrentGroup);
|
||||
}
|
||||
} else {
|
||||
Log.e(this.getClass().getName(), "New node can be retrieve in Activity Result");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
AutofillHelper.onActivityResultSetResultAndFinish(this, requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
@Override
|
||||
public void startActivityForResult(Intent intent, int requestCode, Bundle options) {
|
||||
/*
|
||||
* ACTION_SEARCH automatically forces a new task. This occurs when you open a kdb file in
|
||||
* another app such as Files or GoogleDrive and then Search for an entry. Here we remove the
|
||||
* FLAG_ACTIVITY_NEW_TASK flag bit allowing search to open it's activity in the current task.
|
||||
*/
|
||||
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
|
||||
int flags = intent.getFlags();
|
||||
flags &= ~Intent.FLAG_ACTIVITY_NEW_TASK;
|
||||
intent.setFlags(flags);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
super.startActivityForResult(intent, requestCode, options);
|
||||
}
|
||||
}
|
||||
|
||||
class AfterAddNode extends AfterAddNodeOnFinish {
|
||||
AfterAddNode(Handler handler) {
|
||||
super(handler);
|
||||
}
|
||||
|
||||
public void run(PwNode pwNode) {
|
||||
super.run();
|
||||
if (mSuccess) {
|
||||
mAdapter.addNode(pwNode);
|
||||
} else {
|
||||
displayMessage(ListNodesActivity.this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class AfterDeleteNode extends OnFinish {
|
||||
private PwNode pwNode;
|
||||
|
||||
AfterDeleteNode(Handler handler, PwNode pwNode) {
|
||||
super(handler);
|
||||
this.pwNode = pwNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if ( mSuccess) {
|
||||
mAdapter.removeNode(pwNode);
|
||||
PwGroup parent = pwNode.getParent();
|
||||
Database db = App.getDB();
|
||||
PwDatabase database = db.getPwDatabase();
|
||||
if (db.isRecycleBinAvailable() &&
|
||||
db.isRecycleBinEnabled()) {
|
||||
PwGroup recycleBin = database.getRecycleBin();
|
||||
// Add trash if it doesn't exists
|
||||
if (parent.equals(recycleBin)
|
||||
&& mCurrentGroup != null
|
||||
&& mCurrentGroup.getParent() == null
|
||||
&& !mCurrentGroup.equals(recycleBin)) {
|
||||
mAdapter.addNode(parent);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mHandler.post(new UIToastTask(ListNodesActivity.this, "Unrecoverable error: " + mMessage));
|
||||
App.setShutdown();
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,297 @@
|
||||
package com.kunzisoft.keepass.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.kunzisoft.keepass.R;
|
||||
import com.kunzisoft.keepass.adapters.NodeAdapter;
|
||||
import com.kunzisoft.keepass.app.App;
|
||||
import com.kunzisoft.keepass.database.PwDatabase;
|
||||
import com.kunzisoft.keepass.database.PwGroup;
|
||||
import com.kunzisoft.keepass.database.PwNode;
|
||||
import com.kunzisoft.keepass.database.SortNodeEnum;
|
||||
import com.kunzisoft.keepass.dialogs.SortDialogFragment;
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil;
|
||||
import com.kunzisoft.keepass.stylish.StylishFragment;
|
||||
|
||||
public class ListNodesFragment extends StylishFragment implements
|
||||
SortDialogFragment.SortSelectionListener {
|
||||
|
||||
private static final String TAG = ListNodesFragment.class.getName();
|
||||
|
||||
private static final String GROUP_KEY = "GROUP_KEY";
|
||||
private static final String IS_SEARCH = "IS_SEARCH";
|
||||
|
||||
private NodeAdapter.NodeClickCallback nodeClickCallback;
|
||||
private NodeAdapter.NodeMenuListener nodeMenuListener;
|
||||
private OnScrollListener onScrollListener;
|
||||
|
||||
private RecyclerView listView;
|
||||
private PwGroup currentGroup;
|
||||
private NodeAdapter mAdapter;
|
||||
|
||||
private View notFoundView;
|
||||
private boolean isASearchResult;
|
||||
|
||||
// Preferences for sorting
|
||||
private SharedPreferences prefs;
|
||||
|
||||
private boolean readOnly;
|
||||
|
||||
public static ListNodesFragment newInstance(PwGroup group, boolean readOnly, boolean isASearch) {
|
||||
Bundle bundle = new Bundle();
|
||||
if (group != null) {
|
||||
bundle.putParcelable(GROUP_KEY, group);
|
||||
}
|
||||
bundle.putBoolean(IS_SEARCH, isASearch);
|
||||
ReadOnlyHelper.putReadOnlyInBundle(bundle, readOnly);
|
||||
ListNodesFragment listNodesFragment = new ListNodesFragment();
|
||||
listNodesFragment.setArguments(bundle);
|
||||
return listNodesFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
try {
|
||||
nodeClickCallback = (NodeAdapter.NodeClickCallback) context;
|
||||
} catch (ClassCastException e) {
|
||||
// The activity doesn't implement the interface, throw exception
|
||||
throw new ClassCastException(context.toString()
|
||||
+ " must implement " + NodeAdapter.NodeClickCallback.class.getName());
|
||||
}
|
||||
try {
|
||||
nodeMenuListener = (NodeAdapter.NodeMenuListener) context;
|
||||
} catch (ClassCastException e) {
|
||||
nodeMenuListener = null;
|
||||
// Context menu can be omit
|
||||
Log.w(TAG, context.toString()
|
||||
+ " must implement " + NodeAdapter.NodeMenuListener.class.getName());
|
||||
}
|
||||
try {
|
||||
onScrollListener = (OnScrollListener) context;
|
||||
} catch (ClassCastException e) {
|
||||
onScrollListener = null;
|
||||
// Context menu can be omit
|
||||
Log.w(TAG, context.toString()
|
||||
+ " must implement " + RecyclerView.OnScrollListener.class.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if ( getActivity() != null ) {
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
readOnly = ReadOnlyHelper.retrieveReadOnlyFromInstanceStateOrArguments(savedInstanceState, getArguments());
|
||||
|
||||
if (getArguments() != null) {
|
||||
// Contains all the group in element
|
||||
if (getArguments().containsKey(GROUP_KEY)) {
|
||||
currentGroup = getArguments().getParcelable(GROUP_KEY);
|
||||
}
|
||||
|
||||
if (getArguments().containsKey(IS_SEARCH)) {
|
||||
isASearchResult = getArguments().getBoolean(IS_SEARCH);
|
||||
}
|
||||
}
|
||||
|
||||
mAdapter = new NodeAdapter(getContextThemed(), getActivity().getMenuInflater());
|
||||
mAdapter.setReadOnly(readOnly);
|
||||
mAdapter.setIsASearchResult(isASearchResult);
|
||||
mAdapter.setOnNodeClickListener(nodeClickCallback);
|
||||
|
||||
if (nodeMenuListener != null) {
|
||||
mAdapter.setActivateContextMenu(true);
|
||||
mAdapter.setNodeMenuListener(nodeMenuListener);
|
||||
}
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
ReadOnlyHelper.onSaveInstanceState(outState, readOnly);
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
// To apply theme
|
||||
View rootView = inflater.cloneInContext(getContextThemed())
|
||||
.inflate(R.layout.list_nodes_fragment, container, false);
|
||||
listView = rootView.findViewById(R.id.nodes_list);
|
||||
notFoundView = rootView.findViewById(R.id.not_found_container);
|
||||
|
||||
if (onScrollListener != null) {
|
||||
listView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
||||
super.onScrolled(recyclerView, dx, dy);
|
||||
onScrollListener.onScrolled(dy);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
rebuildList();
|
||||
|
||||
if (isASearchResult && mAdapter.isEmpty()) {
|
||||
// To show the " no search entry found "
|
||||
listView.setVisibility(View.GONE);
|
||||
notFoundView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
listView.setVisibility(View.VISIBLE);
|
||||
notFoundView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void rebuildList() {
|
||||
// Add elements to the list
|
||||
if (currentGroup != null)
|
||||
mAdapter.rebuildList(currentGroup);
|
||||
assignListToNodeAdapter(listView);
|
||||
}
|
||||
|
||||
protected void assignListToNodeAdapter(RecyclerView recyclerView) {
|
||||
recyclerView.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
recyclerView.setAdapter(mAdapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSortSelected(SortNodeEnum sortNodeEnum, boolean ascending, boolean groupsBefore, boolean recycleBinBottom) {
|
||||
// Toggle setting
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
editor.putString(getString(R.string.sort_node_key), sortNodeEnum.name());
|
||||
editor.putBoolean(getString(R.string.sort_ascending_key), ascending);
|
||||
editor.putBoolean(getString(R.string.sort_group_before_key), groupsBefore);
|
||||
editor.putBoolean(getString(R.string.sort_recycle_bin_bottom_key), recycleBinBottom);
|
||||
editor.apply();
|
||||
|
||||
// Tell the adapter to refresh it's list
|
||||
mAdapter.notifyChangeSort(sortNodeEnum, ascending, groupsBefore);
|
||||
mAdapter.rebuildList(currentGroup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.tree, menu);
|
||||
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch ( item.getItemId() ) {
|
||||
|
||||
case R.id.menu_sort:
|
||||
SortDialogFragment sortDialogFragment;
|
||||
|
||||
PwDatabase database = App.getDB().getPwDatabase();
|
||||
/*
|
||||
// TODO Recycle bin bottom
|
||||
if (database.isRecycleBinAvailable() && database.isRecycleBinEnabled()) {
|
||||
sortDialogFragment =
|
||||
SortDialogFragment.getInstance(
|
||||
PrefsUtil.getListSort(this),
|
||||
PrefsUtil.getAscendingSort(this),
|
||||
PrefsUtil.getGroupsBeforeSort(this),
|
||||
PrefsUtil.getRecycleBinBottomSort(this));
|
||||
} else {
|
||||
*/
|
||||
sortDialogFragment =
|
||||
SortDialogFragment.getInstance(
|
||||
PreferencesUtil.getListSort(getContext()),
|
||||
PreferencesUtil.getAscendingSort(getContext()),
|
||||
PreferencesUtil.getGroupsBeforeSort(getContext()));
|
||||
//}
|
||||
|
||||
sortDialogFragment.show(getChildFragmentManager(), "sortDialog");
|
||||
return true;
|
||||
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
switch (requestCode) {
|
||||
case EntryEditActivity.ADD_OR_UPDATE_ENTRY_REQUEST_CODE:
|
||||
if (resultCode == EntryEditActivity.ADD_ENTRY_RESULT_CODE ||
|
||||
resultCode == EntryEditActivity.UPDATE_ENTRY_RESULT_CODE) {
|
||||
PwNode newNode = data.getParcelableExtra(EntryEditActivity.ADD_OR_UPDATE_ENTRY_KEY);
|
||||
if (newNode != null) {
|
||||
if (resultCode == EntryEditActivity.ADD_ENTRY_RESULT_CODE)
|
||||
mAdapter.addNode(newNode);
|
||||
if (resultCode == EntryEditActivity.UPDATE_ENTRY_RESULT_CODE) {
|
||||
//mAdapter.updateLastNodeRegister(newNode);
|
||||
mAdapter.rebuildList(currentGroup);
|
||||
}
|
||||
} else {
|
||||
Log.e(this.getClass().getName(), "New node can be retrieve in Activity Result");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return mAdapter == null || mAdapter.getItemCount() <= 0;
|
||||
}
|
||||
|
||||
public void addNode(PwNode newNode) {
|
||||
mAdapter.addNode(newNode);
|
||||
}
|
||||
|
||||
public void updateNode(PwNode oldNode, PwNode newNode) {
|
||||
mAdapter.updateNode(oldNode, newNode);
|
||||
}
|
||||
|
||||
public void removeNode(PwNode pwNode) {
|
||||
mAdapter.removeNode(pwNode);
|
||||
}
|
||||
|
||||
public PwGroup getMainGroup() {
|
||||
return currentGroup;
|
||||
}
|
||||
|
||||
public interface OnScrollListener {
|
||||
|
||||
/**
|
||||
* Callback method to be invoked when the RecyclerView has been scrolled. This will be
|
||||
* called after the scroll has completed.
|
||||
*
|
||||
* @param dy The amount of vertical scroll.
|
||||
*/
|
||||
void onScrolled(int dy);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.kunzisoft.keepass.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil;
|
||||
|
||||
public class ReadOnlyHelper {
|
||||
|
||||
public static final String READ_ONLY_KEY = "READ_ONLY_KEY";
|
||||
|
||||
public static final boolean READ_ONLY_DEFAULT = false;
|
||||
|
||||
public static boolean retrieveReadOnlyFromInstanceStateOrPreference(Context context, Bundle savedInstanceState) {
|
||||
boolean readOnly;
|
||||
if (savedInstanceState != null
|
||||
&& savedInstanceState.containsKey(READ_ONLY_KEY)) {
|
||||
readOnly = savedInstanceState.getBoolean(READ_ONLY_KEY);
|
||||
} else {
|
||||
readOnly = PreferencesUtil.enableReadOnlyDatabase(context);
|
||||
}
|
||||
return readOnly;
|
||||
}
|
||||
|
||||
public static boolean retrieveReadOnlyFromInstanceStateOrArguments(Bundle savedInstanceState, Bundle arguments) {
|
||||
boolean readOnly = READ_ONLY_DEFAULT;
|
||||
if (savedInstanceState != null
|
||||
&& savedInstanceState.containsKey(READ_ONLY_KEY)) {
|
||||
readOnly = savedInstanceState.getBoolean(READ_ONLY_KEY);
|
||||
} else if (arguments != null
|
||||
&& arguments.containsKey(READ_ONLY_KEY)) {
|
||||
readOnly = arguments.getBoolean(READ_ONLY_KEY);
|
||||
}
|
||||
return readOnly;
|
||||
}
|
||||
|
||||
public static boolean retrieveReadOnlyFromInstanceStateOrIntent(Bundle savedInstanceState, Intent intent) {
|
||||
boolean readOnly = READ_ONLY_DEFAULT;
|
||||
if (savedInstanceState != null
|
||||
&& savedInstanceState.containsKey(READ_ONLY_KEY)) {
|
||||
readOnly = savedInstanceState.getBoolean(READ_ONLY_KEY);
|
||||
} else {
|
||||
if (intent != null)
|
||||
readOnly = intent.getBooleanExtra(READ_ONLY_KEY, READ_ONLY_DEFAULT);
|
||||
}
|
||||
return readOnly;
|
||||
}
|
||||
|
||||
public static void putReadOnlyInIntent(Intent intent, boolean readOnly) {
|
||||
intent.putExtra(READ_ONLY_KEY, readOnly);
|
||||
}
|
||||
|
||||
public static void putReadOnlyInBundle(Bundle bundle, boolean readOnly) {
|
||||
bundle.putBoolean(READ_ONLY_KEY, readOnly);
|
||||
}
|
||||
|
||||
public static void onSaveInstanceState(Bundle outState, boolean readOnly) {
|
||||
outState.putBoolean(READ_ONLY_KEY, readOnly);
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ abstract class BasicViewHolder extends RecyclerView.ViewHolder {
|
||||
View container;
|
||||
ImageView icon;
|
||||
TextView text;
|
||||
TextView subText;
|
||||
|
||||
BasicViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
package com.kunzisoft.keepass.adapters;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.kunzisoft.keepass.R;
|
||||
|
||||
@@ -30,7 +28,8 @@ class EntryViewHolder extends BasicViewHolder {
|
||||
EntryViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
container = itemView.findViewById(R.id.entry_container);
|
||||
icon = (ImageView) itemView.findViewById(R.id.entry_icon);
|
||||
text = (TextView) itemView.findViewById(R.id.entry_text);
|
||||
icon = itemView.findViewById(R.id.entry_icon);
|
||||
text = itemView.findViewById(R.id.entry_text);
|
||||
subText = itemView.findViewById(R.id.entry_subtext);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
package com.kunzisoft.keepass.adapters;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.kunzisoft.keepass.R;
|
||||
|
||||
@@ -30,7 +28,8 @@ class GroupViewHolder extends BasicViewHolder {
|
||||
GroupViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
container = itemView.findViewById(R.id.group_container);
|
||||
icon = (ImageView) itemView.findViewById(R.id.group_icon);
|
||||
text = (TextView) itemView.findViewById(R.id.group_text);
|
||||
icon = itemView.findViewById(R.id.group_icon);
|
||||
text = itemView.findViewById(R.id.group_text);
|
||||
subText = itemView.findViewById(R.id.group_subtext);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,53 +20,71 @@
|
||||
package com.kunzisoft.keepass.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.util.SortedList;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.util.SortedListAdapterCallback;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.kunzisoft.keepass.R;
|
||||
import com.kunzisoft.keepass.app.App;
|
||||
import com.kunzisoft.keepass.database.Database;
|
||||
import com.kunzisoft.keepass.database.PwEntry;
|
||||
import com.kunzisoft.keepass.database.PwGroup;
|
||||
import com.kunzisoft.keepass.database.PwNode;
|
||||
import com.kunzisoft.keepass.database.SortNodeEnum;
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil;
|
||||
import com.kunzisoft.keepass.utils.Util;
|
||||
|
||||
public class NodeAdapter extends RecyclerView.Adapter<BasicViewHolder> {
|
||||
private static final String TAG = NodeAdapter.class.getName();
|
||||
|
||||
private SortedList<PwNode> nodeSortedList;
|
||||
|
||||
private Context context;
|
||||
private LayoutInflater inflater;
|
||||
private MenuInflater menuInflater;
|
||||
private float textSize;
|
||||
private float subtextSize;
|
||||
private float iconSize;
|
||||
private SortNodeEnum listSort;
|
||||
private boolean groupsBeforeSort;
|
||||
private boolean ascendingSort;
|
||||
private boolean showUsernames;
|
||||
|
||||
private OnNodeClickCallback onNodeClickCallback;
|
||||
private int nodePositionToUpdate;
|
||||
private NodeClickCallback nodeClickCallback;
|
||||
private NodeMenuListener nodeMenuListener;
|
||||
private boolean activateContextMenu;
|
||||
private boolean readOnly;
|
||||
private boolean isASearchResult;
|
||||
|
||||
private Database database;
|
||||
|
||||
private int iconGroupColor;
|
||||
private int iconEntryColor;
|
||||
|
||||
/**
|
||||
* Create node list adapter with contextMenu or not
|
||||
* @param context Context to use
|
||||
*/
|
||||
public NodeAdapter(final Context context) {
|
||||
public NodeAdapter(final Context context, MenuInflater menuInflater) {
|
||||
this.inflater = LayoutInflater.from(context);
|
||||
this.menuInflater = menuInflater;
|
||||
this.context = context;
|
||||
this.textSize = PreferencesUtil.getListTextSize(context);
|
||||
this.listSort = PreferencesUtil.getListSort(context);
|
||||
this.groupsBeforeSort = PreferencesUtil.getGroupsBeforeSort(context);
|
||||
this.ascendingSort = PreferencesUtil.getAscendingSort(context);
|
||||
assignPreferences();
|
||||
this.activateContextMenu = false;
|
||||
this.nodePositionToUpdate = -1;
|
||||
this.readOnly = false;
|
||||
this.isASearchResult = false;
|
||||
|
||||
this.nodeSortedList = new SortedList<>(PwNode.class, new SortedListAdapterCallback<PwNode>(this) {
|
||||
@Override public int compare(PwNode item1, PwNode item2) {
|
||||
@@ -81,22 +99,70 @@ public class NodeAdapter extends RecyclerView.Adapter<BasicViewHolder> {
|
||||
return item1.equals(item2);
|
||||
}
|
||||
});
|
||||
|
||||
// Database
|
||||
this.database = App.getDB();
|
||||
|
||||
// Retrieve the color to tint the icon
|
||||
int[] attrTextColorPrimary = {android.R.attr.textColorPrimary};
|
||||
TypedArray taTextColorPrimary = context.getTheme().obtainStyledAttributes(attrTextColorPrimary);
|
||||
this.iconGroupColor = taTextColorPrimary.getColor(0, Color.BLACK);
|
||||
taTextColorPrimary.recycle();
|
||||
int[] attrTextColor = {android.R.attr.textColor}; // In two times to fix bug compilation
|
||||
TypedArray taTextColor = context.getTheme().obtainStyledAttributes(attrTextColor);
|
||||
this.iconEntryColor = taTextColor.getColor(0, Color.BLACK);
|
||||
taTextColor.recycle();
|
||||
}
|
||||
|
||||
public void setReadOnly(boolean readOnly) {
|
||||
this.readOnly = readOnly;
|
||||
}
|
||||
|
||||
public void setIsASearchResult(boolean isASearchResult) {
|
||||
this.isASearchResult = isASearchResult;
|
||||
}
|
||||
|
||||
public void setActivateContextMenu(boolean activate) {
|
||||
this.activateContextMenu = activate;
|
||||
}
|
||||
|
||||
private void assignPreferences() {
|
||||
float textSizeDefault = Util.getListTextDefaultSize(context);
|
||||
this.textSize = PreferencesUtil.getListTextSize(context);
|
||||
this.subtextSize = context.getResources().getInteger(R.integer.list_small_size_default)
|
||||
* textSize / textSizeDefault;
|
||||
// Retrieve the icon size
|
||||
float iconDefaultSize = context.getResources().getDimension(R.dimen.list_icon_size_default);
|
||||
this.iconSize = iconDefaultSize * textSize / textSizeDefault;
|
||||
this.listSort = PreferencesUtil.getListSort(context);
|
||||
this.groupsBeforeSort = PreferencesUtil.getGroupsBeforeSort(context);
|
||||
this.ascendingSort = PreferencesUtil.getAscendingSort(context);
|
||||
this.showUsernames = PreferencesUtil.showUsernamesListEntries(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild the list by clear and build children from the group
|
||||
*/
|
||||
public void rebuildList(PwGroup group) {
|
||||
this.nodeSortedList.clear();
|
||||
if (group != null) {
|
||||
assignPreferences();
|
||||
// TODO verify sort
|
||||
try {
|
||||
this.nodeSortedList.addAll(group.getDirectChildren());
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Can't add node elements to the list", e);
|
||||
Toast.makeText(context, "Can't add node elements to the list : " + e.getMessage(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the adapter contains or not any element
|
||||
* @return true if the list is empty
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
return nodeSortedList.size() <= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a node to the list
|
||||
* @param node Node to add
|
||||
@@ -106,43 +172,25 @@ public class NodeAdapter extends RecyclerView.Adapter<BasicViewHolder> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a node to update before an action
|
||||
* Call updateLastNodeRegister() after the action to update the node
|
||||
* @param node Node to register
|
||||
*/
|
||||
public void registerANodeToUpdate(PwNode node) {
|
||||
nodePositionToUpdate = nodeSortedList.indexOf(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the last Node register in the list
|
||||
* Work if only registerANodeToUpdate(PwNode node) is called before
|
||||
*/
|
||||
public void updateLastNodeRegister(PwNode node) {
|
||||
// Don't really update here, sorted list knows each original ref, so we just notify a change
|
||||
try {
|
||||
if (nodePositionToUpdate != -1) {
|
||||
// Don't know why but there is a bug to remove a node after this update
|
||||
nodeSortedList.updateItemAt(nodePositionToUpdate, node);
|
||||
nodeSortedList.recalculatePositionOfItemAt(nodePositionToUpdate);
|
||||
nodePositionToUpdate = -1;
|
||||
}
|
||||
else {
|
||||
Log.e(NodeAdapter.class.getName(), "registerANodeToUpdate must be called before updateLastNodeRegister");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
Log.e(NodeAdapter.class.getName(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove node in the list
|
||||
* Remove a node in the list
|
||||
* @param node Node to delete
|
||||
*/
|
||||
public void removeNode(PwNode node) {
|
||||
nodeSortedList.remove(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a node in the list
|
||||
* @param oldNode Node before the update
|
||||
* @param newNode Node after the update
|
||||
*/
|
||||
public void updateNode(PwNode oldNode, PwNode newNode) {
|
||||
nodeSortedList.beginBatchedUpdates();
|
||||
nodeSortedList.remove(oldNode);
|
||||
nodeSortedList.add(newNode);
|
||||
nodeSortedList.endBatchedUpdates();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify a change sort of the list
|
||||
*/
|
||||
@@ -157,8 +205,9 @@ public class NodeAdapter extends RecyclerView.Adapter<BasicViewHolder> {
|
||||
return nodeSortedList.get(position).getType().ordinal();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public BasicViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
public BasicViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
BasicViewHolder basicViewHolder;
|
||||
View view;
|
||||
if (viewType == PwNode.Type.GROUP.ordinal()) {
|
||||
@@ -172,23 +221,54 @@ public class NodeAdapter extends RecyclerView.Adapter<BasicViewHolder> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(BasicViewHolder holder, int position) {
|
||||
public void onBindViewHolder(@NonNull BasicViewHolder holder, int position) {
|
||||
PwNode subNode = nodeSortedList.get(position);
|
||||
// Assign image
|
||||
App.getDB().getDrawFactory().assignDrawableTo(holder.icon,
|
||||
context.getResources(), subNode.getIcon());
|
||||
int iconColor = Color.BLACK;
|
||||
switch (subNode.getType()) {
|
||||
case GROUP:
|
||||
iconColor = iconGroupColor;
|
||||
break;
|
||||
case ENTRY:
|
||||
iconColor = iconEntryColor;
|
||||
break;
|
||||
}
|
||||
database.getDrawFactory().assignDatabaseIconTo(context, holder.icon, subNode.getIcon(), iconColor);
|
||||
// Assign text
|
||||
holder.text.setText(subNode.getDisplayTitle());
|
||||
holder.text.setText(subNode.getTitle());
|
||||
// Assign click
|
||||
holder.container.setOnClickListener(
|
||||
new OnNodeClickListener(subNode));
|
||||
// Context menu
|
||||
if (activateContextMenu) {
|
||||
holder.container.setOnCreateContextMenuListener(
|
||||
new ContextMenuBuilder(subNode, nodeMenuListener));
|
||||
new ContextMenuBuilder(subNode, nodeMenuListener, readOnly));
|
||||
}
|
||||
// Assign text size
|
||||
|
||||
// Add username
|
||||
holder.subText.setText("");
|
||||
holder.subText.setVisibility(View.GONE);
|
||||
if (subNode.getType().equals(PwNode.Type.ENTRY)) {
|
||||
PwEntry entry = (PwEntry) subNode;
|
||||
entry.startToManageFieldReferences(database.getPwDatabase());
|
||||
|
||||
holder.text.setText(entry.getVisualTitle());
|
||||
|
||||
String username = entry.getUsername();
|
||||
if (showUsernames && !username.isEmpty()) {
|
||||
holder.subText.setVisibility(View.VISIBLE);
|
||||
holder.subText.setText(username);
|
||||
}
|
||||
|
||||
entry.stopToManageFieldReferences();
|
||||
}
|
||||
|
||||
// Assign image and text size
|
||||
// Relative size of the icon
|
||||
holder.icon.getLayoutParams().height = ((int) iconSize);
|
||||
holder.icon.getLayoutParams().width = ((int) iconSize);
|
||||
holder.text.setTextSize(textSize);
|
||||
holder.subText.setTextSize(subtextSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -199,8 +279,8 @@ public class NodeAdapter extends RecyclerView.Adapter<BasicViewHolder> {
|
||||
/**
|
||||
* Assign a listener when a node is clicked
|
||||
*/
|
||||
public void setOnNodeClickListener(OnNodeClickCallback onNodeClickCallback) {
|
||||
this.onNodeClickCallback = onNodeClickCallback;
|
||||
public void setOnNodeClickListener(NodeClickCallback nodeClickCallback) {
|
||||
this.nodeClickCallback = nodeClickCallback;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -213,7 +293,7 @@ public class NodeAdapter extends RecyclerView.Adapter<BasicViewHolder> {
|
||||
/**
|
||||
* Callback listener to redefine to do an action when a node is click
|
||||
*/
|
||||
public interface OnNodeClickCallback {
|
||||
public interface NodeClickCallback {
|
||||
void onNodeClick(PwNode node);
|
||||
}
|
||||
|
||||
@@ -223,6 +303,8 @@ public class NodeAdapter extends RecyclerView.Adapter<BasicViewHolder> {
|
||||
public interface NodeMenuListener {
|
||||
boolean onOpenMenuClick(PwNode node);
|
||||
boolean onEditMenuClick(PwNode node);
|
||||
boolean onCopyMenuClick(PwNode node);
|
||||
boolean onMoveMenuClick(PwNode node);
|
||||
boolean onDeleteMenuClick(PwNode node);
|
||||
}
|
||||
|
||||
@@ -238,8 +320,8 @@ public class NodeAdapter extends RecyclerView.Adapter<BasicViewHolder> {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (onNodeClickCallback != null)
|
||||
onNodeClickCallback.onNodeClick(node);
|
||||
if (nodeClickCallback != null)
|
||||
nodeClickCallback.onNodeClick(node);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,28 +330,60 @@ public class NodeAdapter extends RecyclerView.Adapter<BasicViewHolder> {
|
||||
*/
|
||||
private class ContextMenuBuilder implements View.OnCreateContextMenuListener {
|
||||
|
||||
private static final int MENU_OPEN = Menu.FIRST;
|
||||
private static final int MENU_EDIT = MENU_OPEN + 1;
|
||||
private static final int MENU_DELETE = MENU_EDIT + 1;
|
||||
|
||||
private PwNode node;
|
||||
private NodeMenuListener menuListener;
|
||||
private boolean readOnly;
|
||||
|
||||
ContextMenuBuilder(PwNode node, NodeMenuListener menuListener) {
|
||||
ContextMenuBuilder(PwNode node, NodeMenuListener menuListener, boolean readOnly) {
|
||||
this.menuListener = menuListener;
|
||||
this.node = node;
|
||||
this.readOnly = readOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu contextMenu, View view, ContextMenu.ContextMenuInfo contextMenuInfo) {
|
||||
MenuItem clearMenu = contextMenu.add(Menu.NONE, MENU_OPEN, Menu.NONE, R.string.menu_open);
|
||||
clearMenu.setOnMenuItemClickListener(mOnMyActionClickListener);
|
||||
if (!App.getDB().isReadOnly() && !node.equals(App.getDB().getPwDatabase().getRecycleBin())) {
|
||||
// TODO make edit for group
|
||||
// clearMenu = contextMenu.add(Menu.NONE, MENU_EDIT, Menu.NONE, R.string.menu_edit);
|
||||
// clearMenu.setOnMenuItemClickListener(mOnMyActionClickListener);
|
||||
clearMenu = contextMenu.add(Menu.NONE, MENU_DELETE, Menu.NONE, R.string.menu_delete);
|
||||
clearMenu.setOnMenuItemClickListener(mOnMyActionClickListener);
|
||||
menuInflater.inflate(R.menu.node_menu, contextMenu);
|
||||
|
||||
// Opening
|
||||
MenuItem menuItem = contextMenu.findItem(R.id.menu_open);
|
||||
menuItem.setOnMenuItemClickListener(mOnMyActionClickListener);
|
||||
|
||||
// Edition
|
||||
if (readOnly || node.equals(App.getDB().getPwDatabase().getRecycleBin())) {
|
||||
contextMenu.removeItem(R.id.menu_edit);
|
||||
} else {
|
||||
menuItem = contextMenu.findItem(R.id.menu_edit);
|
||||
menuItem.setOnMenuItemClickListener(mOnMyActionClickListener);
|
||||
}
|
||||
|
||||
// Copy (not for group)
|
||||
if (readOnly
|
||||
|| isASearchResult
|
||||
|| node.equals(App.getDB().getPwDatabase().getRecycleBin())
|
||||
|| node.getType().equals(PwNode.Type.GROUP)) {
|
||||
// TODO COPY For Group
|
||||
contextMenu.removeItem(R.id.menu_copy);
|
||||
} else {
|
||||
menuItem = contextMenu.findItem(R.id.menu_copy);
|
||||
menuItem.setOnMenuItemClickListener(mOnMyActionClickListener);
|
||||
}
|
||||
|
||||
// Move
|
||||
if (readOnly
|
||||
|| isASearchResult
|
||||
|| node.equals(App.getDB().getPwDatabase().getRecycleBin())) {
|
||||
contextMenu.removeItem(R.id.menu_move);
|
||||
} else {
|
||||
menuItem = contextMenu.findItem(R.id.menu_move);
|
||||
menuItem.setOnMenuItemClickListener(mOnMyActionClickListener);
|
||||
}
|
||||
|
||||
// Deletion
|
||||
if (readOnly || node.equals(App.getDB().getPwDatabase().getRecycleBin())) {
|
||||
contextMenu.removeItem(R.id.menu_delete);
|
||||
} else {
|
||||
menuItem = contextMenu.findItem(R.id.menu_delete);
|
||||
menuItem.setOnMenuItemClickListener(mOnMyActionClickListener);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,11 +393,15 @@ public class NodeAdapter extends RecyclerView.Adapter<BasicViewHolder> {
|
||||
if (menuListener == null)
|
||||
return false;
|
||||
switch ( item.getItemId() ) {
|
||||
case MENU_OPEN:
|
||||
case R.id.menu_open:
|
||||
return menuListener.onOpenMenuClick(node);
|
||||
case MENU_EDIT:
|
||||
case R.id.menu_edit:
|
||||
return menuListener.onEditMenuClick(node);
|
||||
case MENU_DELETE:
|
||||
case R.id.menu_copy:
|
||||
return menuListener.onCopyMenuClick(node);
|
||||
case R.id.menu_move:
|
||||
return menuListener.onMoveMenuClick(node);
|
||||
case R.id.menu_delete:
|
||||
return menuListener.onDeleteMenuClick(node);
|
||||
default:
|
||||
return false;
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Copyright 2018 Jeremy Jamet / Kunzisoft.
|
||||
*
|
||||
* This file is part of KeePass DX.
|
||||
*
|
||||
* KeePass DX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* KeePass DX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with KeePass DX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.kunzisoft.keepass.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Color;
|
||||
import android.support.v4.widget.CursorAdapter;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.kunzisoft.keepass.R;
|
||||
import com.kunzisoft.keepass.database.Database;
|
||||
import com.kunzisoft.keepass.database.PwEntry;
|
||||
import com.kunzisoft.keepass.database.PwIcon;
|
||||
import com.kunzisoft.keepass.database.PwIconFactory;
|
||||
import com.kunzisoft.keepass.database.cursor.EntryCursor;
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class SearchEntryCursorAdapter extends CursorAdapter {
|
||||
|
||||
private LayoutInflater cursorInflater;
|
||||
private Database database;
|
||||
private boolean displayUsername;
|
||||
private int iconColor;
|
||||
|
||||
public SearchEntryCursorAdapter(Context context, Database database) {
|
||||
super(context, null, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
|
||||
cursorInflater = (LayoutInflater) context.getSystemService(
|
||||
Context.LAYOUT_INFLATER_SERVICE);
|
||||
this.database = database;
|
||||
|
||||
// Get the icon color
|
||||
int[] attrTextColor = {R.attr.textColorInverse};
|
||||
TypedArray taTextColor = context.getTheme().obtainStyledAttributes(attrTextColor);
|
||||
this.iconColor = taTextColor.getColor(0, Color.WHITE);
|
||||
taTextColor.recycle();
|
||||
|
||||
reInit(context);
|
||||
}
|
||||
|
||||
public void reInit(Context context) {
|
||||
this.displayUsername = PreferencesUtil.showUsernamesListEntries(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View newView(Context context, Cursor cursor, ViewGroup parent) {
|
||||
|
||||
View view = cursorInflater.inflate(R.layout.search_entry, parent ,false);
|
||||
ViewHolder viewHolder = new ViewHolder();
|
||||
viewHolder.imageViewIcon = view.findViewById(R.id.entry_icon);
|
||||
viewHolder.textViewTitle = view.findViewById(R.id.entry_text);
|
||||
viewHolder.textViewSubTitle = view.findViewById(R.id.entry_subtext);
|
||||
view.setTag(viewHolder);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindView(View view, Context context, Cursor cursor) {
|
||||
|
||||
// Retrieve elements from cursor
|
||||
UUID uuid = new UUID(cursor.getLong(cursor.getColumnIndex(EntryCursor.COLUMN_INDEX_UUID_MOST_SIGNIFICANT_BITS)),
|
||||
cursor.getLong(cursor.getColumnIndex(EntryCursor.COLUMN_INDEX_UUID_LEAST_SIGNIFICANT_BITS)));
|
||||
PwIconFactory iconFactory = database.getPwDatabase().getIconFactory();
|
||||
PwIcon icon = iconFactory.getIcon(
|
||||
new UUID(cursor.getLong(cursor.getColumnIndex(EntryCursor.COLUMN_INDEX_ICON_CUSTOM_UUID_MOST_SIGNIFICANT_BITS)),
|
||||
cursor.getLong(cursor.getColumnIndex(EntryCursor.COLUMN_INDEX_ICON_CUSTOM_UUID_LEAST_SIGNIFICANT_BITS))));
|
||||
if (icon.isUnknown()) {
|
||||
icon = iconFactory.getIcon(cursor.getInt(cursor.getColumnIndex(EntryCursor.COLUMN_INDEX_ICON_STANDARD)));
|
||||
if (icon.isUnknown())
|
||||
icon = iconFactory.getKeyIcon();
|
||||
}
|
||||
String title = cursor.getString( cursor.getColumnIndex(EntryCursor.COLUMN_INDEX_TITLE) );
|
||||
String username = cursor.getString( cursor.getColumnIndex(EntryCursor.COLUMN_INDEX_USERNAME) );
|
||||
String url = cursor.getString( cursor.getColumnIndex(EntryCursor.COLUMN_INDEX_URL) );
|
||||
|
||||
ViewHolder viewHolder = (ViewHolder) view.getTag();
|
||||
|
||||
// Assign image
|
||||
database.getDrawFactory().assignDatabaseIconTo(context, viewHolder.imageViewIcon, icon, iconColor);
|
||||
|
||||
// Assign title
|
||||
String showTitle = PwEntry.getVisualTitle(false, title, username, url, uuid);
|
||||
viewHolder.textViewTitle.setText(showTitle);
|
||||
if (displayUsername && !username.isEmpty()) {
|
||||
viewHolder.textViewSubTitle.setText(String.format("(%s)", username));
|
||||
} else {
|
||||
viewHolder.textViewSubTitle.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
private static class ViewHolder {
|
||||
ImageView imageViewIcon;
|
||||
TextView textViewTitle;
|
||||
TextView textViewSubTitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
|
||||
return database.searchEntry(constraint.toString());
|
||||
}
|
||||
|
||||
public PwEntry getEntryFromPosition(int position) {
|
||||
PwEntry pwEntry = null;
|
||||
|
||||
Cursor cursor = this.getCursor();
|
||||
if (cursor.moveToFirst()
|
||||
&&
|
||||
cursor.move(position)) {
|
||||
|
||||
pwEntry = database.createEntry();
|
||||
database.populateEntry(pwEntry, (EntryCursor) cursor);
|
||||
}
|
||||
return pwEntry;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -92,7 +92,7 @@ public class App extends MultiDexApplication {
|
||||
@Override
|
||||
public void onTerminate() {
|
||||
if ( db != null ) {
|
||||
db.clear();
|
||||
db.clear(getApplicationContext());
|
||||
}
|
||||
super.onTerminate();
|
||||
}
|
||||
|
||||
@@ -28,18 +28,19 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.kunzisoft.keepass.KeePass;
|
||||
import com.kunzisoft.keepass.fileselect.FileSelectActivity;
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
public class AutoFillAuthActivity extends KeePass {
|
||||
public class AutoFillAuthActivity extends AppCompatActivity {
|
||||
|
||||
private AutofillHelper autofillHelper;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
autofillHelper = new AutofillHelper();
|
||||
startFileSelectActivity();
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@@ -49,12 +50,11 @@ public class AutoFillAuthActivity extends KeePass {
|
||||
intent, PendingIntent.FLAG_CANCEL_CURRENT).getIntentSender();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void startFileSelectActivity() {
|
||||
// Pass extra for Autofill (EXTRA_ASSIST_STRUCTURE)
|
||||
AssistStructure assistStructure = autofillHelper.retrieveAssistStructure(getIntent());
|
||||
if (assistStructure != null) {
|
||||
FileSelectActivity.launch(this, assistStructure);
|
||||
FileSelectActivity.launchForAutofillResult(this, assistStructure);
|
||||
} else {
|
||||
setResult(RESULT_CANCELED);
|
||||
finish();
|
||||
|
||||
@@ -36,6 +36,7 @@ import android.widget.RemoteViews;
|
||||
|
||||
import com.kunzisoft.keepass.R;
|
||||
import com.kunzisoft.keepass.database.PwEntry;
|
||||
import com.kunzisoft.keepass.selection.EntrySelectionHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -64,6 +65,7 @@ public class AutofillHelper {
|
||||
|
||||
public static void addAssistStructureExtraInIntent(Intent intent, AssistStructure assistStructure) {
|
||||
if (assistStructure != null) {
|
||||
EntrySelectionHelper.addEntrySelectionModeExtraInIntent(intent);
|
||||
intent.putExtra(android.view.autofill.AutofillManager.EXTRA_ASSIST_STRUCTURE, assistStructure);
|
||||
}
|
||||
}
|
||||
@@ -144,7 +146,7 @@ public class AutofillHelper {
|
||||
/**
|
||||
* Utility method to loop and close each activity with return data
|
||||
*/
|
||||
public static void onActivityResultSetResult(Activity activity, int requestCode, int resultCode, Intent data) {
|
||||
public static void onActivityResultSetResultAndFinish(Activity activity, int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == AUTOFILL_RESPONSE_REQUEST_CODE) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
activity.setResult(resultCode, data);
|
||||
@@ -152,15 +154,6 @@ public class AutofillHelper {
|
||||
if (resultCode == Activity.RESULT_CANCELED) {
|
||||
activity.setResult(Activity.RESULT_CANCELED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to loop and close each activity with return data
|
||||
*/
|
||||
public static void onActivityResultSetResultAndFinish(Activity activity, int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == AUTOFILL_RESPONSE_REQUEST_CODE) {
|
||||
onActivityResultSetResult(activity, requestCode, resultCode, data);
|
||||
activity.finish();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017 Brian Pellin, Jeremy Jamet / Kunzisoft.
|
||||
*
|
||||
* This file is part of KeePass DX.
|
||||
*
|
||||
* KeePass DX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* KeePass DX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with KeePass DX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.kunzisoft.keepass.compat;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public class BackupManagerCompat {
|
||||
private static Class classBackupManager;
|
||||
private static Constructor constructorBackupManager;
|
||||
private static Method dataChanged;
|
||||
|
||||
private Object backupManager;
|
||||
|
||||
static {
|
||||
try {
|
||||
classBackupManager = Class.forName("android.app.backup.BackupManager");
|
||||
constructorBackupManager = classBackupManager.getConstructor(Context.class);
|
||||
dataChanged = classBackupManager.getMethod("dataChanged", (Class[]) null);
|
||||
} catch (Exception e) {
|
||||
// Do nothing, class does not exist
|
||||
}
|
||||
}
|
||||
|
||||
public BackupManagerCompat(Context ctx) {
|
||||
if (constructorBackupManager != null) {
|
||||
try {
|
||||
backupManager = constructorBackupManager.newInstance(ctx);
|
||||
} catch (Exception e) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void dataChanged() {
|
||||
if (backupManager != null && dataChanged != null) {
|
||||
try {
|
||||
dataChanged.invoke(backupManager, (Object[]) null);
|
||||
} catch (Exception e) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017 Brian Pellin, Jeremy Jamet / Kunzisoft.
|
||||
*
|
||||
* This file is part of KeePass DX.
|
||||
*
|
||||
* KeePass DX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* KeePass DX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with KeePass DX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.kunzisoft.keepass.compat;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
// This compatiblity hack can go away when support for Android 1.5 api level 3 is dropped
|
||||
public class BitmapDrawableCompat {
|
||||
private static Constructor<BitmapDrawable> constResBitmap;
|
||||
|
||||
static {
|
||||
try {
|
||||
constResBitmap = BitmapDrawable.class.getConstructor(Resources.class, Bitmap.class);
|
||||
// This constructor is support in this api version
|
||||
} catch (Exception e) {
|
||||
// This constructor is not supported
|
||||
}
|
||||
}
|
||||
|
||||
public static BitmapDrawable getBitmapDrawable(Resources res, Bitmap bitmap) {
|
||||
if (constResBitmap != null) {
|
||||
try {
|
||||
return constResBitmap.newInstance(res, bitmap);
|
||||
} catch (Exception e) {
|
||||
// Do nothing, fall through to the safe constructor
|
||||
}
|
||||
}
|
||||
|
||||
return new BitmapDrawable(bitmap);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017 Brian Pellin, Jeremy Jamet / Kunzisoft.
|
||||
*
|
||||
* This file is part of KeePass DX.
|
||||
*
|
||||
* KeePass DX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* KeePass DX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with KeePass DX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.kunzisoft.keepass.compat;
|
||||
|
||||
import android.os.Build;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class BuildCompat {
|
||||
private static Field manufacturer;
|
||||
private static String manuText;
|
||||
|
||||
public static final int VERSION_CODE_GINGERBREAD = 9;
|
||||
public static final int VERSION_CODE_ICE_CREAM_SANDWICH = 14;
|
||||
public static final int VERSION_CODE_JELLY_BEAN = 16;
|
||||
public static final int VERSION_CODE_JELLY_BEAN_MR2 = 18;
|
||||
public static final int VERSION_KITKAT = 19;
|
||||
public static final int VERSION_CODE_M = 23;
|
||||
|
||||
private static Field versionSDK;
|
||||
private static int versionInt;
|
||||
|
||||
static {
|
||||
// MANUFACTURER is only available in API version 4 and later
|
||||
try {
|
||||
manufacturer = Build.class.getField("MANUFACTURER");
|
||||
manuText = (String) manufacturer.get(null);
|
||||
} catch (Exception e) {
|
||||
manuText = "";
|
||||
}
|
||||
|
||||
// SDK is only available in API version 4 and later
|
||||
try {
|
||||
versionSDK = Build.VERSION.class.getField("SDK_INT");
|
||||
versionInt = versionSDK.getInt(null);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
versionInt = Integer.parseInt(Build.VERSION.SDK);
|
||||
} catch (Exception nfe) {
|
||||
versionInt = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String getManufacturer() {
|
||||
return manuText;
|
||||
}
|
||||
|
||||
public static int getSdkVersion() {
|
||||
return versionInt;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,9 +25,6 @@ import android.net.Uri;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class ClipDataCompat {
|
||||
private static Class clipData;
|
||||
private static Class clipDataItem;
|
||||
private static Class clipDescription;
|
||||
private static Method getClipDataFromIntent;
|
||||
private static Method getDescription;
|
||||
private static Method getItemCount;
|
||||
@@ -39,14 +36,14 @@ public class ClipDataCompat {
|
||||
|
||||
static {
|
||||
try {
|
||||
clipData = Class.forName("android.content.ClipData");
|
||||
Class clipData = Class.forName("android.content.ClipData");
|
||||
getDescription = clipData.getMethod("getDescription", (Class[])null);
|
||||
getItemCount = clipData.getMethod("getItemCount", (Class[])null);
|
||||
getItemAt = clipData.getMethod("getItemAt", new Class[]{int.class});
|
||||
clipDescription = Class.forName("android.content.ClipDescription");
|
||||
Class clipDescription = Class.forName("android.content.ClipDescription");
|
||||
getLabel = clipDescription.getMethod("getLabel", (Class[])null);
|
||||
|
||||
clipDataItem = Class.forName("android.content.ClipData$Item");
|
||||
Class clipDataItem = Class.forName("android.content.ClipData$Item");
|
||||
getUri = clipDataItem.getMethod("getUri", (Class[])null);
|
||||
|
||||
getClipDataFromIntent = Intent.class.getMethod("getClipData", (Class[])null);
|
||||
@@ -58,7 +55,6 @@ public class ClipDataCompat {
|
||||
}
|
||||
|
||||
public static Uri getUriFromIntent(Intent i, String key) {
|
||||
boolean clipDataSucceeded = false;
|
||||
if (initSucceded) {
|
||||
try {
|
||||
Object clip = getClipDataFromIntent.invoke(i);
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017 Brian Pellin, Jeremy Jamet / Kunzisoft.
|
||||
*
|
||||
* This file is part of KeePass DX.
|
||||
*
|
||||
* KeePass DX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* KeePass DX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with KeePass DX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.kunzisoft.keepass.compat;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.net.Uri;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class ContentResolverCompat {
|
||||
public static boolean available;
|
||||
private static Class contentResolver;
|
||||
private static Method takePersistableUriPermission;
|
||||
|
||||
static {
|
||||
try {
|
||||
contentResolver = ContentResolver.class;
|
||||
takePersistableUriPermission = contentResolver.getMethod("takePersistableUriPermission", new Class[]{Uri.class, int.class});
|
||||
|
||||
available = true;
|
||||
} catch (Exception e) {
|
||||
available = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void takePersistableUriPermission(ContentResolver resolver, Uri uri, int modeFlags) {
|
||||
if (available) {
|
||||
try {
|
||||
takePersistableUriPermission.invoke(resolver, new Object[]{uri, modeFlags});
|
||||
} catch (Exception e) {
|
||||
// Fail silently
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017 Brian Pellin, Jeremy Jamet / Kunzisoft.
|
||||
*
|
||||
* This file is part of KeePass DX.
|
||||
*
|
||||
* KeePass DX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* KeePass DX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with KeePass DX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.kunzisoft.keepass.compat;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class EditorCompat {
|
||||
private static Method apply;
|
||||
|
||||
static {
|
||||
try {
|
||||
apply = Activity.class.getMethod("apply", (Class<SharedPreferences.Editor>[]) null);
|
||||
} catch (Exception e) {
|
||||
// Substitute commit for apply when not available (API level < 9)
|
||||
try {
|
||||
apply = Activity.class.getMethod("commit", (Class<SharedPreferences.Editor>[]) null);
|
||||
} catch (Exception f) {
|
||||
// Should be impossible, but leave apply null in this case
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void apply(SharedPreferences.Editor edit) {
|
||||
try {
|
||||
apply.invoke(edit, (Object[]) null);
|
||||
} catch (Exception e) {
|
||||
// Shouldn't be possible, but call commit directly if this happens
|
||||
edit.commit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -44,7 +44,6 @@ public final class PRNGFixes {
|
||||
|
||||
private static final byte[] BUILD_FINGERPRINT_AND_DEVICE_SERIAL =
|
||||
getBuildFingerprintAndDeviceSerial();
|
||||
private static int sdkVersion = BuildCompat.getSdkVersion();
|
||||
|
||||
/** Hidden constructor to prevent instantiation. */
|
||||
private PRNGFixes() {}
|
||||
@@ -67,11 +66,11 @@ public final class PRNGFixes {
|
||||
|
||||
private static boolean supportedOnThisDevice() {
|
||||
// Blacklist on samsung devices
|
||||
if (StrUtil.indexOfIgnoreCase(BuildCompat.getManufacturer(), "samsung", Locale.ENGLISH) >= 0) {
|
||||
if (StrUtil.indexOfIgnoreCase(Build.MANUFACTURER, "samsung", Locale.ENGLISH) >= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sdkVersion > BuildCompat.VERSION_CODE_JELLY_BEAN_MR2) {
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -126,8 +125,8 @@ public final class PRNGFixes {
|
||||
* @throws SecurityException if the fix is needed but could not be applied.
|
||||
*/
|
||||
private static void applyOpenSSLFix() throws SecurityException {
|
||||
if ((sdkVersion < BuildCompat.VERSION_CODE_JELLY_BEAN)
|
||||
|| (sdkVersion > BuildCompat.VERSION_CODE_JELLY_BEAN_MR2)) {
|
||||
if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
|
||||
|| (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2)) {
|
||||
// No need to apply the fix
|
||||
return;
|
||||
}
|
||||
@@ -162,7 +161,7 @@ public final class PRNGFixes {
|
||||
*/
|
||||
private static void installLinuxPRNGSecureRandom()
|
||||
throws SecurityException {
|
||||
if (sdkVersion > BuildCompat.VERSION_CODE_JELLY_BEAN_MR2) {
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
// No need to apply the fix
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ package com.kunzisoft.keepass.compat;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import com.kunzisoft.keepass.R;
|
||||
@@ -45,7 +46,7 @@ public class StorageAF {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean supportsStorageFramework() { return BuildCompat.getSdkVersion() >= BuildCompat.VERSION_KITKAT; }
|
||||
public static boolean supportsStorageFramework() { return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; }
|
||||
|
||||
public static boolean useStorageFramework(Context ctx) {
|
||||
if (!supportsStorageFramework()) { return false; }
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.crypto.keyDerivation;
|
||||
|
||||
import android.content.res.Resources;
|
||||
|
||||
import com.kunzisoft.keepass.R;
|
||||
import com.kunzisoft.keepass.crypto.CryptoUtil;
|
||||
import com.kunzisoft.keepass.crypto.finalkey.FinalKey;
|
||||
import com.kunzisoft.keepass.crypto.finalkey.FinalKeyFactory;
|
||||
@@ -30,8 +33,8 @@ import java.util.UUID;
|
||||
|
||||
public class AesKdf extends KdfEngine {
|
||||
|
||||
public static final int DEFAULT_ROUNDS = 6000;
|
||||
public static final String DEFAULT_NAME = "AES-KDF";
|
||||
private static final int DEFAULT_ROUNDS = 6000;
|
||||
private static final String DEFAULT_NAME = "AES-KDF";
|
||||
|
||||
public static final UUID CIPHER_UUID = Types.bytestoUUID(
|
||||
new byte[]{(byte) 0xC9, (byte) 0xD9, (byte) 0xF3, (byte) 0x9A, (byte) 0x62, (byte) 0x8A, (byte) 0x44, (byte) 0x60,
|
||||
@@ -41,17 +44,22 @@ public class AesKdf extends KdfEngine {
|
||||
public static final String ParamRounds = "R";
|
||||
public static final String ParamSeed = "S";
|
||||
|
||||
public AesKdf() {
|
||||
uuid = CIPHER_UUID;
|
||||
AesKdf() {
|
||||
setUUID(CIPHER_UUID);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@Override
|
||||
public String getName(Resources resources) {
|
||||
if (resources == null)
|
||||
return DEFAULT_NAME;
|
||||
return resources.getString(R.string.kdf_AES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public KdfParameters getDefaultParameters() {
|
||||
KdfParameters p = super.getDefaultParameters();
|
||||
KdfParameters p = new KdfParameters(uuid);
|
||||
|
||||
p.setParamUUID();
|
||||
p.setUInt32(ParamRounds, DEFAULT_ROUNDS);
|
||||
|
||||
return p;
|
||||
@@ -93,4 +101,9 @@ public class AesKdf extends KdfEngine {
|
||||
public void setKeyRounds(KdfParameters p, long keyRounds) {
|
||||
p.setUInt64(ParamRounds, keyRounds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDefaultKeyRounds() {
|
||||
return DEFAULT_ROUNDS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.crypto.keyDerivation;
|
||||
|
||||
import android.content.res.Resources;
|
||||
|
||||
import com.kunzisoft.keepass.R;
|
||||
import com.kunzisoft.keepass.utils.Types;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -26,21 +29,22 @@ import java.security.SecureRandom;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Argon2Kdf extends KdfEngine {
|
||||
|
||||
public static final UUID CIPHER_UUID = Types.bytestoUUID(
|
||||
new byte[]{(byte) 0xEF, (byte) 0x63, (byte) 0x6D, (byte) 0xDF, (byte) 0x8C, (byte) 0x29, (byte) 0x44, (byte) 0x4B,
|
||||
(byte) 0x91, (byte) 0xF7, (byte) 0xA9, (byte) 0xA4, (byte)0x03, (byte) 0xE3, (byte) 0x0A, (byte) 0x0C
|
||||
});
|
||||
|
||||
public static final String ParamSalt = "S"; // byte[]
|
||||
public static final String ParamParallelism = "P"; // UInt32
|
||||
public static final String ParamMemory = "M"; // UInt64
|
||||
public static final String ParamIterations = "I"; // UInt64
|
||||
public static final String ParamVersion = "V"; // UInt32
|
||||
public static final String ParamSecretKey = "K"; // byte[]
|
||||
public static final String ParamAssocData = "A"; // byte[]
|
||||
private static final String ParamSalt = "S"; // byte[]
|
||||
private static final String ParamParallelism = "P"; // UInt32
|
||||
private static final String ParamMemory = "M"; // UInt64
|
||||
private static final String ParamIterations = "I"; // UInt64
|
||||
private static final String ParamVersion = "V"; // UInt32
|
||||
private static final String ParamSecretKey = "K"; // byte[]
|
||||
private static final String ParamAssocData = "A"; // byte[]
|
||||
|
||||
public static final long MinVersion = 0x10;
|
||||
public static final long MaxVersion = 0x13;
|
||||
private static final long MinVersion = 0x10;
|
||||
private static final long MaxVersion = 0x13;
|
||||
|
||||
private static final int MinSalt = 8;
|
||||
private static final int MaxSalt = Integer.MAX_VALUE;
|
||||
@@ -58,22 +62,28 @@ public class Argon2Kdf extends KdfEngine {
|
||||
private static final long DefaultMemory = 1024 * 1024;
|
||||
private static final long DefaultParallelism = 2;
|
||||
|
||||
public Argon2Kdf() {
|
||||
uuid = CIPHER_UUID;
|
||||
private static final String DEFAULT_NAME = "Argon2";
|
||||
|
||||
Argon2Kdf() {
|
||||
setUUID(CIPHER_UUID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Argon2";
|
||||
public String getName(Resources resources) {
|
||||
if (resources == null)
|
||||
return DEFAULT_NAME;
|
||||
return resources.getString(R.string.kdf_Argon2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public KdfParameters getDefaultParameters() {
|
||||
KdfParameters p = super.getDefaultParameters();
|
||||
KdfParameters p = new KdfParameters(uuid);
|
||||
|
||||
p.setUInt32(ParamVersion, MaxVersion);
|
||||
p.setUInt64(ParamMemory, DefaultMemory);
|
||||
p.setParamUUID();
|
||||
p.setUInt32(ParamParallelism, DefaultParallelism);
|
||||
p.setUInt64(ParamMemory, DefaultMemory);
|
||||
p.setUInt64(ParamIterations, DefaultIterations);
|
||||
p.setUInt32(ParamVersion, MaxVersion);
|
||||
|
||||
return p;
|
||||
}
|
||||
@@ -113,4 +123,35 @@ public class Argon2Kdf extends KdfEngine {
|
||||
p.setUInt64(ParamIterations, keyRounds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDefaultKeyRounds() {
|
||||
return DefaultIterations;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long getMemoryUsage(KdfParameters p) {
|
||||
return p.getUInt64(ParamMemory);
|
||||
}
|
||||
|
||||
public void setMemoryUsage(KdfParameters p, long memory) {
|
||||
p.setUInt64(ParamMemory, memory);
|
||||
}
|
||||
|
||||
public long getDefaultMemoryUsage() {
|
||||
return DefaultMemory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getParallelism(KdfParameters p) {
|
||||
return (int) p.getUInt32(ParamParallelism); // TODO Verify
|
||||
}
|
||||
|
||||
public void setParallelism(KdfParameters p, int parallelism) {
|
||||
p.setUInt32(ParamParallelism, parallelism);
|
||||
}
|
||||
|
||||
public int getDefaultParallelism() {
|
||||
return (int) DefaultParallelism; // TODO Verify
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,24 +19,59 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.crypto.keyDerivation;
|
||||
|
||||
import com.kunzisoft.keepass.database.ObjectNameResource;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class KdfEngine {
|
||||
public UUID uuid;
|
||||
public abstract class KdfEngine implements ObjectNameResource{
|
||||
|
||||
public KdfParameters getDefaultParameters() {
|
||||
return new KdfParameters(uuid);
|
||||
public static final int UNKNOW_VALUE = -1;
|
||||
public static final String UNKNOW_VALUE_STRING = String.valueOf(-1);
|
||||
|
||||
protected UUID uuid;
|
||||
|
||||
public UUID getUUID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUUID(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public abstract KdfParameters getDefaultParameters();
|
||||
|
||||
public abstract byte[] transform(byte[] masterKey, KdfParameters p) throws IOException;
|
||||
|
||||
public abstract void randomize(KdfParameters p);
|
||||
|
||||
public abstract String getName();
|
||||
|
||||
public abstract long getKeyRounds(KdfParameters p);
|
||||
|
||||
public abstract void setKeyRounds(KdfParameters p, long keyRounds);
|
||||
|
||||
public abstract long getDefaultKeyRounds();
|
||||
|
||||
public long getMemoryUsage(KdfParameters p) {
|
||||
return UNKNOW_VALUE;
|
||||
}
|
||||
|
||||
public void setMemoryUsage(KdfParameters p, long memory) {
|
||||
// Do nothing by default
|
||||
}
|
||||
|
||||
public long getDefaultMemoryUsage() {
|
||||
return UNKNOW_VALUE;
|
||||
}
|
||||
|
||||
public int getParallelism(KdfParameters p) {
|
||||
return UNKNOW_VALUE;
|
||||
}
|
||||
|
||||
public void setParallelism(KdfParameters p, int parallelism) {
|
||||
// Do nothing by default
|
||||
}
|
||||
|
||||
public int getDefaultParallelism() {
|
||||
return UNKNOW_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,31 +19,37 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.crypto.keyDerivation;
|
||||
|
||||
import com.kunzisoft.keepass.database.exception.UnknownKDF;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class KdfFactory {
|
||||
|
||||
public static List<KdfEngine> kdfList = new ArrayList<>();
|
||||
public static AesKdf aesKdf = new AesKdf();
|
||||
public static Argon2Kdf argon2Kdf = new Argon2Kdf();
|
||||
|
||||
public static List<KdfEngine> kdfListV3 = new ArrayList<>();
|
||||
public static List<KdfEngine> kdfListV4 = new ArrayList<>();
|
||||
|
||||
static {
|
||||
kdfList.add(new AesKdf());
|
||||
kdfList.add(new Argon2Kdf());
|
||||
kdfListV3.add(aesKdf);
|
||||
|
||||
kdfListV4.add(aesKdf);
|
||||
kdfListV4.add(argon2Kdf);
|
||||
}
|
||||
|
||||
public static KdfParameters getDefaultParameters() {
|
||||
return kdfList.get(0).getDefaultParameters();
|
||||
public static KdfEngine getEngineV4(KdfParameters kdfParameters) throws UnknownKDF {
|
||||
UnknownKDF unknownKDFException = new UnknownKDF();
|
||||
if (kdfParameters == null) {
|
||||
throw unknownKDFException;
|
||||
}
|
||||
|
||||
public static KdfEngine get(UUID uuid) {
|
||||
for (KdfEngine engine: kdfList) {
|
||||
if (engine.uuid.equals(uuid)) {
|
||||
for (KdfEngine engine: kdfListV4) {
|
||||
if (engine.getUUID().equals(kdfParameters.getUUID())) {
|
||||
return engine;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
throw unknownKDFException;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,34 +31,36 @@ import java.util.UUID;
|
||||
|
||||
public class KdfParameters extends VariantDictionary {
|
||||
|
||||
public UUID kdfUUID;
|
||||
private UUID kdfUUID;
|
||||
|
||||
private static final String ParamUUID = "$UUID";
|
||||
|
||||
public KdfParameters(UUID uuid) {
|
||||
KdfParameters(UUID uuid) {
|
||||
kdfUUID = uuid;
|
||||
}
|
||||
|
||||
public UUID getUUID() {
|
||||
return kdfUUID;
|
||||
}
|
||||
|
||||
protected void setParamUUID() {
|
||||
setByteArray(ParamUUID, Types.UUIDtoBytes(kdfUUID));
|
||||
}
|
||||
|
||||
public static KdfParameters deserialize(byte[] data) throws IOException {
|
||||
ByteArrayInputStream bis = new ByteArrayInputStream(data);
|
||||
LEDataInputStream lis = new LEDataInputStream(bis);
|
||||
|
||||
VariantDictionary d = VariantDictionary.deserialize(lis);
|
||||
if (d == null) {
|
||||
assert(false);
|
||||
return null;
|
||||
}
|
||||
|
||||
UUID uuid = Types.bytestoUUID(d.getByteArray(ParamUUID));
|
||||
if (uuid == null) {
|
||||
assert(false);
|
||||
return null;
|
||||
}
|
||||
|
||||
KdfParameters kdfP = new KdfParameters(uuid);
|
||||
kdfP.copyTo(d);
|
||||
return kdfP;
|
||||
|
||||
}
|
||||
|
||||
public static byte[] serialize(KdfParameters kdf) throws IOException {
|
||||
|
||||
@@ -19,20 +19,57 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.database;
|
||||
|
||||
import java.io.Serializable;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.kunzisoft.keepass.utils.MemUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class AutoType implements Cloneable, Serializable {
|
||||
public class AutoType implements Cloneable, Parcelable {
|
||||
private static final long OBF_OPT_NONE = 0;
|
||||
|
||||
public boolean enabled = true;
|
||||
public long obfuscationOptions = OBF_OPT_NONE;
|
||||
public String defaultSequence = "";
|
||||
|
||||
private HashMap<String, String> windowSeqPairs = new HashMap<>();
|
||||
|
||||
public AutoType() {}
|
||||
|
||||
public AutoType(Parcel in) {
|
||||
enabled = in.readByte() != 0;
|
||||
obfuscationOptions = in.readLong();
|
||||
defaultSequence = in.readString();
|
||||
windowSeqPairs = MemUtil.readStringParcelableMap(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeByte((byte) (enabled ? 1 : 0));
|
||||
dest.writeLong(obfuscationOptions);
|
||||
dest.writeString(defaultSequence);
|
||||
MemUtil.writeStringParcelableMap(dest, windowSeqPairs);
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<AutoType> CREATOR = new Parcelable.Creator<AutoType>() {
|
||||
@Override
|
||||
public AutoType createFromParcel(Parcel in) {
|
||||
return new AutoType(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AutoType[] newArray(int size) {
|
||||
return new AutoType[size];
|
||||
}
|
||||
};
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public AutoType clone() {
|
||||
AutoType auto;
|
||||
|
||||
@@ -51,6 +51,8 @@ public class BinaryPool {
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
for (Entry<Integer, ProtectedBinary> entry: pool.entrySet())
|
||||
entry.getValue().clear();
|
||||
pool.clear();
|
||||
}
|
||||
|
||||
@@ -63,30 +65,36 @@ public class BinaryPool {
|
||||
@Override
|
||||
public boolean operate(PwEntryV4 entry) {
|
||||
for (PwEntryV4 histEntry : entry.getHistory()) {
|
||||
poolAdd(histEntry.getBinaries());
|
||||
add(histEntry.getBinaries());
|
||||
}
|
||||
poolAdd(entry.getBinaries());
|
||||
add(entry.getBinaries());
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void poolAdd(Map<String, ProtectedBinary> dict) {
|
||||
private void add(Map<String, ProtectedBinary> dict) {
|
||||
for (ProtectedBinary pb : dict.values()) {
|
||||
poolAdd(pb);
|
||||
add(pb);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void poolAdd(ProtectedBinary pb) {
|
||||
public void add(ProtectedBinary pb) {
|
||||
assert(pb != null);
|
||||
if (findKey(pb) != -1) return;
|
||||
|
||||
if (poolFind(pb) != -1) return;
|
||||
|
||||
pool.put(pool.size(), pb);
|
||||
pool.put(findUnusedKey(), pb);
|
||||
}
|
||||
|
||||
public int poolFind(ProtectedBinary pb) {
|
||||
public int findUnusedKey() {
|
||||
int unusedKey = pool.size();
|
||||
while(get(unusedKey) != null)
|
||||
unusedKey++;
|
||||
return unusedKey;
|
||||
}
|
||||
|
||||
public int findKey(ProtectedBinary pb) {
|
||||
for (Entry<Integer, ProtectedBinary> pair : pool.entrySet()) {
|
||||
if (pair.getValue().equals(pb)) return pair.getKey();
|
||||
}
|
||||
|
||||
@@ -20,25 +20,27 @@
|
||||
package com.kunzisoft.keepass.database;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import com.kunzisoft.keepass.R;
|
||||
import com.kunzisoft.keepass.crypto.keyDerivation.KdfEngine;
|
||||
import com.kunzisoft.keepass.crypto.keyDerivation.KdfFactory;
|
||||
import com.kunzisoft.keepass.database.cursor.EntryCursor;
|
||||
import com.kunzisoft.keepass.database.exception.ContentFileNotFoundException;
|
||||
import com.kunzisoft.keepass.database.exception.InvalidDBException;
|
||||
import com.kunzisoft.keepass.database.exception.InvalidPasswordException;
|
||||
import com.kunzisoft.keepass.database.exception.PwDbOutputException;
|
||||
import com.kunzisoft.keepass.database.load.Importer;
|
||||
import com.kunzisoft.keepass.database.load.ImporterFactory;
|
||||
import com.kunzisoft.keepass.database.save.PwDbOutput;
|
||||
import com.kunzisoft.keepass.icons.DrawableFactory;
|
||||
import com.kunzisoft.keepass.search.SearchDbHelper;
|
||||
import com.kunzisoft.keepass.tasks.UpdateStatus;
|
||||
import com.kunzisoft.keepass.database.search.SearchDbHelper;
|
||||
import com.kunzisoft.keepass.icons.IconDrawableFactory;
|
||||
import com.kunzisoft.keepass.tasks.ProgressTaskUpdater;
|
||||
import com.kunzisoft.keepass.utils.UriUtil;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
@@ -47,28 +49,33 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.SyncFailedException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
public class Database {
|
||||
|
||||
private static final String TAG = Database.class.getName();
|
||||
|
||||
private PwDatabase pm;
|
||||
private PwDatabase pwDatabase;
|
||||
private Uri mUri;
|
||||
private SearchDbHelper searchHelper;
|
||||
private boolean readOnly = false;
|
||||
private boolean passwordEncodingError = false;
|
||||
|
||||
private DrawableFactory drawFactory = new DrawableFactory();
|
||||
private IconDrawableFactory drawFactory = new IconDrawableFactory();
|
||||
|
||||
private boolean loaded = false;
|
||||
|
||||
public PwDatabase getPwDatabase() {
|
||||
return pm;
|
||||
return pwDatabase;
|
||||
}
|
||||
|
||||
public void setPwDatabase(PwDatabase pm) {
|
||||
this.pm = pm;
|
||||
this.pwDatabase = pm;
|
||||
}
|
||||
|
||||
public void setUri(Uri mUri) {
|
||||
@@ -87,7 +94,7 @@ public class Database {
|
||||
return passwordEncodingError;
|
||||
}
|
||||
|
||||
public DrawableFactory getDrawFactory() {
|
||||
public IconDrawableFactory getDrawFactory() {
|
||||
return drawFactory;
|
||||
}
|
||||
|
||||
@@ -99,19 +106,11 @@ public class Database {
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
public void loadData(Context ctx, InputStream is, String password, InputStream keyInputStream) throws IOException, InvalidDBException {
|
||||
loadData(ctx, is, password, keyInputStream, new UpdateStatus(), !Importer.DEBUG);
|
||||
}
|
||||
|
||||
public void loadData(Context ctx, Uri uri, String password, Uri keyfile) throws IOException, FileNotFoundException, InvalidDBException {
|
||||
loadData(ctx, uri, password, keyfile, new UpdateStatus(), !Importer.DEBUG);
|
||||
}
|
||||
|
||||
public void loadData(Context ctx, Uri uri, String password, Uri keyfile, UpdateStatus status) throws IOException, FileNotFoundException, InvalidDBException {
|
||||
public void loadData(Context ctx, Uri uri, String password, Uri keyfile, ProgressTaskUpdater status) throws IOException, FileNotFoundException, InvalidDBException {
|
||||
loadData(ctx, uri, password, keyfile, status, !Importer.DEBUG);
|
||||
}
|
||||
|
||||
public void loadData(Context ctx, Uri uri, String password, Uri keyfile, UpdateStatus status, boolean debug) throws IOException, FileNotFoundException, InvalidDBException {
|
||||
private void loadData(Context ctx, Uri uri, String password, Uri keyfile, ProgressTaskUpdater status, boolean debug) throws IOException, FileNotFoundException, InvalidDBException {
|
||||
mUri = uri;
|
||||
readOnly = false;
|
||||
if (uri.getScheme().equals("file")) {
|
||||
@@ -119,26 +118,10 @@ public class Database {
|
||||
readOnly = !file.canWrite();
|
||||
}
|
||||
|
||||
try {
|
||||
passUrisAsInputStreams(ctx, uri, password, keyfile, status, debug, 0);
|
||||
} catch (InvalidPasswordException e) {
|
||||
// Retry with rounds fix
|
||||
try {
|
||||
passUrisAsInputStreams(ctx, uri, password, keyfile, status, debug, getFixRounds(ctx));
|
||||
} catch (Exception e2) {
|
||||
// Rethrow original exception
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
passUrisAsInputStreams(ctx, uri, password, keyfile, status, debug);
|
||||
}
|
||||
|
||||
private long getFixRounds(Context ctx) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
|
||||
return prefs.getLong(ctx.getString(R.string.roundsFix_key), ctx.getResources().getInteger(R.integer.roundsFix_default));
|
||||
}
|
||||
|
||||
|
||||
private void passUrisAsInputStreams(Context ctx, Uri uri, String password, Uri keyfile, UpdateStatus status, boolean debug, long roundsFix) throws IOException, FileNotFoundException, InvalidDBException {
|
||||
private void passUrisAsInputStreams(Context ctx, Uri uri, String password, Uri keyfile, ProgressTaskUpdater status, boolean debug) throws IOException, FileNotFoundException, InvalidDBException {
|
||||
InputStream is, kfIs;
|
||||
try {
|
||||
is = UriUtil.getUriInputStream(ctx, uri);
|
||||
@@ -153,18 +136,14 @@ public class Database {
|
||||
Log.e("KPD", "Database::loadData", e);
|
||||
throw ContentFileNotFoundException.getInstance(keyfile);
|
||||
}
|
||||
loadData(ctx, is, password, kfIs, status, debug, roundsFix);
|
||||
loadData(ctx, is, password, kfIs, status, debug);
|
||||
}
|
||||
|
||||
public void loadData(Context ctx, InputStream is, String password, InputStream kfIs, boolean debug) throws IOException, InvalidDBException {
|
||||
loadData(ctx, is, password, kfIs, new UpdateStatus(), debug);
|
||||
public void loadData(Context ctx, InputStream is, String password, InputStream keyFileInputStream, boolean debug) throws IOException, InvalidDBException {
|
||||
loadData(ctx, is, password, keyFileInputStream, null, debug);
|
||||
}
|
||||
|
||||
public void loadData(Context ctx, InputStream is, String password, InputStream kfIs, UpdateStatus status, boolean debug) throws IOException, InvalidDBException {
|
||||
loadData(ctx, is, password, kfIs, status, debug, 0);
|
||||
}
|
||||
|
||||
public void loadData(Context ctx, InputStream is, String password, InputStream kfIs, UpdateStatus status, boolean debug, long roundsFix) throws IOException, InvalidDBException {
|
||||
private void loadData(Context ctx, InputStream is, String password, InputStream keyFileInputStream, ProgressTaskUpdater progressTaskUpdater, boolean debug) throws IOException, InvalidDBException {
|
||||
BufferedInputStream bis = new BufferedInputStream(is);
|
||||
|
||||
if ( ! bis.markSupported() ) {
|
||||
@@ -174,24 +153,25 @@ public class Database {
|
||||
// We'll end up reading 8 bytes to identify the header. Might as well use two extra.
|
||||
bis.mark(10);
|
||||
|
||||
Importer imp = ImporterFactory.createImporter(bis, debug);
|
||||
// Get the file directory to save the attachments
|
||||
Importer databaseImporter = ImporterFactory.createImporter(bis, ctx.getFilesDir(), debug);
|
||||
|
||||
bis.reset(); // Return to the start
|
||||
|
||||
pm = imp.openDatabase(bis, password, kfIs, status, roundsFix);
|
||||
if ( pm != null ) {
|
||||
pwDatabase = databaseImporter.openDatabase(bis, password, keyFileInputStream, progressTaskUpdater);
|
||||
if ( pwDatabase != null ) {
|
||||
try {
|
||||
switch (pm.getVersion()) {
|
||||
switch (pwDatabase.getVersion()) {
|
||||
case V3:
|
||||
PwGroupV3 rootV3 = ((PwDatabaseV3) pm).getRootGroup();
|
||||
((PwDatabaseV3) pm).populateGlobals(rootV3);
|
||||
passwordEncodingError = !pm.validatePasswordEncoding(password);
|
||||
PwGroupV3 rootV3 = ((PwDatabaseV3) pwDatabase).getRootGroup();
|
||||
((PwDatabaseV3) pwDatabase).populateGlobals(rootV3);
|
||||
passwordEncodingError = !pwDatabase.validatePasswordEncoding(password);
|
||||
searchHelper = new SearchDbHelper.SearchDbHelperV3(ctx);
|
||||
break;
|
||||
case V4:
|
||||
PwGroupV4 rootV4 = ((PwDatabaseV4) pm).getRootGroup();
|
||||
((PwDatabaseV4) pm).populateGlobals(rootV4);
|
||||
passwordEncodingError = !pm.validatePasswordEncoding(password);
|
||||
PwGroupV4 rootV4 = ((PwDatabaseV4) pwDatabase).getRootGroup();
|
||||
((PwDatabaseV4) pwDatabase).populateGlobals(rootV4);
|
||||
passwordEncodingError = !pwDatabase.validatePasswordEncoding(password);
|
||||
searchHelper = new SearchDbHelper.SearchDbHelperV4(ctx);
|
||||
break;
|
||||
}
|
||||
@@ -204,13 +184,17 @@ public class Database {
|
||||
}
|
||||
|
||||
public PwGroup search(String str) {
|
||||
return search(str, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public PwGroup search(String str, int max) {
|
||||
if (searchHelper == null) { return null; }
|
||||
try {
|
||||
switch (pm.getVersion()) {
|
||||
switch (pwDatabase.getVersion()) {
|
||||
case V3:
|
||||
return ((SearchDbHelper.SearchDbHelperV3) searchHelper).search(((PwDatabaseV3) pm), str);
|
||||
return ((SearchDbHelper.SearchDbHelperV3) searchHelper).search(((PwDatabaseV3) pwDatabase), str, max);
|
||||
case V4:
|
||||
return ((SearchDbHelper.SearchDbHelperV4) searchHelper).search(((PwDatabaseV4) pm), str);
|
||||
return ((SearchDbHelper.SearchDbHelperV4) searchHelper).search(((PwDatabaseV4) pwDatabase), str, max);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Search can't be performed with this SearchHelper", e);
|
||||
@@ -218,23 +202,78 @@ public class Database {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Cursor searchEntry(String query) {
|
||||
final EntryCursor cursor = new EntryCursor();
|
||||
|
||||
// TODO real content provider
|
||||
if (!query.isEmpty()) {
|
||||
PwGroup searchResult = search(query, 6);
|
||||
PwVersion version = getPwDatabase().getVersion();
|
||||
if (searchResult != null) {
|
||||
for (int i = 0; i < searchResult.numbersOfChildEntries(); i++) {
|
||||
PwEntry entry = searchResult.getChildEntryAt(i);
|
||||
if (!entry.isMetaStream()) { // TODO metastream
|
||||
try {
|
||||
switch (version) {
|
||||
case V3:
|
||||
cursor.addEntry((PwEntryV3) entry);
|
||||
continue;
|
||||
case V4:
|
||||
cursor.addEntry((PwEntryV4) entry);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Can't add PwEntry to the cursor", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return cursor;
|
||||
}
|
||||
|
||||
public void populateEntry(PwEntry pwEntry, EntryCursor cursor) {
|
||||
PwIconFactory iconFactory = getPwDatabase().getIconFactory();
|
||||
try {
|
||||
switch (getPwDatabase().getVersion()) {
|
||||
case V3:
|
||||
cursor.populateEntry((PwEntryV3) pwEntry, iconFactory);
|
||||
break;
|
||||
case V4:
|
||||
// TODO invert field reference manager
|
||||
pwEntry.startToManageFieldReferences(getPwDatabase());
|
||||
cursor.populateEntry((PwEntryV4) pwEntry, iconFactory);
|
||||
pwEntry.stopToManageFieldReferences();
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "This version of PwGroup can't be populated", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveData(Context ctx) throws IOException, PwDbOutputException {
|
||||
saveData(ctx, mUri);
|
||||
}
|
||||
|
||||
public void saveData(Context ctx, Uri uri) throws IOException, PwDbOutputException {
|
||||
private void saveData(Context ctx, Uri uri) throws IOException, PwDbOutputException {
|
||||
String errorMessage = "Failed to store database.";
|
||||
|
||||
if (uri.getScheme().equals("file")) {
|
||||
String filename = uri.getPath();
|
||||
File tempFile = new File(filename + ".tmp");
|
||||
FileOutputStream fos = new FileOutputStream(tempFile);
|
||||
//BufferedOutputStream bos = new BufferedOutputStream(fos);
|
||||
|
||||
//PwDbV3Output pmo = new PwDbV3Output(pm, bos, App.getCalendar());
|
||||
PwDbOutput pmo = PwDbOutput.getInstance(pm, fos);
|
||||
FileOutputStream fos = null;
|
||||
try {
|
||||
fos = new FileOutputStream(tempFile);
|
||||
PwDbOutput pmo = PwDbOutput.getInstance(pwDatabase, fos);
|
||||
if (pmo != null)
|
||||
pmo.output();
|
||||
//bos.flush();
|
||||
//bos.close();
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, errorMessage, e);
|
||||
throw new IOException(errorMessage, e);
|
||||
} finally {
|
||||
if (fos != null)
|
||||
fos.close();
|
||||
}
|
||||
|
||||
// Force data to disk before continuing
|
||||
try {
|
||||
@@ -246,28 +285,41 @@ public class Database {
|
||||
File orig = new File(filename);
|
||||
|
||||
if (!tempFile.renameTo(orig)) {
|
||||
throw new IOException("Failed to store database.");
|
||||
throw new IOException(errorMessage);
|
||||
}
|
||||
}
|
||||
else {
|
||||
OutputStream os;
|
||||
OutputStream os = null;
|
||||
try {
|
||||
os = ctx.getContentResolver().openOutputStream(uri);
|
||||
} catch (Exception e) {
|
||||
throw new IOException("Failed to store database.");
|
||||
}
|
||||
|
||||
PwDbOutput pmo = PwDbOutput.getInstance(pm, os);
|
||||
PwDbOutput pmo = PwDbOutput.getInstance(pwDatabase, os);
|
||||
if (pmo != null)
|
||||
pmo.output();
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, errorMessage, e);
|
||||
throw new IOException(errorMessage, e);
|
||||
} finally {
|
||||
if (os != null)
|
||||
os.close();
|
||||
}
|
||||
}
|
||||
mUri = uri;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
drawFactory.clear();
|
||||
// TODO Clear database when lock broadcast is receive in backstage
|
||||
public void clear(Context context) {
|
||||
drawFactory.clearCache();
|
||||
// Delete the cache of the database if present
|
||||
if (pwDatabase != null)
|
||||
pwDatabase.clearCache();
|
||||
// In all cases, delete all the files in the temp dir
|
||||
try {
|
||||
FileUtils.cleanDirectory(context.getFilesDir());
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Unable to clear the directory cache.", e);
|
||||
}
|
||||
|
||||
pm = null;
|
||||
pwDatabase = null;
|
||||
mUri = null;
|
||||
loaded = false;
|
||||
passwordEncodingError = false;
|
||||
@@ -348,16 +400,88 @@ public class Database {
|
||||
}
|
||||
}
|
||||
|
||||
public PwEncryptionAlgorithm getEncryptionAlgorithm() {
|
||||
return getPwDatabase().getEncryptionAlgorithm();
|
||||
}
|
||||
|
||||
public List<PwEncryptionAlgorithm> getAvailableEncryptionAlgorithms() {
|
||||
switch (getPwDatabase().getVersion()) {
|
||||
case V4:
|
||||
return ((PwDatabaseV4) getPwDatabase()).getAvailableEncryptionAlgorithms();
|
||||
case V3:
|
||||
return ((PwDatabaseV3) getPwDatabase()).getAvailableEncryptionAlgorithms();
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
public boolean allowEncryptionAlgorithmModification() {
|
||||
return getAvailableEncryptionAlgorithms().size() > 1;
|
||||
}
|
||||
|
||||
public void assignEncryptionAlgorithm(PwEncryptionAlgorithm algorithm) {
|
||||
switch (getPwDatabase().getVersion()) {
|
||||
case V4:
|
||||
((PwDatabaseV4) getPwDatabase()).setEncryptionAlgorithm(algorithm);
|
||||
((PwDatabaseV4) getPwDatabase()).setDataEngine(algorithm.getCipherEngine());
|
||||
((PwDatabaseV4) getPwDatabase()).setDataCipher(algorithm.getDataCipher());
|
||||
}
|
||||
}
|
||||
|
||||
public String getEncryptionAlgorithmName(Resources resources) {
|
||||
return getPwDatabase().getEncryptionAlgorithm().getName(resources);
|
||||
}
|
||||
|
||||
public String getKeyDerivationName() {
|
||||
return getPwDatabase().getKeyDerivationName();
|
||||
public List<KdfEngine> getAvailableKdfEngines() {
|
||||
switch (getPwDatabase().getVersion()) {
|
||||
case V4:
|
||||
return KdfFactory.kdfListV4;
|
||||
case V3:
|
||||
return KdfFactory.kdfListV3;
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
public boolean allowKdfModification() {
|
||||
return getAvailableKdfEngines().size() > 1;
|
||||
}
|
||||
|
||||
public KdfEngine getKdfEngine() {
|
||||
switch (getPwDatabase().getVersion()) {
|
||||
case V4:
|
||||
KdfEngine kdfEngine = ((PwDatabaseV4) getPwDatabase()).getKdfEngine();
|
||||
if (kdfEngine == null)
|
||||
return KdfFactory.aesKdf;
|
||||
return kdfEngine;
|
||||
default:
|
||||
case V3:
|
||||
return KdfFactory.aesKdf;
|
||||
}
|
||||
}
|
||||
|
||||
public void assignKdfEngine(KdfEngine kdfEngine) {
|
||||
switch (getPwDatabase().getVersion()) {
|
||||
case V4:
|
||||
PwDatabaseV4 db = ((PwDatabaseV4) getPwDatabase());
|
||||
if (db.getKdfParameters() == null
|
||||
|| !db.getKdfParameters().getUUID().equals(kdfEngine.getDefaultParameters().getUUID()))
|
||||
db.setKdfParameters(kdfEngine.getDefaultParameters());
|
||||
setNumberKeyEncryptionRounds(kdfEngine.getDefaultKeyRounds());
|
||||
setMemoryUsage(kdfEngine.getDefaultMemoryUsage());
|
||||
setParallelism(kdfEngine.getDefaultParallelism());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public String getKeyDerivationName(Resources resources) {
|
||||
KdfEngine kdfEngine = getKdfEngine();
|
||||
if (kdfEngine != null) {
|
||||
return kdfEngine.getName(resources);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getNumberKeyEncryptionRoundsAsString() {
|
||||
return Long.toString(getPwDatabase().getNumberKeyEncryptionRounds());
|
||||
return Long.toString(getNumberKeyEncryptionRounds());
|
||||
}
|
||||
|
||||
public long getNumberKeyEncryptionRounds() {
|
||||
@@ -368,6 +492,78 @@ public class Database {
|
||||
getPwDatabase().setNumberKeyEncryptionRounds(numberRounds);
|
||||
}
|
||||
|
||||
public String getMemoryUsageAsString() {
|
||||
return Long.toString(getMemoryUsage());
|
||||
}
|
||||
|
||||
public long getMemoryUsage() {
|
||||
switch (getPwDatabase().getVersion()) {
|
||||
case V4:
|
||||
return ((PwDatabaseV4) getPwDatabase()).getMemoryUsage();
|
||||
}
|
||||
return KdfEngine.UNKNOW_VALUE;
|
||||
}
|
||||
|
||||
public void setMemoryUsage(long memory) {
|
||||
switch (getPwDatabase().getVersion()) {
|
||||
case V4:
|
||||
((PwDatabaseV4) getPwDatabase()).setMemoryUsage(memory);
|
||||
}
|
||||
}
|
||||
|
||||
public String getParallelismAsString() {
|
||||
return Integer.toString(getParallelism());
|
||||
}
|
||||
|
||||
public int getParallelism() {
|
||||
switch (getPwDatabase().getVersion()) {
|
||||
case V4:
|
||||
return ((PwDatabaseV4) getPwDatabase()).getParallelism();
|
||||
}
|
||||
return KdfEngine.UNKNOW_VALUE;
|
||||
}
|
||||
|
||||
public void setParallelism(int parallelism) {
|
||||
switch (getPwDatabase().getVersion()) {
|
||||
case V4:
|
||||
((PwDatabaseV4) getPwDatabase()).setParallelism(parallelism);
|
||||
}
|
||||
}
|
||||
|
||||
public PwEntry createEntry() {
|
||||
return createEntry(null);
|
||||
}
|
||||
|
||||
public PwEntry createEntry(@Nullable PwGroup parent) {
|
||||
try {
|
||||
switch (getPwDatabase().getVersion()) {
|
||||
case V3:
|
||||
return new PwEntryV3((PwGroupV3) parent);
|
||||
case V4:
|
||||
return new PwEntryV4((PwGroupV4) parent);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "This version of PwEntry can't be created", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public PwGroup createGroup(PwGroup parent) {
|
||||
PwGroup newPwGroup = null;
|
||||
try {
|
||||
switch (getPwDatabase().getVersion()) {
|
||||
case V3:
|
||||
newPwGroup = new PwGroupV3((PwGroupV3) parent);
|
||||
case V4:
|
||||
newPwGroup = new PwGroupV4((PwGroupV4) parent);
|
||||
}
|
||||
newPwGroup.setId(pwDatabase.newGroupId());
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "This version of PwGroup can't be created", e);
|
||||
}
|
||||
return newPwGroup;
|
||||
}
|
||||
|
||||
public void addEntryTo(PwEntry entry, PwGroup parent) {
|
||||
try {
|
||||
switch (getPwDatabase().getVersion()) {
|
||||
@@ -501,6 +697,59 @@ public class Database {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateGroup(PwGroup oldGroup, PwGroup newGroup) {
|
||||
try {
|
||||
switch (getPwDatabase().getVersion()) {
|
||||
case V3:
|
||||
((PwGroupV3) oldGroup).updateWith((PwGroupV3) newGroup);
|
||||
break;
|
||||
case V4:
|
||||
((PwGroupV4) oldGroup).updateWith((PwGroupV4) newGroup);
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "This version of PwEntry can't be updated", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A duplicate entry with the same values, a new UUID,
|
||||
* @param entryToCopy
|
||||
* @param newParent
|
||||
*/
|
||||
public @Nullable PwEntry copyEntry(PwEntry entryToCopy, PwGroup newParent) {
|
||||
try {
|
||||
// TODO encapsulate
|
||||
switch (getPwDatabase().getVersion()) {
|
||||
case V3:
|
||||
PwEntryV3 entryV3Copied = ((PwEntryV3) entryToCopy).clone();
|
||||
entryV3Copied.setUUID(UUID.randomUUID());
|
||||
entryV3Copied.setParent((PwGroupV3) newParent);
|
||||
addEntryTo(entryV3Copied, newParent);
|
||||
return entryV3Copied;
|
||||
case V4:
|
||||
PwEntryV4 entryV4Copied = ((PwEntryV4) entryToCopy).clone();
|
||||
entryV4Copied.setUUID(UUID.randomUUID());
|
||||
entryV4Copied.setParent((PwGroupV4) newParent);
|
||||
addEntryTo(entryV4Copied, newParent);
|
||||
return entryV4Copied;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "This version of PwEntry can't be updated", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void moveEntry(PwEntry entryToMove, PwGroup newParent) {
|
||||
removeEntryFrom(entryToMove, entryToMove.parent);
|
||||
addEntryTo(entryToMove, newParent);
|
||||
}
|
||||
|
||||
public void moveGroup(PwGroup groupToMove, PwGroup newParent) {
|
||||
removeGroupFrom(groupToMove, groupToMove.parent);
|
||||
addGroupTo(groupToMove, newParent);
|
||||
}
|
||||
|
||||
public void deleteEntry(PwEntry entry) {
|
||||
try {
|
||||
switch (getPwDatabase().getVersion()) {
|
||||
|
||||
@@ -19,9 +19,12 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.database;
|
||||
|
||||
import com.kunzisoft.keepass.database.security.ProtectedString;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.kunzisoft.keepass.database.security.ProtectedString;
|
||||
import com.kunzisoft.keepass.utils.MemUtil;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
@@ -32,7 +35,7 @@ import static com.kunzisoft.keepass.database.PwEntryV4.STR_TITLE;
|
||||
import static com.kunzisoft.keepass.database.PwEntryV4.STR_URL;
|
||||
import static com.kunzisoft.keepass.database.PwEntryV4.STR_USERNAME;
|
||||
|
||||
public class ExtraFields implements Serializable, Cloneable {
|
||||
public class ExtraFields implements Parcelable, Cloneable {
|
||||
|
||||
private Map<String, ProtectedString> fields;
|
||||
|
||||
@@ -40,10 +43,52 @@ public class ExtraFields implements Serializable, Cloneable {
|
||||
fields = new HashMap<>();
|
||||
}
|
||||
|
||||
public ExtraFields(Parcel in) {
|
||||
fields = MemUtil.readStringParcelableMap(in, ProtectedString.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
MemUtil.writeStringParcelableMap(dest, flags, fields);
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<ExtraFields> CREATOR = new Parcelable.Creator<ExtraFields>() {
|
||||
@Override
|
||||
public ExtraFields createFromParcel(Parcel in) {
|
||||
return new ExtraFields(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExtraFields[] newArray(int size) {
|
||||
return new ExtraFields[size];
|
||||
}
|
||||
};
|
||||
|
||||
public boolean containsCustomFields() {
|
||||
return !getCustomProtectedFields().keySet().isEmpty();
|
||||
}
|
||||
|
||||
public boolean containsCustomFieldsProtected() {
|
||||
for (Map.Entry<String, ProtectedString> field : getCustomProtectedFields().entrySet()) {
|
||||
if (field.getValue().isProtected())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean containsCustomFieldsNotProtected() {
|
||||
for (Map.Entry<String, ProtectedString> field : getCustomProtectedFields().entrySet()) {
|
||||
if (!field.getValue().isProtected())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getProtectedStringValue(String key) {
|
||||
ProtectedString value = fields.get(key);
|
||||
if ( value == null ) return "";
|
||||
|
||||
@@ -17,16 +17,13 @@
|
||||
* along with KeePass DX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.kunzisoft.keepass.database.edit;
|
||||
package com.kunzisoft.keepass.database;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.content.res.Resources;
|
||||
|
||||
import com.kunzisoft.keepass.database.PwNode;
|
||||
|
||||
public abstract class AfterAddNodeOnFinish extends OnFinish {
|
||||
public AfterAddNodeOnFinish(Handler handler) {
|
||||
super(handler);
|
||||
}
|
||||
|
||||
public abstract void run(PwNode pwNode);
|
||||
/**
|
||||
* Interface to generify items with a name resource, that can be (for example) visible in a list
|
||||
*/
|
||||
public interface ObjectNameResource {
|
||||
String getName(Resources resources);
|
||||
}
|
||||
@@ -19,19 +19,15 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.database;
|
||||
|
||||
import com.kunzisoft.keepass.crypto.finalkey.FinalKey;
|
||||
import com.kunzisoft.keepass.crypto.finalkey.FinalKeyFactory;
|
||||
import com.kunzisoft.keepass.database.exception.InvalidKeyFileException;
|
||||
import com.kunzisoft.keepass.database.exception.KeyFileEmptyException;
|
||||
import com.kunzisoft.keepass.stream.NullOutputStream;
|
||||
import com.kunzisoft.keepass.utils.Util;
|
||||
import com.kunzisoft.keepass.utils.MemUtil;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.DigestOutputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
@@ -39,7 +35,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class PwDatabase<PwGroupDB extends PwGroup<PwGroupDB, PwGroupDB, PwEntryDB>,
|
||||
public abstract class PwDatabase<PwGroupDB extends PwGroup<PwGroupDB, PwEntryDB>,
|
||||
PwEntryDB extends PwEntry<PwGroupDB>> {
|
||||
|
||||
public static final UUID UUID_ZERO = new UUID(0,0);
|
||||
@@ -100,42 +96,10 @@ public abstract class PwDatabase<PwGroupDB extends PwGroup<PwGroupDB, PwGroupDB,
|
||||
return finalKey;
|
||||
}
|
||||
|
||||
public void makeFinalKey(byte[] masterSeed, byte[] masterSeed2, long numRounds) throws IOException {
|
||||
|
||||
// Write checksum Checksum
|
||||
MessageDigest md;
|
||||
try {
|
||||
md = MessageDigest.getInstance("SHA-256");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new IOException("SHA-256 not implemented here.");
|
||||
}
|
||||
NullOutputStream nos = new NullOutputStream();
|
||||
DigestOutputStream dos = new DigestOutputStream(nos, md);
|
||||
|
||||
byte[] transformedMasterKey = transformMasterKey(masterSeed2, masterKey, numRounds);
|
||||
dos.write(masterSeed);
|
||||
dos.write(transformedMasterKey);
|
||||
|
||||
finalKey = md.digest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypt the master key a few times to make brute-force key-search harder
|
||||
* @throws IOException
|
||||
*/
|
||||
protected static byte[] transformMasterKey( byte[] pKeySeed, byte[] pKey, long rounds ) throws IOException {
|
||||
FinalKey key = FinalKeyFactory.createFinalKey();
|
||||
|
||||
return key.transformMasterKey(pKeySeed, pKey, rounds);
|
||||
}
|
||||
|
||||
|
||||
public abstract byte[] getMasterKey(String key, InputStream keyInputStream) throws InvalidKeyFileException, IOException;
|
||||
|
||||
public void setMasterKey(String key, InputStream keyInputStream)
|
||||
public void retrieveMasterKey(String key, InputStream keyInputStream)
|
||||
throws InvalidKeyFileException, IOException {
|
||||
assert(key != null);
|
||||
|
||||
masterKey = getMasterKey(key, keyInputStream);
|
||||
}
|
||||
|
||||
@@ -164,7 +128,7 @@ public abstract class PwDatabase<PwGroupDB extends PwGroup<PwGroupDB, PwGroupDB,
|
||||
assert(keyInputStream != null);
|
||||
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
Util.copyStream(keyInputStream, bos);
|
||||
MemUtil.copyStream(keyInputStream, bos);
|
||||
byte[] keyData = bos.toByteArray();
|
||||
|
||||
ByteArrayInputStream bis = new ByteArrayInputStream(keyData);
|
||||
@@ -220,6 +184,9 @@ public abstract class PwDatabase<PwGroupDB extends PwGroup<PwGroupDB, PwGroupDB,
|
||||
}
|
||||
|
||||
public boolean validatePasswordEncoding(String key) {
|
||||
if (key == null)
|
||||
return false;
|
||||
|
||||
String encoding = getPasswordEncoding();
|
||||
|
||||
byte[] bKey;
|
||||
@@ -243,10 +210,8 @@ public abstract class PwDatabase<PwGroupDB extends PwGroup<PwGroupDB, PwGroupDB,
|
||||
protected abstract String getPasswordEncoding();
|
||||
|
||||
public byte[] getPasswordKey(String key) throws IOException {
|
||||
assert(key!=null);
|
||||
|
||||
if ( key.length() == 0 )
|
||||
throw new IllegalArgumentException( "Key cannot be empty." );
|
||||
if ( key == null)
|
||||
throw new IllegalArgumentException( "Key cannot be empty." ); // TODO
|
||||
|
||||
MessageDigest md;
|
||||
try {
|
||||
@@ -281,7 +246,7 @@ public abstract class PwDatabase<PwGroupDB extends PwGroup<PwGroupDB, PwGroupDB,
|
||||
this.algorithm = algorithm;
|
||||
}
|
||||
|
||||
public abstract String getKeyDerivationName();
|
||||
public abstract List<PwEncryptionAlgorithm> getAvailableEncryptionAlgorithms();
|
||||
|
||||
public abstract List<PwGroupDB> getGrpRoots();
|
||||
|
||||
@@ -465,4 +430,6 @@ public abstract class PwDatabase<PwGroupDB extends PwGroup<PwGroupDB, PwGroupDB,
|
||||
*/
|
||||
public abstract void initNew(String dbPath);
|
||||
|
||||
public abstract void clearCache();
|
||||
|
||||
}
|
||||
|
||||
@@ -45,12 +45,16 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
package com.kunzisoft.keepass.database;
|
||||
|
||||
// Java
|
||||
import com.kunzisoft.keepass.crypto.keyDerivation.AesKdf;
|
||||
import com.kunzisoft.keepass.crypto.finalkey.FinalKey;
|
||||
import com.kunzisoft.keepass.crypto.finalkey.FinalKeyFactory;
|
||||
import com.kunzisoft.keepass.database.exception.InvalidKeyFileException;
|
||||
import com.kunzisoft.keepass.stream.NullOutputStream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.DigestOutputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
@@ -71,13 +75,6 @@ public class PwDatabaseV3 extends PwDatabase<PwGroupV3, PwEntryV3> {
|
||||
|
||||
private int numKeyEncRounds;
|
||||
|
||||
private void initAndAddGroup(String name, int iconId, PwGroupV3 parent) {
|
||||
PwGroupV3 group = createGroup();
|
||||
group.initNewGroup(name, newGroupId());
|
||||
group.setIcon(iconFactory.getIcon(iconId));
|
||||
addGroupTo(group, parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initNew(String dbPath) {
|
||||
algorithm = PwEncryptionAlgorithm.AES_Rijndael;
|
||||
@@ -90,14 +87,24 @@ public class PwDatabaseV3 extends PwDatabase<PwGroupV3, PwEntryV3> {
|
||||
initAndAddGroup("eMail", 19, rootGroup);
|
||||
}
|
||||
|
||||
private void initAndAddGroup(String name, int iconId, PwGroupV3 parent) {
|
||||
PwGroupV3 group = createGroup();
|
||||
group.setId(newGroupId());
|
||||
group.setName(name);
|
||||
group.setIconStandard(iconFactory.getIcon(iconId));
|
||||
addGroupTo(group, parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PwVersion getVersion() {
|
||||
return PwVersion.V3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKeyDerivationName() {
|
||||
return AesKdf.DEFAULT_NAME;
|
||||
public List<PwEncryptionAlgorithm> getAvailableEncryptionAlgorithms() {
|
||||
List<PwEncryptionAlgorithm> list = new ArrayList<>();
|
||||
list.add(PwEncryptionAlgorithm.AES_Rijndael);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -169,7 +176,7 @@ public class PwDatabaseV3 extends PwDatabase<PwGroupV3, PwEntryV3> {
|
||||
*/
|
||||
for (int i = 0; i < entries.size(); i++) {
|
||||
PwEntryV3 ent = entries.get(i);
|
||||
if (ent.getGroupId() == parent.getGroupId())
|
||||
if (ent.getParent().getGroupId() == parent.getGroupId())
|
||||
kids.add(ent);
|
||||
}
|
||||
return kids;
|
||||
@@ -235,20 +242,50 @@ public class PwDatabaseV3 extends PwDatabase<PwGroupV3, PwEntryV3> {
|
||||
return newId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getMasterKey(String key, InputStream keyInputStream)
|
||||
throws InvalidKeyFileException, IOException {
|
||||
|
||||
if (key != null && key.length() > 0 && keyInputStream != null) {
|
||||
if (key != null && keyInputStream != null) {
|
||||
return getCompositeKey(key, keyInputStream);
|
||||
} else if (key != null && key.length() > 0) {
|
||||
} else if (key != null) { // key.length() >= 0
|
||||
return getPasswordKey(key);
|
||||
} else if (keyInputStream != null) {
|
||||
} else if (keyInputStream != null) { // key == null
|
||||
return getFileKey(keyInputStream);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Key cannot be empty.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypt the master key a few times to make brute-force key-search harder
|
||||
* @throws IOException
|
||||
*/
|
||||
private static byte[] transformMasterKey( byte[] pKeySeed, byte[] pKey, long rounds ) throws IOException {
|
||||
FinalKey key = FinalKeyFactory.createFinalKey();
|
||||
|
||||
return key.transformMasterKey(pKeySeed, pKey, rounds);
|
||||
}
|
||||
|
||||
public void makeFinalKey(byte[] masterSeed, byte[] masterSeed2, long numRounds) throws IOException {
|
||||
|
||||
// Write checksum Checksum
|
||||
MessageDigest md;
|
||||
try {
|
||||
md = MessageDigest.getInstance("SHA-256");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new IOException("SHA-256 not implemented here.");
|
||||
}
|
||||
NullOutputStream nos = new NullOutputStream();
|
||||
DigestOutputStream dos = new DigestOutputStream(nos, md);
|
||||
|
||||
byte[] transformedMasterKey = transformMasterKey(masterSeed2, masterKey, numRounds);
|
||||
dos.write(masterSeed);
|
||||
dos.write(transformedMasterKey);
|
||||
|
||||
finalKey = md.digest();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPasswordEncoding() {
|
||||
return "ISO-8859-1";
|
||||
@@ -287,7 +324,6 @@ public class PwDatabaseV3 extends PwDatabase<PwGroupV3, PwEntryV3> {
|
||||
|
||||
// Add tree to root groups
|
||||
groups.add(newGroup);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -340,4 +376,7 @@ public class PwDatabaseV3 extends PwDatabase<PwGroupV3, PwEntryV3> {
|
||||
|
||||
return !(omitBackup && isBackup(group));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearCache() {}
|
||||
}
|
||||
|
||||
@@ -19,17 +19,18 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.database;
|
||||
|
||||
import android.util.Log;
|
||||
import android.webkit.URLUtil;
|
||||
|
||||
import com.kunzisoft.keepass.collections.VariantDictionary;
|
||||
import com.kunzisoft.keepass.crypto.CryptoUtil;
|
||||
import com.kunzisoft.keepass.crypto.engine.AesEngine;
|
||||
import com.kunzisoft.keepass.crypto.engine.CipherEngine;
|
||||
import com.kunzisoft.keepass.crypto.keyDerivation.AesKdf;
|
||||
import com.kunzisoft.keepass.crypto.keyDerivation.KdfEngine;
|
||||
import com.kunzisoft.keepass.crypto.keyDerivation.KdfFactory;
|
||||
import com.kunzisoft.keepass.crypto.keyDerivation.KdfParameters;
|
||||
import com.kunzisoft.keepass.database.exception.InvalidKeyFileException;
|
||||
import com.kunzisoft.keepass.database.exception.UnknownKDF;
|
||||
import com.kunzisoft.keepass.utils.EmptyUtils;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
@@ -50,6 +51,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
@@ -57,6 +59,7 @@ import biz.source_code.base64Coder.Base64Coder;
|
||||
|
||||
|
||||
public class PwDatabaseV4 extends PwDatabase<PwGroupV4, PwEntryV4> {
|
||||
private static final String TAG = PwDatabaseV4.class.getName();
|
||||
|
||||
private static final int DEFAULT_HISTORY_MAX_ITEMS = 10; // -1 unlimited
|
||||
private static final long DEFAULT_HISTORY_MAX_SIZE = 6 * 1024 * 1024; // -1 unlimited
|
||||
@@ -66,9 +69,10 @@ public class PwDatabaseV4 extends PwDatabase<PwGroupV4, PwEntryV4> {
|
||||
private UUID dataCipher = AesEngine.CIPHER_UUID;
|
||||
private CipherEngine dataEngine = new AesEngine();
|
||||
private PwCompressionAlgorithm compressionAlgorithm = PwCompressionAlgorithm.Gzip;
|
||||
private KdfEngine kdfEngine;
|
||||
private KdfParameters kdfParameters;
|
||||
private long numKeyEncRounds;
|
||||
private VariantDictionary publicCustomData = new VariantDictionary();
|
||||
|
||||
private long numKeyEncRounds = AesKdf.DEFAULT_ROUNDS; // By default take the AES rounds
|
||||
protected String name = "KeePass DX database";
|
||||
private PwDate nameChanged = new PwDate();
|
||||
private PwDate settingsChanged = new PwDate();
|
||||
@@ -98,8 +102,6 @@ public class PwDatabaseV4 extends PwDatabase<PwGroupV4, PwEntryV4> {
|
||||
private List<PwIconCustom> customIcons = new ArrayList<>();
|
||||
private Map<String, String> customData = new HashMap<>();
|
||||
|
||||
private KdfParameters kdfParameters = KdfFactory.getDefaultParameters();
|
||||
private VariantDictionary publicCustomData = new VariantDictionary();
|
||||
private BinaryPool binPool = new BinaryPool();
|
||||
|
||||
public String localizedAppName = "KeePassDX"; // TODO resource
|
||||
@@ -131,7 +133,15 @@ public class PwDatabaseV4 extends PwDatabase<PwGroupV4, PwEntryV4> {
|
||||
|
||||
public void setDataEngine(CipherEngine dataEngine) {
|
||||
this.dataEngine = dataEngine;
|
||||
this.algorithm = dataEngine.getPwEncryptionAlgorithm();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PwEncryptionAlgorithm> getAvailableEncryptionAlgorithms() {
|
||||
List<PwEncryptionAlgorithm> list = new ArrayList<>();
|
||||
list.add(PwEncryptionAlgorithm.AES_Rijndael);
|
||||
list.add(PwEncryptionAlgorithm.Twofish);
|
||||
list.add(PwEncryptionAlgorithm.ChaCha20);
|
||||
return list;
|
||||
}
|
||||
|
||||
public PwCompressionAlgorithm getCompressionAlgorithm() {
|
||||
@@ -142,6 +152,23 @@ public class PwDatabaseV4 extends PwDatabase<PwGroupV4, PwEntryV4> {
|
||||
this.compressionAlgorithm = compressionAlgorithm;
|
||||
}
|
||||
|
||||
public @Nullable KdfEngine getKdfEngine() {
|
||||
try {
|
||||
return KdfFactory.getEngineV4(kdfParameters);
|
||||
} catch (UnknownKDF unknownKDF) {
|
||||
Log.i(TAG, "Unable to retrieve KDF engine", unknownKDF);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public KdfParameters getKdfParameters() {
|
||||
return kdfParameters;
|
||||
}
|
||||
|
||||
public void setKdfParameters(KdfParameters kdfParameters) {
|
||||
this.kdfParameters = kdfParameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getNumberKeyEncryptionRounds() {
|
||||
if (getKdfEngine() != null && getKdfParameters() != null)
|
||||
@@ -156,6 +183,30 @@ public class PwDatabaseV4 extends PwDatabase<PwGroupV4, PwEntryV4> {
|
||||
numKeyEncRounds = rounds;
|
||||
}
|
||||
|
||||
public long getMemoryUsage() {
|
||||
if (getKdfEngine() != null && getKdfParameters() != null) {
|
||||
return getKdfEngine().getMemoryUsage(getKdfParameters());
|
||||
}
|
||||
return KdfEngine.UNKNOW_VALUE;
|
||||
}
|
||||
|
||||
public void setMemoryUsage(long memory) {
|
||||
if (getKdfEngine() != null && getKdfParameters() != null)
|
||||
getKdfEngine().setMemoryUsage(getKdfParameters(), memory);
|
||||
}
|
||||
|
||||
public int getParallelism() {
|
||||
if (getKdfEngine() != null && getKdfParameters() != null) {
|
||||
return getKdfEngine().getParallelism(getKdfParameters());
|
||||
}
|
||||
return KdfEngine.UNKNOW_VALUE;
|
||||
}
|
||||
|
||||
public void setParallelism(int parallelism) {
|
||||
if (getKdfEngine() != null && getKdfParameters() != null)
|
||||
getKdfEngine().setParallelism(getKdfParameters(), parallelism);
|
||||
}
|
||||
|
||||
public PwDate getNameChanged() {
|
||||
return nameChanged;
|
||||
}
|
||||
@@ -326,27 +377,17 @@ public class PwDatabaseV4 extends PwDatabase<PwGroupV4, PwEntryV4> {
|
||||
this.customData.put(label, value);
|
||||
}
|
||||
|
||||
public KdfEngine getKdfEngine() {
|
||||
return kdfEngine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKeyDerivationName() {
|
||||
return kdfEngine.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getMasterKey(String key, InputStream keyInputStream)
|
||||
throws InvalidKeyFileException, IOException {
|
||||
assert(key != null);
|
||||
|
||||
byte[] fKey = new byte[]{};
|
||||
|
||||
if ( key.length() > 0 && keyInputStream != null) {
|
||||
if (key != null && keyInputStream != null) {
|
||||
return getCompositeKey(key, keyInputStream);
|
||||
} else if ( key.length() > 0 ) {
|
||||
} else if (key != null) { // key.length() >= 0
|
||||
fKey = getPasswordKey(key);
|
||||
} else if ( keyInputStream != null) {
|
||||
} else if (keyInputStream != null) { // key == null
|
||||
fKey = getFileKey(keyInputStream);
|
||||
}
|
||||
|
||||
@@ -360,47 +401,11 @@ public class PwDatabaseV4 extends PwDatabase<PwGroupV4, PwEntryV4> {
|
||||
return md.digest(fKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void makeFinalKey(byte[] masterSeed, byte[] masterSeed2, long numRounds) throws IOException {
|
||||
public void makeFinalKey(byte[] masterSeed) throws IOException {
|
||||
|
||||
byte[] transformedMasterKey = transformMasterKey(masterSeed2, masterKey, numRounds);
|
||||
KdfEngine kdfEngine = KdfFactory.getEngineV4(kdfParameters);
|
||||
|
||||
|
||||
byte[] cmpKey = new byte[65];
|
||||
System.arraycopy(masterSeed, 0, cmpKey, 0, 32);
|
||||
System.arraycopy(transformedMasterKey, 0, cmpKey, 32, 32);
|
||||
finalKey = CryptoUtil.resizeKey(cmpKey, 0, 64, dataEngine.keyLength());
|
||||
|
||||
MessageDigest md;
|
||||
try {
|
||||
md = MessageDigest.getInstance("SHA-512");
|
||||
cmpKey[64] = 1;
|
||||
hmacKey = md.digest(cmpKey);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new IOException("No SHA-512 implementation");
|
||||
} finally {
|
||||
Arrays.fill(cmpKey, (byte)0);
|
||||
}
|
||||
}
|
||||
public void makeFinalKey(byte[] masterSeed, KdfParameters kdfP) throws IOException {
|
||||
makeFinalKey(masterSeed, kdfP, 0);
|
||||
}
|
||||
|
||||
public void makeFinalKey(byte[] masterSeed, KdfParameters kdfP, long roundsFix)
|
||||
throws IOException {
|
||||
|
||||
kdfEngine = KdfFactory.get(kdfP.kdfUUID);
|
||||
if (kdfEngine == null) {
|
||||
throw new IOException("Unknown key derivation function");
|
||||
}
|
||||
|
||||
// Set to 6000 rounds to open corrupted database
|
||||
if (roundsFix > 0 && kdfP.kdfUUID.equals(AesKdf.CIPHER_UUID)) {
|
||||
kdfP.setUInt32(AesKdf.ParamRounds, roundsFix);
|
||||
numKeyEncRounds = roundsFix;
|
||||
}
|
||||
|
||||
byte[] transformedMasterKey = kdfEngine.transform(masterKey, kdfP);
|
||||
byte[] transformedMasterKey = kdfEngine.transform(masterKey, kdfParameters);
|
||||
if (transformedMasterKey.length != 32) {
|
||||
transformedMasterKey = CryptoUtil.hashSha256(transformedMasterKey);
|
||||
}
|
||||
@@ -550,15 +555,15 @@ public class PwDatabaseV4 extends PwDatabase<PwGroupV4, PwEntryV4> {
|
||||
super.populateGlobals(currentGroup);
|
||||
}
|
||||
|
||||
/** Ensure that the recycle bin tree exists, if enabled and create it
|
||||
/**
|
||||
* Ensure that the recycle bin tree exists, if enabled and create it
|
||||
* if it doesn't exist
|
||||
*
|
||||
*/
|
||||
private void ensureRecycleBin() {
|
||||
if (getRecycleBin() == null) {
|
||||
// Create recycle bin
|
||||
|
||||
PwGroupV4 recycleBin = new PwGroupV4(RECYCLEBIN_NAME, iconFactory.getIcon(PwIconStandard.TRASH_BIN));
|
||||
PwGroupV4 recycleBin = new PwGroupV4(RECYCLEBIN_NAME, iconFactory.getTrashIcon());
|
||||
recycleBin.setEnableAutoType(false);
|
||||
recycleBin.setEnableSearching(false);
|
||||
recycleBin.setExpanded(false);
|
||||
@@ -682,8 +687,7 @@ public class PwDatabaseV4 extends PwDatabase<PwGroupV4, PwEntryV4> {
|
||||
@Override
|
||||
public void undoDeleteEntry(PwEntryV4 entry, PwGroupV4 origParent) {
|
||||
super.undoDeleteEntry(entry, origParent);
|
||||
// TODO undo delete entry
|
||||
deletedObjects.remove(entry);
|
||||
deletedObjects.remove(new PwDeletedObject(entry.getUUID()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -696,14 +700,6 @@ public class PwDatabaseV4 extends PwDatabase<PwGroupV4, PwEntryV4> {
|
||||
return groups.get(recycleId);
|
||||
}
|
||||
|
||||
public KdfParameters getKdfParameters() {
|
||||
return kdfParameters;
|
||||
}
|
||||
|
||||
public void setKdfParameters(KdfParameters kdfParameters) {
|
||||
this.kdfParameters = kdfParameters;
|
||||
}
|
||||
|
||||
public VariantDictionary getPublicCustomData() {
|
||||
return publicCustomData;
|
||||
}
|
||||
@@ -740,9 +736,7 @@ public class PwDatabaseV4 extends PwDatabase<PwGroupV4, PwEntryV4> {
|
||||
|
||||
@Override
|
||||
public void initNew(String dbPath) {
|
||||
String filename = URLUtil.guessFileName(dbPath, null, null);
|
||||
|
||||
rootGroup = new PwGroupV4(dbNameFromPath(dbPath), iconFactory.getIcon(PwIconStandard.FOLDER));
|
||||
rootGroup = new PwGroupV4(dbNameFromPath(dbPath), iconFactory.getFolderIcon());
|
||||
groups.put(rootGroup.getId(), rootGroup);
|
||||
}
|
||||
|
||||
@@ -760,64 +754,8 @@ public class PwDatabaseV4 extends PwDatabase<PwGroupV4, PwEntryV4> {
|
||||
return filename.substring(0, lastExtDot);
|
||||
}
|
||||
|
||||
private class GroupHasCustomData extends GroupHandler<PwGroupV4> {
|
||||
|
||||
public boolean hasCustomData = false;
|
||||
|
||||
@Override
|
||||
public boolean operate(PwGroupV4 group) {
|
||||
if (group == null) {
|
||||
return true;
|
||||
public void clearCache() {
|
||||
binPool.clear();
|
||||
}
|
||||
if (group.containsCustomData()) {
|
||||
hasCustomData = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private class EntryHasCustomData extends EntryHandler<PwEntryV4> {
|
||||
|
||||
public boolean hasCustomData = false;
|
||||
|
||||
@Override
|
||||
public boolean operate(PwEntryV4 entry) {
|
||||
if (entry == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (entry.containsCustomData()) {
|
||||
hasCustomData = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public int getMinKdbxVersion() {
|
||||
if (!AesKdf.CIPHER_UUID.equals(kdfParameters.kdfUUID)) {
|
||||
return PwDbHeaderV4.FILE_VERSION_32;
|
||||
}
|
||||
|
||||
if (publicCustomData.size() > 0) {
|
||||
return PwDbHeaderV4.FILE_VERSION_32;
|
||||
}
|
||||
|
||||
EntryHasCustomData entryHandler = new EntryHasCustomData();
|
||||
GroupHasCustomData groupHandler = new GroupHasCustomData();
|
||||
|
||||
if (rootGroup == null ) {
|
||||
return PwDbHeaderV4.FILE_VERSION_32_3;
|
||||
}
|
||||
rootGroup.preOrderTraverseTree(groupHandler, entryHandler);
|
||||
if (groupHandler.hasCustomData || entryHandler.hasCustomData) {
|
||||
return PwDbHeaderV4.FILE_VERSION_32;
|
||||
}
|
||||
|
||||
return PwDbHeaderV4.FILE_VERSION_32_3;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,10 +19,12 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.database;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.kunzisoft.keepass.app.App;
|
||||
import com.kunzisoft.keepass.utils.Types;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
@@ -33,15 +35,14 @@ import java.util.Date;
|
||||
* @author bpellin
|
||||
*
|
||||
*/
|
||||
public class PwDate implements Cloneable, Serializable {
|
||||
public class PwDate implements Cloneable, Parcelable {
|
||||
|
||||
private static final int DATE_SIZE = 5;
|
||||
|
||||
private boolean cDateBuilt = false;
|
||||
private boolean jDateBuilt = false;
|
||||
|
||||
private Date jDate;
|
||||
private byte[] cDate;
|
||||
private boolean jDateBuilt = false;
|
||||
transient private byte[] cDate;
|
||||
transient private boolean cDateBuilt = false;
|
||||
|
||||
public static final Date NEVER_EXPIRE = getNeverExpire();
|
||||
public static final Date DEFAULT_DATE = getDefaultDate();
|
||||
@@ -94,6 +95,35 @@ public class PwDate implements Cloneable, Serializable {
|
||||
jDateBuilt = true;
|
||||
}
|
||||
|
||||
protected PwDate(Parcel in) {
|
||||
jDate = (Date) in.readSerializable();
|
||||
jDateBuilt = in.readByte() != 0;
|
||||
cDateBuilt = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeSerializable(getDate());
|
||||
dest.writeByte((byte) (jDateBuilt ? 1 : 0));
|
||||
}
|
||||
|
||||
public static final Creator<PwDate> CREATOR = new Creator<PwDate>() {
|
||||
@Override
|
||||
public PwDate createFromParcel(Parcel in) {
|
||||
return new PwDate(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PwDate[] newArray(int size) {
|
||||
return new PwDate[size];
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public PwDate clone() {
|
||||
PwDate copy = new PwDate();
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package com.kunzisoft.keepass.database;
|
||||
|
||||
import com.kunzisoft.keepass.crypto.keyDerivation.AesKdf;
|
||||
import com.kunzisoft.keepass.crypto.keyDerivation.KdfFactory;
|
||||
import com.kunzisoft.keepass.crypto.keyDerivation.KdfParameters;
|
||||
import com.kunzisoft.keepass.database.exception.InvalidDBVersionException;
|
||||
import com.kunzisoft.keepass.stream.CopyInputStream;
|
||||
@@ -45,7 +46,6 @@ public class PwDbHeaderV4 extends PwDbHeader {
|
||||
private static final int FILE_VERSION_CRITICAL_MASK = 0xFFFF0000;
|
||||
public static final int FILE_VERSION_32_3 = 0x00030001;
|
||||
public static final int FILE_VERSION_32_4 = 0x00040000;
|
||||
public static final int FILE_VERSION_32 = FILE_VERSION_32_4;
|
||||
|
||||
public class PwDbHeaderV4Fields {
|
||||
public static final byte EndOfHeader = 0;
|
||||
@@ -91,10 +91,81 @@ public class PwDbHeaderV4 extends PwDbHeader {
|
||||
public CrsAlgorithm innerRandomStream;
|
||||
public long version;
|
||||
|
||||
public PwDbHeaderV4(PwDatabaseV4 d) {
|
||||
db = d;
|
||||
version = d.getMinKdbxVersion();
|
||||
masterSeed = new byte[32];
|
||||
public PwDbHeaderV4(PwDatabaseV4 databaseV4) {
|
||||
this.db = databaseV4;
|
||||
this.version = getMinKdbxVersion(databaseV4); // Only for writing
|
||||
this.masterSeed = new byte[32];
|
||||
}
|
||||
|
||||
public long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
private class GroupHasCustomData extends GroupHandler<PwGroupV4> {
|
||||
|
||||
boolean hasCustomData = false;
|
||||
|
||||
@Override
|
||||
public boolean operate(PwGroupV4 group) {
|
||||
if (group == null) {
|
||||
return true;
|
||||
}
|
||||
if (group.containsCustomData()) {
|
||||
hasCustomData = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private class EntryHasCustomData extends EntryHandler<PwEntryV4> {
|
||||
|
||||
boolean hasCustomData = false;
|
||||
|
||||
@Override
|
||||
public boolean operate(PwEntryV4 entry) {
|
||||
if (entry == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (entry.containsCustomData()) {
|
||||
hasCustomData = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private int getMinKdbxVersion(PwDatabaseV4 databaseV4) {
|
||||
// Return v4 if AES is not use
|
||||
if (databaseV4.getKdfParameters() != null
|
||||
&& !databaseV4.getKdfParameters().getUUID().equals(AesKdf.CIPHER_UUID)) {
|
||||
return PwDbHeaderV4.FILE_VERSION_32_4;
|
||||
}
|
||||
|
||||
// Return V4 if custom data are present
|
||||
if (databaseV4.containsPublicCustomData()) {
|
||||
return PwDbHeaderV4.FILE_VERSION_32_4;
|
||||
}
|
||||
|
||||
EntryHasCustomData entryHandler = new EntryHasCustomData();
|
||||
GroupHasCustomData groupHandler = new GroupHasCustomData();
|
||||
|
||||
if (databaseV4.getRootGroup() == null ) {
|
||||
return PwDbHeaderV4.FILE_VERSION_32_3;
|
||||
}
|
||||
databaseV4.getRootGroup().preOrderTraverseTree(groupHandler, entryHandler);
|
||||
if (groupHandler.hasCustomData || entryHandler.hasCustomData) {
|
||||
return PwDbHeaderV4.FILE_VERSION_32_4;
|
||||
}
|
||||
|
||||
return PwDbHeaderV4.FILE_VERSION_32_3;
|
||||
}
|
||||
|
||||
/** Assumes the input stream is at the beginning of the .kdbx file
|
||||
@@ -122,7 +193,7 @@ public class PwDbHeaderV4 extends PwDbHeader {
|
||||
throw new InvalidDBVersionException();
|
||||
}
|
||||
|
||||
version = lis.readUInt();
|
||||
version = lis.readUInt(); // Erase previous value
|
||||
if ( ! validVersion(version) ) {
|
||||
throw new InvalidDBVersionException();
|
||||
}
|
||||
@@ -173,24 +244,13 @@ public class PwDbHeaderV4 extends PwDbHeader {
|
||||
break;
|
||||
|
||||
case PwDbHeaderV4Fields.TransformSeed:
|
||||
assert(version < PwDbHeaderV4.FILE_VERSION_32_4); // TODO file > FILEVERSION
|
||||
AesKdf kdfS = new AesKdf();
|
||||
if (!db.getKdfParameters().kdfUUID.equals(kdfS.uuid)) {
|
||||
db.setKdfParameters(kdfS.getDefaultParameters());
|
||||
}
|
||||
|
||||
db.getKdfParameters().setByteArray(AesKdf.ParamSeed, fieldData);
|
||||
if(version < PwDbHeaderV4.FILE_VERSION_32_4)
|
||||
setTransformSeed(fieldData);
|
||||
break;
|
||||
|
||||
case PwDbHeaderV4Fields.TransformRounds:
|
||||
assert(version < PwDbHeaderV4.FILE_VERSION_32_4);
|
||||
AesKdf kdfR = new AesKdf();
|
||||
if (!db.getKdfParameters().kdfUUID.equals(kdfR.uuid)) {
|
||||
db.setKdfParameters(kdfR.getDefaultParameters());
|
||||
}
|
||||
long rounds = LEDataInputStream.readLong(fieldData, 0);
|
||||
db.getKdfParameters().setUInt64(AesKdf.ParamRounds, rounds);
|
||||
db.setNumberKeyEncryptionRounds(rounds);
|
||||
if(version < PwDbHeaderV4.FILE_VERSION_32_4)
|
||||
setTransformRound(fieldData);
|
||||
break;
|
||||
|
||||
case PwDbHeaderV4Fields.EncryptionIV:
|
||||
@@ -198,7 +258,7 @@ public class PwDbHeaderV4 extends PwDbHeader {
|
||||
break;
|
||||
|
||||
case PwDbHeaderV4Fields.InnerRandomstreamKey:
|
||||
assert(version < PwDbHeaderV4.FILE_VERSION_32_4);
|
||||
if(version < PwDbHeaderV4.FILE_VERSION_32_4)
|
||||
innerRandomStreamKey = fieldData;
|
||||
break;
|
||||
|
||||
@@ -207,7 +267,7 @@ public class PwDbHeaderV4 extends PwDbHeader {
|
||||
break;
|
||||
|
||||
case PwDbHeaderV4Fields.InnerRandomStreamID:
|
||||
assert(version < PwDbHeaderV4.FILE_VERSION_32_4);
|
||||
if(version < PwDbHeaderV4.FILE_VERSION_32_4)
|
||||
setRandomStreamID(fieldData);
|
||||
break;
|
||||
|
||||
@@ -225,6 +285,12 @@ public class PwDbHeaderV4 extends PwDbHeader {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void assignAesKdfEngineIfNotExists() {
|
||||
if (db.getKdfParameters() == null || !db.getKdfParameters().getUUID().equals(KdfFactory.aesKdf.getUUID())) {
|
||||
db.setKdfParameters(KdfFactory.aesKdf.getDefaultParameters());
|
||||
}
|
||||
}
|
||||
|
||||
private void setCipher(byte[] pbId) throws IOException {
|
||||
if ( pbId == null || pbId.length != 16 ) {
|
||||
throw new IOException("Invalid cipher ID.");
|
||||
@@ -233,6 +299,18 @@ public class PwDbHeaderV4 extends PwDbHeader {
|
||||
db.setDataCipher(Types.bytestoUUID(pbId));
|
||||
}
|
||||
|
||||
private void setTransformSeed(byte[] seed) {
|
||||
assignAesKdfEngineIfNotExists();
|
||||
db.getKdfParameters().setByteArray(AesKdf.ParamSeed, seed);
|
||||
}
|
||||
|
||||
private void setTransformRound(byte[] roundsByte) {
|
||||
assignAesKdfEngineIfNotExists();
|
||||
long rounds = LEDataInputStream.readLong(roundsByte, 0);
|
||||
db.getKdfParameters().setUInt64(AesKdf.ParamRounds, rounds);
|
||||
db.setNumberKeyEncryptionRounds(rounds);
|
||||
}
|
||||
|
||||
private void setCompressionFlags(byte[] pbFlags) throws IOException {
|
||||
if ( pbFlags == null || pbFlags.length != 4 ) {
|
||||
throw new IOException("Invalid compression flags.");
|
||||
@@ -244,23 +322,6 @@ public class PwDbHeaderV4 extends PwDbHeader {
|
||||
}
|
||||
|
||||
db.setCompressionAlgorithm(PwCompressionAlgorithm.fromId(flag));
|
||||
|
||||
}
|
||||
|
||||
private void setTransformRounds(byte[] rounds) throws IOException {
|
||||
if ( rounds == null || rounds.length != 8 ) {
|
||||
throw new IOException("Invalid rounds.");
|
||||
}
|
||||
|
||||
long rnd = LEDataInputStream.readLong(rounds, 0);
|
||||
|
||||
if ( rnd < 0 || rnd > Integer.MAX_VALUE ) {
|
||||
//TODO: Actually support really large numbers
|
||||
throw new IOException("Rounds higher than " + Integer.MAX_VALUE + " are not currently supported.");
|
||||
}
|
||||
|
||||
db.setNumberKeyEncryptionRounds(rnd);
|
||||
|
||||
}
|
||||
|
||||
public void setRandomStreamID(byte[] streamID) throws IOException {
|
||||
@@ -276,25 +337,22 @@ public class PwDbHeaderV4 extends PwDbHeader {
|
||||
innerRandomStream = CrsAlgorithm.fromId(id);
|
||||
}
|
||||
|
||||
/** Determines if this is a supported version.
|
||||
/**
|
||||
* Determines if this is a supported version.
|
||||
*
|
||||
* A long is needed here to represent the unsigned int since we perform
|
||||
* arithmetic on it.
|
||||
* @param version
|
||||
* @return
|
||||
* A long is needed here to represent the unsigned int since we perform arithmetic on it.
|
||||
* @param version Database version
|
||||
* @return true if it's a supported version
|
||||
*/
|
||||
private boolean validVersion(long version) {
|
||||
|
||||
return ! ((version & FILE_VERSION_CRITICAL_MASK) > (FILE_VERSION_32 & FILE_VERSION_CRITICAL_MASK));
|
||||
|
||||
return ! ((version & FILE_VERSION_CRITICAL_MASK) > (FILE_VERSION_32_4 & FILE_VERSION_CRITICAL_MASK));
|
||||
}
|
||||
|
||||
public static boolean matchesHeader(int sig1, int sig2) {
|
||||
return (sig1 == PWM_DBSIG_1) && ( (sig2 == DBSIG_2) || (sig2 == DBSIG_2) );
|
||||
return (sig1 == PWM_DBSIG_1) && ( (sig2 == DBSIG_PRE2) || (sig2 == DBSIG_2) );
|
||||
}
|
||||
|
||||
public static byte[] computeHeaderHmac(byte[] header, byte[] key) throws IOException{
|
||||
byte[] headerHmac;
|
||||
byte[] blockKey = HmacBlockStream.GetHmacKey64(key, Types.ULONG_MAX_VALUE);
|
||||
|
||||
Mac hmac;
|
||||
@@ -312,8 +370,7 @@ public class PwDbHeaderV4 extends PwDbHeader {
|
||||
}
|
||||
|
||||
public byte[] getTransformSeed() {
|
||||
assert(version < FILE_VERSION_32_4);
|
||||
|
||||
// version < FILE_VERSION_32_4)
|
||||
return db.getKdfParameters().getByteArray(AesKdf.ParamSeed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,14 @@ package com.kunzisoft.keepass.database;
|
||||
import android.content.res.Resources;
|
||||
|
||||
import com.kunzisoft.keepass.R;
|
||||
import com.kunzisoft.keepass.crypto.engine.AesEngine;
|
||||
import com.kunzisoft.keepass.crypto.engine.ChaCha20Engine;
|
||||
import com.kunzisoft.keepass.crypto.engine.CipherEngine;
|
||||
import com.kunzisoft.keepass.crypto.engine.TwofishEngine;
|
||||
|
||||
public enum PwEncryptionAlgorithm {
|
||||
import java.util.UUID;
|
||||
|
||||
public enum PwEncryptionAlgorithm implements ObjectNameResource {
|
||||
|
||||
AES_Rijndael,
|
||||
Twofish,
|
||||
@@ -33,11 +39,35 @@ public enum PwEncryptionAlgorithm {
|
||||
switch (this) {
|
||||
default:
|
||||
case AES_Rijndael:
|
||||
return resources.getString(R.string.rijndael);
|
||||
return resources.getString(R.string.encryption_rijndael);
|
||||
case Twofish:
|
||||
return resources.getString(R.string.twofish);
|
||||
return resources.getString(R.string.encryption_twofish);
|
||||
case ChaCha20:
|
||||
return resources.getString(R.string.chacha20);
|
||||
return resources.getString(R.string.encryption_chacha20);
|
||||
}
|
||||
}
|
||||
|
||||
public CipherEngine getCipherEngine() {
|
||||
switch (this) {
|
||||
default:
|
||||
case AES_Rijndael:
|
||||
return new AesEngine();
|
||||
case Twofish:
|
||||
return new TwofishEngine();
|
||||
case ChaCha20:
|
||||
return new ChaCha20Engine();
|
||||
}
|
||||
}
|
||||
|
||||
public UUID getDataCipher() {
|
||||
switch (this) {
|
||||
default:
|
||||
case AES_Rijndael:
|
||||
return AesEngine.CIPHER_UUID;
|
||||
case Twofish:
|
||||
return TwofishEngine.CIPHER_UUID;
|
||||
case ChaCha20:
|
||||
return ChaCha20Engine.CIPHER_UUID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,50 +19,42 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.database;
|
||||
|
||||
import android.os.Parcel;
|
||||
|
||||
import com.kunzisoft.keepass.database.iterator.EntrySearchStringIterator;
|
||||
import com.kunzisoft.keepass.database.security.ProtectedString;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class PwEntry<Parent extends PwGroup> extends PwNode<Parent> implements Cloneable {
|
||||
public abstract class PwEntry<Parent extends PwGroup> extends PwNode<Parent> {
|
||||
|
||||
private static final String PMS_TAN_ENTRY = "<TAN>";
|
||||
|
||||
protected UUID uuid = PwDatabase.UUID_ZERO;
|
||||
|
||||
public PwEntry() {}
|
||||
|
||||
public PwEntry(Parcel in) {
|
||||
super(in);
|
||||
uuid = (UUID) in.readSerializable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeSerializable(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void construct(Parent parent) {
|
||||
super.construct(parent);
|
||||
uuid = UUID.randomUUID();
|
||||
}
|
||||
|
||||
public static PwEntry getInstance(PwGroup parent) {
|
||||
if (parent instanceof PwGroupV3) {
|
||||
return new PwEntryV3((PwGroupV3)parent);
|
||||
}
|
||||
else if (parent instanceof PwGroupV4) {
|
||||
return new PwEntryV4((PwGroupV4)parent);
|
||||
}
|
||||
else {
|
||||
throw new RuntimeException("Unknown PwGroup instance.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PwEntry clone() {
|
||||
PwEntry newEntry;
|
||||
try {
|
||||
newEntry = (PwEntry) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new RuntimeException("Clone should be supported");
|
||||
}
|
||||
return newEntry;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addCloneAttributesToNewEntry(PwEntry newEntry) {
|
||||
super.addCloneAttributesToNewEntry(newEntry);
|
||||
// uuid is clone automatically (IMMUTABLE)
|
||||
return (PwEntry) super.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -84,7 +76,7 @@ public abstract class PwEntry<Parent extends PwGroup> extends PwNode<Parent> imp
|
||||
}
|
||||
|
||||
public void startToManageFieldReferences(PwDatabase db) {}
|
||||
public void endToManageFieldReferences() {}
|
||||
public void stopToManageFieldReferences() {}
|
||||
|
||||
public abstract String getTitle();
|
||||
public abstract void setTitle(String title);
|
||||
@@ -105,12 +97,28 @@ public abstract class PwEntry<Parent extends PwGroup> extends PwNode<Parent> imp
|
||||
return getTitle().equals(PMS_TAN_ENTRY) && (getUsername().length() > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayTitle() {
|
||||
if ( isTan() ) {
|
||||
return PMS_TAN_ENTRY + " " + getUsername();
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* Get the display title from an entry, <br />
|
||||
* {@link #startToManageFieldReferences(PwDatabase)} and {@link #stopToManageFieldReferences()} must be called
|
||||
* before and after {@link #getVisualTitle()}
|
||||
*/
|
||||
public String getVisualTitle() {
|
||||
// only used to compare, don't car if it's a reference
|
||||
return getVisualTitle(isTan(), getTitle(), getUsername(), getUrl(), getUUID());
|
||||
}
|
||||
|
||||
public static String getVisualTitle(boolean isTAN, String title, String username, String url, UUID uuid) {
|
||||
if ( isTAN ) {
|
||||
return PMS_TAN_ENTRY + " " + username;
|
||||
} else {
|
||||
return getTitle();
|
||||
if (title.isEmpty())
|
||||
if (url.isEmpty())
|
||||
return uuid.toString();
|
||||
else
|
||||
return url;
|
||||
else
|
||||
return title;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,6 +148,22 @@ public abstract class PwEntry<Parent extends PwGroup> extends PwNode<Parent> imp
|
||||
return getFields().containsCustomFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* If entry contains extra fields that are protected
|
||||
* @return true if there is extra fields protected
|
||||
*/
|
||||
public boolean containsCustomFieldsProtected() {
|
||||
return getFields().containsCustomFieldsProtected();
|
||||
}
|
||||
|
||||
/**
|
||||
* If entry contains extra fields that are not protected
|
||||
* @return true if there is extra fields not protected
|
||||
*/
|
||||
public boolean containsCustomFieldsNotProtected() {
|
||||
return getFields().containsCustomFieldsNotProtected();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an extra field to the list (standard or custom)
|
||||
* @param label Label of field, must be unique
|
||||
|
||||
@@ -42,6 +42,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
package com.kunzisoft.keepass.database;
|
||||
|
||||
import android.os.Parcel;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -75,15 +77,11 @@ public class PwEntryV3 extends PwEntry<PwGroupV3> {
|
||||
private static final String PMS_ID_USER = "SYSTEM";
|
||||
private static final String PMS_ID_URL = "$";
|
||||
|
||||
// TODO Parent ID to remove
|
||||
private int groupId;
|
||||
|
||||
private String title;
|
||||
private String username;
|
||||
private byte[] password;
|
||||
private String url;
|
||||
private String additional;
|
||||
|
||||
/** A string describing what is in pBinaryData */
|
||||
private String binaryDesc;
|
||||
private byte[] binaryData;
|
||||
@@ -94,11 +92,45 @@ public class PwEntryV3 extends PwEntry<PwGroupV3> {
|
||||
|
||||
public PwEntryV3(PwGroupV3 p) {
|
||||
construct(p);
|
||||
groupId = ((PwGroupIdV3) this.parent.getId()).getId(); // TODO remove
|
||||
}
|
||||
|
||||
public PwEntryV3(Parcel in) {
|
||||
super(in);
|
||||
title = in.readString();
|
||||
username = in.readString();
|
||||
in.readByteArray(password);
|
||||
url = in.readString();
|
||||
additional = in.readString();
|
||||
binaryDesc = in.readString();
|
||||
in.readByteArray(binaryData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeString(title);
|
||||
dest.writeString(username);
|
||||
dest.writeByteArray(password);
|
||||
dest.writeString(url);
|
||||
dest.writeString(additional);
|
||||
dest.writeString(binaryDesc);
|
||||
dest.writeByteArray(binaryData);
|
||||
}
|
||||
|
||||
public static final Creator<PwEntryV3> CREATOR = new Creator<PwEntryV3>() {
|
||||
@Override
|
||||
public PwEntryV3 createFromParcel(Parcel in) {
|
||||
return new PwEntryV3(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PwEntryV3[] newArray(int size) {
|
||||
return new PwEntryV3[size];
|
||||
}
|
||||
};
|
||||
|
||||
protected void updateWith(PwEntryV3 source) {
|
||||
groupId = source.groupId;
|
||||
super.assign(source);
|
||||
|
||||
title = source.title;
|
||||
username = source.username;
|
||||
@@ -118,10 +150,8 @@ public class PwEntryV3 extends PwEntry<PwGroupV3> {
|
||||
|
||||
@Override
|
||||
public PwEntryV3 clone() {
|
||||
PwEntryV3 newEntry = (PwEntryV3) super.clone();
|
||||
|
||||
// Attributes in parent
|
||||
addCloneAttributesToNewEntry(newEntry);
|
||||
PwEntryV3 newEntry = (PwEntryV3) super.clone();
|
||||
|
||||
// Attributes here
|
||||
// newEntry.parent stay the same in copy
|
||||
@@ -146,12 +176,9 @@ public class PwEntryV3 extends PwEntry<PwGroupV3> {
|
||||
return newEntry;
|
||||
}
|
||||
|
||||
public int getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(int groupId) {
|
||||
this.groupId = groupId;
|
||||
this.parent = new PwGroupV3();
|
||||
this.parent.setGroupId(groupId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -200,7 +227,7 @@ public class PwEntryV3 extends PwEntry<PwGroupV3> {
|
||||
public void populateBlankFields(PwDatabaseV3 db) {
|
||||
// TODO verify and remove
|
||||
if (icon == null) {
|
||||
icon = db.getIconFactory().getFirstIcon();
|
||||
icon = db.getIconFactory().getKeyIcon();
|
||||
}
|
||||
|
||||
if (username == null) {
|
||||
|
||||
@@ -19,8 +19,11 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.database;
|
||||
|
||||
import android.os.Parcel;
|
||||
|
||||
import com.kunzisoft.keepass.database.security.ProtectedBinary;
|
||||
import com.kunzisoft.keepass.database.security.ProtectedString;
|
||||
import com.kunzisoft.keepass.utils.MemUtil;
|
||||
import com.kunzisoft.keepass.utils.SprEngineV4;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -37,7 +40,7 @@ public class PwEntryV4 extends PwEntry<PwGroupV4> implements ITimeLogger {
|
||||
public static final String STR_URL = "URL";
|
||||
public static final String STR_NOTES = "Notes";
|
||||
|
||||
// To decode each field not serializable
|
||||
// To decode each field not parcelable
|
||||
private transient PwDatabaseV4 mDatabase = null;
|
||||
private transient boolean mDecodeRef = false;
|
||||
|
||||
@@ -45,7 +48,6 @@ public class PwEntryV4 extends PwEntry<PwGroupV4> implements ITimeLogger {
|
||||
private long usageCount = 0;
|
||||
private PwDate parentGroupLastMod = new PwDate();
|
||||
private Map<String, String> customData = new HashMap<>();
|
||||
|
||||
private ExtraFields fields = new ExtraFields();
|
||||
private HashMap<String, ProtectedBinary> binaries = new HashMap<>();
|
||||
private String foregroundColor = "";
|
||||
@@ -53,7 +55,6 @@ public class PwEntryV4 extends PwEntry<PwGroupV4> implements ITimeLogger {
|
||||
private String overrideURL = "";
|
||||
private AutoType autoType = new AutoType();
|
||||
private ArrayList<PwEntryV4> history = new ArrayList<>();
|
||||
|
||||
private String url = "";
|
||||
private String additional = "";
|
||||
private String tags = "";
|
||||
@@ -71,8 +72,8 @@ public class PwEntryV4 extends PwEntry<PwGroupV4> implements ITimeLogger {
|
||||
customIcon = source.customIcon;
|
||||
usageCount = source.usageCount;
|
||||
parentGroupLastMod = source.parentGroupLastMod;
|
||||
// TODO customData
|
||||
|
||||
customData.clear();
|
||||
customData.putAll(source.customData); // Add all custom elements in map
|
||||
fields = source.fields;
|
||||
binaries = source.binaries;
|
||||
foregroundColor = source.foregroundColor;
|
||||
@@ -80,19 +81,65 @@ public class PwEntryV4 extends PwEntry<PwGroupV4> implements ITimeLogger {
|
||||
overrideURL = source.overrideURL;
|
||||
autoType = source.autoType;
|
||||
history = source.history;
|
||||
|
||||
url = source.url;
|
||||
additional = source.additional;
|
||||
tags = source.tags;
|
||||
}
|
||||
|
||||
public PwEntryV4(Parcel in) {
|
||||
super(in);
|
||||
customIcon = in.readParcelable(PwIconCustom.class.getClassLoader());
|
||||
usageCount = in.readLong();
|
||||
parentGroupLastMod = in.readParcelable(PwDate.class.getClassLoader());
|
||||
customData = MemUtil.readStringParcelableMap(in);
|
||||
fields = in.readParcelable(ExtraFields.class.getClassLoader());
|
||||
binaries = MemUtil.readStringParcelableMap(in, ProtectedBinary.class);
|
||||
foregroundColor = in.readString();
|
||||
backgroupColor = in.readString();
|
||||
overrideURL = in.readString();
|
||||
autoType = in.readParcelable(AutoType.class.getClassLoader());
|
||||
history = in.readArrayList(PwEntryV4.class.getClassLoader()); // TODO verify
|
||||
url = in.readString();
|
||||
additional = in.readString();
|
||||
tags = in.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeParcelable(customIcon, flags);
|
||||
dest.writeLong(usageCount);
|
||||
dest.writeParcelable(parentGroupLastMod, flags);
|
||||
MemUtil.writeStringParcelableMap(dest, customData);
|
||||
dest.writeParcelable(fields, flags);
|
||||
// TODO MemUtil.writeStringParcelableMap(dest, flags, binaries);
|
||||
dest.writeString(foregroundColor);
|
||||
dest.writeString(backgroupColor);
|
||||
dest.writeString(overrideURL);
|
||||
dest.writeParcelable(autoType, flags);
|
||||
dest.writeList(history);
|
||||
dest.writeString(url);
|
||||
dest.writeString(additional);
|
||||
dest.writeString(tags);
|
||||
}
|
||||
|
||||
public static final Creator<PwEntryV4> CREATOR = new Creator<PwEntryV4>() {
|
||||
@Override
|
||||
public PwEntryV4 createFromParcel(Parcel in) {
|
||||
return new PwEntryV4(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PwEntryV4[] newArray(int size) {
|
||||
return new PwEntryV4[size];
|
||||
}
|
||||
};
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public PwEntryV4 clone() {
|
||||
PwEntryV4 newEntry = (PwEntryV4) super.clone();
|
||||
|
||||
// Attributes in parent
|
||||
addCloneAttributesToNewEntry(newEntry);
|
||||
PwEntryV4 newEntry = (PwEntryV4) super.clone();
|
||||
|
||||
// Attributes here
|
||||
newEntry.customIcon = new PwIconCustom(this.customIcon);
|
||||
@@ -122,7 +169,7 @@ public class PwEntryV4 extends PwEntry<PwGroupV4> implements ITimeLogger {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endToManageFieldReferences() {
|
||||
public void stopToManageFieldReferences() {
|
||||
this.mDatabase = null;
|
||||
this.mDecodeRef = false;
|
||||
}
|
||||
@@ -158,41 +205,31 @@ public class PwEntryV4 extends PwEntry<PwGroupV4> implements ITimeLogger {
|
||||
|
||||
@Override
|
||||
public void setTitle(String title) {
|
||||
PwDatabaseV4 db = mDatabase;
|
||||
boolean protect = db.getMemoryProtection().protectTitle;
|
||||
|
||||
boolean protect = (mDatabase != null) && mDatabase.getMemoryProtection().protectTitle;
|
||||
setProtectedString(STR_TITLE, title, protect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUsername(String user) {
|
||||
PwDatabaseV4 db = mDatabase;
|
||||
boolean protect = db.getMemoryProtection().protectUserName;
|
||||
|
||||
boolean protect = (mDatabase != null) && mDatabase.getMemoryProtection().protectUserName;
|
||||
setProtectedString(STR_USERNAME, user, protect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassword(String pass) {
|
||||
PwDatabaseV4 db = mDatabase;
|
||||
boolean protect = db.getMemoryProtection().protectPassword;
|
||||
|
||||
boolean protect = (mDatabase != null) && mDatabase.getMemoryProtection().protectPassword;
|
||||
setProtectedString(STR_PASSWORD, pass, protect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUrl(String url) {
|
||||
PwDatabaseV4 db = mDatabase;
|
||||
boolean protect = db.getMemoryProtection().protectUrl;
|
||||
|
||||
boolean protect = (mDatabase != null) && mDatabase.getMemoryProtection().protectUrl;
|
||||
setProtectedString(STR_URL, url, protect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNotes(String notes) {
|
||||
PwDatabaseV4 db = mDatabase;
|
||||
boolean protect = db.getMemoryProtection().protectNotes;
|
||||
|
||||
boolean protect = (mDatabase != null) && mDatabase.getMemoryProtection().protectNotes;
|
||||
setProtectedString(STR_NOTES, notes, protect);
|
||||
}
|
||||
|
||||
@@ -204,14 +241,6 @@ public class PwEntryV4 extends PwEntry<PwGroupV4> implements ITimeLogger {
|
||||
fields.putProtectedString(key, value, protect);
|
||||
}
|
||||
|
||||
public PwIconCustom getCustomIcon() {
|
||||
return customIcon;
|
||||
}
|
||||
|
||||
public void setCustomIcon(PwIconCustom icon) {
|
||||
this.customIcon = icon;
|
||||
}
|
||||
|
||||
public PwDate getLocationChanged() {
|
||||
return parentGroupLastMod;
|
||||
}
|
||||
@@ -240,13 +269,26 @@ public class PwEntryV4 extends PwEntry<PwGroupV4> implements ITimeLogger {
|
||||
|
||||
@Override
|
||||
public PwIcon getIcon() {
|
||||
if (customIcon == null || customIcon.uuid.equals(PwDatabase.UUID_ZERO)) {
|
||||
if (customIcon == null || customIcon.isUnknown()) {
|
||||
return super.getIcon();
|
||||
} else {
|
||||
return customIcon;
|
||||
}
|
||||
}
|
||||
|
||||
public void setIconCustom(PwIconCustom icon) {
|
||||
this.customIcon = icon;
|
||||
}
|
||||
|
||||
public PwIconCustom getIconCustom() {
|
||||
return customIcon;
|
||||
}
|
||||
|
||||
public void setIconStandard(PwIconStandard icon) {
|
||||
this.icon = icon;
|
||||
this.customIcon = PwIconCustom.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowExtraFields() {
|
||||
return true;
|
||||
|
||||
@@ -19,59 +19,83 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.database;
|
||||
|
||||
import android.os.Parcel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class PwGroup<Parent extends PwGroup, ChildGroup extends PwGroup, ChildEntry extends PwEntry>
|
||||
extends PwNode<Parent> {
|
||||
public abstract class PwGroup<GroupG extends PwGroup, EntryE extends PwEntry>
|
||||
extends PwNode<GroupG> {
|
||||
|
||||
protected String name = "";
|
||||
|
||||
protected List<ChildGroup> childGroups = new ArrayList<>();
|
||||
protected List<ChildEntry> childEntries = new ArrayList<>();
|
||||
// TODO verify children not needed
|
||||
transient protected List<GroupG> childGroups = new ArrayList<>();
|
||||
transient protected List<EntryE> childEntries = new ArrayList<>();
|
||||
|
||||
public void initNewGroup(String nm, PwGroupId newId) {
|
||||
setId(newId);
|
||||
name = nm;
|
||||
protected PwGroup() {
|
||||
super();
|
||||
}
|
||||
|
||||
public List<ChildGroup> getChildGroups() {
|
||||
protected PwGroup(Parcel in) {
|
||||
super(in);
|
||||
name = in.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeString(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PwGroup clone() {
|
||||
// name is clone automatically (IMMUTABLE)
|
||||
return (PwGroup) super.clone();
|
||||
}
|
||||
|
||||
protected void assign(PwGroup<GroupG, EntryE> source) {
|
||||
super.assign(source);
|
||||
name = source.name;
|
||||
}
|
||||
|
||||
public List<GroupG> getChildGroups() {
|
||||
return childGroups;
|
||||
}
|
||||
|
||||
public List<ChildEntry> getChildEntries() {
|
||||
public List<EntryE> getChildEntries() {
|
||||
return childEntries;
|
||||
}
|
||||
|
||||
public void setGroups(List<ChildGroup> groups) {
|
||||
public void setGroups(List<GroupG> groups) {
|
||||
childGroups = groups;
|
||||
}
|
||||
|
||||
public void setEntries(List<ChildEntry> entries) {
|
||||
public void setEntries(List<EntryE> entries) {
|
||||
childEntries = entries;
|
||||
}
|
||||
|
||||
public void addChildGroup(ChildGroup group) {
|
||||
public void addChildGroup(GroupG group) {
|
||||
this.childGroups.add(group);
|
||||
}
|
||||
|
||||
public void addChildEntry(ChildEntry entry) {
|
||||
public void addChildEntry(EntryE entry) {
|
||||
this.childEntries.add(entry);
|
||||
}
|
||||
|
||||
public ChildGroup getChildGroupAt(int number) {
|
||||
public GroupG getChildGroupAt(int number) {
|
||||
return this.childGroups.get(number);
|
||||
}
|
||||
|
||||
public ChildEntry getChildEntryAt(int number) {
|
||||
public EntryE getChildEntryAt(int number) {
|
||||
return this.childEntries.get(number);
|
||||
}
|
||||
|
||||
public void removeChildGroup(ChildGroup group) {
|
||||
public void removeChildGroup(GroupG group) {
|
||||
this.childGroups.remove(group);
|
||||
}
|
||||
|
||||
public void removeChildEntry(ChildEntry entry) {
|
||||
public void removeChildEntry(EntryE entry) {
|
||||
this.childEntries.remove(entry);
|
||||
}
|
||||
|
||||
@@ -95,7 +119,7 @@ public abstract class PwGroup<Parent extends PwGroup, ChildGroup extends PwGroup
|
||||
public List<PwNode> getDirectChildren() {
|
||||
List<PwNode> children = new ArrayList<>();
|
||||
children.addAll(childGroups);
|
||||
for(ChildEntry child : childEntries) {
|
||||
for(EntryE child : childEntries) {
|
||||
if (!child.isMetaStream())
|
||||
children.add(child);
|
||||
}
|
||||
@@ -106,10 +130,18 @@ public abstract class PwGroup<Parent extends PwGroup, ChildGroup extends PwGroup
|
||||
public abstract void setId(PwGroupId id);
|
||||
|
||||
@Override
|
||||
public String getDisplayTitle() {
|
||||
protected String getVisualTitle() {
|
||||
return getTitle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* The same thing as {@link #getTitle()}
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -122,15 +154,15 @@ public abstract class PwGroup<Parent extends PwGroup, ChildGroup extends PwGroup
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean preOrderTraverseTree(GroupHandler<ChildGroup> groupHandler,
|
||||
EntryHandler<ChildEntry> entryHandler) {
|
||||
public boolean preOrderTraverseTree(GroupHandler<GroupG> groupHandler,
|
||||
EntryHandler<EntryE> entryHandler) {
|
||||
if (entryHandler != null) {
|
||||
for (ChildEntry entry : childEntries) {
|
||||
for (EntryE entry : childEntries) {
|
||||
if (!entryHandler.operate(entry)) return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (ChildGroup group : childGroups) {
|
||||
for (GroupG group : childGroups) {
|
||||
if ((groupHandler != null) && !groupHandler.operate(group)) return false;
|
||||
group.preOrderTraverseTree(groupHandler, entryHandler);
|
||||
}
|
||||
|
||||
@@ -19,8 +19,20 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.database;
|
||||
|
||||
import java.io.Serializable;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
public abstract class PwGroupId implements Serializable {
|
||||
public abstract class PwGroupId implements Parcelable {
|
||||
|
||||
public PwGroupId() {}
|
||||
|
||||
public PwGroupId(Parcel in) {}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,14 +19,40 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.database;
|
||||
|
||||
import android.os.Parcel;
|
||||
|
||||
public class PwGroupIdV3 extends PwGroupId {
|
||||
|
||||
private int id;
|
||||
|
||||
public PwGroupIdV3(int i) {
|
||||
id = i;
|
||||
public PwGroupIdV3(int groupId) {
|
||||
super();
|
||||
this.id = groupId;
|
||||
}
|
||||
|
||||
public PwGroupIdV3(Parcel in) {
|
||||
super(in);
|
||||
id = in.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeInt(id);
|
||||
}
|
||||
|
||||
public static final Creator<PwGroupIdV3> CREATOR = new Creator<PwGroupIdV3>() {
|
||||
@Override
|
||||
public PwGroupIdV3 createFromParcel(Parcel in) {
|
||||
return new PwGroupIdV3(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PwGroupIdV3[] newArray(int size) {
|
||||
return new PwGroupIdV3[size];
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean equals(Object compare) {
|
||||
if ( ! (compare instanceof PwGroupIdV3) ) {
|
||||
|
||||
@@ -19,15 +19,42 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.database;
|
||||
|
||||
import android.os.Parcel;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PwGroupIdV4 extends PwGroupId {
|
||||
|
||||
private UUID uuid;
|
||||
|
||||
public PwGroupIdV4(UUID u) {
|
||||
uuid = u;
|
||||
public PwGroupIdV4(UUID uuid) {
|
||||
super();
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public PwGroupIdV4(Parcel in) {
|
||||
super(in);
|
||||
uuid = (UUID) in.readSerializable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeSerializable(uuid);
|
||||
}
|
||||
|
||||
public static final Creator<PwGroupIdV4> CREATOR = new Creator<PwGroupIdV4>() {
|
||||
@Override
|
||||
public PwGroupIdV4 createFromParcel(Parcel in) {
|
||||
return new PwGroupIdV4(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PwGroupIdV4[] newArray(int size) {
|
||||
return new PwGroupIdV4[size];
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean equals(Object id) {
|
||||
if ( ! (id instanceof PwGroupIdV4) ) {
|
||||
|
||||
@@ -20,19 +20,13 @@
|
||||
|
||||
package com.kunzisoft.keepass.database;
|
||||
|
||||
/**
|
||||
* @author Brian Pellin <bpellin@gmail.com>
|
||||
* @author Naomaru Itoi <nao@phoneid.org>
|
||||
* @author Bill Zwicky <wrzwicky@pobox.com>
|
||||
* @author Dominik Reichl <dominik.reichl@t-online.de>
|
||||
*/
|
||||
public class PwGroupV3 extends PwGroup<PwGroupV3, PwGroupV3, PwEntryV3> {
|
||||
import android.os.Parcel;
|
||||
|
||||
public class PwGroupV3 extends PwGroup<PwGroupV3, PwEntryV3> {
|
||||
|
||||
// for tree traversing
|
||||
private int groupId;
|
||||
|
||||
private int level = 0; // short
|
||||
|
||||
/** Used by KeePass internally, don't use */
|
||||
private int flags;
|
||||
|
||||
@@ -40,6 +34,53 @@ public class PwGroupV3 extends PwGroup<PwGroupV3, PwGroupV3, PwEntryV3> {
|
||||
super();
|
||||
}
|
||||
|
||||
public PwGroupV3(Parcel in) {
|
||||
super(in);
|
||||
groupId = in.readInt();
|
||||
level = in.readInt();
|
||||
flags = in.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeInt(groupId);
|
||||
dest.writeInt(level);
|
||||
dest.writeInt(flags);
|
||||
}
|
||||
|
||||
public static final Creator<PwGroupV3> CREATOR = new Creator<PwGroupV3>() {
|
||||
@Override
|
||||
public PwGroupV3 createFromParcel(Parcel in) {
|
||||
return new PwGroupV3(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PwGroupV3[] newArray(int size) {
|
||||
return new PwGroupV3[size];
|
||||
}
|
||||
};
|
||||
|
||||
public PwGroupV3(PwGroupV3 p) {
|
||||
construct(p);
|
||||
}
|
||||
|
||||
protected void updateWith(PwGroupV3 source) {
|
||||
super.assign(source);
|
||||
groupId = source.groupId;
|
||||
level = source.level;
|
||||
flags = source.flags;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public PwGroupV3 clone() {
|
||||
// newGroup.groupId stay the same in copy
|
||||
// newGroup.level stay the same in copy
|
||||
// newGroup.flags stay the same in copy
|
||||
return (PwGroupV3) super.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParent(PwGroupV3 parent) {
|
||||
super.setParent(parent);
|
||||
@@ -89,7 +130,7 @@ public class PwGroupV3 extends PwGroup<PwGroupV3, PwGroupV3, PwEntryV3> {
|
||||
public void populateBlankFields(PwDatabaseV3 db) {
|
||||
// TODO populate blanck field
|
||||
if (icon == null) {
|
||||
icon = db.getIconFactory().getFirstIcon();
|
||||
icon = db.getIconFactory().getFolderIcon();
|
||||
}
|
||||
|
||||
if (name == null) {
|
||||
|
||||
@@ -19,11 +19,15 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.database;
|
||||
|
||||
import android.os.Parcel;
|
||||
|
||||
import com.kunzisoft.keepass.utils.MemUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PwGroupV4 extends PwGroup<PwGroupV4, PwGroupV4, PwEntryV4> implements ITimeLogger {
|
||||
public class PwGroupV4 extends PwGroup<PwGroupV4, PwEntryV4> implements ITimeLogger {
|
||||
|
||||
public static final boolean DEFAULT_SEARCHING_ENABLED = true;
|
||||
|
||||
@@ -32,9 +36,7 @@ public class PwGroupV4 extends PwGroup<PwGroupV4, PwGroupV4, PwEntryV4> implemen
|
||||
private long usageCount = 0;
|
||||
private PwDate parentGroupLastMod = new PwDate();
|
||||
private Map<String, String> customData = new HashMap<>();
|
||||
|
||||
private boolean expires = false;
|
||||
|
||||
private String notes = "";
|
||||
private boolean isExpanded = true;
|
||||
private String defaultAutoTypeSequence = "";
|
||||
@@ -46,16 +48,105 @@ public class PwGroupV4 extends PwGroup<PwGroupV4, PwGroupV4, PwEntryV4> implemen
|
||||
super();
|
||||
}
|
||||
|
||||
public PwGroupV4(PwGroupV4 p) {
|
||||
construct(p);
|
||||
parentGroupLastMod = new PwDate();
|
||||
}
|
||||
|
||||
public PwGroupV4(String name, PwIconStandard icon) {
|
||||
this.uuid = UUID.randomUUID();
|
||||
this.name = name;
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public PwGroupV4(Parcel in) {
|
||||
super(in);
|
||||
uuid = (UUID) in.readSerializable();
|
||||
customIcon = in.readParcelable(PwIconCustom.class.getClassLoader());
|
||||
usageCount = in.readLong();
|
||||
parentGroupLastMod = in.readParcelable(PwDate.class.getClassLoader());
|
||||
// TODO customData = MemUtil.readStringParcelableMap(in);
|
||||
expires = in.readByte() != 0;
|
||||
notes = in.readString();
|
||||
isExpanded = in.readByte() != 0;
|
||||
defaultAutoTypeSequence = in.readString();
|
||||
byte autoTypeByte = in.readByte();
|
||||
enableAutoType = (autoTypeByte == -1) ? null : autoTypeByte != 0;
|
||||
byte enableSearchingByte = in.readByte();
|
||||
enableSearching = (enableSearchingByte == -1) ? null : enableSearchingByte != 0;
|
||||
lastTopVisibleEntry = (UUID) in.readSerializable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initNewGroup(String nm, PwGroupId newId) {
|
||||
super.initNewGroup(nm, newId);
|
||||
parentGroupLastMod = new PwDate();
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeSerializable(uuid);
|
||||
dest.writeParcelable(customIcon, flags);
|
||||
dest.writeLong(usageCount);
|
||||
dest.writeParcelable(parentGroupLastMod, flags);
|
||||
// TODO MemUtil.writeStringParcelableMap(dest, customData);
|
||||
dest.writeByte((byte) (expires ? 1 : 0));
|
||||
dest.writeString(notes);
|
||||
dest.writeByte((byte) (isExpanded ? 1 : 0));
|
||||
dest.writeString(defaultAutoTypeSequence);
|
||||
dest.writeByte((byte) (enableAutoType == null ? -1 : (enableAutoType ? 1 : 0)));
|
||||
dest.writeByte((byte) (enableAutoType == null ? -1 : (enableAutoType ? 1 : 0)));
|
||||
dest.writeSerializable(lastTopVisibleEntry);
|
||||
}
|
||||
|
||||
public static final Creator<PwGroupV4> CREATOR = new Creator<PwGroupV4>() {
|
||||
@Override
|
||||
public PwGroupV4 createFromParcel(Parcel in) {
|
||||
return new PwGroupV4(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PwGroupV4[] newArray(int size) {
|
||||
return new PwGroupV4[size];
|
||||
}
|
||||
};
|
||||
|
||||
protected void updateWith(PwGroupV4 source) {
|
||||
super.assign(source);
|
||||
uuid = source.uuid;
|
||||
customIcon = source.customIcon;
|
||||
usageCount = source.usageCount;
|
||||
parentGroupLastMod = source.parentGroupLastMod;
|
||||
customData = source.customData;
|
||||
|
||||
expires = source.expires;
|
||||
|
||||
notes = source.notes;
|
||||
isExpanded = source.isExpanded;
|
||||
defaultAutoTypeSequence = source.defaultAutoTypeSequence;
|
||||
enableAutoType = source.enableAutoType;
|
||||
enableSearching = source.enableSearching;
|
||||
lastTopVisibleEntry = source.lastTopVisibleEntry;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public PwGroupV4 clone() {
|
||||
// Attributes in parent
|
||||
PwGroupV4 newGroup = (PwGroupV4) super.clone();
|
||||
|
||||
// Attributes here
|
||||
// newGroup.uuid stay the same in copy
|
||||
newGroup.customIcon = new PwIconCustom(this.customIcon);
|
||||
// newGroup.usageCount stay the same in copy
|
||||
newGroup.parentGroupLastMod = this.parentGroupLastMod.clone();
|
||||
// TODO customData make copy from hashmap newGroup.customData = (HashMap<String, String>) this.customData.clone();
|
||||
|
||||
// newGroup.expires stay the same in copy
|
||||
|
||||
// newGroup.notes stay the same in copy
|
||||
// newGroup.isExpanded stay the same in copy
|
||||
// newGroup.defaultAutoTypeSequence stay the same in copy
|
||||
// newGroup.enableAutoType stay the same in copy
|
||||
// newGroup.enableSearching stay the same in copy
|
||||
// newGroup.lastTopVisibleEntry stay the same in copy
|
||||
|
||||
return newGroup;
|
||||
}
|
||||
|
||||
public void addGroup(PwGroupV4 subGroup) {
|
||||
@@ -78,14 +169,6 @@ public class PwGroupV4 extends PwGroup<PwGroupV4, PwGroupV4, PwEntryV4> implemen
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public PwIconCustom getCustomIcon() {
|
||||
return customIcon;
|
||||
}
|
||||
|
||||
public void setCustomIcon(PwIconCustom icon) {
|
||||
this.customIcon = icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PwGroupId getId() {
|
||||
return new PwGroupIdV4(uuid);
|
||||
@@ -134,13 +217,26 @@ public class PwGroupV4 extends PwGroup<PwGroupV4, PwGroupV4, PwEntryV4> implemen
|
||||
|
||||
@Override
|
||||
public PwIcon getIcon() {
|
||||
if (customIcon == null || customIcon.uuid.equals(PwDatabase.UUID_ZERO)) {
|
||||
if (customIcon == null || customIcon.getUUID().equals(PwDatabase.UUID_ZERO)) {
|
||||
return super.getIcon();
|
||||
} else {
|
||||
return customIcon;
|
||||
}
|
||||
}
|
||||
|
||||
public PwIconCustom getIconCustom() {
|
||||
return customIcon;
|
||||
}
|
||||
|
||||
public void setIconCustom(PwIconCustom icon) {
|
||||
this.customIcon = icon;
|
||||
}
|
||||
|
||||
public void setIconStandard(PwIconStandard icon) { // TODO Encapsulate with PwEntryV4
|
||||
this.icon = icon;
|
||||
this.customIcon = PwIconCustom.ZERO;
|
||||
}
|
||||
|
||||
public void putCustomData(String key, String value) {
|
||||
customData.put(key, value);
|
||||
}
|
||||
|
||||
@@ -19,11 +19,23 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.database;
|
||||
|
||||
import java.io.Serializable;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
public abstract class PwIcon implements Serializable {
|
||||
public abstract class PwIcon implements Parcelable {
|
||||
|
||||
public boolean isMetaStreamIcon() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected PwIcon() {}
|
||||
|
||||
protected PwIcon(Parcel in) {}
|
||||
|
||||
public abstract boolean isUnknown();
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,24 +19,70 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.database;
|
||||
|
||||
import android.os.Parcel;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PwIconCustom extends PwIcon {
|
||||
public static final PwIconCustom ZERO = new PwIconCustom(PwDatabase.UUID_ZERO, new byte[0]);
|
||||
|
||||
public final UUID uuid;
|
||||
public byte[] imageData;
|
||||
private final UUID uuid;
|
||||
transient private byte[] imageData;
|
||||
|
||||
public PwIconCustom(UUID u, byte[] data) {
|
||||
uuid = u;
|
||||
imageData = data;
|
||||
public PwIconCustom(UUID uuid, byte[] data) {
|
||||
super();
|
||||
this.uuid = uuid;
|
||||
this.imageData = data;
|
||||
}
|
||||
|
||||
public PwIconCustom(PwIconCustom icon) {
|
||||
super();
|
||||
uuid = icon.uuid;
|
||||
imageData = icon.imageData;
|
||||
}
|
||||
|
||||
protected PwIconCustom(Parcel in) {
|
||||
super(in);
|
||||
uuid = (UUID) in.readSerializable();
|
||||
// TODO Take too much memories
|
||||
// in.readByteArray(imageData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnknown() {
|
||||
return uuid == null || this.equals(ZERO);
|
||||
}
|
||||
|
||||
public UUID getUUID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public byte[] getImageData() {
|
||||
return imageData;
|
||||
}
|
||||
|
||||
public void setImageData(byte[] imageData) {
|
||||
this.imageData = imageData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeSerializable(uuid);
|
||||
// Too big for a parcelable dest.writeByteArray(imageData);
|
||||
}
|
||||
|
||||
public static final Creator<PwIconCustom> CREATOR = new Creator<PwIconCustom>() {
|
||||
@Override
|
||||
public PwIconCustom createFromParcel(Parcel in) {
|
||||
return new PwIconCustom(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PwIconCustom[] newArray(int size) {
|
||||
return new PwIconCustom[size];
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
@@ -55,10 +101,7 @@ public class PwIconCustom extends PwIcon {
|
||||
return false;
|
||||
PwIconCustom other = (PwIconCustom) obj;
|
||||
if (uuid == null) {
|
||||
if (other.uuid != null)
|
||||
return false;
|
||||
} else if (!uuid.equals(other.uuid))
|
||||
return false;
|
||||
return true;
|
||||
return other.uuid == null;
|
||||
} else return uuid.equals(other.uuid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,20 +37,27 @@ public class PwIconFactory {
|
||||
*/
|
||||
private ReferenceMap customCache = new ReferenceMap(AbstractReferenceMap.HARD, AbstractReferenceMap.WEAK);
|
||||
|
||||
public PwIconStandard getFirstIcon() {
|
||||
return getIcon(0);
|
||||
public PwIconStandard getUnknownIcon() {
|
||||
return getIcon(PwIconStandard.UNKNOWN);
|
||||
}
|
||||
|
||||
public PwIconStandard getKeyIcon() {
|
||||
return getIcon(PwIconStandard.KEY);
|
||||
}
|
||||
|
||||
public PwIconStandard getTrashIcon() {
|
||||
return getIcon(PwIconStandard.TRASH);
|
||||
}
|
||||
|
||||
public PwIconStandard getFolderIcon() {
|
||||
return getIcon(PwIconStandard.FOLDER);
|
||||
}
|
||||
|
||||
public PwIconStandard getIcon(int iconId) {
|
||||
PwIconStandard icon = (PwIconStandard) cache.get(iconId);
|
||||
|
||||
if (icon == null) {
|
||||
if (iconId == 1) {
|
||||
icon = PwIconStandard.FIRST;
|
||||
}
|
||||
else {
|
||||
icon = new PwIconStandard(iconId);
|
||||
}
|
||||
cache.put(iconId, icon);
|
||||
}
|
||||
|
||||
@@ -68,25 +75,8 @@ public class PwIconFactory {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public PwIconCustom getIcon(UUID iconUuid, byte[] data) {
|
||||
PwIconCustom icon = (PwIconCustom) customCache.get(iconUuid);
|
||||
|
||||
if (icon == null) {
|
||||
icon = new PwIconCustom(iconUuid, data);
|
||||
customCache.put(iconUuid, icon);
|
||||
} else {
|
||||
icon.imageData = data;
|
||||
}
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIconData(UUID iconUuid, byte[] data) {
|
||||
getIcon(iconUuid, data);
|
||||
}
|
||||
|
||||
public void put(PwIconCustom icon) {
|
||||
customCache.put(icon.uuid, icon);
|
||||
customCache.put(icon.getUUID(), icon);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,15 +19,20 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.database;
|
||||
|
||||
import android.os.Parcel;
|
||||
|
||||
public class PwIconStandard extends PwIcon {
|
||||
public final int iconId;
|
||||
private final int iconId;
|
||||
|
||||
// The first is number 0
|
||||
public static PwIconStandard FIRST = new PwIconStandard(0);
|
||||
|
||||
public static final int TRASH_BIN = 43;
|
||||
public static final int UNKNOWN = -1;
|
||||
public static final int KEY = 0;
|
||||
public static final int TRASH = 43;
|
||||
public static final int FOLDER = 48;
|
||||
|
||||
public PwIconStandard() {
|
||||
this.iconId = KEY;
|
||||
}
|
||||
|
||||
public PwIconStandard(int iconId) {
|
||||
this.iconId = iconId;
|
||||
}
|
||||
@@ -36,6 +41,37 @@ public class PwIconStandard extends PwIcon {
|
||||
this.iconId = icon.iconId;
|
||||
}
|
||||
|
||||
protected PwIconStandard(Parcel in) {
|
||||
super(in);
|
||||
iconId = in.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnknown() {
|
||||
return iconId == UNKNOWN;
|
||||
}
|
||||
|
||||
public int getIconId() {
|
||||
return iconId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(iconId);
|
||||
}
|
||||
|
||||
public static final Creator<PwIconStandard> CREATOR = new Creator<PwIconStandard>() {
|
||||
@Override
|
||||
public PwIconStandard createFromParcel(Parcel in) {
|
||||
return new PwIconStandard(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PwIconStandard[] newArray(int size) {
|
||||
return new PwIconStandard[size];
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean isMetaStreamIcon() {
|
||||
return iconId == 0;
|
||||
|
||||
@@ -20,48 +20,90 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.database;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import java.io.Serializable;
|
||||
import com.kunzisoft.keepass.app.App;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
/**
|
||||
* Abstract class who manage Groups and Entries
|
||||
*/
|
||||
public abstract class PwNode<Parent extends PwGroup> implements ISmallTimeLogger, Serializable {
|
||||
public abstract class PwNode<Parent extends PwGroup> implements ISmallTimeLogger, Parcelable, Cloneable {
|
||||
|
||||
protected Parent parent = null;
|
||||
|
||||
protected PwIconStandard icon = PwIconStandard.FIRST;
|
||||
|
||||
protected PwIconStandard icon = new PwIconStandard();
|
||||
protected PwDate creation = new PwDate();
|
||||
protected PwDate lastMod = new PwDate();
|
||||
protected PwDate lastAccess = new PwDate();
|
||||
protected PwDate expireDate = PwDate.PW_NEVER_EXPIRE;
|
||||
|
||||
protected PwNode() {}
|
||||
|
||||
protected PwNode(Parcel in) {
|
||||
// TODO better technique ?
|
||||
try {
|
||||
PwGroupId pwGroupId = in.readParcelable(PwGroupId.class.getClassLoader());
|
||||
parent = (Parent) App.getDB().getPwDatabase().getGroupByGroupId(pwGroupId);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
icon = in.readParcelable(PwIconStandard.class.getClassLoader());
|
||||
creation = in.readParcelable(PwDate.class.getClassLoader());
|
||||
lastMod = in.readParcelable(PwDate.class.getClassLoader());
|
||||
lastAccess = in.readParcelable(PwDate.class.getClassLoader());
|
||||
expireDate = in.readParcelable(PwDate.class.getClassLoader());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
PwGroupId parentId = null;
|
||||
if (parent != null)
|
||||
parentId = parent.getId();
|
||||
dest.writeParcelable(parentId, flags);
|
||||
|
||||
dest.writeParcelable(icon, flags);
|
||||
dest.writeParcelable(creation, flags);
|
||||
dest.writeParcelable(lastMod, flags);
|
||||
dest.writeParcelable(lastAccess, flags);
|
||||
dest.writeParcelable(expireDate, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected void construct(Parent parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
protected void assign(PwNode<Parent> source) {
|
||||
this.parent = source.parent;
|
||||
|
||||
this.icon = source.icon;
|
||||
|
||||
this.creation = source.creation;
|
||||
this.lastMod = source.lastMod;
|
||||
this.lastAccess = source.lastAccess;
|
||||
this.expireDate = source.expireDate;
|
||||
}
|
||||
|
||||
protected void addCloneAttributesToNewEntry(PwEntry newEntry) {
|
||||
// newEntry.parent stay the same in copy
|
||||
|
||||
newEntry.icon = new PwIconStandard(this.icon);
|
||||
|
||||
newEntry.creation = creation.clone();
|
||||
newEntry.lastMod = lastMod.clone();
|
||||
newEntry.lastAccess = lastAccess.clone();
|
||||
newEntry.expireDate = expireDate.clone();
|
||||
@Override
|
||||
public PwNode clone() {
|
||||
PwNode newNode;
|
||||
try {
|
||||
newNode = (PwNode) super.clone();
|
||||
// newNode.parent stay the same in copy
|
||||
newNode.icon = new PwIconStandard(this.icon);
|
||||
newNode.creation = creation.clone();
|
||||
newNode.lastMod = lastMod.clone();
|
||||
newNode.lastAccess = lastAccess.clone();
|
||||
newNode.expireDate = expireDate.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new RuntimeException("Clone should be supported");
|
||||
}
|
||||
return newNode;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,22 +119,27 @@ public abstract class PwNode<Parent extends PwGroup> implements ISmallTimeLogger
|
||||
public abstract Type getType();
|
||||
|
||||
/**
|
||||
* @return Title to display as view
|
||||
* @return Title
|
||||
*/
|
||||
public abstract String getDisplayTitle();
|
||||
public abstract String getTitle();
|
||||
|
||||
/**
|
||||
* @return Title to display, typically return alternative title if {@link #getTitle()} is empty
|
||||
*/
|
||||
protected abstract String getVisualTitle();
|
||||
|
||||
/**
|
||||
* @return Visual icon
|
||||
*/
|
||||
public PwIcon getIcon() {
|
||||
return icon;
|
||||
return getIconStandard();
|
||||
}
|
||||
|
||||
public PwIconStandard getIconStandard() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(PwIconStandard icon) {
|
||||
public void setIconStandard(PwIconStandard icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
@@ -111,6 +158,13 @@ public abstract class PwNode<Parent extends PwGroup> implements ISmallTimeLogger
|
||||
parent = prt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if parent is present (can be a root or a detach element)
|
||||
*/
|
||||
public boolean containsParent() {
|
||||
return getParent() != null;
|
||||
}
|
||||
|
||||
public PwDate getCreationTime() {
|
||||
return creation;
|
||||
}
|
||||
@@ -161,7 +215,7 @@ public abstract class PwNode<Parent extends PwGroup> implements ISmallTimeLogger
|
||||
*/
|
||||
public boolean isContentVisuallyTheSame(PwNode o) {
|
||||
return getType().equals(o.getType())
|
||||
&& getDisplayTitle().equals(o.getDisplayTitle())
|
||||
&& getVisualTitle().equals(o.getVisualTitle())
|
||||
&& getIcon().equals(o.getIcon());
|
||||
}
|
||||
|
||||
|
||||
@@ -109,8 +109,8 @@ public enum SortNodeEnum {
|
||||
new EntryNameComparator(ascending),
|
||||
object1,
|
||||
object2,
|
||||
object1.getDisplayTitle()
|
||||
.compareToIgnoreCase(object2.getDisplayTitle()));
|
||||
object1.getTitle()
|
||||
.compareToIgnoreCase(object2.getTitle()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.kunzisoft.keepass.database.action;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.kunzisoft.keepass.database.Database;
|
||||
|
||||
public abstract class ActionWithSaveDatabaseRunnable extends RunnableOnFinish {
|
||||
|
||||
protected Context mContext;
|
||||
protected boolean mDontSave;
|
||||
protected Database mDatabase;
|
||||
|
||||
public ActionWithSaveDatabaseRunnable(Context context, Database database, OnFinishRunnable finish, boolean dontSave) {
|
||||
super(finish);
|
||||
|
||||
this.mDatabase = database;
|
||||
this.mContext = context;
|
||||
this.mDontSave = dontSave;
|
||||
this.mFinish = new AfterActionRunnable(finish);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// Commit to disk
|
||||
SaveDatabaseRunnable save = new SaveDatabaseRunnable(mContext, mDatabase, mFinish, mDontSave);
|
||||
save.run();
|
||||
}
|
||||
|
||||
public void runWithoutSaveDatabase() {
|
||||
mFinish.run();
|
||||
}
|
||||
|
||||
abstract protected void onFinish(boolean success, String message);
|
||||
|
||||
private class AfterActionRunnable extends OnFinishRunnable {
|
||||
|
||||
AfterActionRunnable(OnFinishRunnable finish) {
|
||||
super(finish);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
onFinish(mSuccess, mMessage);
|
||||
super.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright 2017 Brian Pellin, Jeremy Jamet / Kunzisoft.
|
||||
*
|
||||
* This file is part of KeePass DX.
|
||||
*
|
||||
* KeePass DX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* KeePass DX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with KeePass DX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.kunzisoft.keepass.database.action;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
import com.kunzisoft.keepass.database.Database;
|
||||
import com.kunzisoft.keepass.database.PwDatabase;
|
||||
import com.kunzisoft.keepass.database.exception.InvalidKeyFileException;
|
||||
import com.kunzisoft.keepass.utils.UriUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class AssignPasswordInDatabaseRunnable extends ActionWithSaveDatabaseRunnable {
|
||||
|
||||
private String mPassword;
|
||||
private Uri mKeyfile;
|
||||
private byte[] mBackupKey;
|
||||
|
||||
public AssignPasswordInDatabaseRunnable(Context ctx, Database db, String password, Uri keyfile, OnFinishRunnable finish) {
|
||||
this(ctx, db, password, keyfile, finish, false);
|
||||
}
|
||||
|
||||
public AssignPasswordInDatabaseRunnable(Context ctx, Database db, String password, Uri keyfile, OnFinishRunnable finish, boolean dontSave) {
|
||||
super(ctx, db, finish, dontSave);
|
||||
|
||||
this.mPassword = password;
|
||||
this.mKeyfile = keyfile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
PwDatabase pm = mDatabase.getPwDatabase();
|
||||
|
||||
mBackupKey = new byte[pm.getMasterKey().length];
|
||||
System.arraycopy(pm.getMasterKey(), 0, mBackupKey, 0, mBackupKey.length);
|
||||
|
||||
// Set key
|
||||
try {
|
||||
InputStream is = UriUtil.getUriInputStream(mContext, mKeyfile);
|
||||
pm.retrieveMasterKey(mPassword, is);
|
||||
// Save Database
|
||||
super.run();
|
||||
} catch (InvalidKeyFileException|IOException e) {
|
||||
erase(mBackupKey);
|
||||
finish(false, e.getMessage());
|
||||
super.runWithoutSaveDatabase();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinish(boolean success, String message) {
|
||||
if (!success) {
|
||||
// Erase the current master key
|
||||
erase(mDatabase.getPwDatabase().getMasterKey());
|
||||
mDatabase.getPwDatabase().setMasterKey(mBackupKey);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrite the array as soon as we don't need it to avoid keeping the extra data in memory
|
||||
*/
|
||||
private void erase(byte[] array) {
|
||||
if ( array == null ) return;
|
||||
|
||||
for ( int i = 0; i < array.length; i++ ) {
|
||||
array[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
* along with KeePass DX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.kunzisoft.keepass.database.edit;
|
||||
package com.kunzisoft.keepass.database.action;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
@@ -26,18 +26,18 @@ import com.kunzisoft.keepass.database.Database;
|
||||
import com.kunzisoft.keepass.database.PwDatabase;
|
||||
import com.kunzisoft.keepass.utils.UriUtil;
|
||||
|
||||
public class CreateDB extends RunnableOnFinish {
|
||||
public class CreateDatabaseRunnable extends RunnableOnFinish {
|
||||
|
||||
private String mFilename;
|
||||
private Context mContext;
|
||||
private boolean mDontSave;
|
||||
private Context ctx;
|
||||
private String mFilename;
|
||||
|
||||
public CreateDB(Context ctx, String filename, OnFinish finish, boolean dontSave) {
|
||||
public CreateDatabaseRunnable(Context mContext, String filename, OnFinishRunnable finish, boolean dontSave) {
|
||||
super(finish);
|
||||
|
||||
mFilename = filename;
|
||||
mDontSave = dontSave;
|
||||
this.ctx = ctx;
|
||||
this.mContext = mContext;
|
||||
this.mDontSave = dontSave;
|
||||
this.mFilename = filename;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -56,8 +56,9 @@ public class CreateDB extends RunnableOnFinish {
|
||||
App.clearShutdown();
|
||||
|
||||
// Commit changes
|
||||
SaveDB save = new SaveDB(ctx, db, mFinish, mDontSave);
|
||||
SaveDatabaseRunnable save = new SaveDatabaseRunnable(mContext, db, mFinish, mDontSave);
|
||||
mFinish = null;
|
||||
|
||||
save.run();
|
||||
}
|
||||
}
|
||||
@@ -17,17 +17,18 @@
|
||||
* along with KeePass DX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.kunzisoft.keepass.database.edit;
|
||||
package com.kunzisoft.keepass.database.action;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class FileOnFinish extends OnFinish implements Serializable {
|
||||
private Uri mFilename = null;
|
||||
protected FileOnFinish mOnFinish;
|
||||
public class FileOnFinishRunnable extends OnFinishRunnable implements Serializable {
|
||||
|
||||
public FileOnFinish(FileOnFinish finish) {
|
||||
private Uri mFilename = null;
|
||||
protected FileOnFinishRunnable mOnFinish;
|
||||
|
||||
public FileOnFinishRunnable(FileOnFinishRunnable finish) {
|
||||
super(finish);
|
||||
|
||||
mOnFinish = finish;
|
||||