mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-04 12:34:14 +01:00
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into new-fiat-currencies
Conflicts: lib/reactions/on_current_wallet_change.dart
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import 'dart:io' show File, Platform;
|
||||
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
||||
import 'package:cake_wallet/entities/exchange_api_mode.dart';
|
||||
import 'package:cw_core/pathForWallet.dart';
|
||||
import 'package:cake_wallet/entities/secret_store_key.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:cake_wallet/entities/preferences_key.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
@@ -142,7 +144,9 @@ Future defaultSettingsMigration(
|
||||
case 19:
|
||||
await validateBitcoinSavedTransactionPriority(sharedPreferences);
|
||||
break;
|
||||
|
||||
case 20:
|
||||
await migrateExchangeStatus(sharedPreferences);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -501,3 +505,15 @@ Future<void> changeDefaultHavenNode(
|
||||
await node.save();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> migrateExchangeStatus(SharedPreferences sharedPreferences) async {
|
||||
final isExchangeDisabled = sharedPreferences.getBool(PreferencesKey.disableExchangeKey);
|
||||
if (isExchangeDisabled == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
await sharedPreferences.setInt(PreferencesKey.exchangeStatusKey, isExchangeDisabled
|
||||
? ExchangeApiMode.disabled.raw : ExchangeApiMode.enabled.raw);
|
||||
|
||||
await sharedPreferences.remove(PreferencesKey.disableExchangeKey);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cw_core/enumerable_item.dart';
|
||||
|
||||
class ExchangeApiMode extends EnumerableItem<int> with Serializable<int> {
|
||||
const ExchangeApiMode({required String title, required int raw}) : super(title: title, raw: raw);
|
||||
|
||||
static const all = [ExchangeApiMode.enabled, ExchangeApiMode.torOnly, ExchangeApiMode.disabled];
|
||||
|
||||
static const enabled = ExchangeApiMode(raw: 0, title: 'Enabled');
|
||||
static const torOnly = ExchangeApiMode(raw: 1, title: 'Tor only');
|
||||
static const disabled = ExchangeApiMode(raw: 2, title: 'Disabled');
|
||||
|
||||
static ExchangeApiMode deserialize({required int raw}) {
|
||||
switch (raw) {
|
||||
case 0:
|
||||
return enabled;
|
||||
case 1:
|
||||
return torOnly;
|
||||
case 2:
|
||||
return disabled;
|
||||
default:
|
||||
throw Exception('Unexpected token: $raw for ExchangeApiMode deserialize');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
switch (this) {
|
||||
case ExchangeApiMode.enabled:
|
||||
return S.current.enabled;
|
||||
case ExchangeApiMode.torOnly:
|
||||
return S.current.tor_only;
|
||||
case ExchangeApiMode.disabled:
|
||||
return S.current.disabled;
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,10 @@ class LanguageService {
|
||||
'ar': 'العربية (Arabic)',
|
||||
'tr': 'Türkçe (Turkish)',
|
||||
'my': 'မြန်မာ (Burmese)',
|
||||
'ur': 'اردو (Urdu)'
|
||||
'bg': 'Български (Bulgarian)',
|
||||
'cs': 'čeština (Czech)',
|
||||
'ur': 'اردو (Urdu)',
|
||||
'id': 'Bahasa Indonesia (Indonesian)'
|
||||
};
|
||||
|
||||
static const Map<String, String> localeCountryCode = {
|
||||
@@ -46,7 +49,10 @@ class LanguageService {
|
||||
'ar': 'sau',
|
||||
'tr': 'tur',
|
||||
'my': 'mmr',
|
||||
'ur': 'pak'
|
||||
'bg': 'bgr',
|
||||
'cs': 'czk',
|
||||
'ur': 'pak',
|
||||
'id': 'idn'
|
||||
};
|
||||
|
||||
static final list = <String, String> {};
|
||||
|
||||
@@ -13,6 +13,7 @@ class PreferencesKey {
|
||||
static const allowBiometricalAuthenticationKey =
|
||||
'allow_biometrical_authentication';
|
||||
static const disableExchangeKey = 'disable_exchange';
|
||||
static const exchangeStatusKey = 'exchange_status';
|
||||
static const currentTheme = 'current_theme';
|
||||
static const isDarkThemeLegacy = 'dark_theme';
|
||||
static const displayActionListModeKey = 'display_list_mode';
|
||||
|
||||
Reference in New Issue
Block a user