Compare commits

..
117 Commits
Author SHA1 Message Date
Alexander Bakker 0046e8827e Release v3.2
build / build (push) Canceled after 0s
build / test (push) Canceled after 0s
2024-09-08 18:41:30 +02:00
Alexander Bakker 5640b8be83 Update translations from Crowdin 2024-09-08 18:28:07 +02:00
Alexander BakkerandGitHub 3bc3448b5c Merge pull request #1468 from michaelschattgen/feature/add-search-behavior
Add preference to change search behavior
2024-09-06 19:36:54 +02:00
Michael SchättgenandGitHub 7472e32b25 Merge pull request #1466 from alexbakker/fix-audit-log-crash
Account for audit log entries that reference deleted entries
2024-09-04 11:31:12 +02:00
Michael Schättgen 3425256c29 Add preference to switch search behavior 2024-08-28 16:32:23 +02:00
Alexander Bakker b92956dece Account for audit log entries that reference deleted entries
This fixes the following crash I noticed in the developer console:

```
Exception java.lang.AssertionError:
  at com.beemdevelopment.aegis.util.UUIDMap.getByUUID (UUIDMap.java:127)
  at com.beemdevelopment.aegis.vault.VaultRepository.getEntryByUUID (VaultRepository.java:229)
  at com.beemdevelopment.aegis.ui.fragments.preferences.AuditLogPreferencesFragment.lambda$onViewCreated$0 (AuditLogPreferencesFragment.java:70)
  at androidx.lifecycle.LiveData.considerNotify (LiveData.java:133)
  at androidx.lifecycle.LiveData.dispatchingValue (LiveData.java:151)
  at androidx.lifecycle.LiveData.setValue (LiveData.java:309)
  at androidx.lifecycle.LiveData$1.run (LiveData.java:93)
  at android.os.Handler.handleCallback (Handler.java:959)
  at android.os.Handler.dispatchMessage (Handler.java:100)
  at android.os.Looper.loopOnce (Looper.java:232)
  at android.os.Looper.loop (Looper.java:317)
  at android.app.ActivityThread.main (ActivityThread.java:8592)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:580)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:878)
```
2024-08-27 23:01:33 +02:00
Michael SchättgenandGitHub 20c5236cfa Merge pull request #1467 from alexbakker/trim-search
Trim spaces from the search filter
2024-08-27 22:18:46 +02:00
Alexander Bakker 7e1daf731f Trim spaces from the search filter 2024-08-27 22:05:25 +02:00
Michael SchättgenandGitHub 2add8aab14 Merge pull request #1464 from alexbakker/shapeableimageview
Replace CircleImageView with ShapeableImageView
2024-08-27 20:49:38 +02:00
Alexander Bakker 99e633d61a Replace CircleImageView with ShapeableImageView 2024-08-27 20:02:06 +02:00
Michael SchättgenandGitHub 7ce72e046a Merge pull request #1465 from alexbakker/vendor-jcenter-libs
Vendor TextDrawable and TrustedIntents
2024-08-26 23:55:33 +02:00
Alexander Bakker 991da65af0 Vendor TextDrawable and TrustedIntents
These were the only two libraries we were still getting from JCenter,
which was permanently shut down recently: https://jfrog.com/blog/jcenter-sunset/
2024-08-26 23:06:09 +02:00
Alexander BakkerandGitHub 9eae773efb Merge pull request #1458 from michaelschattgen/fix/hidden-dots-size
Fix sizing inconsistency of the dots in hidden view
2024-08-23 23:08:35 +02:00
Michael Schättgen 4ddc42ea51 Fix sizing inconsistency of the dots in hidden view 2024-08-22 01:05:35 +02:00
Alexander BakkerandGitHub a46c816167 Merge pull request #1447 from michaelschattgen/feature/hide-account-name-tiles
Add ability to hide account name in tiles mode
2024-08-12 22:30:44 +02:00
Michael Schättgen 71c0ad2a08 Add ability to hide account name in tiles mode 2024-08-12 21:53:55 +02:00
Michael SchättgenandGitHub bc5cb488f5 Merge pull request #1454 from alexbakker/pass-popup-check
Add an extra check before showing the password reminder popup
2024-08-11 18:07:22 +02:00
Alexander Bakker 010e2628e8 Add an extra check before showing the password reminder popup
This is another attempt to fix a rare crash we're seeing in the
developer console:

```
Exception android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
  at android.view.ViewRootImpl.setView (ViewRootImpl.java:1423)
  at android.view.WindowManagerGlobal.addView (WindowManagerGlobal.java:408)
  at android.view.WindowManagerImpl.addView (WindowManagerImpl.java:148)
  at android.widget.PopupWindow.invokePopup (PopupWindow.java:1583)
  at android.widget.PopupWindow.showAsDropDown (PopupWindow.java:1430)
  at android.widget.PopupWindow.showAsDropDown (PopupWindow.java:1386)
  at com.beemdevelopment.aegis.ui.AuthActivity.lambda$showPasswordReminder$5 (AuthActivity.java:253)
  at android.os.Handler.handleCallback (Handler.java:942)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loopOnce (Looper.java:211)
  at android.os.Looper.loop (Looper.java:300)
  at android.app.ActivityThread.main (ActivityThread.java:8294)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:580)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1028)
```
2024-08-10 13:13:03 +02:00
Alexander Bakker db4c738c8f Update dependencies 2024-08-09 19:49:08 +02:00
Michael SchättgenandGitHub e79c2c174b Merge pull request #1444 from alexbakker/scroll-export-dialog
Make the export dialog scrollable
2024-08-02 22:56:27 +02:00
Alexander Bakker 655881e852 Make the export dialog scrollable
Reported by @valentinb102 on Matrix.
2024-08-02 19:43:47 +02:00
Alexander BakkerandGitHub 29eccaf9cf Merge pull request #1429 from r3dh3ck/fix/preferences_result_location
Remove preferences result
2024-07-23 21:08:27 +02:00
r3dh3ckandAlexander Bakker f796e4542a Remove preferences result 2024-07-23 20:52:59 +02:00
Alexander Bakker a10693e79e Expand the number of cases covered under the slot exclusion tests 2024-07-23 20:30:36 +02:00
Alexander BakkerandGitHub b76e7a369c Merge pull request #1424 from r3dh3ck/fix/biometric_slot_stripping
Strip a biometric slot when a backup is made
2024-07-23 20:26:16 +02:00
Alexander Bakker 4ea19a2b7a Don't enforce backup versioning if versionsToKeep <= 0 2024-07-23 20:12:07 +02:00
Alexander BakkerandGitHub 6a67ca43e4 Merge pull request #1433 from r3dh3ck/feature/infinite_backups
Infinite backups
2024-07-23 20:11:41 +02:00
r3dh3ck fc8cdc6502 Implement infinite backups 2024-07-23 06:08:52 +00:00
Alexander BakkerandGitHub 27a723205e Merge pull request #1437 from michaelschattgen/fix/duplicate-dialog
Fix showing duplicate time sync dialogs
2024-07-22 20:59:55 +02:00
Michael Schättgen 7d76be577d Fix showing duplicate time sync dialogs 2024-07-22 20:08:48 +02:00
r3dh3ck 62f25d9ae9 Strip a biometric slot when a backup is made 2024-07-22 17:53:04 +00:00
Alexander BakkerandGitHub 9d374a2098 Merge pull request #1435 from michaelschattgen/fix/i18n-auditlog
Fix datetime parsing in Audit Log
2024-07-22 19:48:54 +02:00
Michael Schättgen e53688d30d Fix datetime parsing in Audit Log 2024-07-22 19:04:34 +02:00
Michael SchättgenandGitHub ec237ecb4e Merge pull request #1349 from InfiniteCoder06/feature-multi-group
Support for Adding Multiple Groups
2024-07-22 00:36:54 +02:00
Michael Schättgen 8960ffffb4 Release v3.1.1
build / build (push) Canceled after 0s
build / test (push) Canceled after 0s
2024-07-22 00:17:19 +02:00
Praveen Kumar 2e9efa0617 Support for Adding Multiple Groups 2024-07-21 19:35:36 +05:30
Alexander BakkerandGitHub 2050d29236 Merge pull request #1393 from michaelschattgen/feature/hide-keyboard-on-scroll
Hide keyboard on scroll when search field is focused
2024-07-20 10:09:12 +02:00
Michael Schättgen c1ffe4a23e Hide keyboard on scroll when search field is focused 2024-07-19 23:57:54 +02:00
Michael SchättgenandGitHub 52f8c709b5 Merge pull request #1432 from alexbakker/fix-1417
Simplify approach for animating advanced entry settings
2024-07-19 22:59:26 +02:00
Michael SchättgenandGitHub 676a7f603b Merge pull request #1431 from alexbakker/fix-group-chip
Initialize the group chip properly after unlocking Aegis
2024-07-19 22:49:01 +02:00
Alexander Bakker 94d1cc6608 Simplify approach for animating advanced entry settings
This slightly simplifies the approach we use to animate the advanced
entry settings into view, by defaulting its alpha to 0 and setting it to
VISIBLE before the animation starts. That way, we're not dependent on
"animation ended" callbacks that apparently don't fire in all cases.

The XML diff looks a bit scary, but it basically just removes a
wrapping ``RelativeLayout`` that appears to not be necessary.
2024-07-19 21:00:22 +02:00
Alexander Bakker f7862dcdf0 Initialize the group chip properly after unlocking Aegis
This fixes an issue introduced by
46e1421c28 where the group chip would not
show after unlocking Aegis. This happened because the activity result is
received *after* ``onStart``. When we were using ``onResume``, it was
the other way around.
2024-07-19 20:28:48 +02:00
Michael Schättgen d1695aa712 Bump versioncode
build / build (push) Canceled after 0s
build / test (push) Canceled after 0s
because play store
2024-07-17 22:29:45 +02:00
Michael Schättgen f1ff402db4 Release v3.1.1-beta1 2024-07-17 22:17:35 +02:00
Michael SchättgenandGitHub fd2ae9423e Merge pull request #1430 from alexbakker/workaround-1342
Start auth/intro activities from onStart to work around an Android bug
2024-07-17 21:10:02 +02:00
Alexander Bakker 46e1421c28 Start auth/intro activities from onStart to work around an Android bug 2024-07-17 19:18:09 +02:00
Alexander BakkerandGitHub 359621612a Merge pull request #1420 from juleskers/freeotpplus-json
Clarify FreeOTP+ import needs JSON, not URI-format
2024-07-16 17:04:26 +02:00
Jules Kerssemakers edf2201fb3 Clarify FreeOTP+ import needs JSON, not URI-format 2024-07-15 10:34:34 +02:00
Michael SchättgenandGitHub 1201b505f7 Merge pull request #1408 from juleskers/patch-1
DatabaseImporter: add overlooked FreeOTP "1.x" hint
2024-07-03 19:31:17 +02:00
Jules KerssemakersandGitHub 327f97c51d DatabaseImporter: add overlooked FreeOTP "1.x"-only
Include the '(1.x)' qualifier directly in the import-source selection dropdown to avoid raising false expectations.

See also:
- #1204, where the 1.x-hint was introduced
- #1084: tracking issue for 2.x support
- https://github.com/freeotp/freeotp-android/issues/381
  FreeOTP-issue to reconsider the brittle serialised java format used by 2.x
2024-07-02 11:52:12 +02:00
Michael Schättgen 29ebe31f8a Release v3.1
build / build (push) Canceled after 0s
build / test (push) Canceled after 0s
2024-06-29 22:34:06 +02:00
Michael Schättgen 372bbaa3fb Release v3.1-beta
build / build (push) Canceled after 0s
build / test (push) Canceled after 0s
2024-06-14 12:50:37 +02:00
Michael Schättgen 2165ac4b2b Update translations from Crowdin 2024-06-14 12:01:11 +02:00
Michael SchättgenandGitHub 46ceeeafb9 Merge pull request #1364 from michaelschattgen/fix/edit-entry-scroll
Make EditEntryActivity scrollable again
2024-06-13 21:34:22 +02:00
Michael SchättgenandAlexander Bakker 2b2c4fc0ce Make EditEntryActivity scrollable again
Co-authored-by: Alexander Bakker <ab@alexbakker.me>
2024-06-03 20:21:23 +02:00
Michael SchättgenandGitHub 2864f9b30c Merge pull request #1391 from alexbakker/fix-1329
Save the vault when saving group filter right after a vault version bump
2024-06-02 14:38:01 +02:00
Alexander BakkerandGitHub c17f30b89e Merge pull request #1354 from InfiniteCoder06/bug-scrolling
Fix Scrolling in BottomSheet
2024-06-01 14:43:56 +02:00
Praveen KumarandAlexander Bakker 9c07b981d4 Fix scrolling in bottom sheet for groups 2024-06-01 14:41:21 +02:00
Alexander Bakker 2b69dc3a84 Save the vault when saving group filter right after a vault version bump 2024-05-31 17:02:15 +02:00
Alexander Bakker 892116fcd7 Remove metadata translations 2024-05-31 16:18:03 +02:00
Alexander BakkerandGitHub ee1dd322b8 Merge pull request #1357 from michaelschattgen/feature/audit-log
Add audit log
2024-05-28 20:54:51 +02:00
Alexander BakkerandGitHub 56285eb468 Merge pull request #1352 from InfiniteCoder06/bug-spacing
Fix Spacing Issue With Name
2024-05-28 20:45:37 +02:00
Praveen KumarandAlexander Bakker 7e8b86ecf5 Fix spacing issue with entry name 2024-05-28 20:43:45 +02:00
Alexander BakkerandGitHub ea09c67027 Merge pull request #1383 from NWuensche/master
Update change of Code Digit Grouping
2024-05-28 20:33:12 +02:00
Alexander BakkerandGitHub d6468420ee Merge pull request #1382 from codeall9/bug/entry-list-group-selection
Remember group selection after screen rotate
2024-05-28 20:32:47 +02:00
codeall9andAlexander Bakker 65a57f2b9c Remember group selection after screen rotate
Solution:
Restore _groupFilter as _prefGroupFilter in order to reapply correct filter after screen rotate
2024-05-28 20:31:54 +02:00
nwuensche 40f630170c Update change of Code Digit Grouping 2024-05-18 14:54:49 +02:00
Alexander BakkerandGitHub 2b04ae0622 Merge pull request #1370 from michaelschattgen/fix/icon-packs-assign
Fix icon pack selector in AssignIconsActivity
2024-05-17 14:46:53 +02:00
Alexander BakkerandGitHub c28548debb Merge pull request #1378 from codeall9/bug/setting-appearance-title
Fix Language of Appearance Title
2024-05-17 12:21:29 +02:00
codeall9 802d449bfb Fix AppearancePreferencesFragment title after locale changed
root cause:
the `_prefTitle` is saved in `CharSequence`

solution:
we only able to store `CharSequence` since `Preference.getTitleRes` is removed in AndroidX. As a workaround, we update the title again on Fragment.onStart()
2024-05-12 17:01:11 +08:00
Michael Schättgen 69126242bd Fix icon pack selector in AssignIconsActivity 2024-05-06 17:43:42 +02:00
Michael SchättgenandGitHub dee881bc05 Merge pull request #1347 from InfiniteCoder06/refractor-groups
Renaming of Groups
2024-04-20 11:33:12 +02:00
Michael Schättgen 171da34b13 Start working on audit logs 2024-04-20 01:46:00 +02:00
Praveen Kumar a582c2053c Renaming of Groups 2024-04-19 09:03:03 +05:30
Alexander Bakker 9b96bbde54 Adjust R8 settings for easier retracing of stacktraces in release builds 2024-04-12 19:16:37 +02:00
Michael SchättgenandGitHub 3c124deae1 Merge pull request #1336 from alexbakker/limit-strength-analysis
Stop analyzing password strength if it becomes longer than 64 chars
2024-03-27 23:17:02 +01:00
Alexander Bakker 559e68e0d2 Stop analyzing password strength if it becomes longer than 64 chars
This should help reduce the chance that zxcvbn4j explodes on a password
input.

I also took the opportunity to deduplicate related code a bit.
2024-03-27 15:22:35 +01:00
Alexander Bakker 06437132b5 Update FUNDING.yml 2024-03-25 20:33:49 +01:00
Michael SchättgenandGitHub 8e9a1bda92 Merge pull request #1332 from alexbakker/fix-1330
Use DayNight as the default theme
2024-03-25 20:33:16 +01:00
Alexander Bakker 0d34f0749d Use DayNight as the default theme
This reduces the chance that we flashbang the user when they launch the
app. The issue remains on older Android versions that don't natively
support dark mode, but I don't think that's fixable.

Activities override the theme based on the user's settings, so this
change only has effect while the app is launching.
2024-03-25 20:21:49 +01:00
Michael Schättgen f44fe389d7 Release v3.0.1
build / build (push) Canceled after 0s
build / test (push) Canceled after 0s
2024-03-25 19:26:55 +01:00
Michael Schättgen 1644b35e87 Fix typos in our featured screenshots 2024-03-25 19:11:17 +01:00
Michael SchättgenandGitHub 49a2b5d34d Merge pull request #1323 from alexbakker/glide-no-res
Don't use Glide to load drawable resources
2024-03-24 20:51:28 +01:00
Michael SchättgenandGitHub 006815d36b Merge pull request #1322 from alexbakker/new-battle-net
Add support for importing from the new Battle.net app
2024-03-24 20:06:22 +01:00
Michael SchättgenandGitHub ec617e0c94 Merge pull request #1326 from alexbakker/fix-1325
Use Android color reference for android:colorBackground in AMOLED theme
2024-03-24 20:00:05 +01:00
Alexander Bakker 3962d50fa6 Use Android color reference for android:colorBackground in AMOLED theme
My best guess is that API 28 and below somehow interpret ``#000000`` to mean
either ``@null`` or transparent for ``android:colorBackground``.
2024-03-24 19:27:36 +01:00
Alexander Bakker 9815e510df Don't use Glide to load drawable resources
Loading drawables using Glide while the size of the ImageView
is not known yet appears to result in a blurry mess.
2024-03-24 17:58:55 +01:00
Alexander Bakker f9f37d30b2 Release v3.0
build / build (push) Canceled after 0s
build / test (push) Canceled after 0s
2024-03-24 16:47:26 +01:00
Alexander Bakker 4c4acf0cd0 Update translations from Crowdin 2024-03-24 16:42:26 +01:00
Alexander Bakker 3a66851df5 Only fetch 2 specific dependencies from JCenter 2024-03-24 14:26:59 +01:00
Alexander Bakker 4311bd9bd8 Add support for importing from the new Battle.net app 2024-03-23 18:43:02 +01:00
Michael SchättgenandGitHub 09c789b250 Merge pull request #1321 from alexbakker/about-libraries
Switch to AboutLibraries for the third-party license list
2024-03-23 16:03:25 +01:00
Alexander Bakker 60c72d48ee Switch to AboutLibraries for the third-party license list
The previous library we were using is unmaintained and can't be
customized to match the Material 3 theme.
2024-03-23 13:41:02 +01:00
Alexander BakkerandGitHub 8001ecb482 Merge pull request #1320 from michaelschattgen/fix/padding-unlock-button
Fix padding unlock button
2024-03-20 21:34:59 +01:00
Michael Schättgen 8912d75870 Fix padding unlock button 2024-03-20 21:33:15 +01:00
Michael SchättgenandGitHub e70499bcff Merge pull request #1319 from alexbakker/amoled-code-color
Make the code color white for AMOLED
2024-03-20 21:32:09 +01:00
Alexander BakkerandMichael Schättgen 4c28bf2a12 Make the code color white for AMOLED
Co-authored-by: Michael Schättgen <michael@schattgen.me>
2024-03-20 21:21:25 +01:00
Michael SchättgenandGitHub 584b0acb2b Merge pull request #1318 from alexbakker/no-compact-divider
Fix various minor inconsistencies in entry list item offsets
2024-03-19 22:50:13 +01:00
Alexander Bakker 45ced0de60 Fix various minor inconsistencies in entry list item offsets
This patch addresses the following:
- More consistent offsets between entries in the list, especially in
  relation to the action bar and the error card.
- Consistent correct application of card shapes when switching between
  favoriting and unfavoriting entries.
- Removal of CompactDividerDecoration. We no longer uses dividers, so
  this is no longer needed.
2024-03-19 22:40:47 +01:00
Michael Schättgen 7ec786231e Update featured screenshots with material 3 refresh 2024-03-17 23:23:44 +01:00
Alexander BakkerandGitHub 9737c85f86 Merge pull request #1312 from michaelschattgen/fix/favorites-ui
Fix shape of favorited entries
2024-03-16 17:40:29 +01:00
Michael Schättgen bf7c60d620 Fix shape of favorited entries 2024-03-16 17:38:56 +01:00
Alexander BakkerandGitHub 6fc9cd5a71 Merge pull request #1310 from michaelschattgen/feature/last-used
Add ability to sort based on last used timestamp
2024-03-16 16:15:26 +01:00
Michael Schättgen 9bae4d6bbc Add ability to sort based on last used timestamp 2024-03-16 16:14:47 +01:00
Alexander Bakker 7ce43a0afd Update build pipeline to resolve deprecation warnings 2024-03-16 13:08:21 +01:00
Alexander BakkerandGitHub 2b2cac1ada Merge pull request #1308 from michaelschattgen/fix/ui-inconsistencies
Fix a couple UI inconsistencies
2024-03-16 11:28:02 +01:00
Alexander BakkerandGitHub 2f18907ce1 Merge pull request #1307 from michaelschattgen/fix/copied-text
Fix copied text visibility
2024-03-16 11:24:22 +01:00
Michael SchättgenandGitHub ec01a4a96d Merge pull request #1240 from GitGitro/master
Add delta-aegis-icons to the Readme
2024-03-15 22:46:55 +01:00
GitGitro 76f6ebd216 Add delta-aegis-icons to the Readme
fix: remove preview
2024-03-15 22:35:11 +01:00
Michael Schättgen f1e14e6645 Fix a couple UI inconsistencies 2024-03-15 22:12:55 +01:00
Michael Schättgen 52ecf12576 Fix copied text visibility 2024-03-15 21:34:59 +01:00
Michael SchättgenandGitHub dfd720b406 Merge pull request #1303 from alexbakker/amoled-dynamic
Apply dark background colors when combining AMOLED and dynamic colors
2024-03-14 20:38:31 +01:00
Alexander Bakker 8995626d16 Apply dark background colors when combining AMOLED and dynamic colors
Previously, the dark background colors would not be applied for this
combination of settings.

