diff --git a/wakelock_plus/android/src/main/kotlin/dev/fluttercommunity/plus/wakelock/WakelockPlusMessages.g.kt b/wakelock_plus/android/src/main/kotlin/dev/fluttercommunity/plus/wakelock/WakelockPlusMessages.g.kt index de4e18f..e6701b1 100644 --- a/wakelock_plus/android/src/main/kotlin/dev/fluttercommunity/plus/wakelock/WakelockPlusMessages.g.kt +++ b/wakelock_plus/android/src/main/kotlin/dev/fluttercommunity/plus/wakelock/WakelockPlusMessages.g.kt @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v21.2.0), do not edit directly. +// Autogenerated from Pigeon (v22.7.0), do not edit directly. // See also: https://pub.dev/packages/pigeon @file:Suppress("UNCHECKED_CAST", "ArrayInDataClass") @@ -6,7 +6,9 @@ import android.util.Log import io.flutter.plugin.common.BasicMessageChannel import io.flutter.plugin.common.BinaryMessenger +import io.flutter.plugin.common.EventChannel import io.flutter.plugin.common.MessageCodec +import io.flutter.plugin.common.StandardMethodCodec import io.flutter.plugin.common.StandardMessageCodec import java.io.ByteArrayOutputStream import java.nio.ByteBuffer @@ -86,7 +88,7 @@ data class IsEnabledMessage ( ) } } -private object WakelockPlusMessagesPigeonCodec : StandardMessageCodec() { +private open class WakelockPlusMessagesPigeonCodec : StandardMessageCodec() { override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { return when (type) { 129.toByte() -> { @@ -125,7 +127,7 @@ interface WakelockPlusApi { companion object { /** The codec used by WakelockPlusApi. */ val codec: MessageCodec by lazy { - WakelockPlusMessagesPigeonCodec + WakelockPlusMessagesPigeonCodec() } /** Sets up an instance of `WakelockPlusApi` to handle messages through the `binaryMessenger`. */ @JvmOverloads diff --git a/wakelock_plus/example/ios/Podfile.lock b/wakelock_plus/example/ios/Podfile.lock index 6ec0e84..48fcbdb 100644 --- a/wakelock_plus/example/ios/Podfile.lock +++ b/wakelock_plus/example/ios/Podfile.lock @@ -26,9 +26,9 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 integration_test: 252f60fa39af5e17c3aa9899d35d908a0721b573 - package_info_plus: 58f0028419748fad15bf008b270aaa8e54380b1c - wakelock_plus: 78ec7c5b202cab7761af8e2b2b3d0671be6c4ae1 + package_info_plus: c0502532a26c7662a62a356cebe2692ec5fe4ec4 + wakelock_plus: 373cfe59b235a6dd5837d0fb88791d2f13a90d56 PODFILE CHECKSUM: beab77b38961de946f08660e554f80ac174dc842 -COCOAPODS: 1.15.2 +COCOAPODS: 1.16.1 diff --git a/wakelock_plus/ios/Classes/WakelockPlusPlugin.m b/wakelock_plus/ios/Classes/WakelockPlusPlugin.m index 9532863..c5857fe 100644 --- a/wakelock_plus/ios/Classes/WakelockPlusPlugin.m +++ b/wakelock_plus/ios/Classes/WakelockPlusPlugin.m @@ -2,7 +2,7 @@ #import "messages.g.h" #import "UIApplication+idleTimerLock.h" -@interface WakelockPlusPlugin () +@interface WakelockPlusPlugin () @property (nonatomic, assign) BOOL enable; @@ -11,10 +11,10 @@ @interface WakelockPlusPlugin () @implementation WakelockPlusPlugin + (void)registerWithRegistrar:(NSObject*)registrar { WakelockPlusPlugin* instance = [[WakelockPlusPlugin alloc] init]; - SetUpFLTWakelockPlusApi(registrar.messenger, instance); + SetUpWAKELOCKPLUSWakelockPlusApi(registrar.messenger, instance); } -- (void)toggleMsg:(FLTToggleMessage*)input error:(FlutterError**)error { +- (void)toggleMsg:(WAKELOCKPLUSToggleMessage*)input error:(FlutterError**)error { BOOL enable = [input.enable boolValue]; if (!enable) { [[UIApplication sharedApplication] lock_idleTimerlockEnable:enable];//should disable first @@ -34,9 +34,9 @@ - (void)setIdleTimerDisabled:(BOOL)enable { } -- (FLTIsEnabledMessage*)isEnabledWithError:(FlutterError* __autoreleasing *)error { +- (WAKELOCKPLUSIsEnabledMessage*)isEnabledWithError:(FlutterError* __autoreleasing *)error { NSNumber *enabled = [NSNumber numberWithBool:[[UIApplication sharedApplication] isIdleTimerDisabled]]; - FLTIsEnabledMessage* result = [[FLTIsEnabledMessage alloc] init]; + WAKELOCKPLUSIsEnabledMessage* result = [[WAKELOCKPLUSIsEnabledMessage alloc] init]; result.enabled = enabled; return result; } diff --git a/wakelock_plus/ios/Classes/messages.g.h b/wakelock_plus/ios/Classes/messages.g.h index 3398c43..f73f840 100644 --- a/wakelock_plus/ios/Classes/messages.g.h +++ b/wakelock_plus/ios/Classes/messages.g.h @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v21.2.0), do not edit directly. +// Autogenerated from Pigeon (v22.7.0), do not edit directly. // See also: https://pub.dev/packages/pigeon #import @@ -10,32 +10,32 @@ NS_ASSUME_NONNULL_BEGIN -@class FLTToggleMessage; -@class FLTIsEnabledMessage; +@class WAKELOCKPLUSToggleMessage; +@class WAKELOCKPLUSIsEnabledMessage; /// Message for toggling the wakelock on the platform side. -@interface FLTToggleMessage : NSObject +@interface WAKELOCKPLUSToggleMessage : NSObject + (instancetype)makeWithEnable:(nullable NSNumber *)enable; @property(nonatomic, strong, nullable) NSNumber * enable; @end /// Message for reporting the wakelock state from the platform side. -@interface FLTIsEnabledMessage : NSObject +@interface WAKELOCKPLUSIsEnabledMessage : NSObject + (instancetype)makeWithEnabled:(nullable NSNumber *)enabled; @property(nonatomic, strong, nullable) NSNumber * enabled; @end /// The codec used by all APIs. -NSObject *FLTGetMessagesCodec(void); +NSObject *WAKELOCKPLUSGetMessagesCodec(void); -@protocol FLTWakelockPlusApi -- (void)toggleMsg:(FLTToggleMessage *)msg error:(FlutterError *_Nullable *_Nonnull)error; +@protocol WAKELOCKPLUSWakelockPlusApi +- (void)toggleMsg:(WAKELOCKPLUSToggleMessage *)msg error:(FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. -- (nullable FLTIsEnabledMessage *)isEnabledWithError:(FlutterError *_Nullable *_Nonnull)error; +- (nullable WAKELOCKPLUSIsEnabledMessage *)isEnabledWithError:(FlutterError *_Nullable *_Nonnull)error; @end -extern void SetUpFLTWakelockPlusApi(id binaryMessenger, NSObject *_Nullable api); +extern void SetUpWAKELOCKPLUSWakelockPlusApi(id binaryMessenger, NSObject *_Nullable api); -extern void SetUpFLTWakelockPlusApiWithSuffix(id binaryMessenger, NSObject *_Nullable api, NSString *messageChannelSuffix); +extern void SetUpWAKELOCKPLUSWakelockPlusApiWithSuffix(id binaryMessenger, NSObject *_Nullable api, NSString *messageChannelSuffix); NS_ASSUME_NONNULL_END diff --git a/wakelock_plus/ios/Classes/messages.g.m b/wakelock_plus/ios/Classes/messages.g.m index 19a06dd..9a7105c 100644 --- a/wakelock_plus/ios/Classes/messages.g.m +++ b/wakelock_plus/ios/Classes/messages.g.m @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v21.2.0), do not edit directly. +// Autogenerated from Pigeon (v22.7.0), do not edit directly. // See also: https://pub.dev/packages/pigeon #import "messages.g.h" @@ -27,31 +27,31 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) { return (result == [NSNull null]) ? nil : result; } -@interface FLTToggleMessage () -+ (FLTToggleMessage *)fromList:(NSArray *)list; -+ (nullable FLTToggleMessage *)nullableFromList:(NSArray *)list; +@interface WAKELOCKPLUSToggleMessage () ++ (WAKELOCKPLUSToggleMessage *)fromList:(NSArray *)list; ++ (nullable WAKELOCKPLUSToggleMessage *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end -@interface FLTIsEnabledMessage () -+ (FLTIsEnabledMessage *)fromList:(NSArray *)list; -+ (nullable FLTIsEnabledMessage *)nullableFromList:(NSArray *)list; +@interface WAKELOCKPLUSIsEnabledMessage () ++ (WAKELOCKPLUSIsEnabledMessage *)fromList:(NSArray *)list; ++ (nullable WAKELOCKPLUSIsEnabledMessage *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end -@implementation FLTToggleMessage +@implementation WAKELOCKPLUSToggleMessage + (instancetype)makeWithEnable:(nullable NSNumber *)enable { - FLTToggleMessage* pigeonResult = [[FLTToggleMessage alloc] init]; + WAKELOCKPLUSToggleMessage* pigeonResult = [[WAKELOCKPLUSToggleMessage alloc] init]; pigeonResult.enable = enable; return pigeonResult; } -+ (FLTToggleMessage *)fromList:(NSArray *)list { - FLTToggleMessage *pigeonResult = [[FLTToggleMessage alloc] init]; ++ (WAKELOCKPLUSToggleMessage *)fromList:(NSArray *)list { + WAKELOCKPLUSToggleMessage *pigeonResult = [[WAKELOCKPLUSToggleMessage alloc] init]; pigeonResult.enable = GetNullableObjectAtIndex(list, 0); return pigeonResult; } -+ (nullable FLTToggleMessage *)nullableFromList:(NSArray *)list { - return (list) ? [FLTToggleMessage fromList:list] : nil; ++ (nullable WAKELOCKPLUSToggleMessage *)nullableFromList:(NSArray *)list { + return (list) ? [WAKELOCKPLUSToggleMessage fromList:list] : nil; } - (NSArray *)toList { return @[ @@ -60,19 +60,19 @@ + (nullable FLTToggleMessage *)nullableFromList:(NSArray *)list { } @end -@implementation FLTIsEnabledMessage +@implementation WAKELOCKPLUSIsEnabledMessage + (instancetype)makeWithEnabled:(nullable NSNumber *)enabled { - FLTIsEnabledMessage* pigeonResult = [[FLTIsEnabledMessage alloc] init]; + WAKELOCKPLUSIsEnabledMessage* pigeonResult = [[WAKELOCKPLUSIsEnabledMessage alloc] init]; pigeonResult.enabled = enabled; return pigeonResult; } -+ (FLTIsEnabledMessage *)fromList:(NSArray *)list { - FLTIsEnabledMessage *pigeonResult = [[FLTIsEnabledMessage alloc] init]; ++ (WAKELOCKPLUSIsEnabledMessage *)fromList:(NSArray *)list { + WAKELOCKPLUSIsEnabledMessage *pigeonResult = [[WAKELOCKPLUSIsEnabledMessage alloc] init]; pigeonResult.enabled = GetNullableObjectAtIndex(list, 0); return pigeonResult; } -+ (nullable FLTIsEnabledMessage *)nullableFromList:(NSArray *)list { - return (list) ? [FLTIsEnabledMessage fromList:list] : nil; ++ (nullable WAKELOCKPLUSIsEnabledMessage *)nullableFromList:(NSArray *)list { + return (list) ? [WAKELOCKPLUSIsEnabledMessage fromList:list] : nil; } - (NSArray *)toList { return @[ @@ -81,29 +81,29 @@ + (nullable FLTIsEnabledMessage *)nullableFromList:(NSArray *)list { } @end -@interface FLTMessagesPigeonCodecReader : FlutterStandardReader +@interface WAKELOCKPLUSMessagesPigeonCodecReader : FlutterStandardReader @end -@implementation FLTMessagesPigeonCodecReader +@implementation WAKELOCKPLUSMessagesPigeonCodecReader - (nullable id)readValueOfType:(UInt8)type { switch (type) { case 129: - return [FLTToggleMessage fromList:[self readValue]]; + return [WAKELOCKPLUSToggleMessage fromList:[self readValue]]; case 130: - return [FLTIsEnabledMessage fromList:[self readValue]]; + return [WAKELOCKPLUSIsEnabledMessage fromList:[self readValue]]; default: return [super readValueOfType:type]; } } @end -@interface FLTMessagesPigeonCodecWriter : FlutterStandardWriter +@interface WAKELOCKPLUSMessagesPigeonCodecWriter : FlutterStandardWriter @end -@implementation FLTMessagesPigeonCodecWriter +@implementation WAKELOCKPLUSMessagesPigeonCodecWriter - (void)writeValue:(id)value { - if ([value isKindOfClass:[FLTToggleMessage class]]) { + if ([value isKindOfClass:[WAKELOCKPLUSToggleMessage class]]) { [self writeByte:129]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FLTIsEnabledMessage class]]) { + } else if ([value isKindOfClass:[WAKELOCKPLUSIsEnabledMessage class]]) { [self writeByte:130]; [self writeValue:[value toList]]; } else { @@ -112,43 +112,43 @@ - (void)writeValue:(id)value { } @end -@interface FLTMessagesPigeonCodecReaderWriter : FlutterStandardReaderWriter +@interface WAKELOCKPLUSMessagesPigeonCodecReaderWriter : FlutterStandardReaderWriter @end -@implementation FLTMessagesPigeonCodecReaderWriter +@implementation WAKELOCKPLUSMessagesPigeonCodecReaderWriter - (FlutterStandardWriter *)writerWithData:(NSMutableData *)data { - return [[FLTMessagesPigeonCodecWriter alloc] initWithData:data]; + return [[WAKELOCKPLUSMessagesPigeonCodecWriter alloc] initWithData:data]; } - (FlutterStandardReader *)readerWithData:(NSData *)data { - return [[FLTMessagesPigeonCodecReader alloc] initWithData:data]; + return [[WAKELOCKPLUSMessagesPigeonCodecReader alloc] initWithData:data]; } @end -NSObject *FLTGetMessagesCodec(void) { +NSObject *WAKELOCKPLUSGetMessagesCodec(void) { static FlutterStandardMessageCodec *sSharedObject = nil; static dispatch_once_t sPred = 0; dispatch_once(&sPred, ^{ - FLTMessagesPigeonCodecReaderWriter *readerWriter = [[FLTMessagesPigeonCodecReaderWriter alloc] init]; + WAKELOCKPLUSMessagesPigeonCodecReaderWriter *readerWriter = [[WAKELOCKPLUSMessagesPigeonCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void SetUpFLTWakelockPlusApi(id binaryMessenger, NSObject *api) { - SetUpFLTWakelockPlusApiWithSuffix(binaryMessenger, api, @""); +void SetUpWAKELOCKPLUSWakelockPlusApi(id binaryMessenger, NSObject *api) { + SetUpWAKELOCKPLUSWakelockPlusApiWithSuffix(binaryMessenger, api, @""); } -void SetUpFLTWakelockPlusApiWithSuffix(id binaryMessenger, NSObject *api, NSString *messageChannelSuffix) { +void SetUpWAKELOCKPLUSWakelockPlusApiWithSuffix(id binaryMessenger, NSObject *api, NSString *messageChannelSuffix) { messageChannelSuffix = messageChannelSuffix.length > 0 ? [NSString stringWithFormat: @".%@", messageChannelSuffix] : @""; { FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.wakelock_plus_platform_interface.WakelockPlusApi.toggle", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:FLTGetMessagesCodec()]; + codec:WAKELOCKPLUSGetMessagesCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(toggleMsg:error:)], @"FLTWakelockPlusApi api (%@) doesn't respond to @selector(toggleMsg:error:)", api); + NSCAssert([api respondsToSelector:@selector(toggleMsg:error:)], @"WAKELOCKPLUSWakelockPlusApi api (%@) doesn't respond to @selector(toggleMsg:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; - FLTToggleMessage *arg_msg = GetNullableObjectAtIndex(args, 0); + WAKELOCKPLUSToggleMessage *arg_msg = GetNullableObjectAtIndex(args, 0); FlutterError *error; [api toggleMsg:arg_msg error:&error]; callback(wrapResult(nil, error)); @@ -162,12 +162,12 @@ void SetUpFLTWakelockPlusApiWithSuffix(id binaryMessenge [[FlutterBasicMessageChannel alloc] initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.wakelock_plus_platform_interface.WakelockPlusApi.isEnabled", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:FLTGetMessagesCodec()]; + codec:WAKELOCKPLUSGetMessagesCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(isEnabledWithError:)], @"FLTWakelockPlusApi api (%@) doesn't respond to @selector(isEnabledWithError:)", api); + NSCAssert([api respondsToSelector:@selector(isEnabledWithError:)], @"WAKELOCKPLUSWakelockPlusApi api (%@) doesn't respond to @selector(isEnabledWithError:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { FlutterError *error; - FLTIsEnabledMessage *output = [api isEnabledWithError:&error]; + WAKELOCKPLUSIsEnabledMessage *output = [api isEnabledWithError:&error]; callback(wrapResult(output, error)); }]; } else { diff --git a/wakelock_plus/lib/src/web_impl/import_js_library.dart b/wakelock_plus/lib/src/web_impl/import_js_library.dart index b635c65..b998c6d 100644 --- a/wakelock_plus/lib/src/web_impl/import_js_library.dart +++ b/wakelock_plus/lib/src/web_impl/import_js_library.dart @@ -38,7 +38,7 @@ HTMLScriptElement _createScriptTag(String library) { return script; } -/// Injects a bunch of libraries in the and returns a +/// Injects a bunch of libraries in the `` and returns a /// Future that resolves when all load. Future _importJSLibraries(List libraries) { final loading = >[]; diff --git a/wakelock_plus/lib/src/web_impl/js_wakelock.dart b/wakelock_plus/lib/src/web_impl/js_wakelock.dart index ccbca5b..38b7822 100644 --- a/wakelock_plus/lib/src/web_impl/js_wakelock.dart +++ b/wakelock_plus/lib/src/web_impl/js_wakelock.dart @@ -1,5 +1,5 @@ @JS('Wakelock') -library wakelock.js; +library; import 'dart:js_interop'; diff --git a/wakelock_plus/pigeons/messages.dart b/wakelock_plus/pigeons/messages.dart index 9ee49a1..f179cf0 100644 --- a/wakelock_plus/pigeons/messages.dart +++ b/wakelock_plus/pigeons/messages.dart @@ -16,7 +16,7 @@ class IsEnabledMessage { objcHeaderOut: 'ios/Classes/messages.g.h', objcSourceOut: 'ios/Classes/messages.g.m', objcOptions: ObjcOptions( - prefix: 'FLT', + prefix: 'WAKELOCKPLUS', ), kotlinOptions: KotlinOptions(errorClassName: "WakelockPlusFlutterError"), kotlinOut: diff --git a/wakelock_plus/pubspec.yaml b/wakelock_plus/pubspec.yaml index 16e0470..b1170b3 100644 --- a/wakelock_plus/pubspec.yaml +++ b/wakelock_plus/pubspec.yaml @@ -31,8 +31,8 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^3.0.2 - pigeon: ^21.2.0 # dart run pigeon --input "pigeons/messages.dart" + flutter_lints: ^5.0.0 + pigeon: ^22.7.0 # dart run pigeon --input "pigeons/messages.dart" # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/wakelock_plus/test/wakelock_plus_web_plugin_test.dart b/wakelock_plus/test/wakelock_plus_web_plugin_test.dart index f5d9ebe..869b576 100644 --- a/wakelock_plus/test/wakelock_plus_web_plugin_test.dart +++ b/wakelock_plus/test/wakelock_plus_web_plugin_test.dart @@ -1,5 +1,5 @@ @TestOn('browser') -library wakelock_plus_library_plugin_test; +library; import 'package:flutter_test/flutter_test.dart'; import 'package:wakelock_plus/src/wakelock_plus_web_plugin.dart'; diff --git a/wakelock_plus_platform_interface/lib/messages.g.dart b/wakelock_plus_platform_interface/lib/messages.g.dart index 14bdf76..fac93c4 100644 --- a/wakelock_plus_platform_interface/lib/messages.g.dart +++ b/wakelock_plus_platform_interface/lib/messages.g.dart @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v21.2.0), do not edit directly. +// Autogenerated from Pigeon (v22.7.0), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers @@ -74,7 +74,10 @@ class _PigeonCodec extends StandardMessageCodec { const _PigeonCodec(); @override void writeValue(WriteBuffer buffer, Object? value) { - if (value is ToggleMessage) { + if (value is int) { + buffer.putUint8(4); + buffer.putInt64(value); + } else if (value is ToggleMessage) { buffer.putUint8(129); writeValue(buffer, value.encode()); } else if (value is IsEnabledMessage) { diff --git a/wakelock_plus_platform_interface/pubspec.yaml b/wakelock_plus_platform_interface/pubspec.yaml index cb3b825..69fc105 100644 --- a/wakelock_plus_platform_interface/pubspec.yaml +++ b/wakelock_plus_platform_interface/pubspec.yaml @@ -20,4 +20,4 @@ dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^4.0.0 + flutter_lints: ^5.0.0 diff --git a/wakelock_plus_platform_interface/test/messages.g.dart b/wakelock_plus_platform_interface/test/messages.g.dart index c458d1f..3175f44 100644 --- a/wakelock_plus_platform_interface/test/messages.g.dart +++ b/wakelock_plus_platform_interface/test/messages.g.dart @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v21.2.0), do not edit directly. +// Autogenerated from Pigeon (v22.7.0), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, unnecessary_import, no_leading_underscores_for_local_identifiers // ignore_for_file: avoid_relative_lib_imports @@ -14,7 +14,10 @@ class _PigeonCodec extends StandardMessageCodec { const _PigeonCodec(); @override void writeValue(WriteBuffer buffer, Object? value) { - if (value is ToggleMessage) { + if (value is int) { + buffer.putUint8(4); + buffer.putInt64(value); + } else if (value is ToggleMessage) { buffer.putUint8(129); writeValue(buffer, value.encode()); } else if (value is IsEnabledMessage) {