Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/breez/breezmobile
Browse files Browse the repository at this point in the history
* 'master' of https://github.com/breez/breezmobile:
  Translate network page
  Translate PIN code
  Translate security options
  Better identification of payment items
  Translate security & backup screen It is necessary to translate the biometrics opetions yet, I'll make a separetad PR for it as that can have some side effects
  • Loading branch information
roeierez committed Jan 5, 2022
2 parents 70739cc + 7320e3a commit c8546de
Show file tree
Hide file tree
Showing 15 changed files with 936 additions and 366 deletions.
26 changes: 15 additions & 11 deletions lib/bloc/account/account_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -663,25 +663,29 @@ class AccountBloc {
DateTime _firstDate;
print("refreshing payments...");

final hashedSales = await _posRepository.fetchSalesPaymentHashes();
return _breezLib.getPayments().then((payments) {
List<PaymentInfo> _paymentsList = payments.paymentsList.map((payment) {
var singlePaymentInfo =
SinglePaymentInfo(payment, _accountController.value);

return singlePaymentInfo;
}).toList();
List<PaymentInfo> _paymentsList = payments.paymentsList
.map((payment) => SinglePaymentInfo(
payment,
_accountController.value,
hashedSales.contains(payment.paymentHash),
))
.toList();

if (_paymentsList.length > 0) {
_firstDate = DateTime.fromMillisecondsSinceEpoch(
_paymentsList.last.creationTimestamp.toInt() * 1000);
_paymentsList.last.creationTimestamp.toInt() * 1000,
);
}
print("refresh payments finished " +
payments.paymentsList.length.toString());
return PaymentsModel(
_paymentsList,
_filterPayments(_paymentsList),
_paymentFilterController.value,
_firstDate ?? DateTime(DateTime.now().year));
_paymentsList,
_filterPayments(_paymentsList),
_paymentFilterController.value,
_firstDate ?? DateTime(DateTime.now().year),
);
});
}

Expand Down
29 changes: 16 additions & 13 deletions lib/bloc/account/account_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:ffi';
import 'dart:math';

import 'package:breez/bloc/account/fiat_conversion.dart';
import 'package:breez/bloc/pos_catalog/model.dart';
import 'package:breez/bloc/user_profile/currency.dart';
import 'package:breez/services/breezlib/data/rpc.pb.dart';
import 'package:breez/utils/date.dart';
Expand Down Expand Up @@ -413,7 +414,7 @@ enum PaymentType { DEPOSIT, WITHDRAWAL, SENT, RECEIVED, CLOSED_CHANNEL }

