Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Hide HOTP share option

Neeraj Guptab0cde8665a37
diff --git a/mobile/apps/auth/lib/models/code.dart b/mobile/apps/auth/lib/models/code.dart
index 83d045be02..440c2011c4 100644
--- a/mobile/apps/auth/lib/models/code.dart
+++ b/mobile/apps/auth/lib/models/code.dart
@@ -328,6 +328,8 @@ enum Type {
steam;
bool get isTOTPCompatible => this == totp || this == steam;
+
+ bool get canShareCodes => this == totp || this == steam;
}
enum Algorithm {
diff --git a/mobile/apps/auth/lib/ui/code_widget.dart b/mobile/apps/auth/lib/ui/code_widget.dart
index 0aa067cdda..6df84fe62e 100644
--- a/mobile/apps/auth/lib/ui/code_widget.dart
+++ b/mobile/apps/auth/lib/ui/code_widget.dart
@@ -601,7 +601,7 @@ class _CodeWidgetState extends State<CodeWidget> {
) {
if (widget.code.isTrashed) return;
- if (widget.code.type.isTOTPCompatible) {
+ if (widget.code.type.canShareCodes) {
entries.add(
MenuItem(
label: l10n.share,
@@ -949,6 +949,9 @@ class _CodeWidgetState extends State<CodeWidget> {
}
Future<void> _onSharePressed([bool? pop]) async {
+ if (!widget.code.type.canShareCodes) {
+ return;
+ }
if (mounted && pop == true) {
Navigator.of(context).pop();
}
diff --git a/mobile/apps/auth/lib/ui/home_page.dart b/mobile/apps/auth/lib/ui/home_page.dart
index a88aba6aa4..1a0bbc0c73 100644
--- a/mobile/apps/auth/lib/ui/home_page.dart
+++ b/mobile/apps/auth/lib/ui/home_page.dart
@@ -476,6 +476,9 @@ class _HomePageState extends State<HomePage> {
}
Future<void> _onSharePressed(Code code) async {
+ if (!code.type.canShareCodes) {
+ return;
+ }
bool isAuthSuccessful = await LocalAuthenticationService.instance
.requestLocalAuthentication(context, context.l10n.authenticateGeneric);
await PlatformUtil.refocusWindows();
@@ -566,16 +569,18 @@ class _HomePageState extends State<HomePage> {
),
),
const SizedBox(width: 10),
- _buildActionButton(
- context.l10n.share,
- () => _onSharePressed(code),
- iconWidget: HugeIcon(
- icon: HugeIcons.strokeRoundedNavigation03,
- size: 21,
- color: getEnteColorScheme(context).textBase,
+ if (code.type.canShareCodes) ...[
+ _buildActionButton(
+ context.l10n.share,
+ () => _onSharePressed(code),
+ iconWidget: HugeIcon(
+ icon: HugeIcons.strokeRoundedNavigation03,
+ size: 21,
+ color: getEnteColorScheme(context).textBase,
+ ),
),
- ),
- const SizedBox(width: 10),
+ const SizedBox(width: 10),
+ ],
_buildActionButton(
context.l10n.qrCode,
() => _onShowQrPressed(code),
@@ -2065,11 +2070,13 @@ class _HomePageState extends State<HomePage> {
);
if (singleCode != null) {
- addButton(
- context.l10n.share,
- Icons.adaptive.share_outlined,
- () => _onSharePressed(singleCode),
- );
+ if (singleCode.type.canShareCodes) {
+ addButton(
+ context.l10n.share,
+ Icons.adaptive.share_outlined,
+ () => _onSharePressed(singleCode),
+ );
+ }
addButton(
context.l10n.qr,
Icons.qr_code_2_outlined,
diff --git a/mobile/apps/auth/lib/ui/share/code_share.dart b/mobile/apps/auth/lib/ui/share/code_share.dart
index 8168f12662..7c80d9ff51 100644
--- a/mobile/apps/auth/lib/ui/share/code_share.dart
+++ b/mobile/apps/auth/lib/ui/share/code_share.dart
@@ -143,6 +143,9 @@ class _ShareCodeDialogState extends State<ShareCodeDialog> {
}
void showShareDialog(BuildContext context, Code code) {
+ if (!code.type.canShareCodes) {
+ return;
+ }
showDialog(
context: context,
builder: (BuildContext context) {
diff --git a/mobile/apps/auth/test/models/code_test.dart b/mobile/apps/auth/test/models/code_test.dart
index f51364118e..ce18a8704f 100644
--- a/mobile/apps/auth/test/models/code_test.dart
+++ b/mobile/apps/auth/test/models/code_test.dart
@@ -33,6 +33,12 @@ void main() {
expect(code.counter, 15);
});
+ test("shareCodesSupport", () {
+ expect(Type.totp.canShareCodes, true);
+ expect(Type.steam.canShareCodes, true);
+ expect(Type.hotp.canShareCodes, false);
+ });
+
test("validateDisplay", () {
Code code = Code.fromOTPAuthUrl(
"otpauth://hotp/[email protected]?secret=ASKZNWOU6SVYAMVS&issuer=GitHub&counter=15",