Unfortunately, I couldn't find a way to avoid some duplication in
themes.xml.
2024-03-14 20:27:43 +01:00
Michael SchättgenandGitHub cffe15735c Merge pull request #1302 from alexbakker/fix-cam-btn-color
Set the correct color for the camera switch button
2024-03-14 20:16:18 +01:00
Michael SchättgenandGitHub 8512986a6b Merge pull request #1301 from alexbakker/fix-1300
Use MaterialColors.getColor instead of our own helper
2024-03-14 20:01:53 +01:00
Alexander Bakker c5b8ee9215 Set the correct color for the camera switch button 2024-03-13 20:50:07 +01:00
Alexander Bakker 2e44a81c69 Use MaterialColors.getColor instead of our own helper
I set CompactDividerDecoration to transparant, because that was already
effectively the case. I think we can remove this class entirely, but
I'll do that in a separate PR.
2024-03-13 20:33:09 +01:00
170 changed files with 9879 additions and 1921 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
buy_me_a_coffee: beemdevelopment
custom:
- "https://www.buymeacoffee.com/beemdevelopment"
- "https://www.blockchain.com/btc/address/bc1q26kyxqjkc6tu477pzy0whagwhs4ypv93qls22n"
- "https://nanocrawler.cc/explorer/account/nano_1aegisc559b1x4p3839egnu579jkd4htpidy14eo9e31gzqmwuafypnj4q94"
+7 -7
View File
@@ -5,17 +5,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@55e685c48d84285a5b0418cd094606e199cca3b6
- uses: actions/setup-java@v3
uses: gradle/wrapper-validation-action@699bb18358f12c5b78b37bb0111d3a0e2276e0e2
- uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- name: Build the app
run: ./gradlew build
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: apk
path: app/build/outputs/apk/debug/app-debug.apk
@@ -23,8 +23,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-java@v3
uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
@@ -54,7 +54,7 @@ jobs:
cp -r app/build/reports/androidTests/connected/* artifacts/report/
if adb shell '[ -e /sdcard/Pictures/screenshots ]'; then adb pull /sdcard/Pictures/screenshots artifacts/; fi
test ! -f tests_failing
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: always()
with:
name: instrumented-test-report
+4 -4
View File
@@ -16,7 +16,7 @@ jobs:
security-events: write
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Exclude paths
# The importers are excluded from analysis, because some of the apps Aegis
# can import from don't have such great crypto, which will cause false
@@ -24,18 +24,18 @@ jobs:
run: |
find app/src/main/java/com/beemdevelopment/aegis/importers ! \( -name AegisImporter.java -o -name "DatabaseImporter*" \) -type f -exec rm -f {} +
sed -i '/Importer.class/d' app/src/main/java/com/beemdevelopment/aegis/importers/DatabaseImporter.java
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: java
- name: Build
run: ./gradlew assembleDebug
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
+1 -1
View File
@@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
if: github.repository == 'beemdevelopment/Aegis'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install crowdin-cli
run: |
wget https://github.com/crowdin/crowdin-cli/releases/download/3.7.2/crowdin-cli.zip
+9
View File
@@ -125,6 +125,10 @@ documentation](docs/iconpacks.md).
[<img width=500 alt="aegis-icons preview"
src="https://raw.githubusercontent.com/aegis-icons/aegis-icons/master/showcase.png">](https://github.com/aegis-icons/aegis-icons)
- [delta-aegis-icons](https://github.com/Delta-Icons/aegis-icons)
Delta version of the unofficial monochrome-styled 2FA icon pack aegis-icons.
- [aegis-simple-icons](https://github.com/alexbakker/aegis-simple-icons) *
This project periodically generates an icon pack for Aegis based on [Simple
@@ -151,3 +155,8 @@ Swing by our Matrix room to interact with other contributors:
This project is licensed under the GNU General Public License v3.0. See the
[LICENSE](LICENSE) file for details.
A couple of libraries vendored in Aegis' repository are licensed under a
different license:
- [TextDrawable](app/src/main/java/com/amulyakhare/textdrawable)
- [TrustedIntents](app/src/main/java/info/guardianproject/trustedintents)
+60 -36
View File
@@ -1,6 +1,7 @@
apply plugin: 'com.android.application'
apply plugin: 'com.google.protobuf'
apply plugin: 'dagger.hilt.android.plugin'
apply plugin: 'com.mikepenz.aboutlibraries.plugin'
def getCmdOutput = { cmd ->
def stdout = new ByteArrayOutputStream()
@@ -27,13 +28,19 @@ android {
applicationId "${packageName}"
minSdkVersion 21
targetSdkVersion 34
versionCode 63
versionName "3.0-beta1"
versionCode 71
versionName "3.2"
multiDexEnabled true
buildConfigField "String", "GIT_HASH", "\"${getGitHash()}\""
buildConfigField "String", "GIT_BRANCH", "\"${getGitBranch()}\""
buildConfigField "java.util.concurrent.atomic.AtomicBoolean", "TEST", "new java.util.concurrent.atomic.AtomicBoolean(false)"
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas"]
}
}
testInstrumentationRunner "com.beemdevelopment.aegis.AegisTestRunner"
testInstrumentationRunnerArguments clearPackageData: 'true'
}
@@ -103,6 +110,9 @@ android {
checkDependencies true
disable 'MissingQuantity', 'MissingTranslation'
}
buildFeatures {
buildConfig true
}
}
protobuf {
@@ -120,33 +130,46 @@ protobuf {
}
}
dependencies {
def cameraxVersion = '1.3.1'
def glideVersion = '4.16.0'
def guavaVersion = '33.0.0'
def hiltVersion = '2.50'
def junitVersion = '4.13.2'
def libsuVersion = '5.2.2'
aboutLibraries {
// Tasks for aboutLibraries are not run automatically to keep the build reproducible
// To update manually: ./gradlew app:exportLibraryDefinitions -PaboutLibraries.exportPath=src/main/res/raw
prettyPrint = true
configPath = "app/config"
fetchRemoteFunding = false
registerAndroidTasks = false
exclusionPatterns = [~"javax.annotation.*"]
duplicationMode = com.mikepenz.aboutlibraries.plugin.DuplicateMode.MERGE
}
annotationProcessor 'androidx.annotation:annotation:1.7.1'
dependencies {
def cameraxVersion = '1.3.4'
def glideVersion = '4.16.0'
def guavaVersion = '33.2.1'
def hiltVersion = '2.52'
def junitVersion = '4.13.2'
def libsuVersion = '6.0.0'
def roomVersion = "2.6.1"
annotationProcessor 'androidx.annotation:annotation:1.8.2'
annotationProcessor "androidx.room:room-compiler:$roomVersion"
annotationProcessor "com.google.dagger:hilt-compiler:$hiltVersion"
annotationProcessor "com.github.bumptech.glide:compiler:${glideVersion}"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.activity:activity:1.8.2'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.activity:activity:1.9.1'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation "androidx.biometric:biometric:1.1.0"
implementation "androidx.camera:camera-camera2:$cameraxVersion"
implementation "androidx.camera:camera-lifecycle:$cameraxVersion"
implementation "androidx.camera:camera-view:$cameraxVersion"
implementation "androidx.core:core:1.12.0"
implementation 'androidx.core:core:1.13.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.documentfile:documentfile:1.0.1'
implementation "androidx.lifecycle:lifecycle-process:2.6.2"
implementation 'androidx.lifecycle:lifecycle-process:2.8.4'
implementation "androidx.preference:preference:1.2.1"
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation "androidx.viewpager2:viewpager2:1.0.0"
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
implementation "androidx.room:room-runtime:$roomVersion"
implementation 'androidx.viewpager2:viewpager2:1.1.0'
implementation 'com.caverock:androidsvg-aar:1.4'
implementation "com.google.dagger:hilt-android:$hiltVersion"
implementation 'com.github.avito-tech:krop:0.52'
@@ -158,34 +181,35 @@ dependencies {
implementation "com.github.topjohnwu.libsu:core:${libsuVersion}"
implementation "com.github.topjohnwu.libsu:io:${libsuVersion}"
implementation "com.google.guava:guava:${guavaVersion}-android"
implementation 'com.google.android.material:material:1.11.0'
implementation 'com.google.protobuf:protobuf-javalite:3.25.1'
implementation 'com.google.zxing:core:3.5.2'
implementation 'com.nulab-inc:zxcvbn:1.8.2'
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'de.psdev.licensesdialog:licensesdialog:2.2.0'
implementation 'com.google.android.material:material:1.12.0'
implementation 'com.google.protobuf:protobuf-javalite:4.27.3'
implementation 'com.google.zxing:core:3.5.3'
implementation('com.mikepenz:aboutlibraries:11.2.2') {
exclude group: 'com.mikepenz', module: 'aboutlibraries-core'
}
implementation 'com.mikepenz:aboutlibraries-core-android:11.2.2'
implementation 'com.nulab-inc:zxcvbn:1.9.0'
implementation 'net.lingala.zip4j:zip4j:2.11.5'
implementation 'info.guardianproject.trustedintents:trustedintents:0.2'
implementation 'org.bouncycastle:bcprov-jdk18on:1.77'
implementation "org.simpleflatmapper:sfm-csv:8.2.3"
implementation 'org.bouncycastle:bcprov-jdk18on:1.78.1'
implementation 'org.simpleflatmapper:sfm-csv:8.2.3'
androidTestAnnotationProcessor "com.google.dagger:hilt-android-compiler:$hiltVersion"
androidTestImplementation "com.google.dagger:hilt-android-testing:$hiltVersion"
androidTestImplementation 'androidx.test:core:1.5.0'
androidTestImplementation 'androidx.test:runner:1.5.2'
androidTestImplementation 'androidx.test:rules:1.5.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.5.1'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.5.1'
androidTestImplementation 'androidx.test:core:1.6.1'
androidTestImplementation 'androidx.test:runner:1.6.1'
androidTestImplementation 'androidx.test:rules:1.6.1'
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.6.1'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.6.1'
androidTestImplementation "junit:junit:${junitVersion}"
androidTestUtil 'androidx.test:orchestrator:1.4.2'
androidTestUtil 'androidx.test:orchestrator:1.5.0'
testImplementation 'androidx.test:core:1.5.0'
testImplementation 'androidx.test:core:1.6.1'
testImplementation "com.google.guava:guava:${guavaVersion}-jre"
testImplementation "junit:junit:${junitVersion}"
testImplementation 'org.json:json:20231013'
testImplementation 'org.robolectric:robolectric:4.11.1'
testImplementation 'org.json:json:20240303'
testImplementation 'org.robolectric:robolectric:4.13'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
}
+6
View File
@@ -0,0 +1,6 @@
{
"uniqueId": "com.github.avito-tech:krop",
"licenses": [
"MIT"
]
}
+6
View File
@@ -0,0 +1,6 @@
{
"uniqueId": "com.github.topjohnwu.libsu:.*::regex",
"licenses": [
"Apache-2.0"
]
}
+15
View File
@@ -0,0 +1,15 @@
{
"uniqueId": "com.amulyakhare:com.amulyakhare.textdrawable",
"funding": [
],
"developers": [
],
"artifactVersion": "1.0.1",
"description": "This light-weight library provides images with letter/text like the Gmail app. It extends the Drawable class thus can be used with existing/custom/network ImageView classes. Also included is a fluent interface for creating drawables and a customizable ColorGenerator.",
"name": "textdrawable",
"licenses": [
"MIT"
]
}
+23
View File
@@ -0,0 +1,23 @@
{
"uniqueId": "info.guardianproject.trustedintents:trustedintents",
"funding": [
],
"developers": [
{
"name": "Guardian Project"
}
],
"artifactVersion": "0.2",
"description": "TrustedIntents is a library for flexible trusted interactions between Android apps. It is modeled after Android's `signature` protection level for permissions. The key difference is that the framework allows the trusted signature to be set, rather than requiring to match the current app's signature.",
"scm": {
"connection": "scm:https://github.com/guardianproject/TrustedIntents.git",
"url": "scm:https://github.com/guardianproject/TrustedIntents",
"developerConnection": "scm:git@github.com:guardianproject/TrustedIntents.git"
},
"name": "TrustedIntents",
"website": "https://guardianproject.info/code/trustedintents",
"licenses": [
"3ca920d1875f7ad7ab04a2a331958577"
]
}
@@ -0,0 +1,5 @@
{
"hash": "3ca920d1875f7ad7ab04a2a331958577",
"url": "https://github.com/guardianproject/TrustedIntents/blob/master/LICENSE.txt",
"name": "LGPLv2.1"
}
+4 -1
View File
@@ -1,7 +1,10 @@
-keepattributes LineNumberTable,SourceFile
-renamesourcefileattribute SourceFile
-dontobfuscate
-keepclasseswithmembers public class androidx.recyclerview.widget.RecyclerView { *; }
-keep class com.beemdevelopment.aegis.ui.fragments.preferences.*
-keep class com.beemdevelopment.aegis.importers.** { *; }
-keep class * extends com.google.protobuf.GeneratedMessageLite { *; }
-dontobfuscate
-dontwarn javax.naming.**
@@ -0,0 +1,52 @@
{
"formatVersion": 1,
"database": {
"version": 1,
"identityHash": "392278bdb797d013cb2ada67a3b1cc60",
"entities": [
{
"tableName": "audit_logs",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `event_type` TEXT NOT NULL, `reference` TEXT, `timestamp` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "_eventType",
"columnName": "event_type",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "_reference",
"columnName": "reference",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "_timestamp",
"columnName": "timestamp",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
},
"indices": [],
"foreignKeys": []
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '392278bdb797d013cb2ada67a3b1cc60')"
]
}
}
@@ -7,6 +7,7 @@ import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard;
import static androidx.test.espresso.action.ViewActions.longClick;
import static androidx.test.espresso.action.ViewActions.pressBack;
import static androidx.test.espresso.action.ViewActions.scrollTo;
import static androidx.test.espresso.action.ViewActions.typeText;
import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant;
import static androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA;
@@ -118,10 +119,11 @@ public class OverallTest extends AegisTest {
onView(withId(R.id.rvKeyProfiles)).perform(RecyclerViewActions.actionOnItemAtPosition(entryPosOffset + 1, longClick()));
onView(withId(R.id.action_edit)).perform(click());
onView(withId(R.id.text_name)).perform(clearText(), typeText("Bob"), closeSoftKeyboard());
onView(withId(R.id.dropdown_group)).perform(click());
onView(withText(R.string.new_group)).inRoot(RootMatchers.isPlatformPopup()).perform(click());
onView(withId(R.id.text_group)).perform(click());
onView(withId(R.id.addGroup)).inRoot(RootMatchers.isDialog()).perform(click());
onView(withId(R.id.text_input)).perform(typeText(_groupName), closeSoftKeyboard());
onView(withId(android.R.id.button1)).perform(click());
onView(withText(R.string.save)).perform(click());
onView(isRoot()).perform(pressBack());
onView(withId(android.R.id.button1)).perform(click());
@@ -188,7 +190,7 @@ public class OverallTest extends AegisTest {
onView(withId(R.id.fab)).perform(click());
onView(withId(R.id.fab_enter)).perform(click());
onView(withId(R.id.accordian_header)).perform(click());
onView(withId(R.id.accordian_header)).perform(scrollTo(), click());
onView(withId(R.id.text_name)).perform(typeText(entry.getName()), closeSoftKeyboard());
onView(withId(R.id.text_issuer)).perform(typeText(entry.getIssuer()), closeSoftKeyboard());
@@ -208,7 +210,7 @@ public class OverallTest extends AegisTest {
throw new RuntimeException(String.format("Unexpected entry type: %s", entry.getInfo().getClass().getSimpleName()));
}
onView(withId(R.id.dropdown_type)).perform(click());
onView(withId(R.id.dropdown_type)).perform(scrollTo(), click());
onView(withText(otpType)).inRoot(RootMatchers.isPlatformPopup()).perform(click());
}
+4 -1
View File
@@ -27,6 +27,7 @@
android:icon="@mipmap/${iconName}"
android:label="Aegis"
android:supportsRtl="true"
android:theme="@style/Theme.Aegis.Launch"
tools:targetApi="tiramisu">
<activity android:name=".ui.TransferEntriesActivity"
android:label="@string/title_activity_transfer" />
@@ -82,6 +83,8 @@
android:label="@string/title_activity_manage_groups" />
<activity android:name=".ui.AssignIconsActivity"
android:label="@string/title_activity_assign_icons"/>
<activity android:name=".ui.LicensesActivity"
android:label="@string/title_activity_licenses"/>
<activity
android:name=".ui.PanicResponderActivity"
android:exported="true"
@@ -155,7 +158,7 @@
<package android:name="com.valvesoftware.android.steam.community" />
<package android:name="com.authenticator.authservice2" />
<package android:name="com.duosecurity.duomobile" />
<package android:name="com.blizzard.bma" />
<package android:name="com.blizzard.messenger" />
</queries>
</manifest>
+51
View File
@@ -31,6 +31,55 @@
</head>
<body>
<div></div>
<h3>Version 3.2</h3>
<h4>New</h4>
<ul>
<li>The ability to add a single entry to multiple groups</li>
<li>Option to keep an infinite number of backups</li>
<li>Option to customize which fields to search for in entries</li>
<li>Allow hiding entry names in the tiled view mode</li>
</ul>
<h4>Fixes</h4>
<ul>
<li>With "Tap to reveal" enabled, the size of the shown dots would not be consistent with the size of the code digits, on some devices</li>
<li>After importing a backup, the UI would in some cases incorrectly claim that biometric unlock is enabled</li>
<li>The export dialog was not fully visible on some devices</li>
<li>Various other minor UI, stability and performance improvements</li>
</ul>
<h3>Version 3.1.1</h3>
<h4>Fixes</h4>
<p>
A recent Android Pixel update introduced a bug causing Aegis to sometimes show a black screen after unlocking the vault.
We have reported this issue to the Google Issue Tracker (<a href="https://issuetracker.google.com/issues/352963108">link</a>) and
are awaiting a response from Google. In the meantime, we have implemented a workaround that eliminates this bug.
</p>
<ul>
<li>Group filter now gets applied properly upon unlocking the vault</li>
<li>Advanced entry settings now gets shown correctly</li>
<li>Keyboard when searching for entries now gets hidden when the user starts scrolling through the list</li>
</ul>
<h3>Version 3.1</h3>
<h4>New</h4>
<ul>
<li>A new audit log has been added to check all important events that occurred in your vault</li>
<li>Added the ability to rename groups</li>
</ul>
<h4>Fixes</h4>
<ul>
<li>Group selection will now be remembered again upon launch</li>
<li>Various UI improvements</li>
<li>Stability fixes</li>
</ul>
<h3>Version 3.0.1</h3>
<h4>New</h4>
<ul>
<li>Support for importing from the new Battle.net app</li>
</ul>
<h4>Fixes</h4>
<ul>
<li>Visual glitches when AMOLED theme was used on old Android versions</li>
<li>Minor UI improvements</li>
</ul>
<h3>Version 3.0</h3>
<h4>New</h4>
<ul>
@@ -38,9 +87,11 @@
<li>Automatic assignment of icons to entries</li>
<li>Ability to select all entries in one go</li>
<li>Support for importing 2FAS schema v4 backups</li>
<li>Sort entries based on the last time they were used</li>
<li>Some clarifications related to importing and backup permission errors</li>
<li>Preparations for the ability to assign a single entry to multiple groups</li>
<li>Performance improvements when scrolling through an entry list with lots of icons</li>
<li>A new look for the third-party licenses list</li>
</ul>
<h4>Fixes</h4>
<ul>
@@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2014 Amulya Khare
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,316 @@
package com.amulyakhare.textdrawable;
import android.graphics.*;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.graphics.drawable.shapes.RectShape;
import android.graphics.drawable.shapes.RoundRectShape;
/**
* @author amulya
* @datetime 14 Oct 2014, 3:53 PM
*/
public class TextDrawable extends ShapeDrawable {
private final Paint textPaint;
private final Paint borderPaint;
private static final float SHADE_FACTOR = 0.9f;
private final String text;
private final int color;
private final RectShape shape;
private final int height;
private final int width;
private final int fontSize;
private final float radius;
private final int borderThickness;
private TextDrawable(Builder builder) {
super(builder.shape);
// shape properties
shape = builder.shape;
height = builder.height;
width = builder.width;
radius = builder.radius;
// text and color
text = builder.toUpperCase ? builder.text.toUpperCase() : builder.text;
color = builder.color;
// text paint settings
fontSize = builder.fontSize;
textPaint = new Paint();
textPaint.setColor(builder.textColor);
textPaint.setAntiAlias(true);
textPaint.setFakeBoldText(builder.isBold);
textPaint.setStyle(Paint.Style.FILL);
textPaint.setTypeface(builder.font);
textPaint.setTextAlign(Paint.Align.CENTER);
textPaint.setStrokeWidth(builder.borderThickness);
// border paint settings
borderThickness = builder.borderThickness;
borderPaint = new Paint();
borderPaint.setColor(getDarkerShade(color));
borderPaint.setStyle(Paint.Style.STROKE);
borderPaint.setStrokeWidth(borderThickness);
// drawable paint color
Paint paint = getPaint();
paint.setColor(color);
}
private int getDarkerShade(int color) {
return Color.rgb((int)(SHADE_FACTOR * Color.red(color)),
(int)(SHADE_FACTOR * Color.green(color)),
(int)(SHADE_FACTOR * Color.blue(color)));
}
@Override
public void draw(Canvas canvas) {
super.draw(canvas);
Rect r = getBounds();
// draw border
if (borderThickness > 0) {
drawBorder(canvas);
}
int count = canvas.save();
canvas.translate(r.left, r.top);
// draw text
int width = this.width < 0 ? r.width() : this.width;
int height = this.height < 0 ? r.height() : this.height;
int fontSize = this.fontSize < 0 ? (Math.min(width, height) / 2) : this.fontSize;
textPaint.setTextSize(fontSize);
canvas.drawText(text, width / 2, height / 2 - ((textPaint.descent() + textPaint.ascent()) / 2), textPaint);
canvas.restoreToCount(count);
}
private void drawBorder(Canvas canvas) {
RectF rect = new RectF(getBounds());
rect.inset(borderThickness/2, borderThickness/2);
if (shape instanceof OvalShape) {
canvas.drawOval(rect, borderPaint);
}
else if (shape instanceof RoundRectShape) {
canvas.drawRoundRect(rect, radius, radius, borderPaint);
}
else {
canvas.drawRect(rect, borderPaint);
}
}
@Override
public void setAlpha(int alpha) {
textPaint.setAlpha(alpha);
}
@Override
public void setColorFilter(ColorFilter cf) {
textPaint.setColorFilter(cf);
}
@Override
public int getOpacity() {
return PixelFormat.TRANSLUCENT;
}
@Override
public int getIntrinsicWidth() {
return width;
}
@Override
public int getIntrinsicHeight() {
return height;
}
public static IShapeBuilder builder() {
return new Builder();
}
public static class Builder implements IConfigBuilder, IShapeBuilder, IBuilder {
private String text;
private int color;
private int borderThickness;
private int width;
private int height;
private Typeface font;
private RectShape shape;
public int textColor;
private int fontSize;
private boolean isBold;
private boolean toUpperCase;
public float radius;
private Builder() {
text = "";
color = Color.GRAY;
textColor = Color.WHITE;
borderThickness = 0;
width = -1;
height = -1;
shape = new RectShape();
font = Typeface.create("sans-serif-light", Typeface.NORMAL);
fontSize = -1;
isBold = false;
toUpperCase = false;
}
public IConfigBuilder width(int width) {
this.width = width;
return this;
}
public IConfigBuilder height(int height) {
this.height = height;
return this;
}
public IConfigBuilder textColor(int color) {
this.textColor = color;
return this;
}
public IConfigBuilder withBorder(int thickness) {
this.borderThickness = thickness;
return this;
}
public IConfigBuilder useFont(Typeface font) {
this.font = font;
return this;
}
public IConfigBuilder fontSize(int size) {
this.fontSize = size;
return this;
}
public IConfigBuilder bold() {
this.isBold = true;
return this;
}
public IConfigBuilder toUpperCase() {
this.toUpperCase = true;
return this;
}
@Override
public IConfigBuilder beginConfig() {
return this;
}
@Override
public IShapeBuilder endConfig() {
return this;
}
@Override
public IBuilder rect() {
this.shape = new RectShape();
return this;
}
@Override
public IBuilder round() {
this.shape = new OvalShape();
return this;
}
@Override
public IBuilder roundRect(int radius) {
this.radius = radius;
float[] radii = {radius, radius, radius, radius, radius, radius, radius, radius};
this.shape = new RoundRectShape(radii, null, null);
return this;
}
@Override
public TextDrawable buildRect(String text, int color) {
rect();
return build(text, color);
}
@Override
public TextDrawable buildRoundRect(String text, int color, int radius) {
roundRect(radius);
return build(text, color);
}
@Override
public TextDrawable buildRound(String text, int color) {
round();
return build(text, color);
}
@Override
public TextDrawable build(String text, int color) {
this.color = color;
this.text = text;
return new TextDrawable(this);
}
}
public interface IConfigBuilder {
public IConfigBuilder width(int width);
public IConfigBuilder height(int height);
public IConfigBuilder textColor(int color);
public IConfigBuilder withBorder(int thickness);
public IConfigBuilder useFont(Typeface font);
public IConfigBuilder fontSize(int size);
public IConfigBuilder bold();
public IConfigBuilder toUpperCase();
public IShapeBuilder endConfig();
}
public static interface IBuilder {
public TextDrawable build(String text, int color);
}
public static interface IShapeBuilder {
public IConfigBuilder beginConfig();
public IBuilder rect();
public IBuilder round();
public IBuilder roundRect(int radius);
public TextDrawable buildRect(String text, int color);
public TextDrawable buildRoundRect(String text, int color, int radius);
public TextDrawable buildRound(String text, int color);
}
}
@@ -0,0 +1,69 @@
package com.amulyakhare.textdrawable.util;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
/**
* @author amulya
* @datetime 14 Oct 2014, 5:20 PM
*/
public class ColorGenerator {
public static ColorGenerator DEFAULT;
public static ColorGenerator MATERIAL;
static {
DEFAULT = create(Arrays.asList(
0xfff16364,
0xfff58559,
0xfff9a43e,
0xffe4c62e,
0xff67bf74,
0xff59a2be,
0xff2093cd,
0xffad62a7,
0xff805781
));
MATERIAL = create(Arrays.asList(
0xffe57373,
0xfff06292,
0xffba68c8,
0xff9575cd,
0xff7986cb,
0xff64b5f6,
0xff4fc3f7,
0xff4dd0e1,
0xff4db6ac,
0xff81c784,
0xffaed581,
0xffff8a65,
0xffd4e157,
0xffffd54f,
0xffffb74d,
0xffa1887f,
0xff90a4ae
));
}
private final List<Integer> mColors;
private final Random mRandom;
public static ColorGenerator create(List<Integer> colorList) {
return new ColorGenerator(colorList);
}
private ColorGenerator(List<Integer> colorList) {
mColors = colorList;
mRandom = new Random(System.currentTimeMillis());
}
public int getRandomColor() {
return mColors.get(mRandom.nextInt(mColors.size()));
}
public int getColor(Object key) {
return mColors.get(Math.abs(key.hashCode()) % mColors.size());
}
}
@@ -17,14 +17,23 @@ import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleEventObserver;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.ProcessLifecycleOwner;
import androidx.room.Room;
import com.beemdevelopment.aegis.database.AppDatabase;
import com.beemdevelopment.aegis.database.AuditLogEntry;
import com.beemdevelopment.aegis.database.AuditLogRepository;
import com.beemdevelopment.aegis.receivers.VaultLockReceiver;
import com.beemdevelopment.aegis.ui.MainActivity;
import com.beemdevelopment.aegis.util.IOUtils;
import com.beemdevelopment.aegis.vault.VaultManager;
import com.topjohnwu.superuser.Shell;
import org.checkerframework.checker.units.qual.A;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import dagger.hilt.InstallIn;
import dagger.hilt.android.EarlyEntryPoint;
@@ -8,6 +8,8 @@ import android.os.Build;
import android.os.ParcelFileDescriptor;
import android.util.Log;
import com.beemdevelopment.aegis.database.AppDatabase;
import com.beemdevelopment.aegis.database.AuditLogRepository;
import com.beemdevelopment.aegis.util.IOUtils;
import com.beemdevelopment.aegis.vault.VaultFile;
import com.beemdevelopment.aegis.vault.VaultRepository;
@@ -25,12 +27,16 @@ public class AegisBackupAgent extends BackupAgent {
private Preferences _prefs;
private AuditLogRepository _auditLogRepository;
@Override
public void onCreate() {
super.onCreate();
// Cannot use injection with Dagger Hilt here, because the app is launched in a restricted mode on restore
_prefs = new Preferences(this);
AppDatabase appDatabase = AegisModule.provideAppDatabase(this);
_auditLogRepository = AegisModule.provideAuditLogRepository(appDatabase);
}
@Override
@@ -53,6 +59,7 @@ public class AegisBackupAgent extends BackupAgent {
// report any runtime exceptions, in addition to the expected IOExceptions.
try {
fullBackup(data);
_auditLogRepository.addAndroidBackupCreatedEvent();
_prefs.setAndroidBackupResult(new Preferences.BackupResult(null));
} catch (Exception e) {
Log.e(TAG, String.format("onFullBackup() failed: %s", e));
@@ -2,6 +2,11 @@ package com.beemdevelopment.aegis;
import android.content.Context;
import androidx.room.Room;
import com.beemdevelopment.aegis.database.AppDatabase;
import com.beemdevelopment.aegis.database.AuditLogDao;
import com.beemdevelopment.aegis.database.AuditLogRepository;
import com.beemdevelopment.aegis.icons.IconPackManager;
import com.beemdevelopment.aegis.vault.VaultManager;
@@ -24,12 +29,27 @@ public class AegisModule {
@Provides
@Singleton
public static VaultManager provideVaultManager(@ApplicationContext Context context) {
return new VaultManager(context);
public static AuditLogRepository provideAuditLogRepository(AppDatabase appDatabase) {
AuditLogDao auditLogDao = appDatabase.auditLogDao();
return new AuditLogRepository(auditLogDao);
}
@Provides
@Singleton
public static VaultManager provideVaultManager(@ApplicationContext Context context, AuditLogRepository auditLogRepository) {
return new VaultManager(context, auditLogRepository);
}
@Provides
public static Preferences providePreferences(@ApplicationContext Context context) {
return new Preferences(context);
}
@Provides
@Singleton
public static AppDatabase provideAppDatabase(@ApplicationContext Context context) {
return Room.databaseBuilder(context.getApplicationContext(),
AppDatabase.class, "aegis-db")
.build();
}
}
@@ -0,0 +1,42 @@
package com.beemdevelopment.aegis;
public enum EventType {
VAULT_UNLOCKED,
VAULT_BACKUP_CREATED,
VAULT_ANDROID_BACKUP_CREATED,
VAULT_EXPORTED,
ENTRY_SHARED,
VAULT_UNLOCK_FAILED_PASSWORD,
VAULT_UNLOCK_FAILED_BIOMETRICS;
private static EventType[] _values;
static {
_values = values();
}
public static EventType fromInteger(int x) {
return _values[x];
}
public static int getEventTitleRes(EventType eventType) {
switch (eventType) {
case VAULT_UNLOCKED:
return R.string.event_title_vault_unlocked;
case VAULT_BACKUP_CREATED:
return R.string.event_title_backup_created;
case VAULT_ANDROID_BACKUP_CREATED:
return R.string.event_title_android_backup_created;
case VAULT_EXPORTED:
return R.string.event_title_vault_exported;
case ENTRY_SHARED:
return R.string.event_title_entry_shared;
case VAULT_UNLOCK_FAILED_PASSWORD:
return R.string.event_title_vault_unlock_failed_password;
case VAULT_UNLOCK_FAILED_BIOMETRICS:
return R.string.event_title_vault_unlock_failed_biometrics;
default:
return R.string.event_unknown;
}
}
}
@@ -34,12 +34,26 @@ public class Preferences {
public static final int AUTO_LOCK_ON_MINIMIZE = 1 << 2;
public static final int AUTO_LOCK_ON_DEVICE_LOCK = 1 << 3;
public static final int SEARCH_IN_ISSUER = 1 << 0;
public static final int SEARCH_IN_NAME = 1 << 1;
public static final int SEARCH_IN_NOTE = 1 << 2;
public static final int SEARCH_IN_GROUPS = 1 << 3;
public static final int BACKUPS_VERSIONS_INFINITE = -1;
public static final int[] AUTO_LOCK_SETTINGS = {
AUTO_LOCK_ON_BACK_BUTTON,
AUTO_LOCK_ON_MINIMIZE,
AUTO_LOCK_ON_DEVICE_LOCK
};
public static final int[] SEARCH_BEHAVIOR_SETTINGS = {
SEARCH_IN_ISSUER,
SEARCH_IN_NAME,
SEARCH_IN_NOTE,
SEARCH_IN_GROUPS
};
private SharedPreferences _prefs;
public Preferences(Context context) {
@@ -162,6 +176,20 @@ public class Preferences {
return _prefs.getInt("pref_auto_lock_mask", def);
}
public int getSearchBehaviorMask() {
final int def = SEARCH_IN_ISSUER | SEARCH_IN_NAME;
return _prefs.getInt("pref_search_behavior_mask", def);
}
public boolean isSearchBehaviorTypeEnabled(int searchBehaviorType) {
return (getSearchBehaviorMask() & searchBehaviorType) == searchBehaviorType;
}
public void setSearchBehaviorMask(int searchBehavior) {
_prefs.edit().putInt("pref_search_behavior_mask", searchBehavior).apply();
}
public boolean isAutoLockEnabled() {
return getAutoLockMask() != AUTO_LOCK_OFF;
}
@@ -235,10 +263,51 @@ public class Preferences {
setUsageCount(usageCounts);
}
public long getLastUsedTimestamp(UUID uuid) {
Map<UUID, Long> timestamps = getLastUsedTimestamps();
if (timestamps != null && timestamps.size() > 0){
Long timestamp = timestamps.get(uuid);
return timestamp != null ? timestamp : 0;
}
return 0;
}
public void clearUsageCount() {
_prefs.edit().remove("pref_usage_count").apply();
}
public Map<UUID, Long> getLastUsedTimestamps() {
Map<UUID, Long> lastUsedTimestamps = new HashMap<>();
String lastUsedTimestamp = _prefs.getString("pref_last_used_timestamps", "");
try {
JSONArray arr = new JSONArray(lastUsedTimestamp);
for (int i = 0; i < arr.length(); i++) {
JSONObject json = arr.getJSONObject(i);
lastUsedTimestamps.put(UUID.fromString(json.getString("uuid")), json.getLong("timestamp"));
}
} catch (JSONException ignored) {
}
return lastUsedTimestamps;
}
public void setLastUsedTimestamps(Map<UUID, Long> lastUsedTimestamps) {
JSONArray lastUsedTimestampJson = new JSONArray();
for (Map.Entry<UUID, Long> entry : lastUsedTimestamps.entrySet()) {
JSONObject entryJson = new JSONObject();
try {
entryJson.put("uuid", entry.getKey());
entryJson.put("timestamp", entry.getValue());
lastUsedTimestampJson.put(entryJson);
} catch (JSONException e) {
e.printStackTrace();
}
}
_prefs.edit().putString("pref_last_used_timestamps", lastUsedTimestampJson.toString()).apply();
}
public Map<UUID, Integer> getUsageCounts() {
Map<UUID, Integer> usageCounts = new HashMap<>();
String usageCount = _prefs.getString("pref_usage_count", "");
@@ -1,5 +1,6 @@
package com.beemdevelopment.aegis;
import com.beemdevelopment.aegis.helpers.comparators.LastUsedComparator;
import com.beemdevelopment.aegis.helpers.comparators.UsageCountComparator;
import com.beemdevelopment.aegis.vault.VaultEntry;
import com.beemdevelopment.aegis.helpers.comparators.AccountNameComparator;
@@ -14,7 +15,8 @@ public enum SortCategory {
ACCOUNT_REVERSED,
ISSUER,
ISSUER_REVERSED,
USAGE_COUNT;
USAGE_COUNT,
LAST_USED;
private static SortCategory[] _values;
@@ -45,6 +47,8 @@ public enum SortCategory {
case USAGE_COUNT:
comparator = Collections.reverseOrder(new UsageCountComparator());
break;
case LAST_USED:
comparator = Collections.reverseOrder(new LastUsedComparator());
}
return comparator;
@@ -64,6 +68,8 @@ public enum SortCategory {
return R.id.menu_sort_alphabetically_reverse;
case USAGE_COUNT:
return R.id.menu_sort_usage_count;
case LAST_USED:
return R.id.menu_sort_last_used;
default:
return R.id.menu_sort_custom;
}
@@ -35,11 +35,11 @@ public enum ViewMode {
}
/**
* Retrieves the height (in dp) that the divider between entries should have in this view mode.
* Retrieves the offset (in dp) that should exist between entries in this view mode.
*/
public float getDividerHeight() {
public float getItemOffset() {
if (this == ViewMode.COMPACT) {
return 0;
return 1;
} else if (this == ViewMode.TILES) {
return 4;
}
@@ -47,7 +47,7 @@ public enum ViewMode {
return 8;
}
public int getColumnSpan() {
public int getSpanCount() {
if (this == ViewMode.TILES) {
return 2;
}
@@ -55,14 +55,6 @@ public enum ViewMode {
return 1;
}
public float getDividerWidth() {
if (this == ViewMode.TILES) {
return 4;
}
return 0;
}
public String getFormattedAccountName(String accountName) {
if (this == ViewMode.TILES) {
return accountName;
@@ -0,0 +1,15 @@
package com.beemdevelopment.aegis.database;
import android.content.Context;
import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Database(entities = {AuditLogEntry.class}, version = 1)
public abstract class AppDatabase extends RoomDatabase {
public abstract AuditLogDao auditLogDao();
}
@@ -0,0 +1,17 @@
package com.beemdevelopment.aegis.database;
import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;
import java.util.List;
@Dao
public interface AuditLogDao {
@Insert
void insert(AuditLogEntry log);
@Query("SELECT * FROM audit_logs WHERE timestamp >= strftime('%s', 'now', '-30 days') ORDER BY timestamp DESC")
LiveData<List<AuditLogEntry>> getAll();
}
@@ -0,0 +1,61 @@
package com.beemdevelopment.aegis.database;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;
import com.beemdevelopment.aegis.EventType;
@Entity(tableName = "audit_logs")
public class AuditLogEntry {
@PrimaryKey(autoGenerate = true)
protected long id;
@NonNull
@ColumnInfo(name = "event_type")
private final EventType _eventType;
@ColumnInfo(name = "reference")
private final String _reference;
@ColumnInfo(name = "timestamp")
private final long _timestamp;
@Ignore
public AuditLogEntry(@NonNull EventType eventType) {
this(eventType, null);
}
@Ignore
public AuditLogEntry(@NonNull EventType eventType, @Nullable String reference) {
_eventType = eventType;
_reference = reference;
_timestamp = System.currentTimeMillis();
}
AuditLogEntry(long id, @NonNull EventType eventType, @Nullable String reference, long timestamp) {
this.id = id;
_eventType = eventType;
_reference = reference;
_timestamp = timestamp;
}
public long getId() {
return id;
}
public EventType getEventType() {
return _eventType;
}
public String getReference() {
return _reference;
}
public long getTimestamp() {
return _timestamp;
}
}
@@ -0,0 +1,66 @@
package com.beemdevelopment.aegis.database;
import androidx.lifecycle.LiveData;
import com.beemdevelopment.aegis.EventType;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
public class AuditLogRepository {
private final AuditLogDao _auditLogDao;
private final Executor _executor;
public AuditLogRepository(AuditLogDao auditLogDao) {
_auditLogDao = auditLogDao;
_executor = Executors.newSingleThreadExecutor();
}
public LiveData<List<AuditLogEntry>> getAllAuditLogEntries() {
return _auditLogDao.getAll();
}
public void addVaultUnlockedEvent() {
AuditLogEntry auditLogEntry = new AuditLogEntry(EventType.VAULT_UNLOCKED);
insert(auditLogEntry);
}
public void addBackupCreatedEvent() {
AuditLogEntry auditLogEntry = new AuditLogEntry(EventType.VAULT_BACKUP_CREATED);
insert(auditLogEntry);
}
public void addAndroidBackupCreatedEvent() {
AuditLogEntry auditLogEntry = new AuditLogEntry(EventType.VAULT_ANDROID_BACKUP_CREATED);
insert(auditLogEntry);
}
public void addVaultExportedEvent() {
AuditLogEntry auditLogEntry = new AuditLogEntry(EventType.VAULT_EXPORTED);
insert(auditLogEntry);
}
public void addEntrySharedEvent(String reference) {
AuditLogEntry auditLogEntry = new AuditLogEntry(EventType.ENTRY_SHARED, reference);
insert(auditLogEntry);
}
public void addVaultUnlockFailedPasswordEvent() {
AuditLogEntry auditLogEntry = new AuditLogEntry(EventType.VAULT_UNLOCK_FAILED_PASSWORD);
insert(auditLogEntry);
}
public void addVaultUnlockFailedBiometricsEvent() {
AuditLogEntry auditLogEntry = new AuditLogEntry(EventType.VAULT_UNLOCK_FAILED_BIOMETRICS);
insert(auditLogEntry);
}
public void insert(AuditLogEntry auditLogEntry) {
_executor.execute(() -> {
_auditLogDao.insert(auditLogEntry);
});
}
}
@@ -0,0 +1,30 @@
package com.beemdevelopment.aegis.helpers;
import android.graphics.Rect;
import android.text.TextPaint;
import android.text.style.MetricAffectingSpan;
import androidx.annotation.NonNull;
public class CenterVerticalSpan extends MetricAffectingSpan {
Rect _substringBounds;
public CenterVerticalSpan(Rect substringBounds) {
_substringBounds = substringBounds;
}
@Override
public void updateMeasureState(@NonNull TextPaint textPaint) {
applyBaselineShift(textPaint);
}
@Override
public void updateDrawState(@NonNull TextPaint textPaint) {
applyBaselineShift(textPaint);
}
private void applyBaselineShift(TextPaint textPaint) {
float topDifference = textPaint.getFontMetrics().top - _substringBounds.top;
textPaint.baselineShift -= (topDifference / 2f);
}
}
@@ -1,14 +1,60 @@
package com.beemdevelopment.aegis.helpers;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.beemdevelopment.aegis.R;
import com.google.android.material.textfield.TextInputLayout;
import com.google.common.base.Strings;
import com.nulabinc.zxcvbn.Strength;
import com.nulabinc.zxcvbn.Zxcvbn;
public class PasswordStrengthHelper {
// Material design color palette
private static String[] COLORS = {"#FF5252", "#FF5252", "#FFC107", "#8BC34A", "#4CAF50"};
// Limit the password length to prevent zxcvbn4j from exploding
private static final int MAX_PASSWORD_LENGTH = 64;
public static String getString(int score, Context context) {
// Material design color palette
private final static String[] COLORS = {"#FF5252", "#FF5252", "#FFC107", "#8BC34A", "#4CAF50"};
private final Zxcvbn _zxcvbn = new Zxcvbn();
private final EditText _textPassword;
private final ProgressBar _barPasswordStrength;
private final TextView _textPasswordStrength;
private final TextInputLayout _textPasswordWrapper;
public PasswordStrengthHelper(
EditText textPassword,
ProgressBar barPasswordStrength,
TextView textPasswordStrength,
TextInputLayout textPasswordWrapper
) {
_textPassword = textPassword;
_barPasswordStrength = barPasswordStrength;
_textPasswordStrength = textPasswordStrength;
_textPasswordWrapper = textPasswordWrapper;
}
public void measure(Context context) {
if (_textPassword.getText().length() > MAX_PASSWORD_LENGTH) {
_barPasswordStrength.setProgress(0);
_textPasswordStrength.setText(R.string.password_strength_unknown);
} else {
Strength strength = _zxcvbn.measure(_textPassword.getText());
_barPasswordStrength.setProgress(strength.getScore());
_barPasswordStrength.setProgressTintList(ColorStateList.valueOf(Color.parseColor(getColor(strength.getScore()))));
_textPasswordStrength.setText((_textPassword.getText().length() != 0) ? getString(strength.getScore(), context) : "");
String warning = strength.getFeedback().getWarning();
_textPasswordWrapper.setError(warning);
_textPasswordWrapper.setErrorEnabled(!Strings.isNullOrEmpty(warning));
strength.wipe();
}
}
private static String getString(int score, Context context) {
if (score < 0 || score > 4) {
throw new IllegalArgumentException("Not a valid zxcvbn score");
}
@@ -17,7 +63,7 @@ public class PasswordStrengthHelper {
return strings[score];
}
public static String getColor(int score) {
private static String getColor(int score) {
if (score < 0 || score > 4) {
throw new IllegalArgumentException("Not a valid zxcvbn score");
}
@@ -1,23 +1,55 @@
package com.beemdevelopment.aegis.helpers;
import android.content.res.Resources;
import android.graphics.Color;
import android.util.TypedValue;
import android.content.res.Configuration;
import androidx.annotation.ColorInt;
import androidx.appcompat.app.AppCompatActivity;
import com.beemdevelopment.aegis.Preferences;
import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.Theme;
import com.google.android.material.color.DynamicColors;
import com.google.android.material.color.DynamicColorsOptions;
import java.util.Map;
public class ThemeHelper {
private ThemeHelper() {
private final AppCompatActivity _activity;
private final Preferences _prefs;
public ThemeHelper(AppCompatActivity activity, Preferences prefs) {
_activity = activity;
_prefs = prefs;
}
public static int getThemeColor(int attributeId, Resources.Theme currentTheme) {
TypedValue typedValue = new TypedValue();
currentTheme.resolveAttribute(attributeId, typedValue, true);
@ColorInt int color = typedValue.data;
/**
* Sets the theme of the activity. The actual style that is set is picked from the
* given map, based on the theme configured by the user.
*/
public void setTheme(Map<Theme, Integer> themeMap) {
int theme = themeMap.get(getConfiguredTheme());
_activity.setTheme(theme);
return color;
if (_prefs.isDynamicColorsEnabled()) {
DynamicColorsOptions.Builder optsBuilder = new DynamicColorsOptions.Builder();
if (getConfiguredTheme().equals(Theme.AMOLED)) {
optsBuilder.setThemeOverlay(R.style.ThemeOverlay_Aegis_Dynamic_Amoled);
}
DynamicColors.applyToActivityIfAvailable(_activity, optsBuilder.build());
}
}
public Theme getConfiguredTheme() {
Theme theme = _prefs.getCurrentTheme();
if (theme == Theme.SYSTEM || theme == Theme.SYSTEM_AMOLED) {
int currentNightMode = _activity.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
if (currentNightMode == Configuration.UI_MODE_NIGHT_YES) {
theme = theme == Theme.SYSTEM_AMOLED ? Theme.AMOLED : Theme.DARK;
} else {
theme = Theme.LIGHT;
}
}
return theme;
}
}
@@ -0,0 +1,12 @@
package com.beemdevelopment.aegis.helpers.comparators;
import com.beemdevelopment.aegis.vault.VaultEntry;
import java.util.Comparator;
public class LastUsedComparator implements Comparator<VaultEntry> {
@Override
public int compare(VaultEntry a, VaultEntry b) {
return Long.compare(a.getLastUsedTimestamp(), b.getLastUsedTimestamp());
}
}
@@ -11,6 +11,7 @@ import com.beemdevelopment.aegis.otp.OtpInfoException;
import com.beemdevelopment.aegis.otp.TotpInfo;
import com.beemdevelopment.aegis.util.PreferenceParser;
import com.beemdevelopment.aegis.vault.VaultEntry;
import com.google.common.base.Strings;
import com.topjohnwu.superuser.io.SuFile;
import org.xmlpull.v1.XmlPullParser;
@@ -18,12 +19,10 @@ import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
public class BattleNetImporter extends DatabaseImporter {
private static final String _pkgName = "com.blizzard.bma";
private static final String _subPath = "shared_prefs/com.blizzard.bma.AUTH_STORE.xml";
private static final String _pkgName = "com.blizzard.messenger";
private static final String _subPath = "shared_prefs/com.blizzard.messenger.authenticator_preferences.xml";
private static final byte[] _key;
@@ -46,71 +45,80 @@ public class BattleNetImporter extends DatabaseImporter {
@Override
protected State read(InputStream stream, boolean isInternal) throws DatabaseImporterException {
final String serialKey = "com.blizzard.messenger.AUTHENTICATOR_SERIAL";
final String secretKey = "com.blizzard.messenger.AUTHENTICATOR_DEVICE_SECRET";
try {
XmlPullParser parser = Xml.newPullParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
parser.setInput(stream, null);
parser.nextTag();
List<String> entries = new ArrayList<>();
String serial = "";
String secretValue = null;
for (PreferenceParser.XmlEntry entry : PreferenceParser.parse(parser)) {
if (entry.Name.equals("com.blizzard.bma.AUTH_STORE.HASH")) {
entries.add(entry.Value);
break;
if (entry.Name.equals(secretKey)) {
secretValue = entry.Value;
} else if (entry.Name.equals(serialKey)) {
serial = entry.Value;
}
}
return new BattleNetImporter.State(entries);
if (secretValue == null) {
throw new DatabaseImporterException(String.format("Key not found: %s", secretKey));
}
return new BattleNetImporter.State(serial, secretValue);
} catch (XmlPullParserException | IOException e) {
throw new DatabaseImporterException(e);
}
}
public static class State extends DatabaseImporter.State {
private final List<String> _entries;
private final String _serial;
private final String _secretValue;
public State(List<String> entries) {
public State(String serial, String secretValue) {
super(false);
_entries = entries;
_serial = serial;
_secretValue = secretValue;
}
@Override
public Result convert() {
Result result = new Result();
for (String str : _entries) {
try {
VaultEntry entry = convertEntry(str);
result.addEntry(entry);
} catch (DatabaseImporterEntryException e) {
result.addError(e);
}
try {
VaultEntry entry = convertEntry(_serial, _secretValue);
result.addEntry(entry);
} catch (DatabaseImporterEntryException e) {
result.addError(e);
}
return result;
}
private static VaultEntry convertEntry(String hashString) throws DatabaseImporterEntryException {
private static VaultEntry convertEntry(String serial, String secretString) throws DatabaseImporterEntryException {
try {
byte[] hash = Hex.decode(hashString);
if (hash.length != _key.length) {
throw new DatabaseImporterEntryException(String.format("Unexpected hash length: %d", hash.length), hashString);
if (!Strings.isNullOrEmpty(serial)) {
serial = unmask(serial);
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hash.length; i++) {
char c = (char) (hash[i] ^ _key[i]);
sb.append(c);
}
final int secretLen = 40;
byte[] secret = Hex.decode(sb.substring(0, secretLen));
String serial = sb.substring(secretLen);
byte[] secret = Hex.decode(unmask(secretString));
OtpInfo info = new TotpInfo(secret, OtpInfo.DEFAULT_ALGORITHM, 8, TotpInfo.DEFAULT_PERIOD);
return new VaultEntry(info, serial, "Battle.net");
} catch (OtpInfoException | EncodingException e) {
throw new DatabaseImporterEntryException(e, hashString);
throw new DatabaseImporterEntryException(e, secretString);
}
}
private static String unmask(String s) throws EncodingException {
byte[] ds = Hex.decode(s);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < ds.length; i++) {
char c = (char) (ds[i] ^ _key[i]);
sb.append(c);
}
return sb.toString();
}
}
}
@@ -39,8 +39,8 @@ public abstract class DatabaseImporter {
_importers.add(new Definition("Battle.net Authenticator", BattleNetImporter.class, R.string.importer_help_battle_net_authenticator, true));
_importers.add(new Definition("Bitwarden", BitwardenImporter.class, R.string.importer_help_bitwarden, false));
_importers.add(new Definition("Duo", DuoImporter.class, R.string.importer_help_duo, true));
_importers.add(new Definition("FreeOTP", FreeOtpImporter.class, R.string.importer_help_freeotp, true));
_importers.add(new Definition("FreeOTP+", FreeOtpPlusImporter.class, R.string.importer_help_freeotp_plus, true));
_importers.add(new Definition("FreeOTP (1.x)", FreeOtpImporter.class, R.string.importer_help_freeotp, true));
_importers.add(new Definition("FreeOTP+ (JSON)", FreeOtpPlusImporter.class, R.string.importer_help_freeotp_plus, true));
_importers.add(new Definition("Google Authenticator", GoogleAuthImporter.class, R.string.importer_help_google_authenticator, true));
_importers.add(new Definition("Microsoft Authenticator", MicrosoftAuthImporter.class, R.string.importer_help_microsoft_authenticator, true));
_importers.add(new Definition("Plain text", GoogleAuthUriImporter.class, R.string.importer_help_plain_text, false));
@@ -1,34 +0,0 @@
package com.beemdevelopment.aegis.licenses;
import android.content.Context;
import com.beemdevelopment.aegis.R;
import de.psdev.licensesdialog.licenses.License;
public class GlideLicense extends License {
@Override
public String getName() {
return "Glide License";
}
@Override
public String readSummaryTextFromResources(Context context) {
return getContent(context, R.raw.glide_license);
}
@Override
public String readFullTextFromResources(Context context) {
return getContent(context, R.raw.glide_license);
}
@Override
public String getVersion() {
return null;
}
@Override
public String getUrl() {
return "https://github.com/bumptech/glide/blob/master/LICENSE";
}
}
@@ -1,34 +0,0 @@
package com.beemdevelopment.aegis.licenses;
import android.content.Context;
import com.beemdevelopment.aegis.R;
import de.psdev.licensesdialog.licenses.License;
public class ProtobufLicense extends License {
@Override
public String getName() {
return "Protocol Buffers License";
}
@Override
public String readSummaryTextFromResources(Context context) {
return getContent(context, R.raw.protobuf_license);
}
@Override
public String readFullTextFromResources(Context context) {
return getContent(context, R.raw.protobuf_license);
}
@Override
public String getVersion() {
return null;
}
@Override
public String getUrl() {
return "https://raw.githubusercontent.com/protocolbuffers/protobuf/master/LICENSE";
}
}
@@ -16,14 +16,9 @@ import androidx.annotation.StringRes;
import com.beemdevelopment.aegis.BuildConfig;
import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.helpers.ThemeHelper;
import com.beemdevelopment.aegis.licenses.GlideLicense;
import com.beemdevelopment.aegis.licenses.ProtobufLicense;
import com.beemdevelopment.aegis.ui.dialogs.ChangelogDialog;
import com.beemdevelopment.aegis.ui.dialogs.LicenseDialog;
import de.psdev.licensesdialog.LicenseResolver;
import de.psdev.licensesdialog.LicensesDialog;
import com.google.android.material.color.MaterialColors;
public class AboutActivity extends AegisActivity {
@@ -53,12 +48,15 @@ public class AboutActivity extends AegisActivity {
View btnLicense = findViewById(R.id.btn_license);
btnLicense.setOnClickListener(v -> {
LicenseDialog.create()
.setTheme(getConfiguredTheme())
.setTheme(_themeHelper.getConfiguredTheme())
.show(getSupportFragmentManager(), null);
});
View btnThirdPartyLicenses = findViewById(R.id.btn_third_party_licenses);
btnThirdPartyLicenses.setOnClickListener(v -> showThirdPartyLicenseDialog());
btnThirdPartyLicenses.setOnClickListener(v -> {
Intent intent = new Intent(this, LicensesActivity.class);
startActivity(intent);
});
TextView appVersion = findViewById(R.id.app_version);
appVersion.setText(getCurrentAppVersion());
@@ -89,7 +87,7 @@ public class AboutActivity extends AegisActivity {
View btnChangelog = findViewById(R.id.btn_changelog);
btnChangelog.setOnClickListener(v -> {
ChangelogDialog.create()
.setTheme(getConfiguredTheme())
.setTheme(_themeHelper.getConfiguredTheme())
.show(getSupportFragmentManager(), null);
});
}
@@ -126,29 +124,9 @@ public class AboutActivity extends AegisActivity {
startActivity(Intent.createChooser(mailIntent, getString(R.string.email)));
}
private void showThirdPartyLicenseDialog() {
String stylesheet = getString(R.string.custom_notices_format_style);
String backgroundColor = getThemeColorAsHex(com.google.android.material.R.attr.colorSurfaceContainerLow);
String textColor = getThemeColorAsHex(com.google.android.material.R.attr.colorOnSurface);
String licenseColor = getThemeColorAsHex(com.google.android.material.R.attr.colorSurfaceContainerLow);
String linkColor = getThemeColorAsHex(com.google.android.material.R.attr.colorAccent);
stylesheet = String.format(stylesheet, backgroundColor, textColor, licenseColor, linkColor);
LicenseResolver.registerLicense(new GlideLicense());
LicenseResolver.registerLicense(new ProtobufLicense());
new LicensesDialog.Builder(this)
.setNotices(R.raw.notices)
.setTitle(R.string.third_party_licenses)
.setNoticesCssStyle(stylesheet)
.setIncludeOwnLicense(true)
.build()
.show();
}
private String getThemeColorAsHex(@AttrRes int attributeId) {
return String.format("%06X", (0xFFFFFF & ThemeHelper.getThemeColor(attributeId, getTheme())));
int color = MaterialColors.getColor(this, attributeId, getClass().getCanonicalName());
return String.format("%06X", 0xFFFFFF & color);
}
@Override
@@ -20,19 +20,18 @@ import androidx.core.view.ViewPropertyAnimatorCompat;
import com.beemdevelopment.aegis.Preferences;
import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.Theme;
import com.beemdevelopment.aegis.ThemeMap;
import com.beemdevelopment.aegis.database.AuditLogRepository;
import com.beemdevelopment.aegis.helpers.ThemeHelper;
import com.beemdevelopment.aegis.icons.IconPackManager;
import com.beemdevelopment.aegis.vault.VaultManager;
import com.beemdevelopment.aegis.vault.VaultRepositoryException;
import com.google.android.material.color.DynamicColors;
import com.google.android.material.color.MaterialColors;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Locale;
import java.util.Map;
import javax.inject.Inject;
@@ -45,10 +44,14 @@ import dagger.hilt.components.SingletonComponent;
@AndroidEntryPoint
public abstract class AegisActivity extends AppCompatActivity implements VaultManager.LockListener {
protected Preferences _prefs;
protected ThemeHelper _themeHelper;
@Inject
protected VaultManager _vaultManager;
@Inject
protected AuditLogRepository _auditLogRepository;
@Inject
protected IconPackManager _iconPackManager;
@@ -58,6 +61,7 @@ public abstract class AegisActivity extends AppCompatActivity implements VaultMa
protected void onCreate(Bundle savedInstanceState) {
// set the theme and locale before creating the activity
_prefs = EarlyEntryPoints.get(getApplicationContext(), PrefEntryPoint.class).getPreferences();
_themeHelper = new ThemeHelper(this, _prefs);
onSetTheme();
setLocale(_prefs.getLocale());
super.onCreate(savedInstanceState);
@@ -110,35 +114,7 @@ public abstract class AegisActivity extends AppCompatActivity implements VaultMa
* Called when the activity is expected to set its theme.
*/
protected void onSetTheme() {
setTheme(ThemeMap.DEFAULT);
}
/**
* Sets the theme of the activity. The actual style that is set is picked from the
* given map, based on the theme configured by the user.
*/
protected void setTheme(Map<Theme, Integer> themeMap) {
int theme = themeMap.get(getConfiguredTheme());
setTheme(theme);
if (_prefs.isDynamicColorsEnabled()) {
DynamicColors.applyToActivityIfAvailable(this);
}
}
protected Theme getConfiguredTheme() {
Theme theme = _prefs.getCurrentTheme();
if (theme == Theme.SYSTEM || theme == Theme.SYSTEM_AMOLED) {
int currentNightMode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
if (currentNightMode == Configuration.UI_MODE_NIGHT_YES) {
theme = theme == Theme.SYSTEM_AMOLED ? Theme.AMOLED : Theme.DARK;
} else {
theme = Theme.LIGHT;
}
}
return theme;
_themeHelper.setTheme(ThemeMap.DEFAULT);
}
protected void setLocale(Locale locale) {
@@ -251,7 +227,7 @@ public abstract class AegisActivity extends AppCompatActivity implements VaultMa
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
int statusBarColor = visibility == View.VISIBLE
? ThemeHelper.getThemeColor(com.google.android.material.R.attr.colorSurfaceContainer, getTheme())
? MaterialColors.getColor(actionModeView, com.google.android.material.R.attr.colorSurfaceContainer)
: _statusBarColor;
getWindow().setStatusBarColor(statusBarColor);
}
@@ -42,6 +42,7 @@ import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
public class AssignIconsActivity extends AegisActivity implements AssignIconAdapter.Listener {
private AssignIconAdapter _adapter;
@@ -184,7 +185,11 @@ public class AssignIconsActivity extends AegisActivity implements AssignIconAdap
@Override
public void onAssignIconEntryClick(AssignIconEntry entry) {
BottomSheetDialog dialog = IconPickerDialog.create(this, Collections.singletonList(_favoriteIconPack), entry.getEntry().getIssuer(), false, new IconAdapter.Listener() {
List<IconPack> iconPacks = _iconPackManager.getIconPacks().stream()
.sorted(Comparator.comparing(IconPack::getName))
.collect(Collectors.toList());
BottomSheetDialog dialog = IconPickerDialog.create(this, iconPacks, entry.getEntry().getIssuer(), false, new IconAdapter.Listener() {
@Override
public void onIconSelected(IconPack.Icon icon) {
entry.setNewIcon(icon);
@@ -241,7 +241,7 @@ public class AuthActivity extends AegisActivity {
popup.setFocusable(false);
popup.setOutsideTouchable(true);
_textPassword.post(() -> {
if (isFinishing()) {
if (isFinishing() || !_textPassword.isAttachedToWindow()) {
return;
}
@@ -344,6 +344,8 @@ public class AuthActivity extends AegisActivity {
finish(result.getKey(), result.isSlotRepaired());
} else {
_decryptButton.setEnabled(true);
_auditLogRepository.addVaultUnlockFailedPasswordEvent();
onInvalidPassword();
}
}
@@ -356,6 +358,7 @@ public class AuthActivity extends AegisActivity {
_bioPrompt = null;
if (!BiometricsHelper.isCanceled(errorCode)) {
_auditLogRepository.addVaultUnlockFailedBiometricsEvent();
Toast.makeText(AuthActivity.this, errString, Toast.LENGTH_LONG).show();
}
}
@@ -1,6 +1,5 @@
package com.beemdevelopment.aegis.ui;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
@@ -16,9 +15,11 @@ import android.view.animation.AccelerateInterpolator;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.activity.OnBackPressedCallback;
import androidx.activity.result.ActivityResultLauncher;
@@ -67,7 +68,10 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.google.android.material.chip.Chip;
import com.google.android.material.chip.ChipGroup;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.imageview.ShapeableImageView;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
@@ -75,21 +79,20 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import de.hdodenhof.circleimageview.CircleImageView;
public class EditEntryActivity extends AegisActivity {
private boolean _isNew = false;
private boolean _isManual = false;
@@ -99,11 +102,13 @@ public class EditEntryActivity extends AegisActivity {
// keep track of icon changes separately as the generated jpeg's are not deterministic
private boolean _hasChangedIcon = false;
private IconPack.Icon _selectedIcon;
private CircleImageView _iconView;
private ShapeableImageView _iconView;
private ImageView _saveImageButton;
private TextInputEditText _textName;
private TextInputEditText _textIssuer;
private TextInputLayout _textGroupLayout;
private TextInputEditText _textGroup;
private TextInputEditText _textPeriodCounter;
private TextInputLayout _textPeriodCounterLayout;
private TextInputEditText _textDigits;
@@ -113,17 +118,17 @@ public class EditEntryActivity extends AegisActivity {
private LinearLayout _textPinLayout;
private TextInputEditText _textUsageCount;
private TextInputEditText _textNote;
private TextView _textLastUsed;
private AutoCompleteTextView _dropdownType;
private AutoCompleteTextView _dropdownAlgo;
private TextInputLayout _dropdownAlgoLayout;
private AutoCompleteTextView _dropdownGroup;
private List<VaultGroupModel> _dropdownGroupList = new ArrayList<>();
private List<UUID> _selectedGroups = new ArrayList<>();
private KropView _kropView;
private RelativeLayout _advancedSettingsHeader;
private RelativeLayout _advancedSettings;
private LinearLayout _advancedSettingsLayout;
private BackPressHandler _backPressHandler;
private IconBackPressHandler _iconBackPressHandler;
@@ -191,6 +196,8 @@ public class EditEntryActivity extends AegisActivity {
_saveImageButton = findViewById(R.id.iv_saveImage);
_textName = findViewById(R.id.text_name);
_textIssuer = findViewById(R.id.text_issuer);
_textGroup = findViewById(R.id.text_group);
_textGroupLayout = findViewById(R.id.text_group_layout);
_textPeriodCounter = findViewById(R.id.text_period_counter);
_textPeriodCounterLayout = findViewById(R.id.text_period_counter_layout);
_textDigits = findViewById(R.id.text_digits);
@@ -200,14 +207,12 @@ public class EditEntryActivity extends AegisActivity {
_textPinLayout = findViewById(R.id.layout_pin);
_textUsageCount = findViewById(R.id.text_usage_count);
_textNote = findViewById(R.id.text_note);
_textLastUsed = findViewById(R.id.text_last_used);
_dropdownType = findViewById(R.id.dropdown_type);
DropdownHelper.fillDropdown(this, _dropdownType, R.array.otp_types_array);
_dropdownAlgoLayout = findViewById(R.id.dropdown_algo_layout);
_dropdownAlgo = findViewById(R.id.dropdown_algo);
DropdownHelper.fillDropdown(this, _dropdownAlgo, R.array.otp_algo_array);
_dropdownGroup = findViewById(R.id.dropdown_group);
updateGroupDropdownList();
DropdownHelper.fillDropdown(this, _dropdownGroup, _dropdownGroupList);
// if this is NOT a manually entered entry, move the "Secret" field from basic to advanced settings
if (!_isNew || !_isManual) {
@@ -236,7 +241,7 @@ public class EditEntryActivity extends AegisActivity {
_advancedSettingsHeader = findViewById(R.id.accordian_header);
_advancedSettingsHeader.setOnClickListener(v -> openAdvancedSettings());
_advancedSettings = findViewById(R.id.expandableLayout);
_advancedSettingsLayout = findViewById(R.id.layout_advanced);
// fill the fields with values if possible
GlideHelper.loadEntryIcon(Glide.with(this), _origEntry, _iconView);
@@ -281,10 +286,15 @@ public class EditEntryActivity extends AegisActivity {
Set<UUID> groups = _origEntry.getGroups();
if (groups.isEmpty()) {
setGroup(new VaultGroupModel(getString(R.string.no_group)));
_textGroup.setText(getString(R.string.no_group));
} else {
VaultGroup group = _vaultManager.getVault().getGroupByUUID(groups.iterator().next());
setGroup(new VaultGroupModel(group));
String text = groups.stream().map(uuid -> {
VaultGroup group = _vaultManager.getVault().getGroupByUUID(uuid);
return group.getName();
})
.collect(Collectors.joining(", "));
_selectedGroups.addAll(groups);
_textGroup.setText(text);
}
// Update the icon if the issuer or name has changed
@@ -293,11 +303,11 @@ public class EditEntryActivity extends AegisActivity {
// Register listeners to trigger validation
_textIssuer.addTextChangedListener(_validationListener);
_textGroup.addTextChangedListener(_validationListener);
_textName.addTextChangedListener(_validationListener);
_textNote.addTextChangedListener(_validationListener);
_textSecret.addTextChangedListener(_validationListener);
_dropdownType.addTextChangedListener(_validationListener);
_dropdownGroup.addTextChangedListener(_validationListener);
_dropdownAlgo.addTextChangedListener(_validationListener);
_textPeriodCounter.addTextChangedListener(_validationListener);
_textDigits.addTextChangedListener(_validationListener);
@@ -349,35 +359,107 @@ public class EditEntryActivity extends AegisActivity {
startIconSelection();
});
_dropdownGroup.setOnItemClickListener((parent, view, position, id) -> {
VaultGroupModel selectedGroup = _dropdownGroupList.get(position);
if (selectedGroup.isPlaceholder() && Objects.equals(selectedGroup.getName(), getString(R.string.new_group))) {
Dialogs.TextInputListener onAddGroup = text -> {
String groupName = new String(text).trim();
if (!groupName.isEmpty()) {
VaultGroup group = _vaultManager.getVault().findGroupByName(groupName);
if (group == null) {
group = new VaultGroup(groupName);
_vaultManager.getVault().addGroup(group);
}
updateGroupDropdownList();
setGroup(new VaultGroupModel(group));
}
};
DialogInterface.OnCancelListener onCancel = dialogInterface -> {
VaultGroupModel previous = (VaultGroupModel) _dropdownGroup.getTag();
_dropdownGroup.setText(previous.getName(), false);
};
Dialogs.showTextInputDialog(EditEntryActivity.this, R.string.set_group, R.string.group_name_hint, onAddGroup, onCancel);
} else {
setGroup(_dropdownGroupList.get(position));
_textGroup.setShowSoftInputOnFocus(false);
_textGroup.setOnClickListener(v -> showGroupSelectionDialog());
_textGroup.setOnFocusChangeListener((v, hasFocus) -> {
if (hasFocus) {
showGroupSelectionDialog();
}
});
_textGroupLayout.setOnClickListener(v -> {
showGroupSelectionDialog();
});
_textUsageCount.setText(_prefs.getUsageCount(entryUUID).toString());
setLastUsedTimestamp(_prefs.getLastUsedTimestamp(entryUUID));
}
private void showGroupSelectionDialog() {
BottomSheetDialog dialog = new BottomSheetDialog(this);
View view = getLayoutInflater().inflate(R.layout.dialog_select_groups, null);
dialog.setContentView(view);
ChipGroup chipGroup = view.findViewById(R.id.groupChipGroup);
TextView addGroupInfo = view.findViewById(R.id.addGroupInfo);
LinearLayout addGroup = view.findViewById(R.id.addGroup);
Button clearButton = view.findViewById(R.id.btnClear);
Button saveButton = view.findViewById(R.id.btnSave);
chipGroup.removeAllViews();
addGroupInfo.setVisibility(View.VISIBLE);
addGroup.setVisibility(View.VISIBLE);
for (VaultGroup group : _groups) {
addChipTo(chipGroup, new VaultGroupModel(group), false);
}
addGroup.setOnClickListener(v1 -> {
Dialogs.TextInputListener onAddGroup = text -> {
String groupName = new String(text).trim();
if (!groupName.isEmpty()) {
VaultGroup group = _vaultManager.getVault().findGroupByName(groupName);
if (group == null) {
group = new VaultGroup(groupName);
_vaultManager.getVault().addGroup(group);
}
_selectedGroups.add(group.getUUID());
addChipTo(chipGroup, new VaultGroupModel(group), true);
}
};
Dialogs.showTextInputDialog(EditEntryActivity.this, R.string.set_group, R.string.group_name_hint, onAddGroup);
});
saveButton.setOnClickListener(v1 -> {
if(getCheckedUUID(chipGroup).isEmpty()) {
_selectedGroups.clear();
_textGroup.setText(getString(R.string.no_group));
} else {
_selectedGroups.clear();
_selectedGroups.addAll(getCheckedUUID(chipGroup));
_textGroup.setText(getCheckedNames(chipGroup));
}
dialog.dismiss();
});
clearButton.setOnClickListener(v1 -> {
chipGroup.clearCheck();
});
Dialogs.showSecureDialog(dialog);
}
private void addChipTo(ChipGroup chipGroup, VaultGroupModel group, Boolean isNew) {
Chip chip = (Chip) getLayoutInflater().inflate(R.layout.chip_group_filter, null, false);
chip.setText(group.getName());
chip.setCheckable(true);
chip.setChecked((!_selectedGroups.isEmpty() && _selectedGroups.contains(group.getUUID())) || isNew);
chip.setCheckedIconVisible(true);
chip.setTag(group);
chipGroup.addView(chip);
}
private static Set<UUID> getCheckedUUID(ChipGroup chipGroup) {
return chipGroup.getCheckedChipIds().stream()
.map(i -> {
Chip chip = chipGroup.findViewById(i);
VaultGroupModel group = (VaultGroupModel) chip.getTag();
return group.getUUID();
})
.collect(Collectors.toSet());
}
private static String getCheckedNames(ChipGroup chipGroup) {
return chipGroup.getCheckedChipIds().stream()
.map(i -> {
Chip chip = chipGroup.findViewById(i);
VaultGroupModel group = (VaultGroupModel) chip.getTag();
return group.getName();
})
.collect(Collectors.joining(", "));
}
private void updateAdvancedFieldStatus(String otpType) {
@@ -394,36 +476,20 @@ public class EditEntryActivity extends AegisActivity {
_textPin.setHint(otpType.equals(MotpInfo.ID) ? R.string.motp_pin : R.string.yandex_pin);
}
private void setGroup(VaultGroupModel group) {
_dropdownGroup.setText(group.getName(), false);
_dropdownGroup.setTag(group);
}
private void openAdvancedSettings() {
Animation fadeOut = new AlphaAnimation(1, 0);
fadeOut.setInterpolator(new AccelerateInterpolator());
fadeOut.setDuration((long) (220 * AnimationsHelper.Scale.ANIMATOR.getValue(this)));
_advancedSettingsHeader.startAnimation(fadeOut);
Animation fadeIn = new AlphaAnimation(0, 1);
fadeIn.setInterpolator(new AccelerateInterpolator());
fadeIn.setDuration((long) (250 * AnimationsHelper.Scale.ANIMATOR.getValue(this)));
fadeOut.setAnimationListener(new SimpleAnimationEndListener((a) -> {
_advancedSettingsHeader.setVisibility(View.GONE);
_advancedSettings.startAnimation(fadeIn);
_advancedSettingsLayout.setVisibility(View.VISIBLE);
_advancedSettingsLayout.animate()
.setInterpolator(new AccelerateInterpolator())
.setDuration((long) (250 * AnimationsHelper.Scale.ANIMATOR.getValue(this)))
.alpha(1);
}));
fadeIn.setAnimationListener(new SimpleAnimationEndListener((a) -> {
_advancedSettings.setVisibility(View.VISIBLE);
}));
}
private void updateGroupDropdownList() {
_dropdownGroupList.clear();
_dropdownGroupList.add(new VaultGroupModel(getString(R.string.new_group)));
_dropdownGroupList.addAll(_groups.stream().map(VaultGroupModel::new).collect(Collectors.toList()));
_dropdownGroupList.add(new VaultGroupModel(getString(R.string.no_group)));
}
private boolean hasUnsavedChanges(VaultEntry newEntry) {
@@ -608,6 +674,16 @@ public class EditEntryActivity extends AegisActivity {
saveAndFinish(entry, false);
}
private void setLastUsedTimestamp(long timestamp) {
String readableDate = getString(R.string.last_used_never);
if (timestamp != 0) {
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.getDefault());
readableDate = dateFormat.format(new Date(timestamp));
}
_textLastUsed.setText(String.format("%s: %s", getString(R.string.last_used), readableDate));
}
private void deleteAndFinish(VaultEntry entry) {
_vaultManager.getVault().removeEntry(entry);
saveAndFinish(entry, true);
@@ -715,13 +791,10 @@ public class EditEntryActivity extends AegisActivity {
entry.setName(_textName.getText().toString());
entry.setNote(_textNote.getText().toString());
VaultGroupModel group = (VaultGroupModel) _dropdownGroup.getTag();
if (group.isPlaceholder()) {
if (_selectedGroups.isEmpty()) {
entry.setGroups(new HashSet<>());
} else {
Set<UUID> groups = new HashSet<>();
groups.add(group.getUUID());
entry.setGroups(groups);
entry.setGroups(new HashSet<>(_selectedGroups));
}
if (_hasChangedIcon) {
@@ -13,9 +13,14 @@ import androidx.recyclerview.widget.RecyclerView;
import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.ui.dialogs.Dialogs;
import com.beemdevelopment.aegis.ui.views.GroupAdapter;
import com.beemdevelopment.aegis.util.Cloner;
import com.beemdevelopment.aegis.vault.VaultEntryException;
import com.beemdevelopment.aegis.vault.VaultGroup;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -25,6 +30,7 @@ import java.util.UUID;
public class GroupManagerActivity extends AegisActivity implements GroupAdapter.Listener {
private GroupAdapter _adapter;
private HashSet<UUID> _removedGroups;
private HashSet<VaultGroup> _renamedGroups;
private RecyclerView _groupsView;
private View _emptyStateView;
private BackPressHandler _backPressHandler;
@@ -45,13 +51,24 @@ public class GroupManagerActivity extends AegisActivity implements GroupAdapter.
getOnBackPressedDispatcher().addCallback(this, _backPressHandler);
_removedGroups = new HashSet<>();
_renamedGroups = new HashSet<>();
if (savedInstanceState != null) {
List<String> groups = savedInstanceState.getStringArrayList("removedGroups");
if (groups != null) {
for (String uuid : groups) {
List<String> removedGroups = savedInstanceState.getStringArrayList("removedGroups");
List<String> renamedGroups = savedInstanceState.getStringArrayList("renamedGroups");
if (removedGroups != null) {
for (String uuid : removedGroups) {
_removedGroups.add(UUID.fromString(uuid));
}
}
if (renamedGroups != null) {
for (String groupObject : renamedGroups) {
try {
_renamedGroups.add(VaultGroup.fromJson(new JSONObject(groupObject)));
} catch (VaultEntryException | JSONException ignored) {
// This is intentionally ignored since the json object is valid
}
}
}
}
_adapter = new GroupAdapter(this);
@@ -67,6 +84,11 @@ public class GroupManagerActivity extends AegisActivity implements GroupAdapter.
}
}
for(VaultGroup group: _renamedGroups) {
_adapter.replaceGroup(group.getUUID(), group);
}
_emptyStateView = findViewById(R.id.vEmptyList);
updateEmptyState();
}
@@ -78,10 +100,31 @@ public class GroupManagerActivity extends AegisActivity implements GroupAdapter.
for (UUID uuid : _removedGroups) {
removed.add(uuid.toString());
}
ArrayList<String> renamed = new ArrayList<>();
for (VaultGroup group : _renamedGroups) {
renamed.add(group.toJson().toString());
}
outState.putStringArrayList("renamedGroups", renamed);
outState.putStringArrayList("removedGroups", removed);
}
@Override
public void onEditGroup(VaultGroup group) {
Dialogs.TextInputListener onEditGroup = text -> {
String newGroupName = new String(text).trim();
if (!newGroupName.isEmpty()) {
VaultGroup newGroup = Cloner.clone(group);
newGroup.setName(newGroupName);
_renamedGroups.add(newGroup);
_adapter.replaceGroup(group.getUUID(), newGroup);
_backPressHandler.setEnabled(true);
}
};
Dialogs.showTextInputDialog(GroupManagerActivity.this, R.string.rename_group, R.string.group_name_hint, onEditGroup, group.getName());
}
@Override
public void onRemoveGroup(VaultGroup group) {
Dialogs.showSecureDialog(new MaterialAlertDialogBuilder(this, R.style.ThemeOverlay_Aegis_AlertDialog_Warning)
@@ -126,12 +169,20 @@ public class GroupManagerActivity extends AegisActivity implements GroupAdapter.
saveAndBackupVault();
}
if (!_renamedGroups.isEmpty()) {
_renamedGroups.removeIf(group -> _removedGroups.contains(group.getUUID()));
for (VaultGroup renamedGroup : _renamedGroups) {
_vaultManager.getVault().renameGroup(renamedGroup);
}
saveAndBackupVault();
}
finish();
}
private void discardAndFinish() {
if (_removedGroups.isEmpty()) {
if (_removedGroups.isEmpty() && _renamedGroups.isEmpty()) {
finish();
return;
}
@@ -0,0 +1,40 @@
package com.beemdevelopment.aegis.ui;
import android.os.Bundle;
import com.beemdevelopment.aegis.Preferences;
import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.ThemeMap;
import com.beemdevelopment.aegis.helpers.ThemeHelper;
import com.mikepenz.aboutlibraries.LibsBuilder;
import com.mikepenz.aboutlibraries.ui.LibsActivity;
import org.jetbrains.annotations.Nullable;
import dagger.hilt.InstallIn;
import dagger.hilt.android.EarlyEntryPoint;
import dagger.hilt.android.EarlyEntryPoints;
import dagger.hilt.components.SingletonComponent;
public class LicensesActivity extends LibsActivity {
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
LibsBuilder builder = new LibsBuilder()
.withSearchEnabled(true)
.withAboutMinimalDesign(true)
.withActivityTitle(getString(R.string.title_activity_licenses));
setIntent(builder.intent(this));
Preferences _prefs = EarlyEntryPoints.get(getApplicationContext(), PrefEntryPoint.class).getPreferences();
ThemeHelper themeHelper = new ThemeHelper(this, _prefs);
themeHelper.setTheme(ThemeMap.DEFAULT);
super.onCreate(savedInstanceState);
}
@EarlyEntryPoint
@InstallIn(SingletonComponent.class)
public interface PrefEntryPoint {
Preferences getPreferences();
}
}
@@ -23,6 +23,7 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.Toast;
@@ -34,13 +35,12 @@ import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.view.ActionMode;
import androidx.appcompat.widget.SearchView;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import com.beemdevelopment.aegis.AccountNamePosition;
import com.beemdevelopment.aegis.CopyBehavior;
import com.beemdevelopment.aegis.Preferences;
import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.SortCategory;
import com.beemdevelopment.aegis.ViewMode;
import com.beemdevelopment.aegis.helpers.FabScrollHelper;
import com.beemdevelopment.aegis.helpers.PermissionHelper;
import com.beemdevelopment.aegis.otp.GoogleAuthInfo;
@@ -133,12 +133,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
});
private final ActivityResultLauncher<Intent> preferenceResultLauncher =
registerForActivityResult(new StartActivityForResult(), activityResult -> {
if (activityResult.getResultCode() != RESULT_OK || activityResult.getData() == null) {
return;
}
onPreferencesResult(activityResult.getData());
});
registerForActivityResult(new StartActivityForResult(), activityResult -> onPreferencesResult());
private final ActivityResultLauncher<Intent> editEntryResultLauncher =
registerForActivityResult(new StartActivityForResult(), activityResult -> {
@@ -200,6 +195,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
_entryListView.setSortCategory(_prefs.getCurrentSortCategory(), false);
_entryListView.setViewMode(_prefs.getCurrentViewMode());
_entryListView.setCopyBehavior(_prefs.getCopyBehavior());
_entryListView.setSearchBehaviorMask(_prefs.getSearchBehaviorMask());
_entryListView.setPrefGroupFilter(_prefs.getGroupFilter());
FloatingActionButton fab = findViewById(R.id.fab);
@@ -241,6 +237,11 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
_prefs.setUsageCount(usageMap);
}
Map<UUID, Long> lastUsedMap = _entryListView.getLastUsedTimestamps();
if (lastUsedMap != null) {
_prefs.setLastUsedTimestamps(lastUsedMap);
}
super.onPause();
}
@@ -280,36 +281,21 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
@Override
public void onEntryListTouch() {
_isDPadPressed = false;
if (_searchView != null && !_searchView.isIconified()) {
if (ViewCompat.getRootWindowInsets(findViewById(android.R.id.content).getRootView()).isVisible(WindowInsetsCompat.Type.ime())) {
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputMethodManager != null && getCurrentFocus() != null) {
inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
}
}
}
}
private void onPreferencesResult(Intent data) {
private void onPreferencesResult() {
// refresh the entire entry list if needed
if (_loaded) {
if (data.getBooleanExtra("needsRecreate", false)) {
recreate();
} else if (data.getBooleanExtra("needsRefresh", false)) {
AccountNamePosition accountNamePosition = _prefs.getAccountNamePosition();
boolean showIcons = _prefs.isIconVisible();
boolean onlyShowNecessaryAccountNames = _prefs.onlyShowNecessaryAccountNames();
Preferences.CodeGrouping codeGroupSize = _prefs.getCodeGroupSize();
boolean highlightEntry = _prefs.isEntryHighlightEnabled();
boolean pauseFocused = _prefs.isPauseFocusedEnabled();
boolean tapToReveal = _prefs.isTapToRevealEnabled();
int tapToRevealTime = _prefs.getTapToRevealTime();
ViewMode viewMode = _prefs.getCurrentViewMode();
CopyBehavior copyBehavior = _prefs.getCopyBehavior();
_entryListView.setAccountNamePosition(accountNamePosition);
_entryListView.setOnlyShowNecessaryAccountNames(onlyShowNecessaryAccountNames);
_entryListView.setShowIcon(showIcons);
_entryListView.setCodeGroupSize(codeGroupSize);
_entryListView.setHighlightEntry(highlightEntry);
_entryListView.setPauseFocused(pauseFocused);
_entryListView.setTapToReveal(tapToReveal);
_entryListView.setTapToRevealTime(tapToRevealTime);
_entryListView.setViewMode(viewMode);
_entryListView.setCopyBehavior(copyBehavior);
_entryListView.refresh(true);
}
recreate();
}
}
@@ -503,7 +489,6 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
private void onIntroResult() {
loadEntries();
checkTimeSyncSetting();
}
private void checkTimeSyncSetting() {
@@ -517,8 +502,9 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
}
private void onDecryptResult() {
_auditLogRepository.addVaultUnlockedEvent();
loadEntries();
checkTimeSyncSetting();
}
private void startScanActivity() {
@@ -650,8 +636,8 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
}
@Override
protected void onResume() {
super.onResume();
protected void onStart() {
super.onStart();
if (_vaultManager.isVaultInitNeeded()) {
if (_prefs.isIntroDone()) {
@@ -696,6 +682,8 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
// update the usage counts in case they are edited outside of the EntryListView
_entryListView.setUsageCounts(_prefs.getUsageCounts());
_entryListView.setLastUsedTimestamps(_prefs.getLastUsedTimestamps());
// refresh all codes to prevent showing old ones
_entryListView.refresh(false);
} else {
@@ -825,6 +813,8 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
sortCategory = SortCategory.ACCOUNT_REVERSED;
} else if (subItemId == R.id.menu_sort_usage_count) {
sortCategory = SortCategory.USAGE_COUNT;
} else if (subItemId == R.id.menu_sort_last_used) {
sortCategory = SortCategory.LAST_USED;
} else {
sortCategory = SortCategory.CUSTOM;
}
@@ -846,9 +836,13 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
private void loadEntries() {
if (!_loaded) {
_entryListView.setGroups(_vaultManager.getVault().getUsedGroups());
_entryListView.setUsageCounts(_prefs.getUsageCounts());
_entryListView.setLastUsedTimestamps(_prefs.getLastUsedTimestamps());
_entryListView.addEntries(_vaultManager.getVault().getEntries());
_entryListView.runEntriesAnimation();
if (!_isRecreated) {
_entryListView.runEntriesAnimation();
}
_loaded = true;
}
}
@@ -1035,6 +1029,9 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
@Override
public void onSaveGroupFilter(Set<UUID> groupFilter) {
if (_vaultManager.getVault().isGroupsMigrationFresh()) {
saveAndBackupVault();
}
_prefs.setGroupFilter(groupFilter);
}
@@ -1166,6 +1163,8 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
for (VaultEntry entry : _selectedEntries) {
GoogleAuthInfo authInfo = new GoogleAuthInfo(entry.getInfo(), entry.getName(), entry.getIssuer());
authInfos.add(authInfo);
_auditLogRepository.addEntrySharedEvent(entry.getUUID().toString());
}
intent.putExtra("authInfos", authInfos);
@@ -10,6 +10,7 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.ui.fragments.preferences.AppearancePreferencesFragment;
import com.beemdevelopment.aegis.ui.fragments.preferences.MainPreferencesFragment;
import com.beemdevelopment.aegis.ui.fragments.preferences.PreferencesFragment;
@@ -56,24 +57,8 @@ public class PreferencesActivity extends AegisActivity implements
}
}
@Override
protected void onRestoreInstanceState(@NonNull final Bundle inState) {
if (_fragment instanceof PreferencesFragment) {
// pass the stored result intent back to the fragment
if (inState.containsKey("result")) {
((PreferencesFragment) _fragment).setResult(inState.getParcelable("result"));
}
}
super.onRestoreInstanceState(inState);
}
@Override
protected void onSaveInstanceState(@NonNull final Bundle outState) {
if (_fragment instanceof PreferencesFragment) {
// save the result intent of the fragment
// this is done so we don't lose anything if the fragment calls recreate on this activity
outState.putParcelable("result", ((PreferencesFragment) _fragment).getResult());
}
outState.putCharSequence("prefTitle", _prefTitle);
super.onSaveInstanceState(outState);
}
@@ -128,6 +113,9 @@ public class PreferencesActivity extends AegisActivity implements
public void onFragmentStarted(@NonNull FragmentManager fm, @NonNull Fragment f) {
if (f instanceof MainPreferencesFragment) {
setTitle(R.string.action_settings);
} else if (f instanceof AppearancePreferencesFragment) {
_prefTitle = getString(R.string.pref_section_appearance_title);
setTitle(_prefTitle);
}
}
}
@@ -89,7 +89,7 @@ public class ScannerActivity extends AegisActivity implements QrCodeAnalyzer.Lis
@Override
protected void onSetTheme() {
setTheme(ThemeMap.FULLSCREEN);
_themeHelper.setTheme(ThemeMap.FULLSCREEN);
}
@Override
@@ -152,7 +152,7 @@ public class TransferEntriesActivity extends AegisActivity {
_entriesCount.setText(getResources().getQuantityString(R.plurals.qr_count, _authInfos.size(), _currentEntryCount, _authInfos.size()));
@ColorInt int backgroundColor = Color.WHITE;
if (getConfiguredTheme() == Theme.LIGHT) {
if (_themeHelper.getConfiguredTheme() == Theme.LIGHT) {
TypedValue typedValue = new TypedValue();
getTheme().resolveAttribute(androidx.appcompat.R.attr.background, typedValue, true);
backgroundColor = typedValue.data;
@@ -5,8 +5,6 @@ import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.text.InputType;
import android.text.SpannableStringBuilder;
import android.text.TextWatcher;
@@ -43,8 +41,6 @@ import com.beemdevelopment.aegis.vault.slots.SlotException;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
import com.nulabinc.zxcvbn.Strength;
import com.nulabinc.zxcvbn.Zxcvbn;
import java.util.ArrayList;
import java.util.List;
@@ -120,7 +116,6 @@ public class Dialogs {
}
public static void showSetPasswordDialog(ComponentActivity activity, PasswordSlotListener listener) {
Zxcvbn zxcvbn = new Zxcvbn();
View view = activity.getLayoutInflater().inflate(R.layout.dialog_password, null);
EditText textPassword = view.findViewById(R.id.text_password);
EditText textPasswordConfirm = view.findViewById(R.id.text_password_confirm);
@@ -128,6 +123,8 @@ public class Dialogs {
TextView textPasswordStrength = view.findViewById(R.id.text_password_strength);
TextInputLayout textPasswordWrapper = view.findViewById(R.id.text_password_wrapper);
CheckBox switchToggleVisibility = view.findViewById(R.id.check_toggle_visibility);
PasswordStrengthHelper passStrength = new PasswordStrengthHelper(
textPassword, barPasswordStrength, textPasswordStrength, textPasswordWrapper);
switchToggleVisibility.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked) {
@@ -183,13 +180,7 @@ public class Dialogs {
TextWatcher watcher = new SimpleTextWatcher(text -> {
boolean equal = EditTextHelper.areEditTextsEqual(textPassword, textPasswordConfirm);
buttonOK.get().setEnabled(equal);
Strength strength = zxcvbn.measure(textPassword.getText());
barPasswordStrength.setProgress(strength.getScore());
barPasswordStrength.setProgressTintList(ColorStateList.valueOf(Color.parseColor(PasswordStrengthHelper.getColor(strength.getScore()))));
textPasswordStrength.setText((textPassword.getText().length() != 0) ? PasswordStrengthHelper.getString(strength.getScore(), activity) : "");
textPasswordWrapper.setError(strength.getFeedback().getWarning());
strength.wipe();
passStrength.measure(activity);
});
textPassword.addTextChangedListener(watcher);
textPasswordConfirm.addTextChangedListener(watcher);
@@ -197,10 +188,13 @@ public class Dialogs {
showSecureDialog(dialog);
}
private static void showTextInputDialog(Context context, @StringRes int titleId, @StringRes int messageId, @StringRes int hintId, TextInputListener listener, DialogInterface.OnCancelListener cancelListener, boolean isSecret) {
private static void showTextInputDialog(Context context, @StringRes int titleId, @StringRes int messageId, @StringRes int hintId, TextInputListener listener, DialogInterface.OnCancelListener cancelListener, boolean isSecret,@Nullable String hint) {
final AtomicReference<Button> buttonOK = new AtomicReference<>();
View view = LayoutInflater.from(context).inflate(R.layout.dialog_text_input, null);
TextInputEditText input = view.findViewById(R.id.text_input);
if(hint != null) {
input.setText(hint);
}
input.addTextChangedListener(new SimpleTextWatcher(text -> {
if (buttonOK.get() != null) {
buttonOK.get().setEnabled(!text.toString().isEmpty());
@@ -242,12 +236,16 @@ public class Dialogs {
showSecureDialog(dialog);
}
private static void showTextInputDialog(Context context, @StringRes int titleId, @StringRes int hintId, TextInputListener listener, boolean isSecret) {
showTextInputDialog(context, titleId, 0, hintId, listener, null, isSecret);
public static void showTextInputDialog(Context context, @StringRes int titleId, @StringRes int hintId, TextInputListener listener, String text) {
showTextInputDialog(context, titleId, 0, hintId, listener, null, false, text);
}
public static void showTextInputDialog(Context context, @StringRes int titleId, @StringRes int hintId, TextInputListener listener, @Nullable DialogInterface.OnCancelListener onCancel) {
showTextInputDialog(context, titleId, 0, hintId, listener, onCancel, false);
private static void showTextInputDialog(Context context, @StringRes int titleId, @StringRes int hintId, TextInputListener listener, boolean isSecret) {
showTextInputDialog(context, titleId, 0, hintId, listener, null, isSecret, null);
}
public static void showTextInputDialog(Context context, @StringRes int titleId, @StringRes int hintId, TextInputListener listener) {
showTextInputDialog(context, titleId, 0, hintId, listener, null, false, null);
}
public static void showPasswordInputDialog(Context context, TextInputListener listener) {
@@ -255,19 +253,19 @@ public class Dialogs {
}
public static void showPasswordInputDialog(Context context, TextInputListener listener, DialogInterface.OnCancelListener cancelListener) {
showTextInputDialog(context, R.string.set_password, 0, R.string.password, listener, cancelListener, true);
showTextInputDialog(context, R.string.set_password, 0, R.string.password, listener, cancelListener, true, null);
}
public static void showPasswordInputDialog(Context context, @StringRes int messageId, TextInputListener listener) {
showTextInputDialog(context, R.string.set_password, messageId, R.string.password, listener, null, true);
showTextInputDialog(context, R.string.set_password, messageId, R.string.password, listener, null, true, null);
}
public static void showPasswordInputDialog(Context context, @StringRes int messageId, TextInputListener listener, DialogInterface.OnCancelListener cancelListener) {
showTextInputDialog(context, R.string.set_password, messageId, R.string.password, listener, cancelListener, true);
showTextInputDialog(context, R.string.set_password, messageId, R.string.password, listener, cancelListener, true, null);
}
public static void showPasswordInputDialog(Context context, @StringRes int titleId, @StringRes int messageId, TextInputListener listener, DialogInterface.OnCancelListener cancelListener) {
showTextInputDialog(context, titleId, messageId, R.string.password, listener, cancelListener, true);
showTextInputDialog(context, titleId, messageId, R.string.password, listener, cancelListener, true, null);
}
public static void showCheckboxDialog(Context context, @StringRes int titleId, @StringRes int messageId, @StringRes int checkboxMessageId, CheckboxInputListener listener) {
@@ -320,25 +318,32 @@ public class Dialogs {
}
public static void showBackupVersionsPickerDialog(Context context, int currentVersionCount, NumberInputListener listener) {
final int max = 30;
String[] numbers = new String[max / 5];
for (int i = 0; i < numbers.length; i++) {
numbers[i] = Integer.toString(i * 5 + 5);
String infinite = context.getString(R.string.pref_backups_versions_infinite);
String[] values = {"5", "10", "15", "20", "25", "30", infinite};
int[] numbers = {5, 10, 15, 20, 25, 30, Preferences.BACKUPS_VERSIONS_INFINITE};
int selectedIndex;
if (currentVersionCount == Preferences.BACKUPS_VERSIONS_INFINITE) {
selectedIndex = numbers.length - 1;
} else {
selectedIndex = currentVersionCount / 5 - 1;
}
View view = LayoutInflater.from(context).inflate(R.layout.dialog_number_picker, null);
NumberPicker numberPicker = view.findViewById(R.id.numberPicker);
numberPicker.setDisplayedValues(numbers);
numberPicker.setMaxValue(numbers.length - 1);
numberPicker.setDisplayedValues(values);
numberPicker.setMaxValue(values.length - 1);
numberPicker.setMinValue(0);
numberPicker.setValue(currentVersionCount / 5 - 1);
numberPicker.setValue(selectedIndex);
numberPicker.setWrapSelectorWheel(false);
AlertDialog dialog = new MaterialAlertDialogBuilder(context)
.setTitle(R.string.set_number)
.setView(view)
.setPositiveButton(android.R.string.ok, (dialog1, which) ->
listener.onNumberInputResult(numberPicker.getValue()))
.setPositiveButton(android.R.string.ok, (dialog1, which) -> {
int index = numberPicker.getValue();
int number = numbers[index];
listener.onNumberInputResult(number);
})
.create();
showSecureDialog(dialog);
@@ -17,7 +17,7 @@ import androidx.fragment.app.DialogFragment;
import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.Theme;
import com.beemdevelopment.aegis.helpers.ThemeHelper;
import com.google.android.material.color.MaterialColors;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.common.io.CharStreams;
@@ -70,11 +70,21 @@ public abstract class SimpleWebViewDialog extends DialogFragment {
}
protected String getBackgroundColor() {
return colorToCSS(ThemeHelper.getThemeColor(com.google.android.material.R.attr.colorSurfaceContainerHigh, requireContext().getTheme()));
int color = MaterialColors.getColor(
requireContext(),
com.google.android.material.R.attr.colorSurfaceContainerHigh,
getClass().getCanonicalName()
);
return colorToCSS(color);
}
protected String getTextColor() {
return colorToCSS(0xFFFFFF & ThemeHelper.getThemeColor(com.google.android.material.R.attr.colorOnSurface, requireContext().getTheme()));
int color = MaterialColors.getColor(
requireContext(),
com.google.android.material.R.attr.colorOnSurface,
getClass().getCanonicalName()
);
return colorToCSS(0xFFFFFF & color);
}
@SuppressLint("DefaultLocale")
@@ -27,7 +27,6 @@ public class AppearancePreferencesFragment extends PreferencesFragment {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
super.onCreatePreferences(savedInstanceState, rootKey);
addPreferencesFromResource(R.xml.preferences_appearance);
_groupsPreference = requirePreference("pref_groups");
@@ -62,7 +61,6 @@ public class AppearancePreferencesFragment extends PreferencesFragment {
dialog.dismiss();
getResult().putExtra("needsRecreate", true);
requireActivity().recreate();
})
.setNegativeButton(android.R.string.cancel, null)
@@ -74,7 +72,6 @@ public class AppearancePreferencesFragment extends PreferencesFragment {
Preference dynamicColorsPreference = requirePreference("pref_dynamic_colors");
dynamicColorsPreference.setEnabled(DynamicColors.isDynamicColorAvailable());
dynamicColorsPreference.setOnPreferenceChangeListener((preference, newValue) -> {
getResult().putExtra("needsRecreate", true);
requireActivity().recreate();
return true;
});
@@ -96,7 +93,6 @@ public class AppearancePreferencesFragment extends PreferencesFragment {
dialog.dismiss();
getResult().putExtra("needsRecreate", true);
requireActivity().recreate();
})
.setNegativeButton(android.R.string.cancel, null)
@@ -120,8 +116,7 @@ public class AppearancePreferencesFragment extends PreferencesFragment {
int i = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
_prefs.setCurrentViewMode(ViewMode.fromInteger(i));
viewModePreference.setSummary(String.format("%s: %s", getString(R.string.selected), getResources().getStringArray(R.array.view_mode_titles)[i]));
getResult().putExtra("needsRefresh", true);
overrideAccountNamePosition(ViewMode.fromInteger(i) == ViewMode.TILES);
refreshAccountNamePositionText();
dialog.dismiss();
})
.setNegativeButton(android.R.string.cancel, null)
@@ -132,9 +127,10 @@ public class AppearancePreferencesFragment extends PreferencesFragment {
String[] codeGroupings = getResources().getStringArray(R.array.pref_code_groupings_values);
String[] codeGroupingNames = getResources().getStringArray(R.array.pref_code_groupings);
int currentCodeGroupingIndex = Arrays.asList(codeGroupings).indexOf(_prefs.getCodeGroupSize().name());
Preference codeDigitGroupingPreference = requirePreference("pref_code_group_size_string");
codeDigitGroupingPreference.setOnPreferenceClickListener(preference -> {
int currentCodeGroupingIndex = Arrays.asList(codeGroupings).indexOf(_prefs.getCodeGroupSize().name());
Dialogs.showSecureDialog(new MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.pref_code_group_size_title)
.setSingleChoiceItems(codeGroupingNames, currentCodeGroupingIndex, (dialog, which) -> {
@@ -142,19 +138,12 @@ public class AppearancePreferencesFragment extends PreferencesFragment {
_prefs.setCodeGroupSize(Preferences.CodeGrouping.valueOf(codeGroupings[newCodeGroupingIndex]));
dialog.dismiss();
getResult().putExtra("needsRefresh", true);
})
.setNegativeButton(android.R.string.cancel, null)
.create());
return true;
});
Preference onlyShowNecessaryAccountNames = requirePreference("pref_shared_issuer_account_name");
onlyShowNecessaryAccountNames.setOnPreferenceChangeListener((preference, newValue) -> {
getResult().putExtra("needsRefresh", true);
return true;
});
int currentAccountNamePosition = _prefs.getAccountNamePosition().ordinal();
_currentAccountNamePositionPreference = requirePreference("pref_account_name_position");
_currentAccountNamePositionPreference.setSummary(String.format("%s: %s", getString(R.string.selected), getResources().getStringArray(R.array.account_name_position_titles)[currentAccountNamePosition]));
@@ -167,7 +156,7 @@ public class AppearancePreferencesFragment extends PreferencesFragment {
int i = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
_prefs.setAccountNamePosition(AccountNamePosition.fromInteger(i));
_currentAccountNamePositionPreference.setSummary(String.format("%s: %s", getString(R.string.selected), getResources().getStringArray(R.array.account_name_position_titles)[i]));
getResult().putExtra("needsRefresh", true);
refreshAccountNamePositionText();
dialog.dismiss();
})
.setNegativeButton(android.R.string.cancel, null)
@@ -176,21 +165,15 @@ public class AppearancePreferencesFragment extends PreferencesFragment {
return true;
});
Preference showIconsPreference = requirePreference("pref_show_icons");
showIconsPreference.setOnPreferenceChangeListener((preference, newValue) -> {
getResult().putExtra("needsRefresh", true);
return true;
});
overrideAccountNamePosition(_prefs.getCurrentViewMode() == ViewMode.TILES);
refreshAccountNamePositionText();
}
private void overrideAccountNamePosition(boolean override) {
private void refreshAccountNamePositionText() {
boolean override = (_prefs.getCurrentViewMode() == ViewMode.TILES && _prefs.getAccountNamePosition() == AccountNamePosition.END);
if (override) {
_currentAccountNamePositionPreference.setEnabled(false);
_currentAccountNamePositionPreference.setSummary(getString(R.string.pref_account_name_position_summary_override));
_currentAccountNamePositionPreference.setSummary(String.format("%s: %s. %s", getString(R.string.selected), getResources().getStringArray(R.array.account_name_position_titles)[_prefs.getAccountNamePosition().ordinal()], getString(R.string.pref_account_name_position_summary_override)));
} else {
_currentAccountNamePositionPreference.setEnabled(true);
_currentAccountNamePositionPreference.setSummary(String.format("%s: %s", getString(R.string.selected), getResources().getStringArray(R.array.account_name_position_titles)[_prefs.getAccountNamePosition().ordinal()]));
}
}
@@ -0,0 +1,97 @@
package com.beemdevelopment.aegis.ui.fragments.preferences;
import android.graphics.Rect;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.LiveData;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.database.AuditLogEntry;
import com.beemdevelopment.aegis.database.AuditLogRepository;
import com.beemdevelopment.aegis.helpers.MetricsHelper;
import com.beemdevelopment.aegis.ui.models.AuditLogEntryModel;
import com.beemdevelopment.aegis.ui.views.AuditLogAdapter;
import com.beemdevelopment.aegis.vault.VaultEntry;
import com.beemdevelopment.aegis.vault.VaultManager;
import java.util.List;
import java.util.UUID;
import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint;
@AndroidEntryPoint
public class AuditLogPreferencesFragment extends Fragment {
@Inject
AuditLogRepository _auditLogRepository;
private AuditLogAdapter _adapter;
private RecyclerView _auditLogRecyclerView;
private LinearLayout _noAuditLogsView;
@Inject
VaultManager _vaultManager;
public AuditLogPreferencesFragment() {
super(R.layout.fragment_audit_log);
}
@Override
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
LiveData<List<AuditLogEntry>> entries = _auditLogRepository.getAllAuditLogEntries();
_adapter = new AuditLogAdapter();
_noAuditLogsView = view.findViewById(R.id.vEmptyList);
_auditLogRecyclerView = view.findViewById(R.id.list_audit_log);
LinearLayoutManager layoutManager = new LinearLayoutManager(requireContext());
_auditLogRecyclerView.addItemDecoration(new SpacesItemDecoration(8));
_auditLogRecyclerView.setLayoutManager(layoutManager);
_auditLogRecyclerView.setAdapter(_adapter);
_auditLogRecyclerView.setNestedScrollingEnabled(false);
entries.observe(getViewLifecycleOwner(), entries1 -> {
_noAuditLogsView.setVisibility(entries1.isEmpty() ? View.VISIBLE : View.GONE);
for (AuditLogEntry entry : entries1) {
VaultEntry referencedEntry = null;
if (entry.getReference() != null) {
UUID referencedEntryUUID = UUID.fromString(entry.getReference());
if (_vaultManager.getVault().hasEntryByUUID(referencedEntryUUID)) {
referencedEntry = _vaultManager.getVault().getEntryByUUID(referencedEntryUUID);
}
}
AuditLogEntryModel auditLogEntryModel = new AuditLogEntryModel(entry, referencedEntry);
_adapter.addAuditLogEntryModel(auditLogEntryModel);
}
});
}
private class SpacesItemDecoration extends RecyclerView.ItemDecoration {
private final int _space;
public SpacesItemDecoration(int dpSpace) {
_space = MetricsHelper.convertDpToPixels(getContext(), dpSpace);
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
outRect.left = _space;
outRect.right = _space;
outRect.bottom = _space;
if (parent.getChildLayoutPosition(view) == 0) {
outRect.top = _space;
}
}
}
}
@@ -19,9 +19,9 @@ import androidx.preference.SwitchPreferenceCompat;
import com.beemdevelopment.aegis.Preferences;
import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.helpers.ThemeHelper;
import com.beemdevelopment.aegis.ui.dialogs.Dialogs;
import com.beemdevelopment.aegis.vault.VaultRepositoryException;
import com.google.android.material.color.MaterialColors;
public class BackupsPreferencesFragment extends PreferencesFragment {
private SwitchPreferenceCompat _androidBackupsPreference;
@@ -52,7 +52,6 @@ public class BackupsPreferencesFragment extends PreferencesFragment {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
super.onCreatePreferences(savedInstanceState, rootKey);
addPreferencesFromResource(R.xml.preferences_backups);
_backupsPasswordWarningPreference = requirePreference("pref_backups_warning_password");
@@ -131,12 +130,11 @@ public class BackupsPreferencesFragment extends PreferencesFragment {
});
_backupsVersionsPreference = requirePreference("pref_backups_versions");
_backupsVersionsPreference.setSummary(getResources().getQuantityString(R.plurals.pref_backups_versions_summary, _prefs.getBackupsVersionCount(), _prefs.getBackupsVersionCount()));
updateBackupsVersionsSummary();
_backupsVersionsPreference.setOnPreferenceClickListener(preference -> {
Dialogs.showBackupVersionsPickerDialog(requireContext(), _prefs.getBackupsVersionCount(), number -> {
number = number * 5 + 5;
_prefs.setBackupsVersionCount(number);
_backupsVersionsPreference.setSummary(getResources().getQuantityString(R.plurals.pref_backups_versions_summary, _prefs.getBackupsVersionCount(), _prefs.getBackupsVersionCount()));
updateBackupsVersionsSummary();
});
return false;
});
@@ -216,7 +214,7 @@ public class BackupsPreferencesFragment extends PreferencesFragment {
message = getString(R.string.backup_status_failed, res.getElapsedSince(requireContext()));
}
int color = ThemeHelper.getThemeColor(colorAttr, requireContext().getTheme());
int color = MaterialColors.getColor(requireContext(), colorAttr, getClass().getCanonicalName());
Spannable spannable = new SpannableString(message);
spannable.setSpan(new ForegroundColorSpan(color), 0, message.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
spannable.setSpan(new StyleSpan(Typeface.BOLD), 0, message.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
@@ -242,4 +240,14 @@ public class BackupsPreferencesFragment extends PreferencesFragment {
Dialogs.showErrorDialog(requireContext(), R.string.backup_error, e);
}
}
private void updateBackupsVersionsSummary() {
int count = _prefs.getBackupsVersionCount();
if (count == Preferences.BACKUPS_VERSIONS_INFINITE) {
_backupsVersionsPreference.setSummary(R.string.pref_backups_versions_infinite_summary);
} else {
String summary = getResources().getQuantityString(R.plurals.pref_backups_versions_summary, count, count);
_backupsVersionsPreference.setSummary(summary);
}
}
}
@@ -1,23 +1,68 @@
package com.beemdevelopment.aegis.ui.fragments.preferences;
import android.os.Bundle;
import android.widget.Button;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import com.beemdevelopment.aegis.CopyBehavior;
import com.beemdevelopment.aegis.Preferences;
import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.ui.dialogs.Dialogs;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
public class BehaviorPreferencesFragment extends PreferencesFragment {
private Preference _entryPausePreference;
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
super.onCreatePreferences(savedInstanceState, rootKey);
addPreferencesFromResource(R.xml.preferences_behavior);
Preference currentSearchBehaviorPreference = requirePreference("pref_search_behavior");
currentSearchBehaviorPreference.setSummary(getSearchBehaviorSummary());
currentSearchBehaviorPreference.setOnPreferenceClickListener((preference) -> {
final int[] items = Preferences.SEARCH_BEHAVIOR_SETTINGS;
final String[] textItems = getResources().getStringArray(R.array.pref_search_behavior_types);
final boolean[] checkedItems = new boolean[items.length];
for (int i = 0; i < items.length; i++) {
checkedItems[i] = _prefs.isSearchBehaviorTypeEnabled(items[i]);
}
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.pref_search_behavior_prompt)
.setMultiChoiceItems(textItems, checkedItems, (dialog, index, isChecked) -> {
checkedItems[index] = isChecked;
boolean containsAtLeastOneCheckedItem = false;
for(boolean b: checkedItems) {
if (b) {
containsAtLeastOneCheckedItem = true;
break;
}
}
AlertDialog alertDialog = (AlertDialog) dialog;
Button positiveButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
positiveButton.setEnabled(containsAtLeastOneCheckedItem);
})
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
int searchBehavior = 0;
for (int i = 0; i < checkedItems.length; i++) {
if (checkedItems[i]) {
searchBehavior |= items[i];
}
}
_prefs.setSearchBehaviorMask(searchBehavior);
currentSearchBehaviorPreference.setSummary(getSearchBehaviorSummary());
})
.setNegativeButton(android.R.string.cancel, null);
Dialogs.showSecureDialog(builder.create());
return true;
});
int currentCopyBehavior = _prefs.getCopyBehavior().ordinal();
Preference copyBehaviorPreference = requirePreference("pref_copy_behavior");
copyBehaviorPreference.setSummary(String.format("%s: %s", getString(R.string.selected), getResources().getStringArray(R.array.copy_behavior_titles)[currentCopyBehavior]));
@@ -30,7 +75,6 @@ public class BehaviorPreferencesFragment extends PreferencesFragment {
int i = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
_prefs.setCopyBehavior(CopyBehavior.fromInteger(i));
copyBehaviorPreference.setSummary(String.format("%s: %s", getString(R.string.selected), getResources().getStringArray(R.array.copy_behavior_titles)[i]));
getResult().putExtra("needsRefresh", true);
dialog.dismiss();
})
.setNegativeButton(android.R.string.cancel, null)
@@ -39,18 +83,31 @@ public class BehaviorPreferencesFragment extends PreferencesFragment {
return true;
});
Preference entryPausePreference = requirePreference("pref_pause_entry");
entryPausePreference.setEnabled(_prefs.isTapToRevealEnabled() || _prefs.isEntryHighlightEnabled());
Preference entryHighlightPreference = requirePreference("pref_highlight_entry");
entryHighlightPreference.setOnPreferenceChangeListener((preference, newValue) -> {
getResult().putExtra("needsRefresh", true);
_entryPausePreference.setEnabled(_prefs.isTapToRevealEnabled() || (boolean) newValue);
entryPausePreference.setEnabled(_prefs.isTapToRevealEnabled() || (boolean) newValue);
return true;
});
}
_entryPausePreference = requirePreference("pref_pause_entry");
_entryPausePreference.setOnPreferenceChangeListener((preference, newValue) -> {
getResult().putExtra("needsRefresh", true);
return true;
});
_entryPausePreference.setEnabled(_prefs.isTapToRevealEnabled() || _prefs.isEntryHighlightEnabled());
private String getSearchBehaviorSummary() {
final int[] settings = Preferences.SEARCH_BEHAVIOR_SETTINGS;
final String[] descriptions = getResources().getStringArray(R.array.pref_search_behavior_types);
StringBuilder builder = new StringBuilder();
for (int i = 0; i < settings.length; i++) {
if (_prefs.isSearchBehaviorTypeEnabled(settings[i])) {
if (builder.length() != 0) {
builder.append(", ");
}
builder.append(descriptions[i].toLowerCase());
}
}
return getString(R.string.pref_search_behavior_summary, builder.toString());
}
}
@@ -69,11 +69,6 @@ public class ImportExportPreferencesFragment extends PreferencesFragment {
private DatabaseImporter.Definition _importerDef;
private Vault.EntryFilter _exportFilter;
private final ActivityResultLauncher<Intent> importResultLauncher =
registerForActivityResult(new StartActivityForResult(), activityResult -> {
getResult().putExtra("needsRecreate", true);
});
private final ActivityResultLauncher<Intent> importSelectResultLauncher =
registerForActivityResult(new StartActivityForResult(), activityResult -> {
Intent data = activityResult.getData();
@@ -100,7 +95,6 @@ public class ImportExportPreferencesFragment extends PreferencesFragment {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
super.onCreatePreferences(savedInstanceState, rootKey);
addPreferencesFromResource(R.xml.preferences_import_export);
if (savedInstanceState != null) {
@@ -167,7 +161,7 @@ public class ImportExportPreferencesFragment extends PreferencesFragment {
Intent intent = new Intent(requireContext(), ImportEntriesActivity.class);
intent.putExtra("importerDef", importerDef);
intent.putExtra("file", file);
importResultLauncher.launch(intent);
startActivity(intent);
}
private void startExport() {
@@ -277,6 +271,7 @@ public class ImportExportPreferencesFragment extends PreferencesFragment {
.setType(getExportMimeType(getExportRequestCode(pos, encrypt)))
.putExtra(Intent.EXTRA_TITLE, fileInfo.toString());
_auditLogRepository.addVaultExportedEvent();
ActivityResultLauncher<Intent> resultLauncher = getExportRequestLauncher(pos, encrypt);
_vaultManager.fireIntentLauncher(this, intent, resultLauncher);
});
@@ -320,7 +315,7 @@ public class ImportExportPreferencesFragment extends PreferencesFragment {
// if the user creates an export, hide the backup reminder
_prefs.setLatestExportTimeNow();
_auditLogRepository.addVaultExportedEvent();
Uri uri = FileProvider.getUriForFile(requireContext(), BuildConfig.FILE_PROVIDER_AUTHORITY, file);
Intent intent = new Intent(Intent.ACTION_SEND)
.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
@@ -559,7 +554,7 @@ public class ImportExportPreferencesFragment extends PreferencesFragment {
} else {
// if the user creates an export, hide the backup reminder
_prefs.setLatestExportTimeNow();
_auditLogRepository.addVaultExportedEvent();
Toast.makeText(requireContext(), getString(R.string.exported_vault), Toast.LENGTH_SHORT).show();
}
}
@@ -7,7 +7,6 @@ import com.beemdevelopment.aegis.R;
public class MainPreferencesFragment extends PreferencesFragment {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
super.onCreatePreferences(savedInstanceState, rootKey);
addPreferencesFromResource(R.xml.preferences);
}
}
@@ -1,8 +1,6 @@
package com.beemdevelopment.aegis.ui.fragments.preferences;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.animation.Animation;
import androidx.annotation.CallSuper;
@@ -13,6 +11,7 @@ import androidx.preference.PreferenceFragmentCompat;
import com.beemdevelopment.aegis.Preferences;
import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.database.AuditLogRepository;
import com.beemdevelopment.aegis.helpers.AnimationsHelper;
import com.beemdevelopment.aegis.ui.dialogs.Dialogs;
import com.beemdevelopment.aegis.vault.VaultManager;
@@ -30,19 +29,14 @@ public abstract class PreferencesFragment extends PreferenceFragmentCompat {
public static final int CODE_EXPORT_GOOGLE_URI = 7;
public static final int CODE_EXPORT_HTML = 8;
private Intent _result;
@Inject
Preferences _prefs;
@Inject
VaultManager _vaultManager;
@Override
@CallSuper
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setResult(new Intent());
}
@Inject
protected AuditLogRepository _auditLogRepository;
@Override
@CallSuper
@@ -57,10 +51,6 @@ public abstract class PreferencesFragment extends PreferenceFragmentCompat {
}
}
public Intent getResult() {
return _result;
}
@Override
@Nullable
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
@@ -71,11 +61,6 @@ public abstract class PreferencesFragment extends PreferenceFragmentCompat {
return super.onCreateAnimation(transit, enter, nextAnim);
}
public void setResult(Intent result) {
_result = result;
requireActivity().setResult(Activity.RESULT_OK, _result);
}
protected boolean saveAndBackupVault() {
try {
_vaultManager.saveAndBackup();
@@ -55,18 +55,10 @@ public class SecurityPreferencesFragment extends PreferencesFragment {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
super.onCreatePreferences(savedInstanceState, rootKey);
addPreferencesFromResource(R.xml.preferences_security);
Preference tapToRevealPreference = requirePreference("pref_tap_to_reveal");
tapToRevealPreference.setOnPreferenceChangeListener((preference, newValue) -> {
getResult().putExtra("needsRefresh", true);
return true;
});
Preference screenPreference = requirePreference("pref_secure_screen");
screenPreference.setOnPreferenceChangeListener((preference, newValue) -> {
getResult().putExtra("needsRecreate", true);
Window window = requireActivity().getWindow();
if ((boolean) newValue) {
window.addFlags(WindowManager.LayoutParams.FLAG_SECURE);
@@ -82,7 +74,6 @@ public class SecurityPreferencesFragment extends PreferencesFragment {
Dialogs.showTapToRevealTimeoutPickerDialog(requireContext(), _prefs.getTapToRevealTime(), number -> {
_prefs.setTapToRevealTime(number);
tapToRevealTimePreference.setSummary(number + " seconds");
getResult().putExtra("needsRefresh", true);
});
return false;
});
@@ -4,10 +4,8 @@ import android.graphics.drawable.Drawable;
import android.os.Build;
import android.widget.ImageView;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RawRes;
import com.amulyakhare.textdrawable.TextDrawable;
import com.beemdevelopment.aegis.helpers.TextDrawableHelper;
@@ -38,21 +36,6 @@ public class GlideHelper {
loadIconFile(rm, icon.getFile(), icon.getIconType(), targetView);
}
public static void loadResource(RequestManager rm, @RawRes @DrawableRes @Nullable Integer resourceId, ImageView targetView) {
loadResource(rm, resourceId, null, targetView);
}
public static void loadResource(RequestManager rm, @RawRes @DrawableRes @Nullable Integer resourceId, @Nullable Integer tint, ImageView targetView) {
setCommonOptions(rm.load(resourceId), null)
.listener(new ViewReadyListener<>(view -> {
if (tint != null) {
view.setColorFilter(tint);
}
setLayerType(targetView, IconType.INVALID);
}))
.into(targetView);
}
public static void loadEntryIcon(RequestManager rm, VaultEntry entry, ImageView targetView) {
if (entry.hasIcon()) {
setCommonOptions(rm.load(entry.getIcon()), entry.getIcon().getType()).into(targetView);
@@ -0,0 +1,24 @@
package com.beemdevelopment.aegis.ui.models;
import com.beemdevelopment.aegis.database.AuditLogEntry;
import com.beemdevelopment.aegis.vault.VaultEntry;
import javax.annotation.Nullable;
public class AuditLogEntryModel {
private AuditLogEntry _auditLogEntry;
private VaultEntry _referencedVaultEntry;
public AuditLogEntryModel(AuditLogEntry auditLogEntry, @Nullable VaultEntry referencedVaultEntry) {
_auditLogEntry = auditLogEntry;
_referencedVaultEntry = referencedVaultEntry;
}
public AuditLogEntry getAuditLogEntry() {
return _auditLogEntry;
}
public VaultEntry getReferencedVaultEntry() {
return _referencedVaultEntry;
}
}
@@ -1,10 +1,12 @@
package com.beemdevelopment.aegis.ui.slides;
import android.content.res.ColorStateList;
import android.graphics.Color;
import static com.beemdevelopment.aegis.ui.slides.SecurityPickerSlide.CRYPT_TYPE_BIOMETRIC;
import static com.beemdevelopment.aegis.ui.slides.SecurityPickerSlide.CRYPT_TYPE_INVALID;
import static com.beemdevelopment.aegis.ui.slides.SecurityPickerSlide.CRYPT_TYPE_NONE;
import static com.beemdevelopment.aegis.ui.slides.SecurityPickerSlide.CRYPT_TYPE_PASS;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.text.method.PasswordTransformationMethod;
import android.view.LayoutInflater;
import android.view.View;
@@ -23,6 +25,7 @@ import com.beemdevelopment.aegis.helpers.BiometricSlotInitializer;
import com.beemdevelopment.aegis.helpers.BiometricsHelper;
import com.beemdevelopment.aegis.helpers.EditTextHelper;
import com.beemdevelopment.aegis.helpers.PasswordStrengthHelper;
import com.beemdevelopment.aegis.helpers.SimpleTextWatcher;
import com.beemdevelopment.aegis.ui.dialogs.Dialogs;
import com.beemdevelopment.aegis.ui.intro.SlideFragment;
import com.beemdevelopment.aegis.ui.tasks.KeyDerivationTask;
@@ -32,17 +35,10 @@ import com.beemdevelopment.aegis.vault.slots.PasswordSlot;
import com.beemdevelopment.aegis.vault.slots.Slot;
import com.beemdevelopment.aegis.vault.slots.SlotException;
import com.google.android.material.textfield.TextInputLayout;
import com.nulabinc.zxcvbn.Strength;
import com.nulabinc.zxcvbn.Zxcvbn;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import static com.beemdevelopment.aegis.ui.slides.SecurityPickerSlide.CRYPT_TYPE_BIOMETRIC;
import static com.beemdevelopment.aegis.ui.slides.SecurityPickerSlide.CRYPT_TYPE_INVALID;
import static com.beemdevelopment.aegis.ui.slides.SecurityPickerSlide.CRYPT_TYPE_NONE;
import static com.beemdevelopment.aegis.ui.slides.SecurityPickerSlide.CRYPT_TYPE_PASS;
public class SecuritySetupSlide extends SlideFragment {
private EditText _textPassword;
private EditText _textPasswordConfirm;
@@ -76,27 +72,15 @@ public class SecuritySetupSlide extends SlideFragment {
}
});
_textPassword.addTextChangedListener(new TextWatcher() {
private Zxcvbn _zxcvbn = new Zxcvbn();
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
Strength strength = _zxcvbn.measure(_textPassword.getText());
_barPasswordStrength.setProgress(strength.getScore());
_barPasswordStrength.setProgressTintList(ColorStateList.valueOf(Color.parseColor(PasswordStrengthHelper.getColor(strength.getScore()))));
_textPasswordStrength.setText((_textPassword.getText().length() != 0) ? PasswordStrengthHelper.getString(strength.getScore(), requireContext()) : "");
_textPasswordWrapper.setError(strength.getFeedback().getWarning());
strength.wipe();
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
_textPassword.addTextChangedListener(new SimpleTextWatcher(new SimpleTextWatcher.Listener() {
private final PasswordStrengthHelper passStrength = new PasswordStrengthHelper(
_textPassword, _barPasswordStrength, _textPasswordStrength, _textPasswordWrapper);
@Override
public void afterTextChanged(Editable s) {
passStrength.measure(requireContext());
}
});
}));
return view;
}
@@ -47,7 +47,8 @@ public class AssignIconHolder extends RecyclerView.ViewHolder implements AssignI
if (_entry.getNewIcon() != null) {
GlideHelper.loadIcon(Glide.with(_view.getContext()), _entry.getNewIcon(), _newIcon);
} else {
GlideHelper.loadResource(Glide.with(_view.getContext()), R.drawable.ic_unselected, _newIcon);
Glide.with(_view.getContext()).clear(_newIcon);
_newIcon.setImageResource(R.drawable.ic_unselected);
}
_btnReset.setVisibility(_entry.getNewIcon() != null ? View.VISIBLE : View.INVISIBLE);
@@ -0,0 +1,62 @@
package com.beemdevelopment.aegis.ui.views;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.database.AuditLogEntry;
import com.beemdevelopment.aegis.ui.models.AuditLogEntryModel;
import com.beemdevelopment.aegis.vault.VaultEntry;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class AuditLogAdapter extends RecyclerView.Adapter<AuditLogHolder> {
private List<AuditLogEntryModel> _auditLogEntryModels;
private List<VaultEntry> _referencedEntries;
public AuditLogAdapter() {
_auditLogEntryModels = new ArrayList<>();
_referencedEntries = new ArrayList<>();
}
public void addAuditLogEntryModel(AuditLogEntryModel auditLogEntryModel) {
_auditLogEntryModels.add(auditLogEntryModel);
int position = getItemCount() - 1;
if (position == 0) {
notifyDataSetChanged();
} else {
notifyItemInserted(position);
}
}
public void addReferencedEntry(VaultEntry vaultEntry) {
_referencedEntries.add(vaultEntry);
}
@NonNull
@Override
public AuditLogHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_audit_log, parent, false);
return new AuditLogHolder(view);
}
@Override
public void onBindViewHolder(@NonNull AuditLogHolder holder, int position) {
AuditLogEntryModel auditLogEntryModel = _auditLogEntryModels.get(position);
VaultEntry referencedEntry = null;
holder.setData(auditLogEntryModel);
}
@Override
public int getItemCount() {
return _auditLogEntryModels.size();
}
}
@@ -0,0 +1,145 @@
package com.beemdevelopment.aegis.ui.views;
import android.content.Context;
import android.content.res.ColorStateList;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.RecyclerView;
import com.beemdevelopment.aegis.EventType;
import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.database.AuditLogEntry;
import com.beemdevelopment.aegis.ui.models.AuditLogEntryModel;
import com.beemdevelopment.aegis.vault.VaultEntry;
import com.google.android.material.color.MaterialColors;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.time.temporal.ChronoUnit;
public class AuditLogHolder extends RecyclerView.ViewHolder {
private final CardView _cardView;
private final ImageView _auditLogEntryIcon;
private final TextView _auditLogEntryTitle;
private final TextView _auditLogEntryDescription;
private final TextView _auditLogEntryReference;
private final TextView _auditLogEntryTimestamp;
private final int _errorBackgroundColor;
private final ColorStateList _initialBackgroundColor;
private final int _initialIconColor;
public AuditLogHolder(final View view) {
super(view);
_cardView = (CardView)view;
_auditLogEntryIcon = view.findViewById(R.id.iv_icon_view);
_auditLogEntryTitle = view.findViewById(R.id.text_audit_log_title);
_auditLogEntryDescription = view.findViewById(R.id.text_audit_log_description);
_auditLogEntryReference = view.findViewById(R.id.text_audit_log_reference);
_auditLogEntryTimestamp = view.findViewById(R.id.text_audit_log_timestamp);
_initialBackgroundColor = _cardView.getCardBackgroundColor();
_initialIconColor = MaterialColors.getColor(view, com.google.android.material.R.attr.colorTertiaryContainer);
_errorBackgroundColor = MaterialColors.getColor(view, com.google.android.material.R.attr.colorErrorContainer);
}
public void setData(AuditLogEntryModel auditLogEntryModel) {
AuditLogEntry auditLogEntry = auditLogEntryModel.getAuditLogEntry();
_auditLogEntryIcon.setImageResource(getIconResource(auditLogEntry.getEventType()));
_auditLogEntryTitle.setText(EventType.getEventTitleRes(auditLogEntry.getEventType()));
_auditLogEntryDescription.setText(getEventTypeDescriptionRes(auditLogEntry.getEventType()));
_auditLogEntryTimestamp.setText(formatTimestamp(_cardView.getContext(), auditLogEntry.getTimestamp()).toLowerCase());
if (auditLogEntryModel.getReferencedVaultEntry() != null) {
VaultEntry referencedVaultEntry = auditLogEntryModel.getReferencedVaultEntry();
_auditLogEntryReference.setText(String.format("%s (%s)", referencedVaultEntry.getIssuer(), referencedVaultEntry.getName()));
_auditLogEntryReference.setVisibility(View.VISIBLE);
} else if (auditLogEntryModel.getAuditLogEntry().getReference() != null) {
_auditLogEntryReference.setText(R.string.audit_log_entry_deleted);
_auditLogEntryReference.setVisibility(View.VISIBLE);
} else {
_auditLogEntryReference.setVisibility(View.GONE);
}
setCardBackgroundColor(auditLogEntry.getEventType());
}
private void setCardBackgroundColor(EventType eventType) {
if (eventType == EventType.VAULT_UNLOCK_FAILED_PASSWORD || eventType == EventType.VAULT_UNLOCK_FAILED_BIOMETRICS) {
_cardView.setCardBackgroundColor(_errorBackgroundColor);
_auditLogEntryIcon.setBackgroundColor(_errorBackgroundColor);
} else {
_cardView.setCardBackgroundColor(_initialBackgroundColor);
_auditLogEntryIcon.setBackgroundColor(_initialIconColor);
}
}
private int getEventTypeDescriptionRes(EventType eventType) {
switch (eventType) {
case VAULT_UNLOCKED:
return R.string.event_description_vault_unlocked;
case VAULT_BACKUP_CREATED:
return R.string.event_description_backup_created;
case VAULT_ANDROID_BACKUP_CREATED:
return R.string.event_description_android_backup_created;
case VAULT_EXPORTED:
return R.string.event_description_vault_exported;
case ENTRY_SHARED:
return R.string.event_description_entry_shared;
case VAULT_UNLOCK_FAILED_PASSWORD:
return R.string.event_description_vault_unlock_failed_password;
case VAULT_UNLOCK_FAILED_BIOMETRICS:
return R.string.event_description_vault_unlock_failed_biometrics;
default:
return R.string.event_unknown;
}
}
private int getIconResource(EventType eventType) {
switch(eventType) {
case VAULT_UNLOCKED:
return R.drawable.ic_lock_open;
case VAULT_BACKUP_CREATED:
case VAULT_ANDROID_BACKUP_CREATED:
return R.drawable.ic_folder_zip;
case VAULT_EXPORTED:
return R.drawable.ic_export_notes;
case ENTRY_SHARED:
return R.drawable.ic_share;
case VAULT_UNLOCK_FAILED_PASSWORD:
case VAULT_UNLOCK_FAILED_BIOMETRICS:
return R.drawable.ic_lock;
}
return -1;
}
private static String formatTimestamp(Context context, long epochMilli) {
LocalDateTime now = LocalDateTime.now();
LocalDateTime timestamp = LocalDateTime.ofInstant(Instant.ofEpochMilli(epochMilli), ZoneId.systemDefault());
long daysBetween = ChronoUnit.DAYS.between(timestamp.toLocalDate(), now.toLocalDate());
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("h:mm a");
if (daysBetween < 1) {
String formattedTime = timestamp.format(timeFormatter);
return context.getString(R.string.today_at_time, formattedTime);
} else if (daysBetween < 7) {
DateTimeFormatter dayOfWeekFormatter = DateTimeFormatter.ofPattern("EEEE");
String dayOfWeek = timestamp.format(dayOfWeekFormatter);
String formattedTime = timestamp.format(timeFormatter);
return context.getString(R.string.day_of_week_at_time, dayOfWeek, formattedTime);
} else {
DateTimeFormatter dateFormatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM);
return timestamp.format(dateFormatter);
}
}
}
@@ -32,11 +32,13 @@ import com.beemdevelopment.aegis.otp.TotpInfo;
import com.beemdevelopment.aegis.ui.models.ErrorCardInfo;
import com.beemdevelopment.aegis.util.CollectionUtils;
import com.beemdevelopment.aegis.vault.VaultEntry;
import com.beemdevelopment.aegis.vault.VaultGroup;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -50,7 +52,9 @@ public class EntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
private List<VaultEntry> _entries;
private List<VaultEntry> _shownEntries;
private List<VaultEntry> _selectedEntries;
private Collection<VaultGroup> _groups;
private Map<UUID, Integer> _usageCounts;
private Map<UUID, Long> _lastUsedTimestamps;
private VaultEntry _focusedEntry;
private VaultEntry _clickedEntry;
private Preferences.CodeGrouping _codeGroupSize;
@@ -62,6 +66,7 @@ public class EntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
private boolean _tapToReveal;
private int _tapToRevealTime;
private CopyBehavior _copyBehavior;
private int _searchBehaviorMask;
private Set<UUID> _groupFilter;
private SortCategory _sortCategory;
private ViewMode _viewMode;
@@ -128,6 +133,8 @@ public class EntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
public void setCopyBehavior(CopyBehavior copyBehavior) { _copyBehavior = copyBehavior; }
public void setSearchBehaviorMask(int searchBehaviorMask) { _searchBehaviorMask = searchBehaviorMask; }
public void setPauseFocused(boolean pauseFocused) {
_pauseFocused = pauseFocused;
}
@@ -190,6 +197,7 @@ public class EntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
public void addEntries(Collection<VaultEntry> entries) {
for (VaultEntry entry: entries) {
entry.setUsageCount(_usageCounts.containsKey(entry.getUUID()) ? _usageCounts.get(entry.getUUID()) : 0);
entry.setLastUsedTimestamp(_lastUsedTimestamps.containsKey(entry.getUUID()) ? _lastUsedTimestamps.get(entry.getUUID()) : 0);
}
_entries.addAll(entries);
@@ -305,6 +313,7 @@ public class EntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Set<UUID> groups = entry.getGroups();
String issuer = entry.getIssuer().toLowerCase();
String name = entry.getName().toLowerCase();
String note = entry.getNote().toLowerCase();
if (!_groupFilter.isEmpty()) {
if (groups.isEmpty() && !_groupFilter.contains(null)) {
@@ -319,7 +328,17 @@ public class EntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
return false;
}
return !issuer.contains(_searchFilter) && !name.contains(_searchFilter);
return ((_searchBehaviorMask & Preferences.SEARCH_IN_ISSUER) == 0 || !issuer.contains(_searchFilter))
&& ((_searchBehaviorMask & Preferences.SEARCH_IN_NAME) == 0 || !name.contains(_searchFilter))
&& ((_searchBehaviorMask & Preferences.SEARCH_IN_NOTE) == 0 || !note.contains(_searchFilter))
&& ((_searchBehaviorMask & Preferences.SEARCH_IN_GROUPS) == 0 || !doesAnyGroupMatchSearchFilter(entry.getGroups(), _searchFilter));
}
private boolean doesAnyGroupMatchSearchFilter(Set<UUID> entryGroupUUIDs, String searchFilter) {
return _groups.stream()
.filter(group -> entryGroupUUIDs.contains(group.getUUID()))
.map(VaultGroup::getName)
.anyMatch(groupName -> groupName.toLowerCase().contains(searchFilter.toLowerCase()));
}
public void refresh(boolean hard) {
@@ -359,7 +378,7 @@ public class EntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
}
public void setSearchFilter(String search) {
_searchFilter = (search != null && !search.isEmpty()) ? search.toLowerCase() : null;
_searchFilter = (search != null && !search.isEmpty()) ? search.toLowerCase().trim() : null;
updateShownEntries();
}
@@ -375,6 +394,7 @@ public class EntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
}
sortShownEntries();
checkPeriodUniformity();
_view.onListChange();
notifyDataSetChanged();
}
@@ -407,6 +427,12 @@ public class EntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
public Map<UUID, Integer> getUsageCounts() { return _usageCounts; }
public void setGroups(Collection<VaultGroup> groups) { _groups = groups; }
public void setLastUsedTimestamps(Map<UUID, Long> lastUsedTimestamps) { _lastUsedTimestamps = lastUsedTimestamps; }
public Map<UUID, Long> getLastUsedTimestamps() { return _lastUsedTimestamps; }
public int getShownFavoritesCount() {
return (int) _shownEntries.stream().filter(VaultEntry::isFavorite).count();
}
@@ -542,7 +568,7 @@ public class EntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
case SINGLETAP:
if (!handled) {
_view.onEntryCopy(entry);
entryHolder.animateCopyText(_viewMode != ViewMode.TILES);
entryHolder.animateCopyText();
_clickedEntry = null;
}
break;
@@ -551,7 +577,7 @@ public class EntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
if(entry == _clickedEntry) {
_view.onEntryCopy(entry);
entryHolder.animateCopyText(_viewMode != ViewMode.TILES);
entryHolder.animateCopyText();
_clickedEntry = null;
} else {
_clickedEntry = entry;
@@ -669,6 +695,10 @@ public class EntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
return -1;
}
if (infos.size() == 1) {
return infos.get(0).getPeriod();
}
Map<Integer, Integer> occurrences = new HashMap<>();
for (TotpInfo info : infos) {
int period = info.getPeriod();
@@ -805,6 +835,8 @@ public class EntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
int usageCount = _usageCounts.get(entry.getUUID());
_usageCounts.put(entry.getUUID(), ++usageCount);
}
_lastUsedTimestamps.put(entry.getUUID(), new Date().getTime());
}
public boolean isDragAndDropAllowed() {
@@ -1,7 +1,14 @@
package com.beemdevelopment.aegis.ui.views;
import android.graphics.Paint;
import android.graphics.Rect;
import android.os.Handler;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.RelativeSizeSpan;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.widget.ImageView;
import android.widget.RelativeLayout;
@@ -15,6 +22,7 @@ import com.beemdevelopment.aegis.Preferences;
import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.ViewMode;
import com.beemdevelopment.aegis.helpers.AnimationsHelper;
import com.beemdevelopment.aegis.helpers.CenterVerticalSpan;
import com.beemdevelopment.aegis.helpers.SimpleAnimationEndListener;
import com.beemdevelopment.aegis.helpers.UiRefresher;
import com.beemdevelopment.aegis.otp.HotpInfo;
@@ -108,6 +116,9 @@ public class EntryHolder extends RecyclerView.ViewHolder {
_codeGrouping = groupSize;
_viewMode = viewMode;
_accountNamePosition = accountNamePosition;
if (viewMode.equals(ViewMode.TILES) && _accountNamePosition == AccountNamePosition.END) {
_accountNamePosition = AccountNamePosition.BELOW;
}
_selected.clearAnimation();
_selected.setVisibility(View.GONE);
@@ -129,7 +140,7 @@ public class EntryHolder extends RecyclerView.ViewHolder {
}
_profileIssuer.setText(profileIssuer);
_profileName.setText(profileName);
setAccountNameLayout(_accountNamePosition);
setAccountNameLayout(_accountNamePosition, !profileIssuer.isEmpty() && !profileName.isEmpty());
if (_hidden) {
hideCode();
@@ -142,16 +153,26 @@ public class EntryHolder extends RecyclerView.ViewHolder {
itemView.setAlpha(dimmed ? DIMMED_ALPHA : DEFAULT_ALPHA);
}
private void setAccountNameLayout(AccountNamePosition accountNamePosition) {
if (_viewMode == ViewMode.TILES) {
return;
}
private void setAccountNameLayout(AccountNamePosition accountNamePosition, Boolean hasBothIssuerAndName) {
RelativeLayout.LayoutParams profileNameLayoutParams;
RelativeLayout.LayoutParams copiedLayoutParams;
switch (accountNamePosition) {
case HIDDEN:
_profileName.setVisibility(View.GONE);
if (_viewMode == ViewMode.TILES) {
_profileCopied.setGravity(Gravity.CENTER_VERTICAL);
((RelativeLayout.LayoutParams)_profileCopied.getLayoutParams()).removeRule(RelativeLayout.BELOW);
_profileCopied.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT;
_profileCopied.setTextSize(14);
_profileIssuer.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT;
_profileIssuer.setGravity(Gravity.CENTER_VERTICAL);
_profileIssuer.setTextSize(14);
_profileName.setVisibility(View.GONE);
}
break;
case BELOW:
@@ -161,24 +182,18 @@ public class EntryHolder extends RecyclerView.ViewHolder {
profileNameLayoutParams.setMarginStart(0);
_profileName.setLayoutParams(profileNameLayoutParams);
_profileName.setVisibility(View.VISIBLE);
copiedLayoutParams = (RelativeLayout.LayoutParams) _profileCopied.getLayoutParams();
copiedLayoutParams.addRule(RelativeLayout.ABOVE, R.id.profile_account_name);
_profileCopied.setLayoutParams(copiedLayoutParams);
break;
case END:
default:
profileNameLayoutParams = (RelativeLayout.LayoutParams) _profileName.getLayoutParams();
profileNameLayoutParams.addRule(RelativeLayout.END_OF, R.id.profile_issuer);
profileNameLayoutParams.setMarginStart(24);
profileNameLayoutParams.removeRule(RelativeLayout.BELOW);
if (hasBothIssuerAndName) {
profileNameLayoutParams.setMarginStart(24);
}
_profileName.setLayoutParams(profileNameLayoutParams);
_profileName.setVisibility(View.VISIBLE);
copiedLayoutParams = (RelativeLayout.LayoutParams) _profileCopied.getLayoutParams();
copiedLayoutParams.addRule(RelativeLayout.ABOVE, R.id.description);
_profileCopied.setLayoutParams(copiedLayoutParams);
break;
}
}
@@ -267,6 +282,10 @@ public class EntryHolder extends RecyclerView.ViewHolder {
}
private void updateCode() {
_profileCode.setText(getOtp());
}
private String getOtp() {
OtpInfo info = _entry.getInfo();
// In previous versions of Aegis, it was possible to import entries with an empty
@@ -283,7 +302,7 @@ public class EntryHolder extends RecyclerView.ViewHolder {
otp = _view.getResources().getString(R.string.error_all_caps);
}
_profileCode.setText(otp);
return otp;
}
private String formatCode(String code) {
@@ -321,12 +340,53 @@ public class EntryHolder extends RecyclerView.ViewHolder {
}
public void hideCode() {
String hiddenText = new String(new char[_entry.getInfo().getDigits()]).replace("\0", Character.toString(HIDDEN_CHAR));
hiddenText = formatCode(hiddenText);
_profileCode.setText(hiddenText);
String code = getOtp();
String hiddenText = code.replaceAll("\\S", Character.toString(HIDDEN_CHAR));
updateTextViewWithDots(_profileCode, hiddenText, code);
_hidden = true;
}
private void updateTextViewWithDots(TextView textView, String hiddenCode, String code) {
Paint paint = new Paint();
paint.setTextSize(_profileCode.getTextSize());
// Calculate the difference between the actual code width and the dots width
float codeWidth = paint.measureText(code);
float dotsWidth = paint.measureText(hiddenCode);
float scaleFactor = codeWidth / dotsWidth;
scaleFactor = (float)(Math.round(scaleFactor * 10.0) / 10.0);
// If scale is higher or equal to 0.8, do nothing and proceed with the normal text rendering
if (scaleFactor >= 0.8) {
textView.setText(hiddenCode);
return;
}
// We need to use an invisible character in order to get the height of the profileCode textview consistent
// Tokens without a space (ie Steam TOTP) will get misaligned without this
SpannableString dotsString = new SpannableString("\u200B" + hiddenCode);
// Only scale the digits/characters, skip the spaces
int start = 1;
for (int i = 0; i <= dotsString.length(); i++) {
if (i == dotsString.length() || dotsString.charAt(i) == ' ') {
if (i > start) {
dotsString.setSpan(new RelativeSizeSpan(scaleFactor), start, i, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
start = i + 1;
}
}
Rect dotsRectBounds = new Rect();
paint.getTextBounds(hiddenCode, 1, hiddenCode.length(), dotsRectBounds);
// Use custom CenterVerticalSpan to make sure the dots are vertically aligned
dotsString.setSpan(new CenterVerticalSpan(dotsRectBounds), 1, dotsString.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
textView.setText(dotsString);
}
public void showIcon(boolean show) {
if (show) {
_profileDrawable.setVisibility(View.VISIBLE);
@@ -355,7 +415,7 @@ public class EntryHolder extends RecyclerView.ViewHolder {
animateAlphaTo(DEFAULT_ALPHA);
}
public void animateCopyText(boolean includeSlideAnimation) {
public void animateCopyText() {
_animationHandler.removeCallbacksAndMessages(null);
Animation slideDownFadeIn = AnimationsHelper.loadScaledAnimation(itemView.getContext(), R.anim.slide_down_fade_in);
@@ -363,23 +423,25 @@ public class EntryHolder extends RecyclerView.ViewHolder {
Animation fadeOut = AnimationsHelper.loadScaledAnimation(itemView.getContext(), R.anim.fade_out);
Animation fadeIn = AnimationsHelper.loadScaledAnimation(itemView.getContext(), R.anim.fade_in);
if (includeSlideAnimation) {
// Use slideDown animation when user is not using Tiles mode
if (_viewMode != ViewMode.TILES) {
_profileCopied.startAnimation(slideDownFadeIn);
View fadeOutView = (_accountNamePosition == AccountNamePosition.BELOW) ? _profileName : _description;
fadeOutView.startAnimation(slideDownFadeOut);
View fadeOutView = (_accountNamePosition == AccountNamePosition.BELOW) ? _profileName : _description;
fadeOutView.startAnimation(slideDownFadeOut);
_animationHandler.postDelayed(() -> {
_profileCopied.startAnimation(fadeOut);
fadeOutView.startAnimation(fadeIn);
}, 3000);
} else {
View visibleProfileText = _accountNamePosition == AccountNamePosition.BELOW ? _profileName : _profileIssuer;
_profileCopied.startAnimation(fadeIn);
_profileName.startAnimation(fadeOut);
visibleProfileText.startAnimation(fadeOut);
_animationHandler.postDelayed(() -> {
_profileCopied.startAnimation(fadeOut);
_profileName.startAnimation(fadeIn);
visibleProfileText.startAnimation(fadeIn);
}, 3000);
}
}
@@ -3,9 +3,11 @@ package com.beemdevelopment.aegis.ui.views;
import static androidx.recyclerview.widget.RecyclerView.NO_POSITION;
import android.annotation.SuppressLint;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
@@ -14,10 +16,13 @@ import android.view.animation.LayoutAnimationController;
import android.widget.Button;
import android.widget.LinearLayout;
import androidx.annotation.AttrRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StyleRes;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.widget.NestedScrollView;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
@@ -32,7 +37,6 @@ import com.beemdevelopment.aegis.ViewMode;
import com.beemdevelopment.aegis.helpers.AnimationsHelper;
import com.beemdevelopment.aegis.helpers.MetricsHelper;
import com.beemdevelopment.aegis.helpers.SimpleItemTouchHelperCallback;
import com.beemdevelopment.aegis.helpers.ThemeHelper;
import com.beemdevelopment.aegis.helpers.UiRefresher;
import com.beemdevelopment.aegis.otp.TotpInfo;
import com.beemdevelopment.aegis.ui.dialogs.Dialogs;
@@ -47,14 +51,18 @@ import com.bumptech.glide.ListPreloader;
import com.bumptech.glide.RequestBuilder;
import com.bumptech.glide.integration.recyclerview.RecyclerViewPreloader;
import com.bumptech.glide.util.ViewPreloadSizeProvider;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.google.android.material.card.MaterialCardView;
import com.google.android.material.chip.Chip;
import com.google.android.material.chip.ChipGroup;
import com.google.android.material.divider.MaterialDividerItemDecoration;
import com.google.android.material.shape.CornerFamily;
import com.google.android.material.shape.ShapeAppearanceModel;
import com.google.common.base.Strings;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -68,8 +76,7 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
private ItemTouchHelper _touchHelper;
private RecyclerView _recyclerView;
private RecyclerView.ItemDecoration _verticalDividerDecoration;
private RecyclerView.ItemDecoration _horizontalDividerDecoration;
private RecyclerView.ItemDecoration _itemDecoration;
private ViewPreloadSizeProvider<VaultEntry> _preloadSizeProvider;
private TotpProgressBar _progressBar;
private boolean _showProgress;
@@ -166,6 +173,29 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
_preloadSizeProvider.setView(view);
}
@Override
public void onViewStateRestored(@Nullable Bundle savedInstanceState) {
super.onViewStateRestored(savedInstanceState);
if (savedInstanceState == null) {
return;
}
HashSet<UUID> filter = (HashSet<UUID>) savedInstanceState.getSerializable("prefGroupFilter");
if (filter != null) {
_prefGroupFilter = filter;
}
}
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
// user can apply _groupFilter without saving
// restore _groupFilter as _prefGroupFilter in order to reapply correct filter after screen rotate
if (_groupFilter != null) {
outState.putSerializable("prefGroupFilter", new HashSet<>(_groupFilter));
}
}
@Override
public void onDestroyView() {
_refresher.destroy();
@@ -192,6 +222,10 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
_adapter.setCopyBehavior(copyBehavior);
}
public void setSearchBehaviorMask(int searchBehaviorMask) {
_adapter.setSearchBehaviorMask(searchBehaviorMask);
}
public List<VaultEntry> selectAllEntries() {
return _adapter.selectAllEntries();
}
@@ -224,6 +258,14 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
return _adapter.getUsageCounts();
}
public void setLastUsedTimestamps(Map<UUID, Long> lastUsedTimestamps) {
_adapter.setLastUsedTimestamps(lastUsedTimestamps);
}
public Map<UUID, Long> getLastUsedTimestamps() {
return _adapter.getLastUsedTimestamps();
}
public void setSearchFilter(String search) {
_adapter.setSearchFilter(search);
_touchCallback.setIsLongPressDragEnabled(_adapter.isDragAndDropAllowed());
@@ -245,7 +287,7 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
_touchCallback.setDragFlags(ItemTouchHelper.UP | ItemTouchHelper.DOWN);
}
((GridLayoutManager)_recyclerView.getLayoutManager()).setSpanCount(mode.getColumnSpan());
((GridLayoutManager)_recyclerView.getLayoutManager()).setSpanCount(mode.getSpanCount());
}
public void startDrag(RecyclerView.ViewHolder viewHolder) {
@@ -494,6 +536,12 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
private void initializeGroupChip() {
View view = getLayoutInflater().inflate(R.layout.dialog_select_groups, null);
BottomSheetDialog dialog = new BottomSheetDialog(requireContext());
NestedScrollView scrollView = view.findViewById(R.id.scrollView);
ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) scrollView.getLayoutParams();
layoutParams.matchConstraintMaxHeight = getResources().getConfiguration().screenHeightDp;
dialog.getBehavior().setState(BottomSheetBehavior.STATE_EXPANDED);
dialog.getBehavior().setSkipCollapsed(false);
dialog.setContentView(view);
ChipGroup chipGroup = view.findViewById(R.id.groupChipGroup);
@@ -555,6 +603,7 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
public void setGroups(Collection<VaultGroup> groups) {
_groups = groups;
_adapter.setGroups(groups);
_groupChip.setVisibility(_groups.isEmpty() ? View.GONE : View.VISIBLE);
updateDividerDecoration();
@@ -581,28 +630,18 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
}
private void updateDividerDecoration() {
if (_verticalDividerDecoration != null) {
_recyclerView.removeItemDecoration(_verticalDividerDecoration);
if (_itemDecoration != null) {
_recyclerView.removeItemDecoration(_itemDecoration);
}
if(_horizontalDividerDecoration != null) {
_recyclerView.removeItemDecoration(_horizontalDividerDecoration);
}
float height = _viewMode.getDividerHeight();
float width = _viewMode.getDividerWidth();
if (_showProgress && height == 0) {
_verticalDividerDecoration = new CompactDividerDecoration();
float offset = _viewMode.getItemOffset();
if (_viewMode == ViewMode.TILES) {
_itemDecoration = new TileSpaceItemDecoration(offset);
} else {
_verticalDividerDecoration = new VerticalSpaceItemDecoration(height);
_itemDecoration = new VerticalSpaceItemDecoration(offset);
}
if (width != 0) {
_horizontalDividerDecoration = new TileSpaceItemDecoration(width, height);
_recyclerView.addItemDecoration(_horizontalDividerDecoration);
} else {
_recyclerView.addItemDecoration(_verticalDividerDecoration);
}
_recyclerView.addItemDecoration(_itemDecoration);
}
private void updateEmptyState() {
@@ -632,38 +671,18 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
void onEntryListTouch();
}
private class CompactDividerDecoration extends MaterialDividerItemDecoration {
public CompactDividerDecoration() {
super(requireContext(), DividerItemDecoration.VERTICAL);
setDividerColor(ThemeHelper.getThemeColor(androidx.appcompat.R.attr.divider, requireContext().getTheme()));
setLastItemDecorated(false);
setDividerThickness(MetricsHelper.convertDpToPixels(requireContext(), 0.5f));
}
@Override
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
if (_adapter.isPositionErrorCard(parent.getChildAdapterPosition(view))) {
outRect.top = MetricsHelper.convertDpToPixels(requireContext(), 4);
return;
}
if (_adapter.isPositionFooter(parent.getChildAdapterPosition(view))) {
int pixels = MetricsHelper.convertDpToPixels(requireContext(), 20);
outRect.top = pixels;
outRect.bottom = pixels;
return;
}
super.getItemOffsets(outRect, view, parent, state);
}
}
private class VerticalSpaceItemDecoration extends RecyclerView.ItemDecoration {
private final int _height;
private final int _offset;
private final ShapeAppearanceModel _defaultShapeModel;
private VerticalSpaceItemDecoration(float dp) {
// convert dp to pixels
_height = MetricsHelper.convertDpToPixels(requireContext(), dp);
private VerticalSpaceItemDecoration(float offset) {
_offset = MetricsHelper.convertDpToPixels(requireContext(), offset);
int shapeAppearanceId = getStyledAttrs(R.style.Widget_Aegis_EntryCardView,
com.google.android.material.R.attr.shapeAppearance);
_defaultShapeModel = ShapeAppearanceModel.builder(
requireContext(), shapeAppearanceId, 0).build();
}
@Override
@@ -674,17 +693,21 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
}
// The error card and the footer always have a top and bottom margin
if (_adapter.isPositionErrorCard(adapterPosition)
|| _adapter.isPositionFooter(adapterPosition)) {
outRect.top = _height;
outRect.bottom = _height;
if (_adapter.isPositionErrorCard(adapterPosition)) {
outRect.top = _viewMode == ViewMode.COMPACT ? _offset * 4 : _offset;
outRect.bottom = _offset;
return;
}
if (_adapter.isPositionFooter(adapterPosition)) {
outRect.top = _offset * 2;
outRect.bottom = _offset;
return;
}
int entryIndex = _adapter.translateEntryPosToIndex(adapterPosition);
// The first entry should have a top margin, but only if the group chip is not shown and the error card is not shown
if (entryIndex == 0 && (_groups == null || _groups.isEmpty()) && !_adapter.isErrorCardShown()) {
outRect.top = _height;
outRect.top = _offset;
}
// Only non-favorite entries have a bottom margin, except for the final favorite entry
@@ -692,37 +715,58 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
if (totalFavorites == 0
|| (entryIndex < _adapter.getShownEntriesCount() && !_adapter.getEntryAtPos(adapterPosition).isFavorite())
|| totalFavorites == entryIndex + 1) {
outRect.bottom = _height;
}
if (totalFavorites > 0) {
// If this entry is the last favorite entry in the list, it should always have
// a bottom margin, regardless of the view mode
if (entryIndex == totalFavorites - 1) {
outRect.bottom = _height;
}
// If this is the first non-favorite entry, it should have a top margin
if (entryIndex == totalFavorites) {
outRect.top = _height;
}
outRect.bottom = _offset;
}
// The last entry should never have a bottom margin
if (_adapter.getShownEntriesCount() == entryIndex + 1) {
outRect.bottom = 0;
}
decorateFavoriteEntries((MaterialCardView) view, parent);
}
private void decorateFavoriteEntries(@NonNull MaterialCardView view, @NonNull RecyclerView parent) {
int adapterPosition = parent.getChildAdapterPosition(view);
int entryIndex = _adapter.translateEntryPosToIndex(adapterPosition);
int totalFavorites = _adapter.getShownFavoritesCount();
ShapeAppearanceModel.Builder builder = _defaultShapeModel.toBuilder();
if (entryIndex < totalFavorites) {
if ((entryIndex == 0 && totalFavorites > 1) || (entryIndex < (totalFavorites - 1))) {
builder.setBottomLeftCorner(CornerFamily.ROUNDED, 0);
builder.setBottomRightCorner(CornerFamily.ROUNDED, 0);
}
if (entryIndex > 0) {
builder.setTopLeftCorner(CornerFamily.ROUNDED, 0);
builder.setTopRightCorner(CornerFamily.ROUNDED, 0);
}
}
view.setShapeAppearanceModel(builder.build());
view.setClipToOutline(true);
}
private int getStyledAttrs(@StyleRes int styleId, @AttrRes int attrId) {
TypedArray cardAttrs = null;
try {
cardAttrs = requireContext().obtainStyledAttributes(styleId, new int[]{attrId});
TypedValue value = new TypedValue();
cardAttrs.getValue(0, value);
return value.data;
} finally {
if (cardAttrs != null) {
cardAttrs.recycle();
}
}
}
}
private class TileSpaceItemDecoration extends RecyclerView.ItemDecoration {
private final int _width;
private final int _height;
private final int _offset;
private TileSpaceItemDecoration(float width, float height) {
// convert dp to pixels
_width = MetricsHelper.convertDpToPixels(requireContext(), width);
_height = MetricsHelper.convertDpToPixels(requireContext(), height);
private TileSpaceItemDecoration(float offset) {
_offset = MetricsHelper.convertDpToPixels(requireContext(), offset);
}
@Override
@@ -732,10 +776,21 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
return;
}
outRect.left = _width;
outRect.right = _width;
outRect.top = _height;
outRect.bottom = _height;
outRect.left = _offset;
outRect.right = _offset;
outRect.top = _offset;
outRect.bottom = _offset;
if (_adapter.isPositionErrorCard(adapterPosition)
|| (isInFirstEntryRow(adapterPosition) && !_adapter.isErrorCardShown())
|| _adapter.isPositionFooter(adapterPosition)) {
outRect.top *= 2;
}
}
private boolean isInFirstEntryRow(int pos) {
int index = _adapter.translateEntryPosToIndex(pos);
return index >= 0 && index < _viewMode.getSpanCount();
}
}
@@ -10,6 +10,7 @@ import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.vault.VaultGroup;
import java.util.ArrayList;
import java.util.UUID;
public class GroupAdapter extends RecyclerView.Adapter<GroupHolder> {
private GroupAdapter.Listener _listener;
@@ -31,6 +32,13 @@ public class GroupAdapter extends RecyclerView.Adapter<GroupHolder> {
}
}
public void replaceGroup(UUID uuid, VaultGroup newGroup) {
VaultGroup oldGroup = getGroupByUUID(uuid);
int position = _groups.indexOf(oldGroup);
_groups.set(position, newGroup);
notifyItemChanged(position);
}
public void removeGroup(VaultGroup group) {
int position = _groups.indexOf(group);
_groups.remove(position);
@@ -46,18 +54,32 @@ public class GroupAdapter extends RecyclerView.Adapter<GroupHolder> {
@Override
public void onBindViewHolder(GroupHolder holder, int position) {
holder.setData(_groups.get(position));
holder.setOnEditClickListener(v -> {
int position12 = holder.getAdapterPosition();
_listener.onEditGroup(_groups.get(position12));
});
holder.setOnDeleteClickListener(v -> {
int position12 = holder.getAdapterPosition();
_listener.onRemoveGroup(_groups.get(position12));
});
}
private VaultGroup getGroupByUUID(UUID uuid) {
for (VaultGroup group : _groups) {
if (group.getUUID().equals(uuid)) {
return group;
}
}
return null;
}
@Override
public int getItemCount() {
return _groups.size();
}
public interface Listener {
void onEditGroup(VaultGroup group);
void onRemoveGroup(VaultGroup group);
}
}
@@ -11,11 +11,13 @@ import com.beemdevelopment.aegis.vault.VaultGroup;
public class GroupHolder extends RecyclerView.ViewHolder {
private TextView _slotName;
private ImageView _buttonEdit;
private ImageView _buttonDelete;
public GroupHolder(final View view) {
super(view);
_slotName = view.findViewById(R.id.text_group_name);
_buttonEdit = view.findViewById(R.id.button_edit);
_buttonDelete = view.findViewById(R.id.button_delete);
}
@@ -23,6 +25,10 @@ public class GroupHolder extends RecyclerView.ViewHolder {
_slotName.setText(group.getName());
}
public void setOnEditClickListener(View.OnClickListener listener) {
_buttonEdit.setOnClickListener(listener);
}
public void setOnDeleteClickListener(View.OnClickListener listener) {
_buttonDelete.setOnClickListener(listener);
}
@@ -8,11 +8,11 @@ import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.helpers.ThemeHelper;
import com.beemdevelopment.aegis.icons.IconPack;
import com.beemdevelopment.aegis.icons.IconType;
import com.beemdevelopment.aegis.ui.glide.GlideHelper;
import com.bumptech.glide.Glide;
import com.google.android.material.color.MaterialColors;
import java.io.File;
@@ -39,8 +39,10 @@ public class IconHolder extends RecyclerView.ViewHolder {
public void loadIcon(Context context) {
if (_isCustom) {
int tint = ThemeHelper.getThemeColor(com.google.android.material.R.attr.colorOnSurfaceVariant, context.getTheme());
GlideHelper.loadResource(Glide.with(context), R.drawable.ic_outline_add_24, tint, _imageView);
Glide.with(context).clear(_imageView);
int tint = MaterialColors.getColor(itemView, com.google.android.material.R.attr.colorOnSurfaceVariant);
_imageView.setColorFilter(tint);
_imageView.setImageResource(R.drawable.ic_outline_add_24);
} else {
GlideHelper.loadIconFile(Glide.with(context), _iconFile, _iconType, _imageView);
}
@@ -16,6 +16,9 @@ public class Vault {
private final UUIDMap<VaultEntry> _entries = new UUIDMap<>();
private final UUIDMap<VaultGroup> _groups = new UUIDMap<>();
// Whether we've migrated the group list to the new format while parsing the vault
private boolean _isGroupsMigrationFresh = false;
public JSONObject toJson() {
return toJson(null);
}
@@ -70,7 +73,9 @@ public class Vault {
JSONArray array = obj.getJSONArray("entries");
for (int i = 0; i < array.length(); i++) {
VaultEntry entry = VaultEntry.fromJson(array.getJSONObject(i));
vault.migrateOldGroup(entry);
if (vault.migrateOldGroup(entry)) {
vault.setGroupsMigrationFresh();
}
// check the vault has a group corresponding to each one the entry claims to be in
for (UUID groupUuid: entry.getGroups()) {
@@ -88,7 +93,15 @@ public class Vault {
return vault;
}
public void migrateOldGroup(VaultEntry entry) {
private void setGroupsMigrationFresh() {
_isGroupsMigrationFresh = true;
}
public boolean isGroupsMigrationFresh() {
return _isGroupsMigrationFresh;
}
public boolean migrateOldGroup(VaultEntry entry) {
if (entry.getOldGroup() != null) {
Optional<VaultGroup> optGroup = getGroups().getValues()
.stream()
@@ -104,7 +117,10 @@ public class Vault {
}
entry.setOldGroup(null);
return true;
}
return false;
}
public UUIDMap<VaultEntry> getEntries() {
@@ -10,6 +10,7 @@ import androidx.annotation.NonNull;
import androidx.documentfile.provider.DocumentFile;
import com.beemdevelopment.aegis.Preferences;
import com.beemdevelopment.aegis.database.AuditLogRepository;
import com.beemdevelopment.aegis.util.IOUtils;
import java.io.File;
@@ -41,17 +42,20 @@ public class VaultBackupManager {
private final Context _context;
private final Preferences _prefs;
private final ExecutorService _executor;
private final AuditLogRepository _auditLogRepository;
public VaultBackupManager(Context context) {
public VaultBackupManager(Context context, AuditLogRepository auditLogRepository) {
_context = context;
_prefs = new Preferences(context);
_executor = Executors.newSingleThreadExecutor();
_auditLogRepository = auditLogRepository;
}
public void scheduleBackup(File tempFile, Uri dirUri, int versionsToKeep) {
_executor.execute(() -> {
try {
createBackup(tempFile, dirUri, versionsToKeep);
_auditLogRepository.addBackupCreatedEvent();
_prefs.setBuiltInBackupResult(new Preferences.BackupResult(null));
} catch (VaultRepositoryException | VaultBackupPermissionException e) {
e.printStackTrace();
@@ -114,6 +118,10 @@ public class VaultBackupManager {
}
private void enforceVersioning(DocumentFile dir, int versionsToKeep) {
if (versionsToKeep <= 0) {
return;
}
Log.i(TAG, String.format("Scanning directory %s for backup files", Uri.decode(dir.getUri().toString())));
List<BackupFile> files = new ArrayList<>();
@@ -23,6 +23,7 @@ public class VaultEntry extends UUIDMap.Value {
private VaultEntryIcon _icon;
private boolean _isFavorite;
private int _usageCount;
private long _lastUsedTimestamp;
private String _note = "";
private String _oldGroup;
private Set<UUID> _groups = new TreeSet<>();
@@ -135,6 +136,10 @@ public class VaultEntry extends UUIDMap.Value {
return _usageCount;
}
public long getLastUsedTimestamp() {
return _lastUsedTimestamp;
}
public String getNote() {
return _note;
}
@@ -143,8 +148,6 @@ public class VaultEntry extends UUIDMap.Value {
return _isFavorite;
}
;
public void setName(String name) {
_name = name;
}
@@ -187,6 +190,8 @@ public class VaultEntry extends UUIDMap.Value {
_usageCount = usageCount;
}
public void setLastUsedTimestamp(long lastUsedTimestamp) { _lastUsedTimestamp = lastUsedTimestamp; }
public void setNote(String note) {
_note = note;
}
@@ -15,6 +15,7 @@ import com.beemdevelopment.aegis.Preferences;
import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.crypto.KeyStoreHandle;
import com.beemdevelopment.aegis.crypto.KeyStoreHandleException;
import com.beemdevelopment.aegis.database.AuditLogRepository;
import com.beemdevelopment.aegis.services.NotificationService;
import com.beemdevelopment.aegis.ui.dialogs.Dialogs;
@@ -37,12 +38,15 @@ public class VaultManager {
private final List<LockListener> _lockListeners;
private boolean _blockAutoLock;
public VaultManager(@NonNull Context context) {
private final AuditLogRepository _auditLogRepository;
public VaultManager(@NonNull Context context, AuditLogRepository auditLogRepository) {
_context = context;
_prefs = new Preferences(_context);
_backups = new VaultBackupManager(_context);
_backups = new VaultBackupManager(_context, auditLogRepository);
_androidBackups = new BackupManager(context);
_lockListeners = new ArrayList<>();
_auditLogRepository = auditLogRepository;
}
/**
@@ -225,6 +225,10 @@ public class VaultRepository {
_vault.getEntries().add(entry);
}
public boolean hasEntryByUUID(UUID uuid) {
return _vault.getEntries().has(uuid);
}
public VaultEntry getEntryByUUID(UUID uuid) {
return _vault.getEntries().getByUUID(uuid);
}
@@ -287,6 +291,10 @@ public class VaultRepository {
removeGroup(group);
}
public void renameGroup(VaultGroup renamedGroup) {
_vault.getGroups().replace(renamedGroup);
}
public void removeGroup(VaultGroup group) {
for (VaultEntry entry : getEntries()) {
entry.removeGroup(group.getUUID());
@@ -310,6 +318,10 @@ public class VaultRepository {
.collect(Collectors.toList());
}
public boolean isGroupsMigrationFresh() {
return _vault.isGroupsMigrationFresh();
}
public VaultFileCredentials getCredentials() {
return _creds == null ? null : _creds.clone();
}
@@ -75,6 +75,7 @@ public class SlotList extends UUIDMap<Slot> {
/**
* Returns a copy of this SlotList that is suitable for exporting.
* Strips biometric slots.
* In case there's a backup password slot, any regular password slots are stripped.
*/
public SlotList exportable() {
@@ -85,18 +86,16 @@ public class SlotList extends UUIDMap<Slot> {
break;
}
}
if (!hasBackupSlots) {
return this;
}
SlotList slots = new SlotList();
for (Slot slot : this) {
if (!(slot instanceof PasswordSlot) || ((PasswordSlot) slot).isBackup()) {
slots.add(slot);
if (slot instanceof BiometricSlot) {
continue;
}
if (hasBackupSlots && slot instanceof PasswordSlot && !((PasswordSlot) slot).isBackup()) {
continue;
}
slots.add(slot);
}
return slots;
}
}
@@ -0,0 +1,117 @@
package info.guardianproject;
import info.guardianproject.trustedintents.ApkSignaturePin;
/**
* This is the second Guardian Project APK signing key. It was generated since
* RSA 1024-bit keys are deprecated. So any new Guardian Project app will be
* signed by this key. It is used to sign these apps:
* <ul>
* <li>Checkey</li>
* <li>Courier</li>
* </ul>
*
* @author hans
*/
public final class GuardianProjectRSA4096 extends ApkSignaturePin {
public GuardianProjectRSA4096() {
fingerprints = new String[] {
"f006a20481c71a690de02e385ab0c9fa4ac1245240f68102682703ba0656867a",
};
certificates = new byte[][] {
{
48, -126, 5, -84, 48, -126, 3, -108, 2, 9, 0, -126, -20, 93, -43, 112, 34,
-87, 29, 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1, 5, 5, 0, 48, -127,
-105, 49, 11, 48, 9, 6, 3, 85, 4, 6, 19, 2, 85, 83, 49, 17, 48, 15, 6, 3,
85, 4, 8, 12, 8, 78, 101, 119, 32, 89, 111, 114, 107, 49, 17, 48, 15, 6, 3,
85, 4, 7, 12, 8, 78, 101, 119, 32, 89, 111, 114, 107, 49, 25, 48, 23, 6, 3,
85, 4, 10, 12, 16, 71, 117, 97, 114, 100, 105, 97, 110, 32, 80, 114, 111,
106, 101, 99, 116, 49, 29, 48, 27, 6, 3, 85, 4, 3, 12, 20, 103, 117, 97,
114, 100, 105, 97, 110, 112, 114, 111, 106, 101, 99, 116, 46, 105, 110,
102, 111, 49, 40, 48, 38, 6, 9, 42, -122, 72, -122, -9, 13, 1, 9, 1, 22,
25, 114, 111, 111, 116, 64, 103, 117, 97, 114, 100, 105, 97, 110, 112, 114,
111, 106, 101, 99, 116, 46, 105, 110, 102, 111, 48, 30, 23, 13, 49, 52, 48,
53, 49, 52, 49, 55, 53, 55, 50, 57, 90, 23, 13, 52, 49, 48, 57, 50, 56, 49,
55, 53, 55, 50, 57, 90, 48, -127, -105, 49, 11, 48, 9, 6, 3, 85, 4, 6, 19,
2, 85, 83, 49, 17, 48, 15, 6, 3, 85, 4, 8, 12, 8, 78, 101, 119, 32, 89,
111, 114, 107, 49, 17, 48, 15, 6, 3, 85, 4, 7, 12, 8, 78, 101, 119, 32, 89,
111, 114, 107, 49, 25, 48, 23, 6, 3, 85, 4, 10, 12, 16, 71, 117, 97, 114,
100, 105, 97, 110, 32, 80, 114, 111, 106, 101, 99, 116, 49, 29, 48, 27, 6,
3, 85, 4, 3, 12, 20, 103, 117, 97, 114, 100, 105, 97, 110, 112, 114, 111,
106, 101, 99, 116, 46, 105, 110, 102, 111, 49, 40, 48, 38, 6, 9, 42, -122,
72, -122, -9, 13, 1, 9, 1, 22, 25, 114, 111, 111, 116, 64, 103, 117, 97,
114, 100, 105, 97, 110, 112, 114, 111, 106, 101, 99, 116, 46, 105, 110,
102, 111, 48, -126, 2, 34, 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1,
1, 5, 0, 3, -126, 2, 15, 0, 48, -126, 2, 10, 2, -126, 2, 1, 0, -51, 108,
83, -44, 61, 81, 46, 61, 2, -61, 46, 60, 2, -30, 44, 38, -70, -63, -93,
-66, -57, 1, 2, -32, -80, -82, 98, -26, -70, -34, 60, -65, -55, -43, 16,
-63, -89, -104, 50, 108, -26, -2, -3, -55, -77, 47, 75, 89, 99, 12, -32,
32, 120, -26, -81, 54, 95, -57, -114, -100, -39, -110, -4, 120, 90, 90,
-40, -89, -53, 63, -122, -45, -80, 32, -6, -12, -29, -107, 45, 10, -23, 76,
5, 112, -15, -63, 48, 35, -61, 0, -107, -110, 44, -46, -126, -30, -30, -33,
86, 22, 30, 8, -72, 29, 75, 121, 31, -120, 119, 59, -57, 19, -64, 31, 84,
-94, -38, 91, 82, 92, -95, 66, 2, 120, -37, -113, 126, 54, -83, 83, -125,
122, 110, -106, 80, 59, -127, -72, -23, 64, 105, 20, 25, -41, -3, -61, -44,
51, -28, 17, 36, -90, -18, -25, 96, 37, -93, -48, 98, 47, 27, 49, 40, -31,
-62, -102, -49, 28, -55, 50, -38, -70, -83, 101, 97, 96, -122, -114, 18,
47, 119, 117, -7, -55, -64, -1, 96, -120, 61, -89, -70, -7, -89, 113, -41,
88, 27, 26, 95, -52, 53, 59, 7, 11, 79, 86, 31, -109, -21, 120, -15, 38,
106, 33, -121, 82, 18, 45, 32, 49, 93, -26, -74, -104, 4, -122, 96, 39,
126, -24, 16, 119, -45, -119, 110, -31, 55, -109, 53, 53, -11, -58, -124,
-84, 41, -42, 64, 17, -5, -78, -57, -100, 118, -105, -38, -94, 84, -16,
-53, -106, -11, 76, 81, 70, -83, -56, 73, -96, -100, -18, 55, -3, -3, 34,
-97, -62, 59, -17, -79, 91, -9, 122, 95, -108, -121, -76, -62, -72, 61,
-82, 105, -99, -59, 10, 51, 52, 77, -105, -127, 37, 79, 88, -127, 27, 39,
44, 15, 123, -59, -118, -96, 61, -28, 23, -54, 124, 100, 57, 37, 123, -83,
-124, 11, 123, 73, -53, 18, 119, -39, -13, 46, 123, -55, 4, -91, 114, 93,
-116, -98, 21, 95, -30, -82, -108, 87, -65, -8, 30, 67, 14, 22, 79, -64,
86, -128, -83, 74, 69, -42, 9, -18, -120, -52, 7, 62, 78, 88, -53, -125,
41, -122, -91, -34, -110, 111, -118, -25, 25, -83, 90, -95, 84, -121, 95,
72, -53, -14, -14, -48, 65, 4, 23, 99, 56, 23, -20, 9, 46, 63, 83, -26,
-86, 54, -104, 79, 9, 94, -91, -69, 10, -125, -17, -28, -32, -79, 5, -11,
37, 103, -46, -75, 71, -119, 39, 48, -53, -51, 118, 43, 28, 68, 14, -33,
-82, -76, -98, 1, 41, 94, -128, -86, 51, -89, 17, -31, 38, -70, -2, -27,
-105, -87, 103, 93, 19, 73, -106, -82, -76, 110, -48, -124, -51, 92, -91,
-51, 22, 1, -48, 52, -127, -24, 26, -77, 4, 22, 33, 24, -128, -1, 9, -42,
23, -53, 78, 10, -39, -115, -95, 17, 100, 90, 16, -23, -127, -38, 10, -62,
-64, 113, -115, -114, 78, -11, -124, 113, 113, -42, -66, 114, -98, -40,
-41, 2, 3, 1, 0, 1, 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1, 5, 5,
0, 3, -126, 2, 1, 0, -54, 125, -113, -9, -45, 82, 2, -79, -87, 31, -17,
-10, 117, 16, 1, 67, -63, 57, -49, -81, -90, 48, 7, -58, 89, -29, 120, 84,
116, 51, 54, -94, 74, -111, -11, 53, -13, 53, -125, -76, -64, 46, -35, 19,
-19, 25, 36, -82, 66, 113, -14, -6, -63, 83, 15, 8, -77, -74, -94, -53,
-35, -61, -75, 52, 13, -128, 9, 96, 66, 46, 46, -57, 24, -28, -39, -46, 96,
-115, -63, 92, -70, 51, 49, -94, 96, 77, 16, 108, -59, -28, 112, -2, -3,
-87, 27, 56, 118, 29, -95, -76, -70, 34, -105, -24, -104, 70, 24, -88, -29,
-28, -101, -98, 24, -48, -32, -111, 97, 61, -70, -21, -111, 70, -55, 68,
-76, 125, -61, 56, -122, 48, -118, 74, 61, -101, -46, -43, -12, -114, -116,
-57, -108, 91, -109, -62, -117, -76, -48, 109, 81, -22, -113, -73, 64, -61,
102, 92, -117, -9, -100, 62, -90, 99, 102, -50, -41, -75, 31, 5, -76, -31,
-85, 118, -57, -21, 102, 71, 41, -34, -45, -92, 88, 82, -95, 65, -100, -31,
-28, -85, -37, 94, -52, 72, 39, 55, -42, 18, 29, 115, 23, -106, -2, -54,
-45, 61, 53, 62, 107, 109, -65, 69, 4, -123, 124, -30, -54, -44, 38, 119,
49, -123, -27, -50, 77, -9, -40, -114, -50, -70, -123, 86, -115, 127, 45,
42, 23, -25, -83, -81, -38, -84, -3, 99, -36, 12, -67, -39, -110, 21, -40,
-128, 6, -96, -24, -116, -62, 63, 127, 39, 57, -83, -63, 0, 127, -12, 73,
85, -41, -101, -70, -48, -94, -94, -73, -38, -115, -62, -34, 62, -92, 96,
16, 6, -19, -84, 38, -93, -117, -52, 32, 92, -21, 123, -117, 81, 50, -71,
103, 121, 127, 4, -3, -40, 62, 100, 22, -123, -68, -69, -54, -127, -67, 50,
-114, 77, -30, 26, -102, 29, 106, 48, 83, 99, 73, 96, 124, -77, 51, 8, 15,
40, 72, -108, 105, 62, 119, -113, -90, 57, -62, 127, -57, -21, -40, -109,
96, 101, 71, -40, -101, 127, 69, 110, 43, 59, -102, -8, -42, -70, -24, 51,
-51, 54, 42, -110, -119, 41, -101, 45, -101, -124, 56, -75, -26, 86, -65,
54, 21, -88, -30, 79, -26, -127, 121, -102, -48, -25, -62, 99, 76, -90,
-48, -37, 123, 9, 67, 51, -41, -116, 29, 69, 88, 93, -42, 23, 73, -112, 24,
-85, 60, 1, 3, -95, 12, -49, -55, 95, 109, -37, 10, -124, 119, -52, -31,
91, 55, -67, 99, 87, -55, 97, 25, -9, -119, -41, -98, 100, -14, 70, -44,
-63, 60, -127, -99, 15, 49, 22, -118, -49, 66, -106, 36, -34, -5, 6, -48,
123, -79, 115, 57, 30, -3, -34, -67, 91, 34, 3, -52, -106, 79, -63, 125,
123, -16, -120, -53, -98, 34, 86, -60, 94, 78, -91, -34, 0, -8, 73, -119,
-87, 12, -101, -112, -10, -79, 10, 105, -82, 120, -106, -9, 99, 57, -63,
-26, 125, -80, 102, -106, -11, -91, -1, 37, 33
},
};
}
}
@@ -0,0 +1,87 @@
package info.guardianproject.trustedintents;
import android.content.pm.Signature;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
public abstract class ApkSignaturePin {
protected String[] fingerprints; // hex-encoded SHA-256 hashes of the certs
protected byte[][] certificates; // array of DER-encoded X.509 certificates
private Signature[] signatures;
public Signature[] getSignatures() {
if (signatures == null) {
signatures = new Signature[certificates.length];
for (int i = 0; i < certificates.length; i++)
signatures[i] = new Signature(certificates[i]);
}
return signatures;
}
/**
* Gets the fingerprint of the first certificate in the signature.
*
* @param algorithm - Which hash to use (e.g. MD5, SHA1, SHA-256)
* @return the fingerprint as hex String
*/
public String getFingerprint(String algorithm) {
try {
MessageDigest md = MessageDigest.getInstance(algorithm);
byte[] hashBytes = md.digest(certificates[0]);
BigInteger bi = new BigInteger(1, hashBytes);
md.reset();
return String.format("%0" + (hashBytes.length << 1) + "x", bi);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return null;
}
/**
* Gets the MD5 fingerprint of the first certificate in the signature.
*
* @return the MD5 sum as hex String
*/
public String getMD5Fingerprint() {
return getFingerprint("MD5");
}
/**
* Gets the SHA1 fingerprint of the first certificate in the signature.
*
* @return the SHA1 sum as hex String
*/
public String getSHA1Fingerprint() {
return getFingerprint("SHA1");
}
/**
* Gets the SHA-256 fingerprint of the first certificate in the signature.
*
* @return the SHA-256 sum as hex String
*/
public String getSHA256Fingerprint() {
return getFingerprint("SHA-256");
}
/**
* Compares the calculated SHA-256 cert fingerprint to the stored one.
*
* @return the result of the comparison
*/
public boolean doFingerprintsMatchCertificates() {
if (fingerprints == null || certificates == null)
return false;
String[] calcedFingerprints = new String[certificates.length];
for (int i = 0; i < calcedFingerprints.length; i++)
calcedFingerprints[i] = getSHA256Fingerprint();
if (fingerprints.length == 0 || calcedFingerprints.length == 0)
return false;
return Arrays.equals(fingerprints, calcedFingerprints);
}
}
@@ -0,0 +1,502 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
@@ -0,0 +1,271 @@
package info.guardianproject.trustedintents;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.pm.Signature;
import android.text.TextUtils;
import android.util.Log;
import java.lang.reflect.Constructor;
import java.security.cert.CertificateException;
import java.util.LinkedHashSet;
public class TrustedIntents {
private static TrustedIntents instance;
private static PackageManager pm;
private final LinkedHashSet<ApkSignaturePin> pinList;
private TrustedIntents(Context context) {
pm = context.getPackageManager();
this.pinList = new LinkedHashSet<ApkSignaturePin>();
}
public static TrustedIntents get(Context context) {
if (instance == null)
instance = new TrustedIntents(context);
return instance;
}
/**
* Check whether a resolved {@link Activity} is trusted.
*
* @param resolveInfo the one to check
* @return whether the {@code Intent}'s receiver is trusted
*/
public boolean isReceiverTrusted(ResolveInfo resolveInfo) {
return isPackageNameTrusted(resolveInfo.activityInfo.packageName);
}
/**
* Check whether a resolved {@link Activity} is trusted.
*
* @param activityInfo the one to check
* @return whether the {@code Intent}'s receiver is trusted
*/
public boolean isReceiverTrusted(ActivityInfo activityInfo) {
return isPackageNameTrusted(activityInfo.packageName);
}
/**
* Check an {@link Intent} is trusted based on the {@code packageName} set
* by {@link Intent#setPackage(String)}
*
* @param intent the one to check
* @return whether the {@code Intent}'s receiver is trusted
*/
public boolean isReceiverTrusted(Intent intent) {
if (!isIntentSane(intent))
return false;
String packageName = intent.getPackage();
if (TextUtils.isEmpty(packageName)) {
packageName = intent.getComponent().getPackageName();
}
return isPackageNameTrusted(packageName);
}
/**
* Check whether a {@code packageName} is trusted.
*
* @param packageName the one to check
* @return whether the {@code packageName} is trusted
*/
public boolean isPackageNameTrusted(String packageName) {
try {
checkTrustedSigner(packageName);
} catch (NameNotFoundException e) {
e.printStackTrace();
return false;
} catch (CertificateException e) {
return false;
}
return true;
}
/**
* Returns an {@link Intent} if the sending app is signed by one of
* the trusted signing keys as set in {@link #addTrustedSigner(Class)}.
*
* @returns {@code null} if there is no {@code Intent} or if the
* sender is not trusted.
* @see #addTrustedSigner(Class)
*/
public Intent getIntentFromTrustedSender(Activity activity) {
Intent intent = activity.getIntent();
String packageName = getCallingPackageName(activity);
if (TextUtils.isEmpty(packageName)) {
return null;
}
if (isPackageNameTrusted(packageName)) {
return intent;
}
return null;
}
/**
* Get the package name of the {@link Activity} that sent the
* {@link Intent} that started this {@code Activity}.
* <p/>
* <strong>WARNING</strong>: If the {@code Activity} has
* {@code android:launchMode="singleInstance"} or {@code "singleTask"}, then
* this method will not disconnect because it is not possible to get the
* calling {@code Activity}, as set by
* {@link Activity#startActivityForResult(Intent, int)}
*
* @param activity the {@code Activity} to check for the {@code Intent}
* @return the package of the sending app or {@code null} if it was not a
* {@code ACTION_CONNECT Intent} or the {@code Intent} was not sent
* with {@link Activity#startActivityForResult(Intent, int)}
*/
public static String getCallingPackageName(Activity activity) {
// getCallingPackage() was unstable until android-18, use this
ComponentName componentName = activity.getCallingActivity();
if (componentName == null)
return null;
String packageName = componentName.getPackageName();
if (TextUtils.isEmpty(packageName)) {
Log.e(activity.getClass().getSimpleName(),
"Received Intent without sender! The Intent must be sent using startActivityForResult() and received without launchMode singleTask or singleInstance!");
}
return packageName;
}
/**
* This is used to check whether an {@link Intent} that will be sent is
* complete. It should <strong>not</strong> be used with {@code Intent}s
* that have been received already.
*/
private boolean isIntentSane(Intent intent) {
if (intent == null)
return false;
if (TextUtils.isEmpty(intent.getPackage())) {
ComponentName componentName = intent.getComponent();
if (componentName == null || TextUtils.isEmpty(componentName.getPackageName())) {
return false;
}
}
return true;
}
/**
* Add an APK signature that is always trusted for any packageName.
*
* @param cls {@link Class} of the {@link ApkSignaturePin} to trust
* @return boolean
* @throws {@link IllegalArgumentException} the class cannot be instantiated
*/
public boolean addTrustedSigner(Class<? extends ApkSignaturePin> cls) {
try {
Constructor<? extends ApkSignaturePin> constructor = cls.getConstructor();
return pinList.add((ApkSignaturePin) constructor.newInstance((Object[]) null));
} catch (Exception e) {
e.printStackTrace();
throw new IllegalArgumentException(e);
}
}
/**
* Remove an APK signature from the trusted set.
*
* @param cls {@link Class} of the {@link ApkSignaturePin} to remove
*/
public boolean removeTrustedSigner(Class<? extends ApkSignaturePin> cls) {
for (ApkSignaturePin pin : pinList) {
if (pin.getClass().equals(cls)) {
return pinList.remove(pin);
}
}
return false;
}
/**
* Remove all {@link ApkSignaturePin}s from the trusted set.
*/
public boolean removeAllTrustedSigners() {
pinList.clear();
return pinList.isEmpty();
}
/**
* Check if a {@link ApkSignaturePin} is trusted.
*
* @param cls {@link Class} of the {@link ApkSignaturePin} to check
*/
public boolean isTrustedSigner(Class<? extends ApkSignaturePin> cls) {
for (ApkSignaturePin pin : pinList) {
if (pin.getClass().equals(cls)) {
return true;
}
}
return false;
}
public void checkTrustedSigner(String packageName)
throws NameNotFoundException, CertificateException {
PackageInfo packageInfo = pm.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
checkTrustedSigner(packageInfo.signatures);
}
public void checkTrustedSigner(PackageInfo packageInfo)
throws NameNotFoundException, CertificateException {
checkTrustedSigner(packageInfo.signatures);
}
public void checkTrustedSigner(Signature[] signatures)
throws NameNotFoundException, CertificateException {
if (signatures == null || signatures.length == 0)
throw new CertificateException("signatures cannot be null or empty!");
for (int i = 0; i < signatures.length; i++)
if (signatures[i] == null || signatures[i].toByteArray().length == 0)
throw new CertificateException("Certificates cannot be null or empty!");
// check whether the APK signer is trusted for all apps
for (ApkSignaturePin pin : pinList)
if (areSignaturesEqual(signatures, pin.getSignatures()))
return; // found a matching trusted APK signer
throw new CertificateException("APK signatures did not match!");
}
public boolean areSignaturesEqual(Signature[] sigs0, Signature[] sigs1) {
// TODO where is Android's implementation of this that I can just call?
if (sigs0 == null || sigs1 == null)
return false;
if (sigs0.length == 0 || sigs1.length == 0)
return false;
if (sigs0.length != sigs1.length)
return false;
for (int i = 0; i < sigs0.length; i++)
if (!sigs0[i].equals(sigs1[i]))
return false;
return true;
}
public void startActivity(Context context, Intent intent) throws CertificateException {
if (!isIntentSane(intent))
throw new ActivityNotFoundException("The intent was null or empty!");
String packageName = intent.getPackage();
if (TextUtils.isEmpty(packageName)) {
packageName = intent.getComponent().getPackageName();
intent.setPackage(packageName);
}
try {
checkTrustedSigner(packageName);
} catch (NameNotFoundException e) {
e.printStackTrace();
throw new ActivityNotFoundException(e.getLocalizedMessage());
}
context.startActivity(intent);
}
}
+2 -2
View File
@@ -5,8 +5,8 @@
<translate
android:duration="300"
android:fromYDelta="0"
android:toYDelta="100%" />
android:fromYDelta="-200%"
android:toYDelta="-100%" />
<alpha
android:fromAlpha="0.0"
@@ -0,0 +1,5 @@
<vector android:alpha="0.5" android:height="24dp"
android:viewportHeight="960" android:viewportWidth="960"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="m648,820 l112,-112v92h40v-160L640,640v40h92L620,792l28,28ZM200,840q-33,0 -56.5,-23.5T120,760v-560q0,-33 23.5,-56.5T200,120h560q33,0 56.5,23.5T840,200v268q-19,-9 -39,-15.5t-41,-9.5v-243L200,200v560h242q3,22 9.5,42t15.5,38L200,840ZM200,720v40,-560 243,-3 280ZM280,680h163q3,-21 9.5,-41t14.5,-39L280,600v80ZM280,520h244q32,-30 71.5,-50t84.5,-27v-3L280,440v80ZM280,360h400v-80L280,280v80ZM720,920q-83,0 -141.5,-58.5T520,720q0,-83 58.5,-141.5T720,520q83,0 141.5,58.5T920,720q0,83 -58.5,141.5T720,920Z"/>
</vector>
@@ -0,0 +1,5 @@
<vector android:alpha="0.5" android:height="24dp"
android:viewportHeight="960" android:viewportWidth="960"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M640,480v-80h80v80h-80ZM640,560h-80v-80h80v80ZM640,640v-80h80v80h-80ZM447,320l-80,-80L160,240v480h400v-80h80v80h160v-400L640,320v80h-80v-80L447,320ZM160,800q-33,0 -56.5,-23.5T80,720v-480q0,-33 23.5,-56.5T160,160h240l80,80h320q33,0 56.5,23.5T880,320v400q0,33 -23.5,56.5T800,800L160,800ZM160,720v-480,480Z"/>
</vector>
+5
View File
@@ -0,0 +1,5 @@
<vector android:alpha="0.5" android:height="24dp"
android:viewportHeight="960" android:viewportWidth="960"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M240,880q-33,0 -56.5,-23.5T160,800v-400q0,-33 23.5,-56.5T240,320h40v-80q0,-83 58.5,-141.5T480,40q83,0 141.5,58.5T680,240v80h40q33,0 56.5,23.5T800,400v400q0,33 -23.5,56.5T720,880L240,880ZM240,800h480v-400L240,400v400ZM480,680q33,0 56.5,-23.5T560,600q0,-33 -23.5,-56.5T480,520q-33,0 -56.5,23.5T400,600q0,33 23.5,56.5T480,680ZM360,320h240v-80q0,-50 -35,-85t-85,-35q-50,0 -85,35t-35,85v80ZM240,800v-400,400Z"/>
</vector>
@@ -0,0 +1,5 @@
<vector android:alpha="0.5" android:height="24dp"
android:viewportHeight="960" android:viewportWidth="960"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M240,320h360v-80q0,-50 -35,-85t-85,-35q-50,0 -85,35t-35,85h-80q0,-83 58.5,-141.5T480,40q83,0 141.5,58.5T680,240v80h40q33,0 56.5,23.5T800,400v400q0,33 -23.5,56.5T720,880L240,880q-33,0 -56.5,-23.5T160,800v-400q0,-33 23.5,-56.5T240,320ZM240,800h480v-400L240,400v400ZM480,680q33,0 56.5,-23.5T560,600q0,-33 -23.5,-56.5T480,520q-33,0 -56.5,23.5T400,600q0,33 23.5,56.5T480,680ZM240,800v-400,400Z"/>
</vector>
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M40,800L40,688Q40,654 57.5,625.5Q75,597 104,582Q166,551 230,535.5Q294,520 360,520Q426,520 490,535.5Q554,551 616,582Q645,597 662.5,625.5Q680,654 680,688L680,800L40,800ZM760,800L760,680Q760,636 735.5,595.5Q711,555 666,526Q717,532 762,546.5Q807,561 846,582Q882,602 901,626.5Q920,651 920,680L920,800L760,800ZM360,480Q294,480 247,433Q200,386 200,320Q200,254 247,207Q294,160 360,160Q426,160 473,207Q520,254 520,320Q520,386 473,433Q426,480 360,480ZM760,320Q760,386 713,433Q666,480 600,480Q589,480 572,477.5Q555,475 544,472Q571,440 585.5,401Q600,362 600,320Q600,278 585.5,239Q571,200 544,168Q558,163 572,161.5Q586,160 600,160Q666,160 713,207Q760,254 760,320ZM120,720L600,720L600,688Q600,677 594.5,668Q589,659 580,654Q526,627 471,613.5Q416,600 360,600Q304,600 249,613.5Q194,627 140,654Q131,659 125.5,668Q120,677 120,688L120,720ZM360,400Q393,400 416.5,376.5Q440,353 440,320Q440,287 416.5,263.5Q393,240 360,240Q327,240 303.5,263.5Q280,287 280,320Q280,353 303.5,376.5Q327,400 360,400ZM360,720L360,720L360,720Q360,720 360,720Q360,720 360,720Q360,720 360,720Q360,720 360,720Q360,720 360,720Q360,720 360,720Q360,720 360,720Q360,720 360,720L360,720ZM360,320Q360,320 360,320Q360,320 360,320Q360,320 360,320Q360,320 360,320Q360,320 360,320Q360,320 360,320Q360,320 360,320Q360,320 360,320Z"/>
</vector>
+5
View File
@@ -0,0 +1,5 @@
<vector android:alpha="0.5" android:height="24dp"
android:viewportHeight="960" android:viewportWidth="960"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M720,880q-50,0 -85,-35t-35,-85q0,-7 1,-14.5t3,-13.5L322,568q-17,15 -38,23.5t-44,8.5q-50,0 -85,-35t-35,-85q0,-50 35,-85t85,-35q23,0 44,8.5t38,23.5l282,-164q-2,-6 -3,-13.5t-1,-14.5q0,-50 35,-85t85,-35q50,0 85,35t35,85q0,50 -35,85t-85,35q-23,0 -44,-8.5T638,288L356,452q2,6 3,13.5t1,14.5q0,7 -1,14.5t-3,13.5l282,164q17,-15 38,-23.5t44,-8.5q50,0 85,35t35,85q0,50 -35,85t-85,35ZM720,240q17,0 28.5,-11.5T760,200q0,-17 -11.5,-28.5T720,160q-17,0 -28.5,11.5T680,200q0,17 11.5,28.5T720,240ZM240,520q17,0 28.5,-11.5T280,480q0,-17 -11.5,-28.5T240,440q-17,0 -28.5,11.5T200,480q0,17 11.5,28.5T240,520ZM720,800q17,0 28.5,-11.5T760,760q0,-17 -11.5,-28.5T720,720q-17,0 -28.5,11.5T680,760q0,17 11.5,28.5T720,800ZM720,200ZM240,480ZM720,760Z"/>
</vector>
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M120,720Q87,720 63.5,696.5Q40,673 40,640Q40,607 63.5,583.5Q87,560 120,560Q126,560 130.5,560Q135,560 140,562L322,380Q320,375 320,370.5Q320,366 320,360Q320,327 343.5,303.5Q367,280 400,280Q433,280 456.5,303.5Q480,327 480,360Q480,362 478,380L580,482Q585,480 589.5,480Q594,480 600,480Q606,480 610.5,480Q615,480 620,482L762,340Q760,335 760,330.5Q760,326 760,320Q760,287 783.5,263.5Q807,240 840,240Q873,240 896.5,263.5Q920,287 920,320Q920,353 896.5,376.5Q873,400 840,400Q834,400 829.5,400Q825,400 820,398L678,540Q680,545 680,549.5Q680,554 680,560Q680,593 656.5,616.5Q633,640 600,640Q567,640 543.5,616.5Q520,593 520,560Q520,554 520,549.5Q520,545 522,540L420,438Q415,440 410.5,440Q406,440 400,440Q398,440 380,438L198,620Q200,625 200,629.5Q200,634 200,640Q200,673 176.5,696.5Q153,720 120,720Z"/>
</vector>
+1 -1
View File
@@ -43,7 +43,7 @@
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="25dp"
android:paddingBottom="12dp"
app:hintEnabled="false"
app:passwordToggleEnabled="true"
app:passwordToggleTint="?attr/colorOnSurface">
+241 -212
View File
@@ -16,246 +16,264 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" />
</com.google.android.material.appbar.AppBarLayout>
<ScrollView
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:isScrollContainer="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="250dp">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/profile_drawable"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
<com.avito.android.krop.KropView
android:id="@+id/krop_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="invisible"
app:krop_aspectX="1"
app:krop_aspectY="1"
app:krop_offset="70dp"
app:krop_overlayColor="#aadddddd">
<ImageView
android:id="@+id/iv_saveImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="15dp"
android:src="@drawable/ic_outline_check_24"
app:tint="?attr/colorOnSurface" />
</com.avito.android.krop.KropView>
</RelativeLayout>
<com.google.android.material.divider.MaterialDivider
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="match_parent"
android:clipToPadding="false"
android:isScrollContainer="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:id="@+id/layout_basic"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="10dp">
<LinearLayout
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_height="250dp">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/profile_drawable"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Aegis.ImageView.Circle" />
<com.avito.android.krop.KropView
android:id="@+id/krop_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_outline_person_24"
app:tint="?attr/colorOnSurface"
android:layout_marginStart="5dp"
android:layout_marginEnd="15dp"
android:layout_gravity="center_vertical"/>
<com.google.android.material.textfield.TextInputLayout
android:hint="@string/name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/text_name"
android:layout_width="match_parent"
android:layout_centerInParent="true"
android:visibility="invisible"
app:krop_aspectX="1"
app:krop_aspectY="1"
app:krop_offset="70dp"
app:krop_overlayColor="#aadddddd">
<ImageView
android:id="@+id/iv_saveImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="text"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
android:layout_gravity="bottom|end"
android:layout_margin="15dp"
android:src="@drawable/ic_outline_check_24"
app:tint="?attr/colorOnSurface" />
</com.avito.android.krop.KropView>
</RelativeLayout>
<com.google.android.material.divider.MaterialDivider
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:id="@+id/layout_basic"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:layout_marginStart="44.5dp">
<com.google.android.material.textfield.TextInputLayout
android:hint="@string/issuer"
android:layout_width="0dp"
android:orientation="vertical"
android:layout_margin="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_outline_person_24"
app:tint="?attr/colorOnSurface"
android:layout_marginStart="5dp"
android:layout_marginEnd="15dp"
android:layout_gravity="center_vertical"/>
<com.google.android.material.textfield.TextInputLayout
android:hint="@string/name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/text_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="5dp"
android:layout_weight="1">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/text_issuer"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:layout_marginStart="44.5dp">
<com.google.android.material.textfield.TextInputLayout
android:hint="@string/issuer"
android:layout_width="0dp"
android:layout_height="match_parent"
android:inputType="text"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="0dp"
android:layout_weight="1">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/text_issuer"
android:maxLines="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_weight="1"
android:hint="@string/group"
style="?attr/dropdownStyle">
<AutoCompleteTextView
android:id="@+id/dropdown_group"
android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="none"/>
</com.google.android.material.textfield.TextInputLayout>
android:src="@drawable/ic_outline_group_24"
app:tint="?attr/colorOnSurface"
android:layout_marginStart="5dp"
android:layout_marginEnd="15dp"
android:layout_gravity="center_vertical"/>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/text_group_layout"
android:hint="@string/group"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/text_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cursorVisible="false"
android:inputType="none"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_outline_notes_24"
app:tint="?attr/colorOnSurface"
android:layout_marginStart="5dp"
android:layout_marginEnd="15dp"
android:layout_gravity="center_vertical"/>
<com.google.android.material.textfield.TextInputLayout
android:hint="@string/note"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/text_note"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text|textMultiLine"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/layout_secret"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_outline_key_24"
app:tint="?attr/colorOnSurface"
android:layout_marginStart="5dp"
android:layout_marginEnd="15dp"
android:layout_gravity="center_vertical"/>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:passwordToggleTint="?attr/colorOnSurface"
app:passwordToggleEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/text_secret"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/secret"
android:inputType="textPassword"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/layout_pin"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal"
tools:visibility="visible">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_outline_fiber_pin_24"
app:tint="?attr/colorOnSurface"
android:layout_marginStart="5dp"
android:layout_marginEnd="15dp"
android:layout_gravity="center_vertical"/>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:passwordToggleTint="?attr/colorOnSurface"
app:passwordToggleEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/text_pin"
android:maxLength="16"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberPassword"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
<RelativeLayout
android:foreground="?android:attr/selectableItemBackground"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
android:id="@+id/accordian_header"
android:focusable="true"
android:clickable="true">
<ImageView
android:id="@+id/down_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_outline_notes_24"
app:tint="?attr/colorOnSurface"
android:layout_marginStart="5dp"
android:layout_marginEnd="15dp"
android:layout_gravity="center_vertical"/>
<com.google.android.material.textfield.TextInputLayout
android:hint="@string/note"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/text_note"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text|textMultiLine"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/layout_secret"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<ImageView
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginStart="14dp"
android:src="@drawable/ic_outline_expand_more_24"
app:tint="?attr/colorOnSurface" />
<TextView
android:id="@+id/accordian_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_outline_key_24"
app:tint="?attr/colorOnSurface"
android:layout_marginStart="5dp"
android:layout_marginEnd="15dp"
android:layout_gravity="center_vertical"/>
android:layout_alignParentTop="true"
android:layout_toEndOf="@+id/down_btn"
android:padding="16dp"
android:text="@string/advanced"
android:textStyle="bold" />
<com.google.android.material.textfield.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:passwordToggleTint="?attr/colorOnSurface"
app:passwordToggleEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/text_secret"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/secret"
android:inputType="textPassword"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/layout_pin"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal"
tools:visibility="visible">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_outline_fiber_pin_24"
app:tint="?attr/colorOnSurface"
android:layout_marginStart="5dp"
android:layout_marginEnd="15dp"
android:layout_gravity="center_vertical"/>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:passwordToggleTint="?attr/colorOnSurface"
app:passwordToggleEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/text_pin"
android:maxLength="16"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberPassword"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:foreground="?android:attr/selectableItemBackground"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/accordian_header"
android:focusable="true"
android:clickable="true">
<ImageView
android:id="@+id/down_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginStart="14dp"
android:src="@drawable/ic_outline_expand_more_24"
app:tint="?attr/colorOnSurface" />
<TextView
android:id="@+id/accordian_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toEndOf="@+id/down_btn"
android:padding="16dp"
android:text="@string/advanced"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/expandableLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible">
</RelativeLayout>
<LinearLayout
android:id="@+id/layout_advanced"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone"
android:alpha="0"
android:layout_marginHorizontal="10dp">
<LinearLayout
android:id="@+id/layout_type_algo"
@@ -376,8 +394,19 @@
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/text_last_used"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:layout_centerInParent="true"
android:layout_gravity="bottom|center"
android:textSize="14sp" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</FrameLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
@@ -47,11 +47,12 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
<de.hdodenhof.circleimageview.CircleImageView
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/ivOldImage"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="center_vertical" />
android:layout_gravity="center_vertical"
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Aegis.ImageView.Circle" />
<ImageView
android:layout_width="32dp"
@@ -62,11 +63,12 @@
android:layout_marginEnd="15dp"
android:layout_gravity="center_vertical"/>
<de.hdodenhof.circleimageview.CircleImageView
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/ivNewImage"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="center_vertical" />
android:layout_gravity="center_vertical"
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Aegis.ImageView.Circle" />
<View
android:layout_width="0dp"
+111
View File
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foreground="?android:attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal"
app:cardElevation="0dp"
style="@style/Widget.Aegis.EntryCardView">
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingTop="12dp"
android:paddingStart="14dp">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/iv_icon_view"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_alignParentStart="true"
android:background="?attr/colorTertiaryContainer"
android:cropToPadding="true"
android:padding="2dp"
android:scaleType="centerInside"
android:src="@drawable/ic_lock_open"
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Aegis.ImageView.Rounded" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="bottom"
android:id="@+id/relativeLayout"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingEnd="12dp"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:paddingStart="12dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/description">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/text_audit_log_title"
android:text="@string/issuer"
android:textStyle="bold"
android:includeFontPadding="false"
android:textSize="16sp"
android:ellipsize="end"
android:maxLines="1"/>
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/text_audit_log_description"
android:layoutDirection="ltr"
android:layout_below="@id/description"
android:includeFontPadding="false"
tools:text="The vault has been succesfully unlocked"
android:layout_alignParentStart="true"
android:layout_marginTop="4dp"
android:textStyle="normal"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/text_audit_log_reference"
android:layoutDirection="ltr"
android:layout_below="@id/text_audit_log_description"
android:includeFontPadding="false"
tools:text="Aegis (authenticator)"
android:layout_alignParentStart="true"
android:layout_marginTop="4dp"
android:textStyle="italic"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/text_audit_log_timestamp"
android:layoutDirection="ltr"
android:layout_below="@id/text_audit_log_reference"
android:includeFontPadding="false"
tools:text="Today at 5:59 PM"
android:textSize="12sp"
android:layout_alignParentStart="true"
android:textColor="?attr/colorOutline"
android:layout_marginTop="8dp"
android:textStyle="normal"/>
</RelativeLayout>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
+19 -17
View File
@@ -34,14 +34,15 @@
android:layout_height="match_parent"
android:paddingStart="14dp">
<de.hdodenhof.circleimageview.CircleImageView
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/ivTextDrawable"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_centerVertical="true"
android:layout_alignParentStart="true" />
android:layout_alignParentStart="true"
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Aegis.ImageView.Circle" />
<de.hdodenhof.circleimageview.CircleImageView
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/ivSelected"
android:layout_width="60dp"
android:layout_height="60dp"
@@ -49,7 +50,8 @@
android:layout_centerVertical="true"
android:src="@drawable/item_selected"
android:visibility="gone"
app:civ_circle_background_color="?attr/colorPrimaryAlternative" />
android:background="?attr/colorPrimaryAlternative"
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Aegis.ImageView.Circle" />
</RelativeLayout>
<RelativeLayout
@@ -65,18 +67,6 @@
android:paddingRight="16dp"
android:paddingStart="16dp">
<TextView
android:id="@+id/profile_copied"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:maxLines="1"
android:text="@string/copied"
android:layout_above="@+id/description"
android:layout_alignStart="@+id/profile_code"
android:textSize="16sp"
android:visibility="invisible" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -107,6 +97,18 @@
</RelativeLayout>
<TextView
android:id="@+id/profile_copied"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:maxLines="1"
android:text="@string/copied"
android:layout_alignStart="@+id/description"
android:layout_below="@id/description"
android:textSize="16sp"
android:visibility="invisible" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -119,7 +121,7 @@
android:includeFontPadding="false"
android:fallbackLineSpacing="false"
android:textSize="34sp"
android:textColor="?attr/colorPrimary"
android:textColor="?attr/colorCode"
android:layout_marginStart="6dp"
android:layout_alignParentStart="true"
android:layout_marginTop="0dp"
+11 -6
View File
@@ -26,6 +26,8 @@
android:layout_width="15dp"
android:layout_height="match_parent"
android:layout_marginStart="-11dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:backgroundTint="?attr/colorFavorite"
android:background="@drawable/favorite_indicator" />
@@ -34,14 +36,15 @@
android:layout_height="match_parent"
android:paddingStart="12dp">
<de.hdodenhof.circleimageview.CircleImageView
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/ivTextDrawable"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_alignParentStart="true"
android:layout_centerVertical="true" />
android:layout_centerVertical="true"
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Aegis.ImageView.Circle" />
<de.hdodenhof.circleimageview.CircleImageView
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/ivSelected"
android:layout_width="45dp"
android:layout_height="45dp"
@@ -49,7 +52,8 @@
android:layout_centerVertical="true"
android:src="@drawable/item_selected"
android:visibility="gone"
app:civ_circle_background_color="?attr/colorPrimaryAlternative" />
android:background="?attr/colorPrimaryAlternative"
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Aegis.ImageView.Circle" />
</RelativeLayout>
<RelativeLayout
@@ -72,8 +76,8 @@
android:includeFontPadding="false"
android:maxLines="1"
android:text="@string/copied"
android:layout_above="@+id/description"
android:layout_alignStart="@+id/profile_code"
android:layout_alignStart="@+id/description"
android:layout_below="@id/description"
android:textSize="13sp"
android:visibility="invisible" />
@@ -120,6 +124,7 @@
android:includeFontPadding="false"
android:fallbackLineSpacing="false"
android:textSize="26sp"
android:textColor="?attr/colorCode"
android:layout_marginStart="6dp"
android:layout_alignParentStart="true"
android:layout_marginTop="0dp"
+11 -7
View File
@@ -15,7 +15,6 @@
<LinearLayout
android:orientation="horizontal"
android:background="?attr/colorSurfaceContainerLow"
android:id="@+id/rlCardEntry"
android:paddingTop="5dp"
android:paddingBottom="5dp"
@@ -27,6 +26,8 @@
android:layout_width="15dp"
android:layout_height="match_parent"
android:layout_marginStart="-11dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:backgroundTint="?attr/colorFavorite"
android:background="@drawable/favorite_indicator" />
@@ -35,14 +36,15 @@
android:layout_height="match_parent"
android:paddingStart="14dp">
<de.hdodenhof.circleimageview.CircleImageView
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/ivTextDrawable"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_centerVertical="true"
android:layout_alignParentStart="true" />
android:layout_alignParentStart="true"
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Aegis.ImageView.Circle" />
<de.hdodenhof.circleimageview.CircleImageView
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/ivSelected"
android:layout_width="45dp"
android:layout_height="45dp"
@@ -50,7 +52,8 @@
android:layout_centerVertical="true"
android:src="@drawable/item_selected"
android:visibility="gone"
app:civ_circle_background_color="?attr/colorPrimaryAlternative" />
android:background="?attr/colorPrimaryAlternative"
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Aegis.ImageView.Circle" />
</RelativeLayout>
<RelativeLayout
@@ -73,8 +76,8 @@
android:includeFontPadding="false"
android:maxLines="1"
android:text="@string/copied"
android:layout_above="@+id/description"
android:layout_alignStart="@+id/profile_code"
android:layout_alignStart="@+id/description"
android:layout_below="@id/description"
android:textSize="13sp"
android:visibility="invisible" />
@@ -119,6 +122,7 @@
android:includeFontPadding="false"
android:fallbackLineSpacing="false"
android:textSize="26sp"
android:textColor="?attr/colorCode"
android:layout_marginStart="6dp"
android:layout_alignParentStart="true"
android:layout_marginTop="0dp"
+10 -10
View File
@@ -46,14 +46,15 @@
android:layout_width="wrap_content"
android:layout_height="match_parent">
<de.hdodenhof.circleimageview.CircleImageView
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/ivTextDrawable"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginEnd="6dp"
android:layout_alignParentStart="true" />
android:layout_alignParentStart="true"
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Aegis.ImageView.Circle" />
<de.hdodenhof.circleimageview.CircleImageView
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/ivSelected"
android:layout_width="24dp"
android:layout_height="24dp"
@@ -61,14 +62,15 @@
android:layout_alignParentStart="true"
android:src="@drawable/item_selected"
android:visibility="gone"
app:civ_circle_background_color="?attr/colorPrimaryAlternative" />
android:background="?attr/colorPrimaryAlternative"
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Aegis.ImageView.Circle" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_height="24dp"
android:id="@+id/description"
android:layout_toEndOf="@+id/layoutImage">
android:layout_toEndOf="@id/layoutImage">
<TextView
android:layout_width="wrap_content"
@@ -80,19 +82,16 @@
android:textSize="11sp"
android:ellipsize="end"
android:maxLines="1"/>
<TextView
android:id="@+id/profile_copied"
android:layout_width="wrap_content"
android:layout_below="@id/profile_issuer"
android:layout_height="wrap_content"
android:layout_below="@id/profile_issuer"
android:maxLines="1"
android:includeFontPadding="false"
android:visibility="invisible"
android:text="@string/copied"
android:textSize="9sp" />
<TextView
android:id="@+id/profile_account_name"
android:layout_width="wrap_content"
@@ -117,6 +116,7 @@
android:includeFontPadding="false"
android:fallbackLineSpacing="false"
android:textSize="26sp"
android:textColor="?attr/colorCode"
android:layout_alignParentStart="true"
android:layout_marginTop="10dp"
android:textStyle="normal|bold"/>
+28 -19
View File
@@ -1,14 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/button_edit"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:baselineAligned="false"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal"
@@ -16,26 +17,32 @@
android:paddingEnd="10dp"
android:paddingTop="12.5dp"
android:paddingBottom="12.5dp"
android:foreground="?android:attr/selectableItemBackground">
android:background="?android:attr/selectableItemBackground">
<LinearLayout
android:layout_width="0dp"
<TextView
android:id="@+id/text_group_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/text_group_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/group_name_hint"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="?android:attr/textColorPrimary" />
</LinearLayout>
android:text="@string/group_name_hint"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="?android:attr/textColorPrimary" />
</LinearLayout>
<ImageView
android:id="@+id/button_edit"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
android:contentDescription="@string/rename_group"
android:focusable="true"
android:background="?android:attr/selectableItemBackground"
android:paddingStart="15dp"
android:paddingTop="12.5dp"
android:paddingEnd="15dp"
android:paddingBottom="12.5dp"
android:src="@drawable/ic_outline_edit_24" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
@@ -43,19 +50,21 @@
android:paddingStart="15dp"
android:paddingEnd="15dp"
android:layout_marginTop="12.5dp"
android:layout_marginBottom="12.5dp"/>
android:layout_marginBottom="12.5dp" />
<ImageView
android:id="@+id/button_delete"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
android:contentDescription="@string/remove_group"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
android:background="?android:attr/selectableItemBackground"
android:paddingStart="15dp"
android:paddingTop="12.5dp"
android:paddingEnd="15dp"
android:paddingBottom="12.5dp"
android:src="@drawable/ic_outline_delete_24" />
android:src="@drawable/ic_outline_delete_24"
app:tint="?attr/colorError" />
</LinearLayout>
+93 -88
View File
@@ -1,96 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:paddingBottom="10dp"
android:paddingTop="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginEnd="25dp"
android:text="@string/export_help" />
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginEnd="25dp"
android:layout_marginTop="15dp"
android:hint="@string/export_format_hint"
style="?attr/dropdownStyle">
<AutoCompleteTextView
android:id="@+id/dropdown_export_format"
android:orientation="vertical"
android:paddingBottom="10dp"
android:paddingTop="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none" />
</com.google.android.material.textfield.TextInputLayout>
<CheckBox
android:id="@+id/checkbox_export_encrypt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginTop="5dp"
android:text="@string/export_encrypted"
android:checked="true" />
<TextView
android:id="@+id/text_separate_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginEnd="25dp"
android:layout_marginTop="5dp"
android:textStyle="italic"
android:text="@string/export_warning_password" />
<TextView
android:id="@+id/text_export_warning"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginEnd="25dp"
android:layout_marginTop="5dp"
android:text="@string/export_warning_unencrypted"
android:textColor="?attr/colorError"
android:visibility="gone" />
<CheckBox
android:id="@+id/checkbox_accept"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginTop="5dp"
android:text="@string/understand_risk_accept"
android:checked="false"
android:visibility="gone" />
<CheckBox
android:id="@+id/export_selected_groups"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginTop="5dp"
android:text="@string/export_all_groups"
android:checked="true"
android:visibility="gone" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/group_selection_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginEnd="25dp"
android:layout_marginTop="15dp"
android:hint="@string/export_choose_groups"
android:visibility="gone"
style="?attr/dropdownStyle">
<com.beemdevelopment.aegis.ui.components.DropdownCheckBoxes
android:id="@+id/group_selection_dropdown"
android:layout_marginStart="25dp"
android:layout_marginEnd="25dp"
android:text="@string/export_help" />
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:allow_filtering="false" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
android:layout_marginStart="25dp"
android:layout_marginEnd="25dp"
android:layout_marginTop="15dp"
android:hint="@string/export_format_hint"
style="?attr/dropdownStyle">
<AutoCompleteTextView
android:id="@+id/dropdown_export_format"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none" />
</com.google.android.material.textfield.TextInputLayout>
<CheckBox
android:id="@+id/checkbox_export_encrypt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginTop="5dp"
android:text="@string/export_encrypted"
android:checked="true" />
<TextView
android:id="@+id/text_separate_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginEnd="25dp"
android:layout_marginTop="5dp"
android:textStyle="italic"
android:text="@string/export_warning_password" />
<TextView
android:id="@+id/text_export_warning"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginEnd="25dp"
android:layout_marginTop="5dp"
android:text="@string/export_warning_unencrypted"
android:textColor="?attr/colorError"
android:visibility="gone" />
<CheckBox
android:id="@+id/checkbox_accept"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginTop="5dp"
android:text="@string/understand_risk_accept"
android:checked="false"
android:visibility="gone" />
<CheckBox
android:id="@+id/export_selected_groups"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginTop="5dp"
android:text="@string/export_all_groups"
android:checked="true"
android:visibility="gone" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/group_selection_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginEnd="25dp"
android:layout_marginTop="15dp"
android:hint="@string/export_choose_groups"
android:visibility="gone"
style="?attr/dropdownStyle">
<com.beemdevelopment.aegis.ui.components.DropdownCheckBoxes
android:id="@+id/group_selection_dropdown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:allow_filtering="false" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</ScrollView>
@@ -1,50 +1,110 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:layout_height="wrap_content">
<com.google.android.material.bottomsheet.BottomSheetDragHandleView
android:id="@+id/drag_handle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/text_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/groups"
android:textSize="20sp" />
android:textSize="20sp"
app:layout_constraintTop_toBottomOf="@+id/drag_handle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/addGroupInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="8dp"
android:padding="8dp"
android:text="@string/no_group_selection"
app:layout_constraintTop_toBottomOf="@+id/text_title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:visibility="gone"/>
<LinearLayout
android:id="@+id/addGroup"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="150dp"
android:orientation="vertical"
android:layout_marginTop="15dp">
android:layout_height="wrap_content"
android:layout_marginHorizontal="8dp"
android:layout_marginTop="15dp"
android:background="?android:attr/selectableItemBackground"
android:gravity="center"
android:orientation="horizontal"
android:padding="8dp"
app:layout_constraintTop_toBottomOf="@+id/addGroupInfo"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:visibility="gone">
<com.google.android.material.chip.ChipGroup
android:id="@+id/groupChipGroup"
android:paddingStart="8dp"
android:paddingEnd="8dp"
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/new_group"
android:src="@drawable/ic_outline_add_24" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content">
</com.google.android.material.chip.ChipGroup>
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:text="@string/new_group"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
</LinearLayout>
<androidx.core.widget.NestedScrollView
android:id="@+id/scrollView"
android:layout_marginTop="15dp"
android:layout_width="match_parent"
android:layout_height="0dp"
android:minWidth="150dp"
app:layout_constraintHeight_default="wrap"
app:layout_constraintTop_toBottomOf="@+id/addGroup"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="150dp"
android:orientation="vertical">
<com.google.android.material.chip.ChipGroup
android:id="@+id/groupChipGroup"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</com.google.android.material.chip.ChipGroup>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<LinearLayout
android:layout_gravity="end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/scrollView"
app:layout_constraintEnd_toEndOf="parent"
android:orientation="horizontal">
<Button
android:id="@+id/btnSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/save"
app:rippleColor="@color/dialog_button_ripple_color"
style="@style/Widget.Material3.Button.TextButton" />
<Button
@@ -52,8 +112,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/clear"
app:rippleColor="@color/dialog_button_ripple_color"
style="@style/Widget.Material3.Button.TextButton" />
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

Some files were not shown because too many files have changed in this diff Show More