Skip to content

Commit

Permalink
Protect Open
Browse files Browse the repository at this point in the history
  • Loading branch information
hhanh00 committed Jun 4, 2022
1 parent bca7d2f commit 6b741e0
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Preparing transaction..."),
"price": MessageLookupByLibrary.simpleMessage("Price"),
"primary": MessageLookupByLibrary.simpleMessage("Primary"),
"protectOpen": MessageLookupByLibrary.simpleMessage("Protect Open"),
"protectSend": MessageLookupByLibrary.simpleMessage("Protect Send"),
"protectSendSettingChanged": MessageLookupByLibrary.simpleMessage(
"Protect Send setting changed"),
Expand Down
2 changes: 2 additions & 0 deletions lib/generated/intl/messages_es.dart
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Preparando la transacción…"),
"price": MessageLookupByLibrary.simpleMessage("Precio"),
"primary": MessageLookupByLibrary.simpleMessage("Primario"),
"protectOpen":
MessageLookupByLibrary.simpleMessage("Proteger presentar"),
"protectSend": MessageLookupByLibrary.simpleMessage("Proteger enviar"),
"protectSendSettingChanged": MessageLookupByLibrary.simpleMessage(
"La configuración de envío protegido ha cambiado"),
Expand Down
2 changes: 2 additions & 0 deletions lib/generated/intl/messages_fr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ class MessageLookup extends MessageLookupByLibrary {
"Préparation de la transaction..."),
"price": MessageLookupByLibrary.simpleMessage("Prix"),
"primary": MessageLookupByLibrary.simpleMessage("Primaire"),
"protectOpen":
MessageLookupByLibrary.simpleMessage("Ouverture protégée"),
"protectSend": MessageLookupByLibrary.simpleMessage("PIN avant envoi"),
"protectSendSettingChanged": MessageLookupByLibrary.simpleMessage(
"Changement de PIN avant envoi"),
Expand Down
10 changes: 10 additions & 0 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -221,5 +221,6 @@
"markAllAsRead": "Mark All as Read",
"showMessagesAsTable": "Show Messages as Table",
"editContact": "Edit Contact",
"now": "Now"
"now": "Now",
"protectOpen": "Protect Open"
}
3 changes: 2 additions & 1 deletion lib/l10n/intl_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -219,5 +219,6 @@
"markAllAsRead": "Marcar Todo como Leido",
"showMessagesAsTable": "Mostrar mensajes como Tabla",
"editContact": "Editar Contacto",
"now": "Ahora"
"now": "Ahora",
"protectOpen": "Proteger presentar"
}
3 changes: 2 additions & 1 deletion lib/l10n/intl_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -219,5 +219,6 @@
"markAllAsRead": "Marquer tous lus",
"showMessagesAsTable": "Messages vus en table",
"editContact": "Changer le Contact",
"now": "Maintenant"
"now": "Maintenant",
"protectOpen": "Ouverture protégée"
}
11 changes: 11 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ class LoadProgressState extends State<LoadProgress> {
_disposed = true;
super.dispose();
}

void cancelResetTimer() {
_reset?.cancel();
_reset = null;
_disposed = true;
}

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -354,6 +360,11 @@ class ZWalletAppState extends State<ZWalletApp> {
}
}
_setProgress(1.0, 'Ready');
progressKey.currentState?.cancelResetTimer();
if (settings.protectOpen) {
while (!await authenticate(this.context, 'Protect Launch')) {
}
}
return true;
}

Expand Down
13 changes: 13 additions & 0 deletions lib/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ class SettingsState extends State<SettingsPage> with SingleTickerProviderStateMi
_needAuth = true;
},
onSaved: _onProtectSend)),
Expanded(
child: FormBuilderCheckbox(
name: 'protect_open',
title: Text(s.protectOpen),
initialValue: settings.protectOpen,
onChanged: (_) {
_needAuth = true;
},
onSaved: _onProtectOpen)),
// if (coin.supportsUA)
// Expanded(
// child: FormBuilderCheckbox(
Expand Down Expand Up @@ -265,6 +274,10 @@ class SettingsState extends State<SettingsPage> with SingleTickerProviderStateMi
settings.setProtectSend(v);
}

_onProtectOpen(v) {
settings.setProtectOpen(v);
}

_onSave() async {
final form = _settingsFormKey.currentState!;
if (form.validate()) {
Expand Down
11 changes: 11 additions & 0 deletions lib/store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ abstract class _Settings with Store {
@observable
bool protectSend = false;

@observable
bool protectOpen = false;

@observable
int primaryColorValue = 0;
@observable
Expand Down Expand Up @@ -174,6 +177,7 @@ abstract class _Settings with Store {
useUA = prefs.getBool('use_ua') ?? false;
autoHide = prefs.getBool('auto_hide') ?? true;
protectSend = prefs.getBool('protect_send') ?? false;
protectOpen = prefs.getBool('protect_open') ?? false;
includeReplyTo = prefs.getBool('include_reply_to') ?? false;
messageTable = prefs.getBool('message_table') ?? false;

Expand Down Expand Up @@ -404,6 +408,13 @@ abstract class _Settings with Store {
prefs.setBool('protect_send', protectSend);
}

@action
Future<void> setProtectOpen(bool v) async {
final prefs = await SharedPreferences.getInstance();
protectOpen = v;
prefs.setBool('protect_open', protectOpen);
}

@action
Future<void> setIncludeReplyTo(bool v) async {
final prefs = await SharedPreferences.getInstance();
Expand Down

0 comments on commit 6b741e0

Please sign in to comment.