π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Add minimize on copy
Hubert8dc06464c7c9
diff --git a/lib/l10n/arb/app_en.arb b/lib/l10n/arb/app_en.arbindex e5cc9b7ab1..b572856ed7 100644--- a/lib/l10n/arb/app_en.arb+++ b/lib/l10n/arb/app_en.arb@@ -332,5 +332,6 @@"showLargeIcons": "Show large icons","shouldHideCode": "Hide codes","focusOnSearchBar": "Focus search on app start",- "confirmUpdatingkey": "Are you sure you want to update the secret key?"+ "confirmUpdatingkey": "Are you sure you want to update the secret key?",+ "minimizeAppOnCopy": "Minimize app on copy"}diff --git a/lib/services/preference_service.dart b/lib/services/preference_service.dartindex cad38143d4..66d96c7fdd 100644--- a/lib/services/preference_service.dart+++ b/lib/services/preference_service.dart@@ -13,6 +13,7 @@ class PreferenceService {static const kShouldShowLargeIconsKey = "should_show_large_icons";static const kShouldHideCodesKey = "should_hide_codes";static const kShouldAutoFocusOnSearchBar = "should_auto_focus_on_search_bar";+ static const kShouldMinimizeOnCopy = "should_minimize_on_copy";Future<void> init() async {_prefs = await SharedPreferences.getInstance();@@ -64,4 +65,16 @@ class PreferenceService {await _prefs.setBool(kShouldAutoFocusOnSearchBar, value);Bus.instance.fire(IconsChangedEvent());}++ bool shouldMinimizeOnCopy() {+ if (_prefs.containsKey(kShouldMinimizeOnCopy)) {+ return _prefs.getBool(kShouldMinimizeOnCopy)!;+ } else {+ return false;+ }+ }++ Future<void> setShouldMinimizeOnCopy(bool value) async {+ await _prefs.setBool(kShouldMinimizeOnCopy, value);+ }}diff --git a/lib/ui/code_widget.dart b/lib/ui/code_widget.dartindex b3f2402241..a26cc20b2b 100644--- a/lib/ui/code_widget.dart+++ b/lib/ui/code_widget.dart@@ -1,4 +1,5 @@import 'dart:async';+import 'dart:io';import 'package:clipboard/clipboard.dart';import 'package:ente_auth/core/configuration.dart';@@ -17,6 +18,7 @@ import 'package:ente_auth/utils/totp_util.dart';import 'package:flutter/material.dart';import 'package:flutter_slidable/flutter_slidable.dart';import 'package:logging/logging.dart';+import 'package:move_to_background/move_to_background.dart';class CodeWidget extends StatefulWidget {final Code code;@@ -141,7 +143,7 @@ class _CodeWidgetState extends State<CodeWidget> {borderRadius: BorderRadius.circular(10),),onTap: () {- _copyToClipboard();+ _copyCurrentOTPToClipboard();},onDoubleTap: isMaskingEnabled? () {@@ -153,7 +155,7 @@ class _CodeWidgetState extends State<CodeWidget> {}: null,onLongPress: () {- _copyToClipboard();+ _copyCurrentOTPToClipboard();},child: _getCardContents(l10n),),@@ -328,17 +330,34 @@ class _CodeWidgetState extends State<CodeWidget> {);}- void _copyToClipboard() {- FlutterClipboard.copy(_getCurrentOTP())- .then((value) => showToast(context, context.l10n.copiedToClipboard));+ void _copyCurrentOTPToClipboard() async {+ _copyToClipboard(+ _getCurrentOTP(),+ confirmationMessage: context.l10n.copiedToClipboard,+ );}void _copyNextToClipboard() {- FlutterClipboard.copy(_getNextTotp()).then(- (value) => showToast(context, context.l10n.copiedNextToClipboard),+ _copyToClipboard(+ _getNextTotp(),+ confirmationMessage: context.l10n.copiedNextToClipboard,);}+ void _copyToClipboard(+ String content, {+ required String confirmationMessage,+ }) async {+ final shouldMinimizeOnCopy =+ PreferenceService.instance.shouldMinimizeOnCopy();++ await FlutterClipboard.copy(content);+ showToast(context, confirmationMessage);+ if (Platform.isAndroid && shouldMinimizeOnCopy) {+ MoveToBackground.moveTaskToBack();+ }+ }+void _onNextHotpTapped() {if (widget.code.type == Type.hotp) {CodeStore.instancediff --git a/lib/ui/settings/general_section_widget.dart b/lib/ui/settings/general_section_widget.dartindex 428e763573..986ef3a8e7 100644--- a/lib/ui/settings/general_section_widget.dart+++ b/lib/ui/settings/general_section_widget.dart@@ -1,3 +1,5 @@+import 'dart:io';+import 'package:ente_auth/app/view/app.dart';import 'package:ente_auth/core/logging/super_logging.dart';import 'package:ente_auth/l10n/l10n.dart';@@ -120,6 +122,23 @@ class _AdvancedSectionWidgetState extends State<AdvancedSectionWidget> {),),sectionOptionSpacing,+ if (Platform.isAndroid) ...[+ MenuItemWidget(+ captionedTextWidget: CaptionedTextWidget(+ title: l10n.minimizeAppOnCopy,+ ),+ trailingWidget: ToggleSwitchWidget(+ value: () => PreferenceService.instance.shouldMinimizeOnCopy(),+ onChanged: () async {+ await PreferenceService.instance.setShouldMinimizeOnCopy(+ !PreferenceService.instance.shouldMinimizeOnCopy(),+ );+ setState(() {});+ },+ ),+ ),+ sectionOptionSpacing,+ ],],);}