From 2838bf2dac168937ad19ed4301633c320b4aa4c0 Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Thu, 18 Nov 2021 12:41:22 +0100 Subject: [PATCH 01/10] Fixed No such element exception --- .../kotlin/fr/g123k/torch_compat/impl/TorchCamera2Impl.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/src/main/kotlin/fr/g123k/torch_compat/impl/TorchCamera2Impl.kt b/android/src/main/kotlin/fr/g123k/torch_compat/impl/TorchCamera2Impl.kt index 08feb2d..c4e1ff5 100644 --- a/android/src/main/kotlin/fr/g123k/torch_compat/impl/TorchCamera2Impl.kt +++ b/android/src/main/kotlin/fr/g123k/torch_compat/impl/TorchCamera2Impl.kt @@ -10,9 +10,9 @@ import androidx.annotation.RequiresApi class TorchCamera2Impl(context: Context) : BaseTorch() { private val cameraManager = context.getSystemService(Context.CAMERA_SERVICE) as CameraManager - private val cameraId = cameraManager.cameraIdList.first { cameraId -> + private val cameraId = cameraManager.cameraIdList.firstOrNull { cameraId -> cameraManager.getCameraCharacteristics(cameraId)[CameraCharacteristics.FLASH_INFO_AVAILABLE] != null - } ?: null + } override fun turnOn() { turn(on = true) From 6681e5938c6206cefd1bac77a4142d73c269968d Mon Sep 17 00:00:00 2001 From: WilliamVerhaeghe Date: Wed, 2 Nov 2022 11:38:24 +0100 Subject: [PATCH 02/10] Ignore not initialized exception --- .../main/kotlin/fr/g123k/torch_compat/TorchCompatPlugin.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/android/src/main/kotlin/fr/g123k/torch_compat/TorchCompatPlugin.kt b/android/src/main/kotlin/fr/g123k/torch_compat/TorchCompatPlugin.kt index ca2f07a..81181c6 100644 --- a/android/src/main/kotlin/fr/g123k/torch_compat/TorchCompatPlugin.kt +++ b/android/src/main/kotlin/fr/g123k/torch_compat/TorchCompatPlugin.kt @@ -104,6 +104,10 @@ class TorchCompatPlugin: FlutterPlugin, MethodCallHandler, ActivityAware { override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { channel.setMethodCallHandler(null) - torchImpl.dispose() + try { + torchImpl.dispose() + } catch (e: UninitializedPropertyAccessException) { + // ignore + } } } From bb9621f52bdb7b241210078858666f3febcdaf6d Mon Sep 17 00:00:00 2001 From: WilliamVerhaeghe Date: Mon, 17 Jul 2023 14:02:00 +0200 Subject: [PATCH 03/10] Update kotlin version --- android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index cf370f8..7c17316 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,7 +2,7 @@ group 'fr.g123k.torch_compat' version '1.0-SNAPSHOT' buildscript { - ext.kotlin_version = '1.3.50' + ext.kotlin_version = '1.6.10' repositories { google() mavenCentral() From ec142c38c3b28d07657acc6e40fd83f499bdbd05 Mon Sep 17 00:00:00 2001 From: WilliamVerhaeghe Date: Thu, 26 Oct 2023 14:28:35 +0200 Subject: [PATCH 04/10] Updated flutter version + renamed to icapps --- .fvm/flutter_sdk | 1 + .fvm/fvm_config.json | 4 ++++ CHANGELOG.md | 6 ++++++ android/build.gradle | 2 +- android/src/main/AndroidManifest.xml | 2 +- .../icapps}/torch_compat/TorchCompatPlugin.kt | 8 ++++---- .../icapps}/torch_compat/impl/BaseTorch.kt | 2 +- .../icapps}/torch_compat/impl/TorchCamera1Impl.kt | 2 +- .../icapps}/torch_compat/impl/TorchCamera2Impl.kt | 2 +- example/analysis_options.yaml | 1 - example/android/app/build.gradle | 2 +- example/android/app/src/debug/AndroidManifest.xml | 2 +- example/android/app/src/main/AndroidManifest.xml | 2 +- .../fr/g123k/torch_compat_example/MainActivity.kt | 2 +- example/android/app/src/profile/AndroidManifest.xml | 2 +- example/ios/Runner.xcodeproj/project.pbxproj | 6 +++--- example/lib/main.dart | 7 +++---- example/test/widget_test.dart | 5 ++--- lib/icapps_torch_compat.dart | 1 + lib/{ => src}/torch_compat.dart | 0 pubspec.yaml | 12 +++++------- test/torch_compat_test.dart | 4 ---- 22 files changed, 39 insertions(+), 36 deletions(-) create mode 120000 .fvm/flutter_sdk create mode 100644 .fvm/fvm_config.json rename android/src/main/kotlin/{fr/g123k => com/icapps}/torch_compat/TorchCompatPlugin.kt (94%) rename android/src/main/kotlin/{fr/g123k => com/icapps}/torch_compat/impl/BaseTorch.kt (80%) rename android/src/main/kotlin/{fr/g123k => com/icapps}/torch_compat/impl/TorchCamera1Impl.kt (97%) rename android/src/main/kotlin/{fr/g123k => com/icapps}/torch_compat/impl/TorchCamera2Impl.kt (96%) create mode 100644 lib/icapps_torch_compat.dart rename lib/{ => src}/torch_compat.dart (100%) diff --git a/.fvm/flutter_sdk b/.fvm/flutter_sdk new file mode 120000 index 0000000..8d6f8f2 --- /dev/null +++ b/.fvm/flutter_sdk @@ -0,0 +1 @@ +/Users/williamverhaeghe/fvm/versions/3.13.9 \ No newline at end of file diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json new file mode 100644 index 0000000..d8abe1b --- /dev/null +++ b/.fvm/fvm_config.json @@ -0,0 +1,4 @@ +{ + "flutterSdkVersion": "3.13.9", + "flavors": {} +} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 69b4301..46f5ca5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [2.0.0] - 26th October 2023 + +* *Breacking* Update to Dart 3 +* Fixed Android crash startup +* Fixed Android crash background + ## [1.0.2] - 23rd March 2020 * Fix: `asTorch` not working on iOS #4 diff --git a/android/build.gradle b/android/build.gradle index 7c17316..c5ab7b6 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,4 +1,4 @@ -group 'fr.g123k.torch_compat' +group 'com.icapps.torch_compat' version '1.0-SNAPSHOT' buildscript { diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 76355c1..d2d73ab 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -1,3 +1,3 @@ + package="com.icapps.torch_compat"> diff --git a/android/src/main/kotlin/fr/g123k/torch_compat/TorchCompatPlugin.kt b/android/src/main/kotlin/com/icapps/torch_compat/TorchCompatPlugin.kt similarity index 94% rename from android/src/main/kotlin/fr/g123k/torch_compat/TorchCompatPlugin.kt rename to android/src/main/kotlin/com/icapps/torch_compat/TorchCompatPlugin.kt index 81181c6..f22269f 100644 --- a/android/src/main/kotlin/fr/g123k/torch_compat/TorchCompatPlugin.kt +++ b/android/src/main/kotlin/com/icapps/torch_compat/TorchCompatPlugin.kt @@ -1,4 +1,4 @@ -package fr.g123k.torch_compat +package com.icapps.torch_compat import android.app.Activity import android.content.Context @@ -12,9 +12,9 @@ import io.flutter.plugin.common.MethodChannel import io.flutter.plugin.common.MethodChannel.MethodCallHandler import io.flutter.plugin.common.MethodChannel.Result -import fr.g123k.torch_compat.impl.BaseTorch -import fr.g123k.torch_compat.impl.TorchCamera2Impl -import fr.g123k.torch_compat.impl.TorchCamera1Impl +import com.icapps.torch_compat.impl.BaseTorch +import com.icapps.torch_compat.impl.TorchCamera2Impl +import com.icapps.torch_compat.impl.TorchCamera1Impl import io.flutter.embedding.engine.plugins.activity.ActivityAware import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding diff --git a/android/src/main/kotlin/fr/g123k/torch_compat/impl/BaseTorch.kt b/android/src/main/kotlin/com/icapps/torch_compat/impl/BaseTorch.kt similarity index 80% rename from android/src/main/kotlin/fr/g123k/torch_compat/impl/BaseTorch.kt rename to android/src/main/kotlin/com/icapps/torch_compat/impl/BaseTorch.kt index e4833a6..c23457f 100644 --- a/android/src/main/kotlin/fr/g123k/torch_compat/impl/BaseTorch.kt +++ b/android/src/main/kotlin/com/icapps/torch_compat/impl/BaseTorch.kt @@ -1,4 +1,4 @@ -package fr.g123k.torch_compat.impl +package com.icapps.torch_compat.impl abstract class BaseTorch { diff --git a/android/src/main/kotlin/fr/g123k/torch_compat/impl/TorchCamera1Impl.kt b/android/src/main/kotlin/com/icapps/torch_compat/impl/TorchCamera1Impl.kt similarity index 97% rename from android/src/main/kotlin/fr/g123k/torch_compat/impl/TorchCamera1Impl.kt rename to android/src/main/kotlin/com/icapps/torch_compat/impl/TorchCamera1Impl.kt index 3631d95..2940ee6 100644 --- a/android/src/main/kotlin/fr/g123k/torch_compat/impl/TorchCamera1Impl.kt +++ b/android/src/main/kotlin/com/icapps/torch_compat/impl/TorchCamera1Impl.kt @@ -1,6 +1,6 @@ @file:Suppress("DEPRECATION") -package fr.g123k.torch_compat.impl +package com.icapps.torch_compat.impl import android.content.Context import android.content.pm.PackageManager diff --git a/android/src/main/kotlin/fr/g123k/torch_compat/impl/TorchCamera2Impl.kt b/android/src/main/kotlin/com/icapps/torch_compat/impl/TorchCamera2Impl.kt similarity index 96% rename from android/src/main/kotlin/fr/g123k/torch_compat/impl/TorchCamera2Impl.kt rename to android/src/main/kotlin/com/icapps/torch_compat/impl/TorchCamera2Impl.kt index c4e1ff5..16a2ab3 100644 --- a/android/src/main/kotlin/fr/g123k/torch_compat/impl/TorchCamera2Impl.kt +++ b/android/src/main/kotlin/com/icapps/torch_compat/impl/TorchCamera2Impl.kt @@ -1,4 +1,4 @@ -package fr.g123k.torch_compat.impl +package com.icapps.torch_compat.impl import android.content.Context import android.hardware.camera2.CameraCharacteristics diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml index 61b6c4d..d56da71 100644 --- a/example/analysis_options.yaml +++ b/example/analysis_options.yaml @@ -7,7 +7,6 @@ # The following line activates a set of recommended lints for Flutter apps, # packages, and plugins designed to encourage good coding practices. -include: package:flutter_lints/flutter.yaml linter: # The lint rules applied to this project can be customized in the diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 14d2905..88bbf36 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -43,7 +43,7 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "fr.g123k.torch_compat_example" + applicationId "com.icapps.torch_compat_example" minSdkVersion 16 targetSdkVersion 30 versionCode flutterVersionCode.toInteger() diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml index 9d9d31f..78ac09e 100644 --- a/example/android/app/src/debug/AndroidManifest.xml +++ b/example/android/app/src/debug/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.icapps.torch_compat_example"> diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index b6f8765..45e508b 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.icapps.torch_compat_example"> diff --git a/example/android/app/src/main/kotlin/fr/g123k/torch_compat_example/MainActivity.kt b/example/android/app/src/main/kotlin/fr/g123k/torch_compat_example/MainActivity.kt index 6be2db5..7552078 100644 --- a/example/android/app/src/main/kotlin/fr/g123k/torch_compat_example/MainActivity.kt +++ b/example/android/app/src/main/kotlin/fr/g123k/torch_compat_example/MainActivity.kt @@ -1,4 +1,4 @@ -package fr.g123k.torch_compat_example +package com.icapps.torch_compat_example import io.flutter.embedding.android.FlutterActivity diff --git a/example/android/app/src/profile/AndroidManifest.xml b/example/android/app/src/profile/AndroidManifest.xml index 9d9d31f..78ac09e 100644 --- a/example/android/app/src/profile/AndroidManifest.xml +++ b/example/android/app/src/profile/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.icapps.torch_compat_example"> diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index dd04717..c406a07 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -291,7 +291,7 @@ ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = fr.g123k.torchCompatExample; + PRODUCT_BUNDLE_IDENTIFIER = com.icapps.torchCompatExample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; @@ -415,7 +415,7 @@ ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = fr.g123k.torchCompatExample; + PRODUCT_BUNDLE_IDENTIFIER = com.icapps.torchCompatExample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -434,7 +434,7 @@ ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = fr.g123k.torchCompatExample; + PRODUCT_BUNDLE_IDENTIFIER = com.icapps.torchCompatExample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; diff --git a/example/lib/main.dart b/example/lib/main.dart index 85071cd..3906838 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,8 +1,8 @@ -import 'package:flutter/material.dart'; import 'dart:async'; +import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:torch_compat/torch_compat.dart'; +import 'package:icapps_torch_compat/icapps_torch_compat.dart'; void main() { runApp(const MyApp()); @@ -30,8 +30,7 @@ class _MyAppState extends State { // Platform messages may fail, so we use a try/catch PlatformException. // We also handle the message potentially returning null. try { - platformVersion = - await TorchCompat.platformVersion ?? 'Unknown platform version'; + platformVersion = await TorchCompat.platformVersion ?? 'Unknown platform version'; } on PlatformException { platformVersion = 'Failed to get platform version.'; } diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index 5aad9a5..7dead10 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -8,7 +8,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:torch_compat_example/main.dart'; +import '../lib/main.dart'; void main() { testWidgets('Verify Platform version', (WidgetTester tester) async { @@ -18,8 +18,7 @@ void main() { // Verify that platform version is retrieved. expect( find.byWidgetPredicate( - (Widget widget) => widget is Text && - widget.data!.startsWith('Running on:'), + (Widget widget) => widget is Text && widget.data!.startsWith('Running on:'), ), findsOneWidget, ); diff --git a/lib/icapps_torch_compat.dart b/lib/icapps_torch_compat.dart new file mode 100644 index 0000000..ab8299b --- /dev/null +++ b/lib/icapps_torch_compat.dart @@ -0,0 +1 @@ +export 'src/torch_compat.dart'; diff --git a/lib/torch_compat.dart b/lib/src/torch_compat.dart similarity index 100% rename from lib/torch_compat.dart rename to lib/src/torch_compat.dart diff --git a/pubspec.yaml b/pubspec.yaml index 176fd56..8288ec4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,12 +1,10 @@ -name: torch_compat +name: icapps_torch_compat description: Plugin to turn on / off the torch (or flash of the camera) on all supported versions of Android (4.1+) and iOS -version: 1.1.2 -homepage: https://github.com/g123k/flutter_torch_compat - -publish_to: 'none' # Remove this line if you wish to publish to pub.dev +version: 2.0.0 +homepage: https://github.com/icapps/flutter_torch_compat environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=3.0.0 <4.0.0' dependencies: flutter: @@ -20,7 +18,7 @@ flutter: plugin: platforms: android: - package: fr.g123k.torch_compat + package: com.icapps.torch_compat pluginClass: TorchCompatPlugin ios: pluginClass: TorchCompatPlugin diff --git a/test/torch_compat_test.dart b/test/torch_compat_test.dart index 8060677..1fdc2bf 100644 --- a/test/torch_compat_test.dart +++ b/test/torch_compat_test.dart @@ -1,7 +1,3 @@ -import 'package:flutter/services.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:torch_compat/torch_compat.dart'; - void main() { // const MethodChannel channel = MethodChannel('torch_compat'); From 6d1870dee70cfc9b508544f85475e5960b9dc2b9 Mon Sep 17 00:00:00 2001 From: WilliamVerhaeghe Date: Thu, 26 Oct 2023 14:37:34 +0200 Subject: [PATCH 05/10] Updated example --- README.md | 6 +- android/build.gradle | 2 +- android/src/main/AndroidManifest.xml | 2 +- .../TorchCompatPlugin.kt | 8 +- .../impl/BaseTorch.kt | 2 +- .../impl/TorchCamera1Impl.kt | 2 +- .../impl/TorchCamera2Impl.kt | 2 +- example/.fvm/flutter_sdk | 1 + example/.fvm/fvm_config.json | 4 + example/.gitignore | 4 +- example/.metadata | 39 +- example/analysis_options.yaml | 4 +- example/android/app/build.gradle | 31 +- .../android/app/src/debug/AndroidManifest.xml | 6 +- .../android/app/src/main/AndroidManifest.xml | 18 +- .../example/example}/MainActivity.kt | 2 +- .../app/src/main/res/values-night/styles.xml | 4 +- .../app/src/main/res/values/styles.xml | 4 +- .../app/src/profile/AndroidManifest.xml | 6 +- example/android/build.gradle | 8 +- .../gradle/wrapper/gradle-wrapper.properties | 3 +- example/android/settings.gradle | 25 +- example/ios/.gitignore | 1 + example/ios/Flutter/AppFrameworkInfo.plist | 2 +- example/ios/Podfile | 5 +- example/ios/Runner.xcodeproj/project.pbxproj | 170 ++++- .../xcshareddata/xcschemes/Runner.xcscheme | 21 +- .../AppIcon.appiconset/Icon-App-20x20@1x.png | Bin 564 -> 295 bytes .../AppIcon.appiconset/Icon-App-20x20@2x.png | Bin 1283 -> 406 bytes .../AppIcon.appiconset/Icon-App-20x20@3x.png | Bin 1588 -> 450 bytes .../AppIcon.appiconset/Icon-App-29x29@1x.png | Bin 1025 -> 282 bytes .../AppIcon.appiconset/Icon-App-29x29@2x.png | Bin 1716 -> 462 bytes .../AppIcon.appiconset/Icon-App-29x29@3x.png | Bin 1920 -> 704 bytes .../AppIcon.appiconset/Icon-App-40x40@1x.png | Bin 1283 -> 406 bytes .../AppIcon.appiconset/Icon-App-40x40@2x.png | Bin 1895 -> 586 bytes .../AppIcon.appiconset/Icon-App-40x40@3x.png | Bin 2665 -> 862 bytes .../AppIcon.appiconset/Icon-App-60x60@2x.png | Bin 2665 -> 862 bytes .../AppIcon.appiconset/Icon-App-60x60@3x.png | Bin 3831 -> 1674 bytes .../AppIcon.appiconset/Icon-App-76x76@1x.png | Bin 1888 -> 762 bytes .../AppIcon.appiconset/Icon-App-76x76@2x.png | Bin 3294 -> 1226 bytes .../Icon-App-83.5x83.5@2x.png | Bin 3612 -> 1418 bytes example/ios/Runner/Info.plist | 10 +- example/ios/RunnerTests/RunnerTests.swift | 12 + example/lib/main.dart | 43 +- example/linux/.gitignore | 1 + example/linux/CMakeLists.txt | 139 ++++ example/linux/flutter/CMakeLists.txt | 88 +++ .../flutter/generated_plugin_registrant.cc | 11 + .../flutter/generated_plugin_registrant.h | 15 + example/linux/flutter/generated_plugins.cmake | 23 + example/linux/main.cc | 6 + example/linux/my_application.cc | 104 +++ example/linux/my_application.h | 18 + example/macos/.gitignore | 7 + example/macos/Flutter/Flutter-Debug.xcconfig | 2 + .../macos/Flutter/Flutter-Release.xcconfig | 2 + .../Flutter/GeneratedPluginRegistrant.swift | 10 + example/macos/Podfile | 43 ++ .../macos/Runner.xcodeproj/project.pbxproj | 695 ++++++++++++++++++ .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../xcshareddata/xcschemes/Runner.xcscheme | 98 +++ .../contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + example/macos/Runner/AppDelegate.swift | 9 + .../AppIcon.appiconset/Contents.json | 68 ++ .../AppIcon.appiconset/app_icon_1024.png | Bin 0 -> 102994 bytes .../AppIcon.appiconset/app_icon_128.png | Bin 0 -> 5680 bytes .../AppIcon.appiconset/app_icon_16.png | Bin 0 -> 520 bytes .../AppIcon.appiconset/app_icon_256.png | Bin 0 -> 14142 bytes .../AppIcon.appiconset/app_icon_32.png | Bin 0 -> 1066 bytes .../AppIcon.appiconset/app_icon_512.png | Bin 0 -> 36406 bytes .../AppIcon.appiconset/app_icon_64.png | Bin 0 -> 2218 bytes example/macos/Runner/Base.lproj/MainMenu.xib | 343 +++++++++ example/macos/Runner/Configs/AppInfo.xcconfig | 14 + example/macos/Runner/Configs/Debug.xcconfig | 2 + example/macos/Runner/Configs/Release.xcconfig | 2 + .../macos/Runner/Configs/Warnings.xcconfig | 13 + .../macos/Runner/DebugProfile.entitlements | 12 + example/macos/Runner/Info.plist | 32 + example/macos/Runner/MainFlutterWindow.swift | 15 + example/macos/Runner/Release.entitlements | 8 + example/macos/RunnerTests/RunnerTests.swift | 12 + example/pubspec.yaml | 4 +- example/test/widget_test.dart | 24 +- example/web/favicon.png | Bin 0 -> 917 bytes example/web/icons/Icon-192.png | Bin 0 -> 5292 bytes example/web/icons/Icon-512.png | Bin 0 -> 8252 bytes example/web/icons/Icon-maskable-192.png | Bin 0 -> 5594 bytes example/web/icons/Icon-maskable-512.png | Bin 0 -> 20998 bytes example/web/index.html | 59 ++ example/web/manifest.json | 35 + example/windows/.gitignore | 17 + example/windows/CMakeLists.txt | 102 +++ example/windows/flutter/CMakeLists.txt | 104 +++ .../flutter/generated_plugin_registrant.cc | 11 + .../flutter/generated_plugin_registrant.h | 15 + .../windows/flutter/generated_plugins.cmake | 23 + example/windows/runner/CMakeLists.txt | 40 + example/windows/runner/Runner.rc | 121 +++ example/windows/runner/flutter_window.cpp | 71 ++ example/windows/runner/flutter_window.h | 33 + example/windows/runner/main.cpp | 43 ++ example/windows/runner/resource.h | 16 + example/windows/runner/resources/app_icon.ico | Bin 0 -> 33772 bytes example/windows/runner/runner.exe.manifest | 20 + example/windows/runner/utils.cpp | 65 ++ example/windows/runner/utils.h | 19 + example/windows/runner/win32_window.cpp | 288 ++++++++ example/windows/runner/win32_window.h | 102 +++ pubspec.yaml | 2 +- 110 files changed, 3344 insertions(+), 132 deletions(-) rename android/src/main/kotlin/com/icapps/{torch_compat => icapps_torch_compat}/TorchCompatPlugin.kt (94%) rename android/src/main/kotlin/com/icapps/{torch_compat => icapps_torch_compat}/impl/BaseTorch.kt (77%) rename android/src/main/kotlin/com/icapps/{torch_compat => icapps_torch_compat}/impl/TorchCamera1Impl.kt (96%) rename android/src/main/kotlin/com/icapps/{torch_compat => icapps_torch_compat}/impl/TorchCamera2Impl.kt (95%) create mode 120000 example/.fvm/flutter_sdk create mode 100644 example/.fvm/fvm_config.json rename example/android/app/src/main/kotlin/{fr/g123k/torch_compat_example => com/example/example}/MainActivity.kt (70%) create mode 100644 example/ios/RunnerTests/RunnerTests.swift create mode 100644 example/linux/.gitignore create mode 100644 example/linux/CMakeLists.txt create mode 100644 example/linux/flutter/CMakeLists.txt create mode 100644 example/linux/flutter/generated_plugin_registrant.cc create mode 100644 example/linux/flutter/generated_plugin_registrant.h create mode 100644 example/linux/flutter/generated_plugins.cmake create mode 100644 example/linux/main.cc create mode 100644 example/linux/my_application.cc create mode 100644 example/linux/my_application.h create mode 100644 example/macos/.gitignore create mode 100644 example/macos/Flutter/Flutter-Debug.xcconfig create mode 100644 example/macos/Flutter/Flutter-Release.xcconfig create mode 100644 example/macos/Flutter/GeneratedPluginRegistrant.swift create mode 100644 example/macos/Podfile create mode 100644 example/macos/Runner.xcodeproj/project.pbxproj create mode 100644 example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme create mode 100644 example/macos/Runner.xcworkspace/contents.xcworkspacedata create mode 100644 example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 example/macos/Runner/AppDelegate.swift create mode 100644 example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png create mode 100644 example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png create mode 100644 example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png create mode 100644 example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png create mode 100644 example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png create mode 100644 example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png create mode 100644 example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png create mode 100644 example/macos/Runner/Base.lproj/MainMenu.xib create mode 100644 example/macos/Runner/Configs/AppInfo.xcconfig create mode 100644 example/macos/Runner/Configs/Debug.xcconfig create mode 100644 example/macos/Runner/Configs/Release.xcconfig create mode 100644 example/macos/Runner/Configs/Warnings.xcconfig create mode 100644 example/macos/Runner/DebugProfile.entitlements create mode 100644 example/macos/Runner/Info.plist create mode 100644 example/macos/Runner/MainFlutterWindow.swift create mode 100644 example/macos/Runner/Release.entitlements create mode 100644 example/macos/RunnerTests/RunnerTests.swift create mode 100644 example/web/favicon.png create mode 100644 example/web/icons/Icon-192.png create mode 100644 example/web/icons/Icon-512.png create mode 100644 example/web/icons/Icon-maskable-192.png create mode 100644 example/web/icons/Icon-maskable-512.png create mode 100644 example/web/index.html create mode 100644 example/web/manifest.json create mode 100644 example/windows/.gitignore create mode 100644 example/windows/CMakeLists.txt create mode 100644 example/windows/flutter/CMakeLists.txt create mode 100644 example/windows/flutter/generated_plugin_registrant.cc create mode 100644 example/windows/flutter/generated_plugin_registrant.h create mode 100644 example/windows/flutter/generated_plugins.cmake create mode 100644 example/windows/runner/CMakeLists.txt create mode 100644 example/windows/runner/Runner.rc create mode 100644 example/windows/runner/flutter_window.cpp create mode 100644 example/windows/runner/flutter_window.h create mode 100644 example/windows/runner/main.cpp create mode 100644 example/windows/runner/resource.h create mode 100644 example/windows/runner/resources/app_icon.ico create mode 100644 example/windows/runner/runner.exe.manifest create mode 100644 example/windows/runner/utils.cpp create mode 100644 example/windows/runner/utils.h create mode 100644 example/windows/runner/win32_window.cpp create mode 100644 example/windows/runner/win32_window.h diff --git a/README.md b/README.md index 901791e..a02fd9a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Torch compat -[![Pub](https://img.shields.io/pub/v/torch_compat.svg)](https://pub.dartlang.org/packages/torch_compat) +[![Pub](https://img.shields.io/pub/v/icapps_torch_compat.svg)](https://pub.dartlang.org/packages/icapps_torch_compat) A plugin to enable or disable the torch of a device that works both on Android (including Android 4.x) and ioS. @@ -25,13 +25,13 @@ This plugin by default only requests `android.permission.FLASHLIGHT`, but if you First import the library to your project in your `pubspec.yaml`: ```yaml -torch_compat: ^1.0.2 +icapps_torch_compat: ^2.0.0 ``` ### 2) Import the library in your Dart code ```dart -import 'package:torch_compat/torch_compat.dart'; +import 'package:icapps_torch_compat/icapps_torch_compat.dart'; ``` ### 3) Turn on or off the flash diff --git a/android/build.gradle b/android/build.gradle index c5ab7b6..5ab4589 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,4 +1,4 @@ -group 'com.icapps.torch_compat' +group 'com.icapps.icapps_torch_compat' version '1.0-SNAPSHOT' buildscript { diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index d2d73ab..8cd30c8 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -1,3 +1,3 @@ + package="com.icapps.icapps_torch_compat"> diff --git a/android/src/main/kotlin/com/icapps/torch_compat/TorchCompatPlugin.kt b/android/src/main/kotlin/com/icapps/icapps_torch_compat/TorchCompatPlugin.kt similarity index 94% rename from android/src/main/kotlin/com/icapps/torch_compat/TorchCompatPlugin.kt rename to android/src/main/kotlin/com/icapps/icapps_torch_compat/TorchCompatPlugin.kt index f22269f..731e124 100644 --- a/android/src/main/kotlin/com/icapps/torch_compat/TorchCompatPlugin.kt +++ b/android/src/main/kotlin/com/icapps/icapps_torch_compat/TorchCompatPlugin.kt @@ -1,4 +1,4 @@ -package com.icapps.torch_compat +package com.icapps.icapps_torch_compat import android.app.Activity import android.content.Context @@ -12,9 +12,9 @@ import io.flutter.plugin.common.MethodChannel import io.flutter.plugin.common.MethodChannel.MethodCallHandler import io.flutter.plugin.common.MethodChannel.Result -import com.icapps.torch_compat.impl.BaseTorch -import com.icapps.torch_compat.impl.TorchCamera2Impl -import com.icapps.torch_compat.impl.TorchCamera1Impl +import com.icapps.icapps_torch_compat.impl.BaseTorch +import com.icapps.icapps_torch_compat.impl.TorchCamera2Impl +import com.icapps.icapps_torch_compat.impl.TorchCamera1Impl import io.flutter.embedding.engine.plugins.activity.ActivityAware import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding diff --git a/android/src/main/kotlin/com/icapps/torch_compat/impl/BaseTorch.kt b/android/src/main/kotlin/com/icapps/icapps_torch_compat/impl/BaseTorch.kt similarity index 77% rename from android/src/main/kotlin/com/icapps/torch_compat/impl/BaseTorch.kt rename to android/src/main/kotlin/com/icapps/icapps_torch_compat/impl/BaseTorch.kt index c23457f..2b4ee2e 100644 --- a/android/src/main/kotlin/com/icapps/torch_compat/impl/BaseTorch.kt +++ b/android/src/main/kotlin/com/icapps/icapps_torch_compat/impl/BaseTorch.kt @@ -1,4 +1,4 @@ -package com.icapps.torch_compat.impl +package com.icapps.icapps_torch_compat.impl abstract class BaseTorch { diff --git a/android/src/main/kotlin/com/icapps/torch_compat/impl/TorchCamera1Impl.kt b/android/src/main/kotlin/com/icapps/icapps_torch_compat/impl/TorchCamera1Impl.kt similarity index 96% rename from android/src/main/kotlin/com/icapps/torch_compat/impl/TorchCamera1Impl.kt rename to android/src/main/kotlin/com/icapps/icapps_torch_compat/impl/TorchCamera1Impl.kt index 2940ee6..d987080 100644 --- a/android/src/main/kotlin/com/icapps/torch_compat/impl/TorchCamera1Impl.kt +++ b/android/src/main/kotlin/com/icapps/icapps_torch_compat/impl/TorchCamera1Impl.kt @@ -1,6 +1,6 @@ @file:Suppress("DEPRECATION") -package com.icapps.torch_compat.impl +package com.icapps.icapps_torch_compat.impl import android.content.Context import android.content.pm.PackageManager diff --git a/android/src/main/kotlin/com/icapps/torch_compat/impl/TorchCamera2Impl.kt b/android/src/main/kotlin/com/icapps/icapps_torch_compat/impl/TorchCamera2Impl.kt similarity index 95% rename from android/src/main/kotlin/com/icapps/torch_compat/impl/TorchCamera2Impl.kt rename to android/src/main/kotlin/com/icapps/icapps_torch_compat/impl/TorchCamera2Impl.kt index 16a2ab3..2d0821a 100644 --- a/android/src/main/kotlin/com/icapps/torch_compat/impl/TorchCamera2Impl.kt +++ b/android/src/main/kotlin/com/icapps/icapps_torch_compat/impl/TorchCamera2Impl.kt @@ -1,4 +1,4 @@ -package com.icapps.torch_compat.impl +package com.icapps.icapps_torch_compat.impl import android.content.Context import android.hardware.camera2.CameraCharacteristics diff --git a/example/.fvm/flutter_sdk b/example/.fvm/flutter_sdk new file mode 120000 index 0000000..8d6f8f2 --- /dev/null +++ b/example/.fvm/flutter_sdk @@ -0,0 +1 @@ +/Users/williamverhaeghe/fvm/versions/3.13.9 \ No newline at end of file diff --git a/example/.fvm/fvm_config.json b/example/.fvm/fvm_config.json new file mode 100644 index 0000000..d8abe1b --- /dev/null +++ b/example/.fvm/fvm_config.json @@ -0,0 +1,4 @@ +{ + "flutterSdkVersion": "3.13.9", + "flavors": {} +} \ No newline at end of file diff --git a/example/.gitignore b/example/.gitignore index 0fa6b67..24476c5 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -8,6 +8,7 @@ .buildlog/ .history .svn/ +migrate_working_dir/ # IntelliJ related *.iml @@ -31,9 +32,6 @@ .pub/ /build/ -# Web related -lib/generated_plugin_registrant.dart - # Symbolication related app.*.symbols diff --git a/example/.metadata b/example/.metadata index 0f055bf..a778330 100644 --- a/example/.metadata +++ b/example/.metadata @@ -4,7 +4,42 @@ # This file should be version controlled and should not be manually edited. version: - revision: ffb2ecea5223acdd139a5039be2f9c796962833d - channel: stable + revision: "d211f42860350d914a5ad8102f9ec32764dc6d06" + channel: "stable" project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 + base_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 + - platform: android + create_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 + base_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 + - platform: ios + create_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 + base_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 + - platform: linux + create_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 + base_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 + - platform: macos + create_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 + base_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 + - platform: web + create_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 + base_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 + - platform: windows + create_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 + base_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml index d56da71..0d29021 100644 --- a/example/analysis_options.yaml +++ b/example/analysis_options.yaml @@ -7,13 +7,13 @@ # The following line activates a set of recommended lints for Flutter apps, # packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml linter: # The lint rules applied to this project can be customized in the # section below to disable rules from the `package:flutter_lints/flutter.yaml` # included above or to enable additional rules. A list of all available lints - # and their documentation is published at - # https://dart-lang.github.io/linter/lints/index.html. + # and their documentation is published at https://dart.dev/lints. # # Instead of disabling a lint rule for the entire project in the # section below, it can also be suppressed for a single line of code diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 88bbf36..118ee1d 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -1,3 +1,9 @@ +plugins { + id "com.android.application" + id "kotlin-android" + id "dev.flutter.flutter-gradle-plugin" +} + def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { @@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) { } } -def flutterRoot = localProperties.getProperty('flutter.sdk') -if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") -} - def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' @@ -21,12 +22,10 @@ if (flutterVersionName == null) { flutterVersionName = '1.0' } -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" - android { - compileSdkVersion 30 + namespace "com.example.example" + compileSdkVersion flutter.compileSdkVersion + ndkVersion flutter.ndkVersion compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 @@ -43,9 +42,11 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "com.icapps.torch_compat_example" - minSdkVersion 16 - targetSdkVersion 30 + applicationId "com.example.example" + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName } @@ -63,6 +64,4 @@ flutter { source '../..' } -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" -} +dependencies {} diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml index 78ac09e..399f698 100644 --- a/example/android/app/src/debug/AndroidManifest.xml +++ b/example/android/app/src/debug/AndroidManifest.xml @@ -1,6 +1,6 @@ - - diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 45e508b..19b862e 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,10 +1,11 @@ - - + - - diff --git a/example/android/app/src/main/kotlin/fr/g123k/torch_compat_example/MainActivity.kt b/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt similarity index 70% rename from example/android/app/src/main/kotlin/fr/g123k/torch_compat_example/MainActivity.kt rename to example/android/app/src/main/kotlin/com/example/example/MainActivity.kt index 7552078..e793a00 100644 --- a/example/android/app/src/main/kotlin/fr/g123k/torch_compat_example/MainActivity.kt +++ b/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt @@ -1,4 +1,4 @@ -package com.icapps.torch_compat_example +package com.example.example import io.flutter.embedding.android.FlutterActivity diff --git a/example/android/app/src/main/res/values-night/styles.xml b/example/android/app/src/main/res/values-night/styles.xml index 449a9f9..06952be 100644 --- a/example/android/app/src/main/res/values-night/styles.xml +++ b/example/android/app/src/main/res/values-night/styles.xml @@ -3,14 +3,14 @@