From 7cc6bf9e50b0f19a3e957a33074ddc819b1784fb Mon Sep 17 00:00:00 2001 From: luckyrat Date: Thu, 31 Aug 2023 19:02:13 +0100 Subject: [PATCH] Fix Android autofill save repetition bug 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. --- lib/cubit/autofill_cubit.dart | 25 ++++++++----------------- pubspec.lock | 4 ++-- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/lib/cubit/autofill_cubit.dart b/lib/cubit/autofill_cubit.dart index 9d7525c..32fdb74 100644 --- a/lib/cubit/autofill_cubit.dart +++ b/lib/cubit/autofill_cubit.dart @@ -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'; @@ -47,23 +47,12 @@ class AutofillCubit extends Cubit { 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; } @@ -72,6 +61,8 @@ class AutofillCubit extends Cubit { 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)); } diff --git a/pubspec.lock b/pubspec.lock index f127157..40d72cf 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -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: