mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 19:49:22 +00:00
- Remove legacy migration from macos
- Remove wake lock native code and just use the ready made package
This commit is contained in:
parent
e8c1d86373
commit
90a7432bf9
8 changed files with 6 additions and 120 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 */; };
|
||||
20ED0868E1BD7E12278C0CB3 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B26E3F56D69167FBB1DC160A /* Pods_Runner.framework */; };
|
||||
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 */; };
|
||||
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
|
||||
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
|
||||
|
@ -280,7 +279,6 @@
|
|||
files = (
|
||||
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
|
||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
|
||||
5AFFEBFD279AD49C00F906A4 /* wakeLock.swift in Sources */,
|
||||
0C9D68C9264854B60011B691 /* secRandom.swift in Sources */,
|
||||
0C44A71A2518EF8000B570ED /* decrypt.swift in Sources */,
|
||||
);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import 'package:cake_wallet/core/yat_service.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_gift_card.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_tip.dart';
|
||||
|
@ -704,8 +703,6 @@ Future setup(
|
|||
param1: item, param2: unspentCoinsListViewModel));
|
||||
});
|
||||
|
||||
getIt.registerFactory(() => WakeLock());
|
||||
|
||||
getIt.registerFactory(() => YatService());
|
||||
|
||||
getIt.registerFactory(() => AddressResolver(yatService: getIt.get<YatService>(),
|
||||
|
|
|
@ -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/wake_lock.dart';
|
||||
import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart';
|
||||
import 'package:cw_core/wallet_type.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/transaction_info.dart';
|
||||
import 'package:cw_core/sync_status.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:wakelock/wakelock.dart';
|
||||
|
||||
ReactionDisposer? _onWalletSyncStatusChangeReaction;
|
||||
|
||||
|
@ -17,7 +15,6 @@ void startWalletSyncStatusChangeReaction(
|
|||
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>,
|
||||
TransactionInfo> wallet,
|
||||
FiatConversionStore fiatConversionStore) {
|
||||
final _wakeLock = getIt.get<WakeLock>();
|
||||
_onWalletSyncStatusChangeReaction?.reaction.dispose();
|
||||
_onWalletSyncStatusChangeReaction =
|
||||
reaction((_) => wallet.syncStatus, (SyncStatus status) async {
|
||||
|
@ -30,10 +27,10 @@ void startWalletSyncStatusChangeReaction(
|
|||
}
|
||||
}
|
||||
if (status is SyncingSyncStatus) {
|
||||
await _wakeLock.enableWake();
|
||||
await Wakelock.enable();
|
||||
}
|
||||
if (status is SyncedSyncStatus || status is FailedSyncStatus) {
|
||||
await _wakeLock.disableWake();
|
||||
await Wakelock.disable();
|
||||
}
|
||||
} catch(e) {
|
||||
print(e.toString());
|
||||
|
|
|
@ -16,6 +16,7 @@ import platform_device_id_macos
|
|||
import share_plus_macos
|
||||
import shared_preferences_foundation
|
||||
import url_launcher_macos
|
||||
import wakelock_macos
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin"))
|
||||
|
@ -29,4 +30,5 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
|||
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
|
||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
||||
WakelockMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockMacosPlugin"))
|
||||
}
|
||||
|
|
|
@ -8,54 +8,8 @@ class AppDelegate: FlutterAppDelegate {
|
|||
return true
|
||||
}
|
||||
|
||||
var assertionID: IOPMAssertionID = 0
|
||||
|
||||
override func applicationDidFinishLaunching(_ notification: Notification) {
|
||||
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(
|
||||
name: "com.cake_wallet/native_utils",
|
||||
|
@ -70,32 +24,10 @@ class AppDelegate: FlutterAppDelegate {
|
|||
}
|
||||
|
||||
result(secRandom(count: count))
|
||||
case "getUnstoppableDomainAddress":
|
||||
// Not supported on macos
|
||||
result(nil)
|
||||
case "enableWakeScreen":
|
||||
result(self?.enableWakeScreen())
|
||||
|
||||
case "disableWakeScreen":
|
||||
result(self?.disableWakeScreen())
|
||||
|
||||
default:
|
||||
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
|
||||
device_display_brightness: ^0.0.6
|
||||
platform_device_id: ^1.0.1
|
||||
wakelock: ^0.6.2
|
||||
cake_backup:
|
||||
git:
|
||||
url: https://github.com/cake-tech/cake_backup.git
|
||||
|
|
Loading…
Reference in a new issue