mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 03:59:23 +00:00
Merge branch 'mac-os-fixes' of https://github.com/cake-tech/cake_wallet into dashboard-desktop-view
This commit is contained in:
commit
de2b887a9b
10 changed files with 18 additions and 134 deletions
|
@ -1,20 +0,0 @@
|
||||||
//
|
|
||||||
// wakeLock.swift
|
|
||||||
// Runner
|
|
||||||
//
|
|
||||||
// Created by Godwin Asuquo on 1/21/22.
|
|
||||||
//
|
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
func enableWakeScreen() -> Bool{
|
|
||||||
UIApplication.shared.isIdleTimerDisabled = true
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func disableWakeScreen() -> Bool{
|
|
||||||
UIApplication.shared.isIdleTimerDisabled = false
|
|
||||||
return true
|
|
||||||
}
|
|
|
@ -12,7 +12,6 @@
|
||||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
|
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
|
||||||
20ED0868E1BD7E12278C0CB3 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B26E3F56D69167FBB1DC160A /* Pods_Runner.framework */; };
|
20ED0868E1BD7E12278C0CB3 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B26E3F56D69167FBB1DC160A /* Pods_Runner.framework */; };
|
||||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
||||||
5AFFEBFD279AD49C00F906A4 /* wakeLock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AFFEBFC279AD49C00F906A4 /* wakeLock.swift */; };
|
|
||||||
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
|
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
|
||||||
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
|
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
|
||||||
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
|
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
|
||||||
|
@ -280,7 +279,6 @@
|
||||||
files = (
|
files = (
|
||||||
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
|
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
|
||||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
|
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
|
||||||
5AFFEBFD279AD49C00F906A4 /* wakeLock.swift in Sources */,
|
|
||||||
0C9D68C9264854B60011B691 /* secRandom.swift in Sources */,
|
0C9D68C9264854B60011B691 /* secRandom.swift in Sources */,
|
||||||
0C44A71A2518EF8000B570ED /* decrypt.swift in Sources */,
|
0C44A71A2518EF8000B570ED /* decrypt.swift in Sources */,
|
||||||
);
|
);
|
||||||
|
|
|
@ -96,11 +96,6 @@ import UnstoppableDomainsResolution
|
||||||
|
|
||||||
result(address)
|
result(address)
|
||||||
}
|
}
|
||||||
case "enableWakeScreen":
|
|
||||||
result(enableWakeScreen())
|
|
||||||
|
|
||||||
case "disableWakeScreen":
|
|
||||||
result(disableWakeScreen())
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
result(FlutterMethodNotImplemented)
|
result(FlutterMethodNotImplemented)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import 'package:cake_wallet/core/yat_service.dart';
|
import 'package:cake_wallet/core/yat_service.dart';
|
||||||
import 'package:cake_wallet/entities/parse_address_from_domain.dart';
|
import 'package:cake_wallet/entities/parse_address_from_domain.dart';
|
||||||
import 'package:cake_wallet/entities/wake_lock.dart';
|
|
||||||
import 'package:cake_wallet/ionia/ionia_anypay.dart';
|
import 'package:cake_wallet/ionia/ionia_anypay.dart';
|
||||||
import 'package:cake_wallet/ionia/ionia_gift_card.dart';
|
import 'package:cake_wallet/ionia/ionia_gift_card.dart';
|
||||||
import 'package:cake_wallet/ionia/ionia_tip.dart';
|
import 'package:cake_wallet/ionia/ionia_tip.dart';
|
||||||
|
@ -705,8 +704,6 @@ Future setup(
|
||||||
param1: item, param2: unspentCoinsListViewModel));
|
param1: item, param2: unspentCoinsListViewModel));
|
||||||
});
|
});
|
||||||
|
|
||||||
getIt.registerFactory(() => WakeLock());
|
|
||||||
|
|
||||||
getIt.registerFactory(() => YatService());
|
getIt.registerFactory(() => YatService());
|
||||||
|
|
||||||
getIt.registerFactory(() => AddressResolver(yatService: getIt.get<YatService>(),
|
getIt.registerFactory(() => AddressResolver(yatService: getIt.get<YatService>(),
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
const channel = MethodChannel('com.cake_wallet/native_utils');
|
const channel = MethodChannel('com.cake_wallet/native_utils');
|
||||||
|
@ -6,6 +8,7 @@ Future<String> fetchUnstoppableDomainAddress(String domain, String ticker) async
|
||||||
var address = '';
|
var address = '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (Platform.isAndroid || Platform.isIOS) {
|
||||||
address = await channel.invokeMethod<String>(
|
address = await channel.invokeMethod<String>(
|
||||||
'getUnstoppableDomainAddress',
|
'getUnstoppableDomainAddress',
|
||||||
<String, String> {
|
<String, String> {
|
||||||
|
@ -13,6 +16,10 @@ Future<String> fetchUnstoppableDomainAddress(String domain, String ticker) async
|
||||||
'ticker' : ticker
|
'ticker' : ticker
|
||||||
}
|
}
|
||||||
) ?? '';
|
) ?? '';
|
||||||
|
} else {
|
||||||
|
// TODO: Integrate with Unstoppable domains resolution API
|
||||||
|
return address;
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Unstoppable domain error: ${e.toString()}');
|
print('Unstoppable domain error: ${e.toString()}');
|
||||||
address = '';
|
address = '';
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
|
|
||||||
class WakeLock {
|
|
||||||
static const _utils = const MethodChannel('com.cake_wallet/native_utils');
|
|
||||||
|
|
||||||
Future<void> enableWake() async {
|
|
||||||
try {
|
|
||||||
await _utils.invokeMethod<bool>('enableWakeScreen');
|
|
||||||
} on PlatformException catch (_) {
|
|
||||||
print('Failed enabling screen wakelock');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> disableWake() async {
|
|
||||||
try {
|
|
||||||
await _utils.invokeMethod<bool>('disableWakeScreen');
|
|
||||||
} on PlatformException catch (_) {
|
|
||||||
print('Failed enabling screen wakelock');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,4 @@
|
||||||
import 'package:cake_wallet/di.dart';
|
|
||||||
import 'package:cake_wallet/entities/update_haven_rate.dart';
|
import 'package:cake_wallet/entities/update_haven_rate.dart';
|
||||||
import 'package:cake_wallet/entities/wake_lock.dart';
|
|
||||||
import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart';
|
import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart';
|
||||||
import 'package:cw_core/wallet_type.dart';
|
import 'package:cw_core/wallet_type.dart';
|
||||||
import 'package:mobx/mobx.dart';
|
import 'package:mobx/mobx.dart';
|
||||||
|
@ -9,7 +7,7 @@ import 'package:cw_core/wallet_base.dart';
|
||||||
import 'package:cw_core/balance.dart';
|
import 'package:cw_core/balance.dart';
|
||||||
import 'package:cw_core/transaction_info.dart';
|
import 'package:cw_core/transaction_info.dart';
|
||||||
import 'package:cw_core/sync_status.dart';
|
import 'package:cw_core/sync_status.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:wakelock/wakelock.dart';
|
||||||
|
|
||||||
ReactionDisposer? _onWalletSyncStatusChangeReaction;
|
ReactionDisposer? _onWalletSyncStatusChangeReaction;
|
||||||
|
|
||||||
|
@ -17,7 +15,6 @@ void startWalletSyncStatusChangeReaction(
|
||||||
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>,
|
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>,
|
||||||
TransactionInfo> wallet,
|
TransactionInfo> wallet,
|
||||||
FiatConversionStore fiatConversionStore) {
|
FiatConversionStore fiatConversionStore) {
|
||||||
final _wakeLock = getIt.get<WakeLock>();
|
|
||||||
_onWalletSyncStatusChangeReaction?.reaction.dispose();
|
_onWalletSyncStatusChangeReaction?.reaction.dispose();
|
||||||
_onWalletSyncStatusChangeReaction =
|
_onWalletSyncStatusChangeReaction =
|
||||||
reaction((_) => wallet.syncStatus, (SyncStatus status) async {
|
reaction((_) => wallet.syncStatus, (SyncStatus status) async {
|
||||||
|
@ -30,10 +27,10 @@ void startWalletSyncStatusChangeReaction(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (status is SyncingSyncStatus) {
|
if (status is SyncingSyncStatus) {
|
||||||
await _wakeLock.enableWake();
|
await Wakelock.enable();
|
||||||
}
|
}
|
||||||
if (status is SyncedSyncStatus || status is FailedSyncStatus) {
|
if (status is SyncedSyncStatus || status is FailedSyncStatus) {
|
||||||
await _wakeLock.disableWake();
|
await Wakelock.disable();
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
print(e.toString());
|
print(e.toString());
|
||||||
|
|
|
@ -34,8 +34,6 @@ target 'Runner' do
|
||||||
|
|
||||||
# Cake Wallet (Legacy)
|
# Cake Wallet (Legacy)
|
||||||
pod 'CryptoSwift'
|
pod 'CryptoSwift'
|
||||||
# Not supported on macos
|
|
||||||
# pod 'UnstoppableDomainsResolution', '~> 5.0.0'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
post_install do |installer|
|
post_install do |installer|
|
||||||
|
|
|
@ -8,54 +8,8 @@ class AppDelegate: FlutterAppDelegate {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
var assertionID: IOPMAssertionID = 0
|
|
||||||
|
|
||||||
override func applicationDidFinishLaunching(_ notification: Notification) {
|
override func applicationDidFinishLaunching(_ notification: Notification) {
|
||||||
let controller : FlutterViewController = mainFlutterWindow?.contentViewController as! FlutterViewController
|
let controller : FlutterViewController = mainFlutterWindow?.contentViewController as! FlutterViewController
|
||||||
let legacyMigrationChannel = FlutterMethodChannel(
|
|
||||||
name: "com.cakewallet.cakewallet/legacy_wallet_migration",
|
|
||||||
binaryMessenger: controller.engine.binaryMessenger)
|
|
||||||
legacyMigrationChannel.setMethodCallHandler({
|
|
||||||
(call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in
|
|
||||||
|
|
||||||
switch call.method {
|
|
||||||
case "decrypt":
|
|
||||||
guard let args = call.arguments as? Dictionary<String, Any>,
|
|
||||||
let data = args["bytes"] as? FlutterStandardTypedData,
|
|
||||||
let key = args["key"] as? String,
|
|
||||||
let salt = args["salt"] as? String else {
|
|
||||||
result(nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
let content = decrypt(data: data.data, key: key, salt: salt)
|
|
||||||
result(content)
|
|
||||||
case "read_user_defaults":
|
|
||||||
guard let args = call.arguments as? Dictionary<String, Any>,
|
|
||||||
let key = args["key"] as? String,
|
|
||||||
let type = args["type"] as? String else {
|
|
||||||
result(nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var value: Any?
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case "string":
|
|
||||||
value = UserDefaults.standard.string(forKey: key)
|
|
||||||
case "int":
|
|
||||||
value = UserDefaults.standard.integer(forKey: key)
|
|
||||||
case "bool":
|
|
||||||
value = UserDefaults.standard.bool(forKey: key)
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
result(value)
|
|
||||||
default:
|
|
||||||
result(FlutterMethodNotImplemented)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
let utilsChannel = FlutterMethodChannel(
|
let utilsChannel = FlutterMethodChannel(
|
||||||
name: "com.cake_wallet/native_utils",
|
name: "com.cake_wallet/native_utils",
|
||||||
|
@ -70,32 +24,10 @@ class AppDelegate: FlutterAppDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
result(secRandom(count: count))
|
result(secRandom(count: count))
|
||||||
case "getUnstoppableDomainAddress":
|
|
||||||
// Not supported on macos
|
|
||||||
result(nil)
|
|
||||||
case "enableWakeScreen":
|
|
||||||
result(self?.enableWakeScreen())
|
|
||||||
|
|
||||||
case "disableWakeScreen":
|
|
||||||
result(self?.disableWakeScreen())
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
result(FlutterMethodNotImplemented)
|
result(FlutterMethodNotImplemented)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func enableWakeScreen(reason: String = "Disabling display sleep") -> Bool{
|
|
||||||
return IOPMAssertionCreateWithName( kIOPMAssertionTypeNoDisplaySleep as CFString,
|
|
||||||
IOPMAssertionLevel(kIOPMAssertionLevelOn),
|
|
||||||
reason as CFString,
|
|
||||||
&assertionID) == kIOReturnSuccess
|
|
||||||
}
|
|
||||||
|
|
||||||
func disableWakeScreen() -> Bool{
|
|
||||||
IOPMAssertionRelease(assertionID)
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@ dependencies:
|
||||||
permission_handler: ^10.0.0
|
permission_handler: ^10.0.0
|
||||||
device_display_brightness: ^0.0.6
|
device_display_brightness: ^0.0.6
|
||||||
platform_device_id: ^1.0.1
|
platform_device_id: ^1.0.1
|
||||||
|
wakelock: ^0.6.2
|
||||||
cake_backup:
|
cake_backup:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/cake-tech/cake_backup.git
|
url: https://github.com/cake-tech/cake_backup.git
|
||||||
|
|
Loading…
Reference in a new issue