Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyrat committed Aug 25, 2023
1 parent 3f949d5 commit f1599be
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
<!-- implicitly READ too. Used for file import / export, attachment export, etc. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<!-- TODO rewrite and try to remove the need for this before Android 13 release -->
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>

<!-- TOTP QR scanning -->
<uses-permission android:name="android.permission.CAMERA" />

Expand Down
5 changes: 5 additions & 0 deletions lib/widgets/entry_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:keevault/cubit/autofill_cubit.dart';
import 'package:keevault/cubit/entry_cubit.dart';
import 'package:keevault/cubit/filter_cubit.dart';
import 'package:keevault/cubit/sort_cubit.dart';
import 'package:keevault/logging/logger.dart';
import 'package:keevault/model/entry.dart';
import 'package:keevault/widgets/entry.dart';
import 'package:keevault/widgets/in_app_messenger.dart';
Expand Down Expand Up @@ -277,6 +278,10 @@ class EntryListItemWidget extends StatelessWidget {
);
},
onClosed: (bool? keepChanges) async {
if (!context.mounted) {
l.e("context not mounted so we can't tidy up or save the entry. Presumably something happened to make the underlying Vault go away, such as autofill save entry screen replacing the main vault.");
return;
}
final entryCubit = BlocProvider.of<EntryCubit>(context);
final iam = InAppMessengerWidget.of(context);
if ((keepChanges == null || keepChanges) && (entryCubit.state as EntryLoaded).entry.isDirty) {
Expand Down
4 changes: 3 additions & 1 deletion lib/widgets/import_export.dart
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,9 @@ class _ImportExportWidgetState extends State<ImportExportWidget> {
final vaultCubit = BlocProvider.of<VaultCubit>(context);
final permissionResult = await tryToGetPermission(
context,
Permission.storage,
//TODO: replace existing file management code to support Android 13
Permission.manageExternalStorage,
//Permission.storage,
'Storage',
str.import.toLowerCase(),
str.cancelExportOrImport(str.import.toLowerCase()),
Expand Down
4 changes: 4 additions & 0 deletions lib/widgets/vault.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ class _VaultWidgetState extends State<VaultWidget> with WidgetsBindingObserver {
// https://github.com/flutter/flutter/issues/51397 seems to suggest that might be the case. maybe have to find some way to pop the OpenContainer from the top of the navigation stack since this AutofillSaveWidget is maybe being inserted into the 2nd level of the stack and therefore invisible until the user somehow dismisses the defunct OpenContainer.
// next, inspect widget hierarchy when in the broken state
// then fix, either by closing the opencontainer or putting this savewidget on top of the navigator instead? latter could offer way to retain any dirty entry user had open but mess up the persistence of the newly saved data, or otherwise screw up various merge pathways
// Confirmed: MaterialApp widget contains two children: VaultWidget>AutofillSaveWidget and EntryWidget (the old entry that incorrectly appears on top of the AutofillSaveWidget).
// Adding and popping new item to navigation history works fine (drawer popup and help screen) and adds the HelpWidget as a 3rd child of the MaterialApp.
// Material widget has deep tree and then 3 _OverlayEntryWidget s in a Theater widget. (4 when Help displayed). a skipCount parameter seems to indicate which widgets should be ignored. In main focus of bug state it's 1, which skips focus to some sort of magical _OverlayEntryWidget that is always there before the visible screen and then the EntryWidget that we don't want to be there anymore.
// Discovered that crash is caused by onClose functionality that expects the context to still exist. Can stop the crash by checking that it is not mounted and avoiding all the usual checks for unsaved data, etc. and just let the navigation stack be popped without question. Not a good user experience though so further investigation is needed.
} else {
return Backdrop(
frontLayer: EntryListWidget(),
Expand Down

0 comments on commit f1599be

Please sign in to comment.