enum PaymentVendor {
BITREFILL,
BREEZ,
BREEZ_SALE,
FAST_BITCOINS,
LIGHTNING_GIFTS,
LN_PIZZA,
Expand Down Expand Up @@ -444,6 +445,7 @@ abstract class PaymentInfo {
String get paymentGroupName;
LNUrlPayInfo get lnurlPayInfo;
PaymentVendor get vendor;
bool get hasSale;
PaymentInfo copyWith(AccountModel account);
}

Expand Down Expand Up @@ -509,11 +511,13 @@ class StreamedPaymentInfo implements PaymentInfo {

LNUrlPayInfo get lnurlPayInfo => null;
PaymentVendor get vendor => null;
bool get hasSale => false;
}

class SinglePaymentInfo implements PaymentInfo {
final Payment _paymentResponse;
final AccountModel _account;
final bool _hasSale;

Map _typeMap = {
Payment_PaymentType.DEPOSIT: PaymentType.DEPOSIT,
Expand Down Expand Up @@ -621,7 +625,7 @@ class SinglePaymentInfo implements PaymentInfo {
switch (vendor) {
case PaymentVendor.BITREFILL:
return "src/icon/vendors/bitrefill_logo.png";
case PaymentVendor.BREEZ:
case PaymentVendor.BREEZ_SALE:
return "breez://avatar/possale";
case PaymentVendor.FAST_BITCOINS:
return "src/icon/vendors/fastbitcoins_logo.png";
Expand All @@ -643,7 +647,7 @@ class SinglePaymentInfo implements PaymentInfo {
switch (vendor) {
case PaymentVendor.BITREFILL:
return "Bitrefill";
case PaymentVendor.BREEZ:
case PaymentVendor.BREEZ_SALE:
final date = BreezDateUtils.formatHourMinute(
DateTime.fromMillisecondsSinceEpoch(
creationTimestamp.toInt() * 1000,
Expand Down Expand Up @@ -737,24 +741,23 @@ class SinglePaymentInfo implements PaymentInfo {
return PaymentVendor.FAST_BITCOINS;
}

if (_isSalePayment()) {
return PaymentVendor.BREEZ;
if (hasSale) {
return PaymentVendor.BREEZ_SALE;
}

return null;
}

bool _isSalePayment() {
final payeeName = _paymentResponse.invoiceMemo.payeeName;
return type == PaymentType.RECEIVED &&
payeeName != null &&
payeeName.isNotEmpty;
}
bool get hasSale => _hasSale;

SinglePaymentInfo(this._paymentResponse, this._account);
SinglePaymentInfo(
this._paymentResponse,
this._account,
this._hasSale,
);

SinglePaymentInfo copyWith(AccountModel account) {
return SinglePaymentInfo(this._paymentResponse, account);
return SinglePaymentInfo(this._paymentResponse, account, this._hasSale);
}
}

Expand Down
1 change: 1 addition & 0 deletions lib/bloc/pos_catalog/repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ abstract class Repository {
Future<int> addSale(Sale sale, String paymentHash);
Future<Sale> fetchSaleByID(int id);
Future<Sale> fetchSaleByPaymentHash(String paymentHash);
Future<Set<String>> fetchSalesPaymentHashes();
}
11 changes: 11 additions & 0 deletions lib/bloc/pos_catalog/sqlite/repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,15 @@ class SqliteRepository implements Repository {
}
return items.map((row) => fromMapFunc(row)).toList();
}

@override
Future<Set<String>> fetchSalesPaymentHashes() async {
return Set.from(
await _fetchDBItems(
await getDB(),
"sale_payments",
(e) => e["payment_hash"],
),
);
}
}
2 changes: 1 addition & 1 deletion lib/bloc/user_profile/user_profile_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ class UserProfileBloc {
}

Future _getEnrolledBiometrics(GetEnrolledBiometrics action) async {
action.resolve(await _localAuthService.enrolledBiometrics);
action.resolve(await _localAuthService.localAuthenticationOption);
}

void _listenRegistrationRequests(ServiceInjector injector) {
Expand Down
50 changes: 50 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,56 @@
}
},
"connect_to_pay_payment_reject": "Payment rejected",
"security_and_backup_title": "Security & Backup",
"security_and_backup_last_backup_no_account": "Last backup: {lastBackup}",
"@security_and_backup_last_backup_no_account": {
"placeholders": {
"lastBackup": {
"type": "String",
"example": "03/01/2022 14:57"
}
}
},
"security_and_backup_last_backup_with_account": "Last backup: {lastBackup}\nAccount: {accountName}",
"@security_and_backup_last_backup_with_account": {
"placeholders": {
"lastBackup": {
"type": "String",
"example": "03/01/2022 14:57"
},
"accountName": {
"type": "String",
"example": "[email protected]"
}
}
},
"security_and_backup_encrypt": "Encrypt Cloud Backup",
"security_and_backup_store_location": "Store Backup Data in",
"security_and_backup_lock_automatically": "Lock Automatically",
"security_and_backup_lock_automatically_option_immediate": "Immediate",
"security_and_backup_change_pin": "Change PIN",
"security_and_backup_enable_biometric_option_face": "Enable Face",
"security_and_backup_enable_biometric_option_face_id": "Enable Face ID",
"security_and_backup_enable_biometric_option_fingerprint": "Enable Fingerprint",
"security_and_backup_enable_biometric_option_touch_id": "Enable Touch ID",
"security_and_backup_enable_biometric_option_none": "",
"security_and_backup_validate_biometrics_reason": "Authenticate to enable this setting",
"security_and_backup_pin_option_create": "Create PIN",
"security_and_backup_pin_option_deactivate": "Deactivate PIN",
"security_and_backup_internal_error": "Internal Error",
"security_and_backup_new_pin": "Enter your new PIN",
"security_and_backup_new_pin_second_time": "Re-enter your new PIN",
"security_and_backup_new_pin_do_not_match": "PIN does not match",
"network_title": "Network",
"network_restart_message": "Please restart Breez to switch to the new Bitcoin Node configuration.",
"network_restart_action_cancel": "CANCEL",
"network_restart_action_confirm": "EXIT BREEZ",
"network_restart_action_reset": "Reset",
"network_restart_action_save": "Save",
"network_bitcoin_node": "Bitcoin Node (BIP 157)",
"network_default_node_error": "Breez is unable to use the default node.",
"network_custom_node_error": "Breez is unable to connect to the specified node. Please make sure this node supports BIP 157.",
"network_testing_node": "Testing node",
"locale": "en",
"app_name": "Breez"
}
50 changes: 50 additions & 0 deletions lib/l10n/app_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,56 @@
}
},
"connect_to_pay_payment_reject": "Pagamento recusado",
"security_and_backup_title": "Seguridad & Respaldo",
"security_and_backup_last_backup_no_account": "Última copia de seguridad: {lastBackup}",
"@security_and_backup_last_backup_no_account": {
"placeholders": {
"lastBackup": {
"type": "String",
"example": "03/01/2022 14:57"
}
}
},
"security_and_backup_last_backup_with_account": "Última copia de seguridad: {lastBackup}\nCuenta: {accountName}",
"@security_and_backup_last_backup_with_account": {
"placeholders": {
"lastBackup": {
"type": "String",
"example": "03/01/2022 14:57"
},
"accountName": {
"type": "String",
"example": "[email protected]"
}
}
},
"security_and_backup_encrypt": "Cifrar copia de seguridad en la nube",
"security_and_backup_store_location": "Guardar en la nube de",
"security_and_backup_lock_automatically": "Bloquear automáticamente",
"security_and_backup_lock_automatically_option_immediate": "Inmediatamente",
"security_and_backup_change_pin": "Cambiar PIN",
"security_and_backup_enable_biometric_option_face": "Habilitar el Reconocimiento Facial",
"security_and_backup_enable_biometric_option_face_id": "Habilitar Face ID",
"security_and_backup_enable_biometric_option_fingerprint": "Habilitar Huella Digital",
"security_and_backup_enable_biometric_option_touch_id": "Habilitar Touch ID",
"security_and_backup_enable_biometric_option_none": "",
"security_and_backup_validate_biometrics_reason": "Iniciar sesión para habilitar esta configuración",
"security_and_backup_pin_option_create": "Crea un PIN",
"security_and_backup_pin_option_deactivate": "Desactivar PIN",
"security_and_backup_internal_error": "Error interno",
"security_and_backup_new_pin": "Ingrese su nuevo PIN",
"security_and_backup_new_pin_second_time": "Vuelva a ingresar su nuevo PIN",
"security_and_backup_new_pin_do_not_match": "Los códigos PIN no coinciden.",
"network_title": "Red",
"network_restart_message": "Por favor, reinicie Breez para aplicar la nueva configuración del nodo Bitcoin.",
"network_restart_action_cancel": "CANCELAR",
"network_restart_action_confirm": "SALIR DE BREEZ",
"network_restart_action_reset": "Restablecer",
"network_restart_action_save": "Guardar",
"network_bitcoin_node": "Nodo Bitcoin (BIP 157)",
"network_default_node_error": "No se pudo usar el nodo estandar.",
"network_custom_node_error": "No se puede conectar al nodo especificado. Asegúrese de que este nodo sea compatible con el BIP 157.",
"network_testing_node": "Probando el nodo",
"locale": "es",
"app_name": "Breez"
}
50 changes: 50 additions & 0 deletions lib/l10n/app_fi.arb
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,56 @@
}
},
"connect_to_pay_payment_reject": "Payment rejected",
"security_and_backup_title": "Security & Backup",
"security_and_backup_last_backup_no_account": "Last backup: {lastBackup}",
"@security_and_backup_last_backup_no_account": {
"placeholders": {
"lastBackup": {
"type": "String",
"example": "03/01/2022 14:57"
}
}
},
"security_and_backup_last_backup_with_account": "Last backup: {lastBackup}\nAccount: {accountName}",
"@security_and_backup_last_backup_with_account": {
"placeholders": {
"lastBackup": {
"type": "String",
"example": "03/01/2022 14:57"
},
"accountName": {
"type": "String",
"example": "[email protected]"
}
}
},
"security_and_backup_encrypt": "Encrypt Cloud Backup",
"security_and_backup_store_location": "Store Backup Data in",
"security_and_backup_lock_automatically": "Lock Automatically",
"security_and_backup_lock_automatically_option_immediate": "Immediate",
"security_and_backup_change_pin": "Change PIN",
"security_and_backup_enable_biometric_option_face": "Enable Face",
"security_and_backup_enable_biometric_option_face_id": "Enable Face ID",
"security_and_backup_enable_biometric_option_fingerprint": "Enable Fingerprint",
"security_and_backup_enable_biometric_option_touch_id": "Enable Touch ID",
"security_and_backup_enable_biometric_option_none": "",
"security_and_backup_validate_biometrics_reason": "Authenticate to enable this setting",
"security_and_backup_pin_option_create": "Create PIN",
"security_and_backup_pin_option_deactivate": "Deactivate PIN",
"security_and_backup_internal_error": "Internal Error",
"security_and_backup_new_pin": "Enter your new PIN",
"security_and_backup_new_pin_second_time": "Re-enter your new PIN",
"security_and_backup_new_pin_do_not_match": "PIN does not match",
"network_title": "Network",
"network_restart_message": "Please restart Breez to switch to the new Bitcoin Node configuration.",
"network_restart_action_cancel": "CANCEL",
"network_restart_action_confirm": "EXIT BREEZ",
"network_restart_action_reset": "Reset",
"network_restart_action_save": "Save",
"network_bitcoin_node": "Bitcoin Node (BIP 157)",
"network_default_node_error": "Breez is unable to use the default node.",
"network_custom_node_error": "Breez is unable to connect to the specified node. Please make sure this node supports BIP 157.",
"network_testing_node": "Testing node",
"locale": "fi",
"app_name": "Breez"
}
50 changes: 50 additions & 0 deletions lib/l10n/app_pt.arb
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,56 @@
}
},
"connect_to_pay_payment_reject": "Pagamento recusado",
"security_and_backup_title": "Segurança & Backup",
"security_and_backup_last_backup_no_account": "Último backup: {lastBackup}",
"@security_and_backup_last_backup_no_account": {
"placeholders": {
"lastBackup": {
"type": "String",
"example": "03/01/2022 14:57"
}
}
},
"security_and_backup_last_backup_with_account": "Último backup: {lastBackup}\nConta: {accountName}",
"@security_and_backup_last_backup_with_account": {
"placeholders": {
"lastBackup": {
"type": "String",
"example": "03/01/2022 14:57"
},
"accountName": {
"type": "String",
"example": "[email protected]"
}
}
},
"security_and_backup_encrypt": "Criptografar backup na nuvem",
"security_and_backup_store_location": "Salvar o backup na nuvem do",
"security_and_backup_lock_automatically": "Bloquear automaticamente",
"security_and_backup_lock_automatically_option_immediate": "Imediatamente",
"security_and_backup_change_pin": "Alterar o PIN",
"security_and_backup_enable_biometric_option_face": "Habilitar o Reconhecimento Facial",
"security_and_backup_enable_biometric_option_face_id": "Habilitar o Face ID",
"security_and_backup_enable_biometric_option_fingerprint": "Habilitar a Impressão Digital",
"security_and_backup_enable_biometric_option_touch_id": "Habilitar o Touch ID",
"security_and_backup_enable_biometric_option_none": "",
"security_and_backup_validate_biometrics_reason": "Autentique-se para habilitar esta configuração",
"security_and_backup_pin_option_create": "Criar um PIN",
"security_and_backup_pin_option_deactivate": "Desativar o PIN",
"security_and_backup_internal_error": "Erro interno",
"security_and_backup_new_pin": "Digite seu novo PIN",
"security_and_backup_new_pin_second_time": "Digite novamente o seu novo PIN",
"security_and_backup_new_pin_do_not_match": "Os PINs não correspondem.",
"network_title": "Rede",
"network_restart_message": "Por favor, reinicie o Breez para aplicar a nova configuração de nó de Bitcoin.",
"network_restart_action_cancel": "CANCELAR",
"network_restart_action_confirm": "SAIR DO BREEZ",
"network_restart_action_reset": "Redefinir",
"network_restart_action_save": "Salvar",
"network_bitcoin_node": "Nó de Bitcoin (BIP 157)",
"network_default_node_error": "Não foi possível utilizar o nó padrão.",
"network_custom_node_error": "Não foi possível se conectar ao nó especificado. Certifique-se de que este nó é compatível com o BIP 157.",
"network_testing_node": "Testando o nó",
"locale": "pt",
"app_name": "Breez"
}
Loading

0 comments on commit c8546de

Please sign in to comment.