π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
remove extra parameters from Code
Prateek Sunalfe11f74c3641
diff --git a/mobile/apps/auth/lib/events/multi_select_action_requested_event.dart b/mobile/apps/auth/lib/events/multi_select_action_requested_event.dartnew file mode 100644index 0000000000..367b56b0ff--- /dev/null+++ b/mobile/apps/auth/lib/events/multi_select_action_requested_event.dart@@ -0,0 +1,14 @@+enum MultiSelectAction {+ pinToggle,+ unpin,+ addTag,+ trash,+ restore,+ deleteForever,+}++class MultiSelectActionRequestedEvent {+ MultiSelectActionRequestedEvent(this.action);++ final MultiSelectAction action;+}diff --git a/mobile/apps/auth/lib/store/authenticator_db.dart b/mobile/apps/auth/lib/store/authenticator_db.dartindex 8e8ac11bb0..89d695ecad 100644--- a/mobile/apps/auth/lib/store/authenticator_db.dart+++ b/mobile/apps/auth/lib/store/authenticator_db.dart@@ -184,6 +184,7 @@ class AuthenticatorDB extends EnteBaseDatabase {debugPrint("Done");}+ @overrideFuture<void> clearTable() async {final db = await instance.database;await db.delete(entityTable);diff --git a/mobile/apps/auth/lib/ui/code_widget.dart b/mobile/apps/auth/lib/ui/code_widget.dartindex dae5e1c04a..2f7343aadd 100644--- a/mobile/apps/auth/lib/ui/code_widget.dart+++ b/mobile/apps/auth/lib/ui/code_widget.dart@@ -6,6 +6,7 @@ import 'package:auto_size_text/auto_size_text.dart';import 'package:clipboard/clipboard.dart';import 'package:ente_auth/core/configuration.dart';import 'package:ente_auth/ente_theme_data.dart';+import 'package:ente_auth/events/multi_select_action_requested_event.dart';import 'package:ente_auth/l10n/l10n.dart';import 'package:ente_auth/models/code.dart';import 'package:ente_auth/onboarding/view/setup_enter_secret_key_page.dart';@@ -23,6 +24,7 @@ import 'package:ente_auth/utils/dialog_util.dart';import 'package:ente_auth/utils/platform_util.dart';import 'package:ente_auth/utils/toast_util.dart';import 'package:ente_auth/utils/totp_util.dart';+import 'package:ente_events/event_bus.dart';import 'package:ente_lock_screen/local_authentication_service.dart';import 'package:flutter/foundation.dart';import 'package:flutter/material.dart';@@ -38,12 +40,6 @@ class CodeWidget extends StatefulWidget {final bool isReordering;final bool enableDesktopContextActions;final List<Code> Function()? selectedCodesBuilder;- final Future<void> Function()? onMultiPinToggle;- final Future<void> Function()? onMultiUnpin;- final Future<void> Function()? onMultiAddTag;- final Future<void> Function()? onMultiTrash;- final Future<void> Function()? onMultiRestore;- final Future<void> Function()? onMultiDeleteForever;const CodeWidget(this.code, {@@ -53,12 +49,6 @@ class CodeWidget extends StatefulWidget {this.isReordering = false,this.enableDesktopContextActions = false,this.selectedCodesBuilder,- this.onMultiPinToggle,- this.onMultiUnpin,- this.onMultiAddTag,- this.onMultiTrash,- this.onMultiRestore,- this.onMultiDeleteForever,});@override@@ -236,8 +226,7 @@ class _CodeWidgetState extends State<CodeWidget> {return ValueListenableBuilder<Set<String>>(valueListenable: CodeDisplayStore.instance.selectedCodeIds,builder: (context, selectedIds, child) {- final isSelected =- selectedIds.contains(widget.code.selectionKey);+ final isSelected = selectedIds.contains(widget.code.selectionKey);return Stack(children: [@@ -553,8 +542,7 @@ class _CodeWidgetState extends State<CodeWidget> {return _buildSingleSelectionMenu(l10n);}- final multiEntries =- _buildMultiSelectionContextMenu(l10n, selectedIds);+ final multiEntries = _buildMultiSelectionContextMenu(l10n, selectedIds);if (multiEntries != null) {return multiEntries;}@@ -588,9 +576,10 @@ class _CodeWidgetState extends State<CodeWidget> {label: l10n.addTag,icon: Icons.local_offer_outlined,onSelected: () {- CodeDisplayStore.instance.selectedCodeIds.value =- {widget.code.selectionKey};- widget.onMultiAddTag?.call();+ CodeDisplayStore.instance.selectedCodeIds.value = {+ widget.code.selectionKey,+ };+ _triggerMultiAction(MultiSelectAction.addTag);},),);@@ -610,9 +599,7 @@ class _CodeWidgetState extends State<CodeWidget> {entries.add(MenuItem(label: widget.code.isPinned ? l10n.unpinText : l10n.pinText,- icon: widget.code.isPinned- ? Icons.push_pin- : Icons.push_pin_outlined,+ icon: widget.code.isPinned ? Icons.push_pin : Icons.push_pin_outlined,onSelected: () => _onPinPressed(null),),);@@ -669,25 +656,21 @@ class _CodeWidgetState extends State<CodeWidget> {final bool allTrashed = selectedCodes.every((code) => code.isTrashed);if (allTrashed) {- if (widget.onMultiRestore != null) {- entries.add(- MenuItem(- label: l10n.restore,- icon: Icons.restore_outlined,- onSelected: () => _invokeMultiAction(widget.onMultiRestore),- ),- );- }- if (widget.onMultiDeleteForever != null) {- entries.add(- MenuItem(- label: l10n.delete,- icon: Icons.delete_forever,- onSelected: () =>- _invokeMultiAction(widget.onMultiDeleteForever),- ),- );- }+ entries.add(+ MenuItem(+ label: l10n.restore,+ icon: Icons.restore_outlined,+ onSelected: () => _triggerMultiAction(MultiSelectAction.restore),+ ),+ );+ entries.add(+ MenuItem(+ label: l10n.delete,+ icon: Icons.delete_forever,+ onSelected: () =>+ _triggerMultiAction(MultiSelectAction.deleteForever),+ ),+ );return entries.isEmpty ? null : entries;}@@ -696,62 +679,51 @@ class _CodeWidgetState extends State<CodeWidget> {final bool isMixedPinned = anyPinned && !allPinned;if (isMixedPinned) {- if (widget.onMultiPinToggle != null) {- entries.add(- MenuItem(- label: l10n.pinText,- icon: Icons.push_pin_outlined,- onSelected: () => _invokeMultiAction(widget.onMultiPinToggle),- ),- );- }- if (widget.onMultiUnpin != null) {- entries.add(- MenuItem(- label: l10n.unpinText,- icon: Icons.push_pin,- onSelected: () => _invokeMultiAction(widget.onMultiUnpin),- ),- );- }- } else {- if (widget.onMultiPinToggle != null) {- entries.add(- MenuItem(- label: allPinned ? l10n.unpinText : l10n.pinText,- icon: allPinned ? Icons.push_pin : Icons.push_pin_outlined,- onSelected: () => _invokeMultiAction(widget.onMultiPinToggle),- ),- );- }- }-- if (widget.onMultiAddTag != null) {entries.add(MenuItem(- label: l10n.addTag,- icon: Icons.local_offer_outlined,- onSelected: () => _invokeMultiAction(widget.onMultiAddTag),+ label: l10n.pinText,+ icon: Icons.push_pin_outlined,+ onSelected: () => _triggerMultiAction(MultiSelectAction.pinToggle),),);- }-- if (widget.onMultiTrash != null) {entries.add(MenuItem(- label: l10n.trash,- icon: Icons.delete_outline,- onSelected: () => _invokeMultiAction(widget.onMultiTrash),+ label: l10n.unpinText,+ icon: Icons.push_pin,+ onSelected: () => _triggerMultiAction(MultiSelectAction.unpin),+ ),+ );+ } else {+ entries.add(+ MenuItem(+ label: allPinned ? l10n.unpinText : l10n.pinText,+ icon: allPinned ? Icons.push_pin : Icons.push_pin_outlined,+ onSelected: () => _triggerMultiAction(MultiSelectAction.pinToggle),),);}+ entries.add(+ MenuItem(+ label: l10n.addTag,+ icon: Icons.local_offer_outlined,+ onSelected: () => _triggerMultiAction(MultiSelectAction.addTag),+ ),+ );++ entries.add(+ MenuItem(+ label: l10n.trash,+ icon: Icons.delete_outline,+ onSelected: () => _triggerMultiAction(MultiSelectAction.trash),+ ),+ );+return entries.isEmpty ? null : entries;}- void _invokeMultiAction(Future<void> Function()? action) {- if (action == null) return;- unawaited(action());+ void _triggerMultiAction(MultiSelectAction action) {+ Bus.instance.fire(MultiSelectActionRequestedEvent(action));}Widget _getIcon() {diff --git a/mobile/apps/auth/lib/ui/home_page.dart b/mobile/apps/auth/lib/ui/home_page.dartindex c08fd92c97..19086c8e0b 100644--- a/mobile/apps/auth/lib/ui/home_page.dart+++ b/mobile/apps/auth/lib/ui/home_page.dart@@ -8,6 +8,7 @@ import 'package:ente_auth/core/configuration.dart';import 'package:ente_auth/ente_theme_data.dart';import 'package:ente_auth/events/codes_updated_event.dart';import 'package:ente_auth/events/icons_changed_event.dart';+import 'package:ente_auth/events/multi_select_action_requested_event.dart';import 'package:ente_auth/events/trigger_logout_event.dart';import "package:ente_auth/l10n/l10n.dart";import 'package:ente_auth/models/code.dart';@@ -91,6 +92,8 @@ class _HomePageState extends State<HomePage> {StreamSubscription<CodesUpdatedEvent>? _streamSubscription;StreamSubscription<TriggerLogoutEvent>? _triggerLogoutEvent;StreamSubscription<IconsChangedEvent>? _iconsChangedEvent;+ StreamSubscription<MultiSelectActionRequestedEvent>?+ _multiSelectActionSubscription;String selectedTag = "";bool _isTrashOpen = false;bool hasTrashedCodes = false;@@ -110,6 +113,9 @@ class _HomePageState extends State<HomePage> {_streamSubscription = Bus.instance.on<CodesUpdatedEvent>().listen((event) {_loadCodes();});+ _multiSelectActionSubscription = Bus.instance+ .on<MultiSelectActionRequestedEvent>()+ .listen(_handleMultiSelectAction);_triggerLogoutEvent =Bus.instance.on<TriggerLogoutEvent>().listen((event) async {await autoLogoutAlert(context);@@ -286,8 +292,10 @@ class _HomePageState extends State<HomePage> {}if (codesToUpdate.length == 1) {- showToast(context,- context.l10n.unpinnedCodeMessage(codesToUpdate.first.issuer));+ showToast(+ context,+ context.l10n.unpinnedCodeMessage(codesToUpdate.first.issuer),+ );} else {showToast(context, 'Unpinned ${codesToUpdate.length} item(s)');}@@ -468,9 +476,11 @@ class _HomePageState extends State<HomePage> {children: [iconWidget ?? Icon(icon!, color: colorScheme.textBase, size: 21),const SizedBox(height: 8),- Text(label,- style: textTheme.small- .copyWith(color: colorScheme.textBase, fontSize: 11)),+ Text(+ label,+ style: textTheme.small+ .copyWith(color: colorScheme.textBase, fontSize: 11),+ ),],),),@@ -530,14 +540,16 @@ class _HomePageState extends State<HomePage> {ValueListenableBuilder<Set<String>>(valueListenable: _codeDisplayStore.selectedCodeIds,builder: (context, selectedIds, child) {- if (selectedIds.isEmpty)+ if (selectedIds.isEmpty) {return const Expanded(child: SizedBox.shrink());+ }final selectedCodes = _allCodes?.where((c) => selectedIds.contains(c.selectionKey)).toList() ??[];- if (selectedCodes.isEmpty)+ if (selectedCodes.isEmpty) {return const Expanded(child: SizedBox.shrink());+ }final bool allArePinned =selectedCodes.every((code) => code.isPinned);@@ -824,7 +836,9 @@ class _HomePageState extends State<HomePage> {Material(shape: StadiumBorder(side: BorderSide(- color: colorScheme.strokeMuted, width: 0.5),+ color: colorScheme.strokeMuted,+ width: 0.5,+ ),),color: colorScheme.backgroundElevated2,clipBehavior: Clip.antiAlias,@@ -837,7 +851,9 @@ class _HomePageState extends State<HomePage> {},child: Padding(padding: const EdgeInsets.symmetric(- horizontal: 12.0, vertical: 8.0),+ horizontal: 12.0,+ vertical: 8.0,+ ),child: Row(mainAxisSize: MainAxisSize.min,children: [@@ -881,10 +897,13 @@ class _HomePageState extends State<HomePage> {: code.issuer;return Padding(padding: const EdgeInsets.symmetric(- horizontal: 4.0),+ horizontal: 4.0,+ ),child: IconUtils.instance.getIcon(- context, iconData.trim(),- width: 17),+ context,+ iconData.trim(),+ width: 17,+ ),);}),if (selectedIds.length > 3)@@ -1086,6 +1105,7 @@ class _HomePageState extends State<HomePage> {_streamSubscription?.cancel();_triggerLogoutEvent?.cancel();_iconsChangedEvent?.cancel();+ _multiSelectActionSubscription?.cancel();_textController.dispose();_textController.removeListener(_applyFilteringAndRefresh);ServicesBinding.instance.keyboard.removeHandler(_handleKeyEvent);@@ -1581,12 +1601,6 @@ class _HomePageState extends State<HomePage> {sortKey: _codeSortKey,enableDesktopContextActions: PlatformUtil.isDesktop(),selectedCodesBuilder: _selectedCodesForContextMenu,- onMultiPinToggle: _onPinSelectedPressed,- onMultiUnpin: _onUnpinSelectedPressed,- onMultiAddTag: () async => _onAddTagPressed(),- onMultiTrash: _onTrashSelectedPressed,- onMultiRestore: _onRestoreSelectedPressed,- onMultiDeleteForever: _onDeleteForeverPressed,),);}),@@ -1638,12 +1652,6 @@ class _HomePageState extends State<HomePage> {enableDesktopContextActions:PlatformUtil.isDesktop(),selectedCodesBuilder: _selectedCodesForContextMenu,- onMultiPinToggle: _onPinSelectedPressed,- onMultiUnpin: _onUnpinSelectedPressed,- onMultiAddTag: () async => _onAddTagPressed(),- onMultiTrash: _onTrashSelectedPressed,- onMultiRestore: _onRestoreSelectedPressed,- onMultiDeleteForever: _onDeleteForeverPressed,);}),itemCount: _filteredCodes.length,@@ -1746,10 +1754,14 @@ class _HomePageState extends State<HomePage> {final bool singleSelection = selectedCodes.length == 1;final Code? singleCode = singleSelection ? selectedCodes.first : null;- final List<Widget> actionButtons = [];+ final List<Widget> actionButtons = <Widget>[];- void addButton(String tooltip, IconData icon, VoidCallback? onPressed,- {Widget? iconWidget}) {+ void addButton(+ String tooltip,+ IconData icon,+ VoidCallback? onPressed, {+ Widget? iconWidget,+ }) {if (actionButtons.isNotEmpty) {actionButtons.add(const SizedBox(width: 12));}@@ -1766,8 +1778,11 @@ class _HomePageState extends State<HomePage> {if (!allTrashed) {if (isMixedPinned) {- addButton(context.l10n.pinText, Icons.push_pin,- () => _onPinSelectedPressed());+ addButton(+ context.l10n.pinText,+ Icons.push_pin,+ () => _onPinSelectedPressed(),+ );addButton(context.l10n.unpinText,Icons.push_pin,@@ -1782,28 +1797,52 @@ class _HomePageState extends State<HomePage> {iconWidget: _buildUnpinIcon(context),);} else {- addButton(context.l10n.pinText, Icons.push_pin,- () => _onPinSelectedPressed());+ addButton(+ context.l10n.pinText,+ Icons.push_pin,+ () => _onPinSelectedPressed(),+ );}addButton(- context.l10n.addTag, Icons.local_offer_outlined, _onAddTagPressed);- addButton(context.l10n.trash, Icons.delete_outline,- () => _onTrashSelectedPressed());+ context.l10n.addTag,+ Icons.local_offer_outlined,+ _onAddTagPressed,+ );+ addButton(+ context.l10n.trash,+ Icons.delete_outline,+ () => _onTrashSelectedPressed(),+ );if (singleCode != null) {- addButton(context.l10n.share, Icons.adaptive.share_outlined,- () => _onSharePressed(singleCode));- addButton(context.l10n.qr, Icons.qr_code_2_outlined,- () => _onShowQrPressed(singleCode));- addButton(context.l10n.edit, Icons.edit_outlined,- () => _onEditPressed(singleCode));+ addButton(+ context.l10n.share,+ Icons.adaptive.share_outlined,+ () => _onSharePressed(singleCode),+ );+ addButton(+ context.l10n.qr,+ Icons.qr_code_2_outlined,+ () => _onShowQrPressed(singleCode),+ );+ addButton(+ context.l10n.edit,+ Icons.edit_outlined,+ () => _onEditPressed(singleCode),+ );}} else {- addButton(context.l10n.restore, Icons.restore_outlined,- () => _onRestoreSelectedPressed());- addButton(context.l10n.delete, Icons.delete_forever_outlined,- () => _onDeleteForeverPressed());+ addButton(+ context.l10n.restore,+ Icons.restore_outlined,+ () => _onRestoreSelectedPressed(),+ );+ addButton(+ context.l10n.delete,+ Icons.delete_forever_outlined,+ () => _onDeleteForeverPressed(),+ );}return Row(@@ -1956,4 +1995,29 @@ class _HomePageState extends State<HomePage> {],);}++ void _handleMultiSelectAction(+ MultiSelectActionRequestedEvent event,+ ) {+ switch (event.action) {+ case MultiSelectAction.pinToggle:+ unawaited(_onPinSelectedPressed());+ break;+ case MultiSelectAction.unpin:+ unawaited(_onUnpinSelectedPressed());+ break;+ case MultiSelectAction.addTag:+ _onAddTagPressed();+ break;+ case MultiSelectAction.trash:+ unawaited(_onTrashSelectedPressed());+ break;+ case MultiSelectAction.restore:+ unawaited(_onRestoreSelectedPressed());+ break;+ case MultiSelectAction.deleteForever:+ unawaited(_onDeleteForeverPressed());+ break;+ }+ }}