mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-02-02 19:26:27 +00:00
CAKE-279 | canceled changes in AndroidManifest.xml and MainActivity.java; added static constants to wyre_service.dart; moved WyreException class into own file; imported WyreService by di.dart
This commit is contained in:
parent
08efc52f71
commit
1cbbc71201
6 changed files with 29 additions and 53 deletions
|
@ -27,8 +27,6 @@
|
|||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<data android:scheme="cakewallet"/>
|
||||
<data android:host="wyre-trade-success"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
|
|
|
@ -1,46 +1,15 @@
|
|||
package com.cakewallet.cake_wallet;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import io.flutter.embedding.android.FlutterFragmentActivity;
|
||||
import io.flutter.embedding.engine.FlutterEngine;
|
||||
import io.flutter.plugin.common.BasicMessageChannel;
|
||||
import io.flutter.plugin.common.BinaryCodec;
|
||||
import io.flutter.plugins.GeneratedPluginRegistrant;
|
||||
|
||||
|
||||
public class MainActivity extends FlutterFragmentActivity {
|
||||
public static final int DATA_EXISTS = 1;
|
||||
public static final int DATA_NOT_EXISTS = 0;
|
||||
BasicMessageChannel<ByteBuffer> dataChannel;
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
|
||||
@Override
|
||||
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
|
||||
GeneratedPluginRegistrant.registerWith(flutterEngine);
|
||||
|
||||
dataChannel = new BasicMessageChannel<ByteBuffer>(
|
||||
flutterEngine.getDartExecutor().getBinaryMessenger(),
|
||||
"data_change", BinaryCodec.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
ByteBuffer buffer = ByteBuffer.allocateDirect(4);
|
||||
if (data != null) {
|
||||
buffer.putInt(DATA_EXISTS);
|
||||
} else {
|
||||
buffer.putInt(DATA_NOT_EXISTS);
|
||||
}
|
||||
handler.post(() -> dataChannel.send(buffer));
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ import 'package:cake_wallet/entities/load_current_wallet.dart';
|
|||
import 'package:cake_wallet/entities/order.dart';
|
||||
import 'package:cake_wallet/entities/transaction_description.dart';
|
||||
import 'package:cake_wallet/entities/transaction_info.dart';
|
||||
import 'package:cake_wallet/entities/wyre_service.dart';
|
||||
import 'package:cake_wallet/monero/monero_wallet_service.dart';
|
||||
import 'package:cake_wallet/entities/contact.dart';
|
||||
import 'package:cake_wallet/entities/node.dart';
|
||||
|
@ -525,10 +526,16 @@ Future setup(
|
|||
getIt.registerFactoryParam<TradeDetailsPage, Trade, void>((Trade trade, _) =>
|
||||
TradeDetailsPage(getIt.get<TradeDetailsViewModel>(param1: trade)));
|
||||
|
||||
getIt.registerFactory(() {
|
||||
final wallet = getIt.get<AppStore>().wallet;
|
||||
return WyreService(walletType: wallet.type, walletAddress: wallet.address);
|
||||
});
|
||||
|
||||
getIt.registerFactory(() {
|
||||
final wallet = getIt.get<AppStore>().wallet;
|
||||
return WyreViewModel(ordersSource, getIt.get<OrdersStore>(),
|
||||
walletId: wallet.id, address: wallet.address, type: wallet.type);
|
||||
walletId: wallet.id, address: wallet.address, type: wallet.type,
|
||||
wyreService: getIt.get<WyreService>());
|
||||
});
|
||||
|
||||
getIt.registerFactoryParam<WyrePage, String, void>((String url, _) =>
|
||||
|
|
8
lib/entities/wyre_exception.dart
Normal file
8
lib/entities/wyre_exception.dart
Normal file
|
@ -0,0 +1,8 @@
|
|||
class WyreException implements Exception {
|
||||
WyreException(this.description);
|
||||
|
||||
String description;
|
||||
|
||||
@override
|
||||
String toString() => description;
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
import 'dart:convert';
|
||||
import 'package:cake_wallet/entities/wyre_exception.dart';
|
||||
import 'package:cake_wallet/exchange/trade_state.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:http/http.dart';
|
||||
|
@ -12,13 +13,17 @@ class WyreService {
|
|||
@required this.walletAddress,
|
||||
this.isTestEnvironment = false}) {
|
||||
baseApiUrl = isTestEnvironment
|
||||
? 'https://api.testwyre.com'
|
||||
: 'https://api.sendwyre.com';
|
||||
? _baseTestApiUrl
|
||||
: _baseProductApiUrl;
|
||||
trackUrl = isTestEnvironment
|
||||
? 'https://dash.testwyre.com/track/'
|
||||
: 'https://dash.sendwyre.com/track/';
|
||||
? _trackTestUrl
|
||||
: _trackProductUrl;
|
||||
}
|
||||
|
||||
static const _baseTestApiUrl = 'https://api.testwyre.com';
|
||||
static const _baseProductApiUrl = 'https://api.sendwyre.com';
|
||||
static const _trackTestUrl = 'https://dash.testwyre.com/track/';
|
||||
static const _trackProductUrl = 'https://dash.sendwyre.com/track/';
|
||||
static const _ordersSuffix = '/v3/orders';
|
||||
static const _reserveSuffix = '/reserve';
|
||||
static const _timeStampSuffix = '?timestamp=';
|
||||
|
@ -103,13 +108,4 @@ class WyreService {
|
|||
amount: amount.toString()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class WyreException implements Exception {
|
||||
WyreException(this.description);
|
||||
|
||||
String description;
|
||||
|
||||
@override
|
||||
String toString() => description;
|
||||
}
|
|
@ -12,8 +12,8 @@ class WyreViewModel = WyreViewModelBase with _$WyreViewModel;
|
|||
|
||||
abstract class WyreViewModelBase with Store {
|
||||
WyreViewModelBase(this.ordersSource, this.ordersStore,
|
||||
{@required this.walletId, @required this.address, @required this.type})
|
||||
: wyreService = WyreService(walletType: type, walletAddress: address);
|
||||
{@required this.walletId, @required this.address, @required this.type,
|
||||
@required this.wyreService});
|
||||
|
||||
Future<String> get wyreUrl => wyreService.getWyreUrl();
|
||||
|
||||
|
@ -26,7 +26,7 @@ abstract class WyreViewModelBase with Store {
|
|||
final WalletType type;
|
||||
final String address;
|
||||
|
||||
WyreService wyreService;
|
||||
final WyreService wyreService;
|
||||
|
||||
Future<void> saveOrder(String orderId) async {
|
||||
try {
|
||||
|
@ -39,6 +39,4 @@ abstract class WyreViewModelBase with Store {
|
|||
print(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue