Skip to content

Commit

Permalink
Fix Android autofill save repetition bug
Browse files Browse the repository at this point in the history
In some circumstances we could keep asking to save an autofill entry
which would be confusing and annoying. We now use the latest autofill
library so this shouldn't happen anymore.
  • Loading branch information
luckyrat committed Aug 31, 2023
1 parent 8a411eb commit 7cc6bf9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
25 changes: 8 additions & 17 deletions lib/cubit/autofill_cubit.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:bloc/bloc.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter_autofill_service/flutter_autofill_service.dart';
import 'package:kdbx/kdbx.dart';
import 'package:keevault/logging/logger.dart';
import 'package:meta/meta.dart';
import 'package:collection/collection.dart';

import '../config/platform.dart';
Expand Down Expand Up @@ -47,23 +47,12 @@ class AutofillCubit extends Cubit<AutofillState> {
emit(AutofillAvailable(enabled));
return;
}

//TODO:f: should below be here? or after potential emit of autofill request for filling?
// if (state is AutofillSaved) {
// emit(AutofillAvailable(enabled));
// return;
// }
if (saveRequested) {
if (state is AutofillSaving || state is AutofillSaved) {
// After launching with a save intent, if we then restore after the save
// has been completed we need to proceed as if no save has been requested...
// but still work the next time a save request intent is sent to the instance.
// Probably need to track a unique ID for each save operation via the intent
// extras? then flag what the latest received via intent is, and the
// latest that user has completed.
//
// A first simple attempt at a solution is below
// See https://github.com/kee-org/keevault2/issues/9 for next steps
final newRequest = (state as AutofillModeActive).androidMetadata.toJson() != androidMetadata!.toJson();
if (!newRequest) {
return;
}
}
emit(AutofillSaving(androidMetadata!));
return;
}
Expand All @@ -72,6 +61,8 @@ class AutofillCubit extends Cubit<AutofillState> {
throw Exception('Android failed to provide the necessary autofill information.');
}

// we only call this cubit's function if we have some sort of intent relating to the
// autofill service so we can now assume the user is asking for us to autofill another app/site
emit(AutofillRequested(autofillForceInteractive, androidMetadata));
}

Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,10 @@ packages:
description:
path: "."
ref: master
resolved-ref: b623282b8b0bfeb6f57c25be84243171a2b4c0a6
resolved-ref: "7d4e54bc430b22a87d4a30d8fb0f70d5ac243197"
url: "https://github.com/kee-org/flutter_autofill_service.git"
source: git
version: "0.17.0"
version: "0.17.1"
flutter_bloc:
dependency: "direct main"
description:
Expand Down

0 comments on commit 7cc6bf9

Please sign in to comment.