Skip to content

Commit

Permalink
Merge pull request #40 from diegotori/android_gradle_8.0_upgrade_fixes
Browse files Browse the repository at this point in the history
Android Gradle 8.x upgrade fixes
  • Loading branch information
diegotori authored Apr 2, 2024
2 parents a7cd961 + 0bb5cb0 commit e8f6642
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 17 deletions.
38 changes: 36 additions & 2 deletions wakelock_plus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,23 @@
[![Pub version](https://img.shields.io/pub/v/wakelock_plus.svg)](https://pub.dev/packages/wakelock_plus) [![GitHub stars](https://img.shields.io/github/stars/fluttercommunity/wakelock_plus.svg)](https://github.com/fluttercommunity/wakelock_plus)
A continuation of the original [wakelock](https://github.com/creativecreatorormaybenot/wakelock) Flutter Plugin written by [creativecreatorormaybenot](https://github.com/creativecreatorormaybenot) that allows you to keep the device screen awake, i.e. prevent the screen from sleeping.

---

You can enable and toggle the screen wakelock, which prevents the screen from turning off
automatically.

---

## Table of Contents
1. [Supported Platforms](#supported-platforms)
2. [Usage](#usage)
1. [Implementation](#implementation)
2. [Ensure the `WidgetsBinding` is initialized](#ensure-the-widgetsbinding-is-initialized)
3. [Calling `WakelockPlus.enable()` in `main()`](#calling-wakelockplusenable-in-main)
3. [Platform Specific Integration Instructions](#platform-specific-integration-instructions)
1. [Android](#android)
4. [Learn More](#learn-more)

---

## Supported Platforms

| Platform | `wakelock_plus` support |
Expand Down Expand Up @@ -112,6 +124,28 @@ This is why you should instead prefer to enable the wakelock whenever components
that require the screen to stay on are active. This can e.g. happen in the `build` method of your
widget.

## Platform Specific Integration Instructions

### Android

When building your app on Android and using this library, you may be prompted by the following:

```bash
One or more plugins require a higher Android NDK version.
```

If this occurs, simply add the NDK version specified in the error message in your `app` module's
`build.gradle` file's `android` closure. For example:

```gradle
android {
// Current version at the time of this writing.
// Use the version specified by the error message.
ndkVersion "25.1.8937393"
//....
}
```

## Learn more

If you want to learn more about how this plugin works, how to contribute, etc., you can read
Expand Down
16 changes: 14 additions & 2 deletions wakelock_plus/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
group 'dev.fluttercommunity.plus.wakelock'
version '1.0-SNAPSHOT'

allprojects {
buildscript {
ext.kotlin_version = '1.7.22'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:8.3.1'
}
}

rootProject.allprojects {
repositories {
google()
mavenCentral()
Expand Down Expand Up @@ -38,7 +50,7 @@ android {
}

dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.23'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
testImplementation 'org.jetbrains.kotlin:kotlin-test'
testImplementation 'org.mockito:mockito-core:5.0.0'
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Autogenerated from Pigeon (v17.2.0), do not edit directly.
// Autogenerated from Pigeon (v17.3.0), do not edit directly.
// See also: https://pub.dev/packages/pigeon


Expand Down
4 changes: 2 additions & 2 deletions wakelock_plus/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ if (flutterVersionName == null) {
}

android {
namespace 'dev.fluttercommunity.plus.wakelock_example'
compileSdk 34
ndkVersion '25.1.8937393'
ndkVersion "25.1.8937393"
namespace 'dev.fluttercommunity.plus.wakelock_example'

compileOptions {
sourceCompatibility JavaVersion.VERSION_17
Expand Down
4 changes: 2 additions & 2 deletions wakelock_plus/example/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pluginManagement {

plugins {
id 'dev.flutter.flutter-plugin-loader' version '1.0.0'
id 'com.android.application' version '8.3.0' apply false
id 'org.jetbrains.kotlin.android' version '1.9.22' apply false
id 'com.android.application' version '8.3.1' apply false
id 'org.jetbrains.kotlin.android' version '1.8.22' apply false
}
include ':app'
2 changes: 1 addition & 1 deletion wakelock_plus/ios/Classes/messages.g.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Autogenerated from Pigeon (v17.2.0), do not edit directly.
// Autogenerated from Pigeon (v17.3.0), do not edit directly.
// See also: https://pub.dev/packages/pigeon

#import <Foundation/Foundation.h>
Expand Down
2 changes: 1 addition & 1 deletion wakelock_plus/ios/Classes/messages.g.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Autogenerated from Pigeon (v17.2.0), do not edit directly.
// Autogenerated from Pigeon (v17.3.0), do not edit directly.
// See also: https://pub.dev/packages/pigeon

#import "messages.g.h"
Expand Down
5 changes: 3 additions & 2 deletions wakelock_plus/lib/src/wakelock_plus_windows_plugin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ class WakelockPlusWindowsPlugin extends WakelockPlusPlatformInterface {
Future<void> toggle({required bool enable}) async {
final int response;
if (enable) {
response = SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
response = SetThreadExecutionState(
EXECUTION_STATE.ES_CONTINUOUS | EXECUTION_STATE.ES_DISPLAY_REQUIRED);
} else {
response = SetThreadExecutionState(ES_CONTINUOUS);
response = SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS);
}

// SetThreadExecutionState returns 0 if the operation failed.
Expand Down
4 changes: 2 additions & 2 deletions wakelock_plus/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^3.0.1
pigeon: ^17.2.0 # dart run pigeon --input "pigeons/messages.dart"
flutter_lints: ^3.0.2
pigeon: ^17.3.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
Expand Down
2 changes: 1 addition & 1 deletion wakelock_plus_platform_interface/lib/messages.g.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Autogenerated from Pigeon (v17.2.0), do not edit directly.
// Autogenerated from Pigeon (v17.3.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

Expand Down
2 changes: 1 addition & 1 deletion wakelock_plus_platform_interface/test/messages.g.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Autogenerated from Pigeon (v17.2.0), do not edit directly.
// Autogenerated from Pigeon (v17.3.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
Expand Down

0 comments on commit e8f6642

Please sign in to comment.