Fix UTF-8 accent support

This commit is contained in:
poka 2021-11-22 03:54:22 +01:00
parent fbff8a6a91
commit 7eceac3f66
4 changed files with 380 additions and 373 deletions

File diff suppressed because it is too large Load Diff

View File

@ -330,12 +330,19 @@ class GenerateWalletsProvider with ChangeNotifier {
bool isBipWord(String word) { bool isBipWord(String word) {
notifyListeners(); notifyListeners();
// Needed for bad encoding of UTF-8
word = word.replaceAll('é', '');
word = word.replaceAll('è', '');
return bip39Words.contains(word); return bip39Words.contains(word);
} }
bool isBipWordsList(List words) { bool isBipWordsList(List words) {
bool isValid = true; bool isValid = true;
for (String word in words) { for (String word in words) {
// Needed for bad encoding of UTF-8
word = word.replaceAll('é', '');
word = word.replaceAll('è', '');
if (!bip39Words.contains(word)) { if (!bip39Words.contains(word)) {
isValid = false; isValid = false;
} }
@ -383,16 +390,14 @@ class GenerateWalletsProvider with ChangeNotifier {
Future<bool> isSentenceValid() async { Future<bool> isSentenceValid() async {
String inputMnemonic = String inputMnemonic =
'${cellController0.text} ${cellController1.text} ${cellController2.text} ${cellController3.text} ${cellController4.text} ${cellController5.text} ${cellController6.text} ${cellController7.text} ${cellController8.text} ${cellController9.text} ${cellController10.text} ${cellController11.text}'; '${cellController0.text} ${cellController1.text} ${cellController2.text} ${cellController3.text} ${cellController4.text} ${cellController5.text} ${cellController6.text} ${cellController7.text} ${cellController8.text} ${cellController9.text} ${cellController10.text} ${cellController11.text}';
//TODO: Fix bad accent management
// inputMnemonic = inputMnemonic.replaceAll('é', 'eM-LM-^A'); // Needed for bad encoding of UTF-8
// inputMnemonic = inputMnemonic.replaceAll('è', 'eM-LM-^@'); inputMnemonic = inputMnemonic.replaceAll('é', '');
inputMnemonic = inputMnemonic.replaceAll('è', '');
NewWallet generatedWallet = NewWallet generatedWallet =
await generateWallet(inputMnemonic, isImport: true); await generateWallet(inputMnemonic, isImport: true);
log.d(inputMnemonic);
if (generatedWallet == null) { if (generatedWallet == null) {
return false; return false;
} else { } else {

View File

@ -18,6 +18,8 @@ class RestoreChest extends StatelessWidget {
GenerateWalletsProvider generateWalletProvider = GenerateWalletsProvider generateWalletProvider =
Provider.of<GenerateWalletsProvider>(context, listen: false); Provider.of<GenerateWalletsProvider>(context, listen: false);
generateWalletProvider.actualWallet = null;
return WillPopScope( return WillPopScope(
onWillPop: () { onWillPop: () {
generateWalletProvider.resetImportView(); generateWalletProvider.resetImportView();
@ -124,7 +126,7 @@ class RestoreChest extends StatelessWidget {
key: const Key('importText'), key: const Key('importText'),
textAlign: TextAlign.justify, textAlign: TextAlign.justify,
style: const TextStyle( style: const TextStyle(
color: Colors.black, fontSize: 21, fontWeight: FontWeight.w400), color: Colors.black, fontSize: 19, fontWeight: FontWeight.w400),
), ),
); );
} }

View File

@ -5,7 +5,7 @@ description: Pay with G1.
# pub.dev using `pub publish`. This is preferred for private packages. # pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 0.0.3+2 version: 0.0.3+3
environment: environment:
sdk: ">=2.7.0 <3.0.0" sdk: ">=2.7.0 <3.0.0"