From 5b00ffb4399284cdf9c0bb601a097a973aadeb1c Mon Sep 17 00:00:00 2001 From: Feodor Fitsner Date: Wed, 9 Oct 2024 12:18:32 -0700 Subject: [PATCH] For Flet 0.25.0 (#20) * path to serious_python * full path to serious_python * doNotStrip * change abi filters order * change order again * split_per_abi * make an error in template * Fix template * Test info_plist * info plist complete * Fix elif * Another fix * Another try * simplify if * simple test * no v * remove everything * remove other options * restore infoplist * equal not is * one line * add macos_entitlements * empty list * empty array * macos entitlements * No hard-coded entitlements * Android manifest * Fix manifest * Fix template again * Remove hard-coded permissions * Fix template * true and false * remove hard-coded permissions * Android deep linking Close #4025 * Template cleanup * Signing Android builds * Fix signing options * Set FLET_APP_DATA and FLET_APP_TEMP dirs for the app * Pyodide 0.26.2 * serious_python: 0.8.0 --- cookiecutter.json | 4 +- .../android/app/build.gradle | 21 +++++++++ .../android/app/src/main/AndroidManifest.xml | 45 +++++++++---------- .../ios/Runner/Info.plist | 32 ++++++++++--- {{cookiecutter.out_dir}}/lib/main.dart | 22 +++++++++ .../macos/Runner/DebugProfile.entitlements | 25 +++++------ .../macos/Runner/Info.plist | 13 ++++-- .../macos/Runner/Release.entitlements | 22 +++++---- {{cookiecutter.out_dir}}/pubspec.yaml | 5 ++- {{cookiecutter.out_dir}}/web/python-worker.js | 2 +- 10 files changed, 127 insertions(+), 64 deletions(-) diff --git a/cookiecutter.json b/cookiecutter.json index c629ec8..b98091f 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -15,5 +15,7 @@ "base_url": "/", "route_url_strategy": "path", "web_renderer": "canvaskit", - "use_color_emoji": "false" + "use_color_emoji": "false", + "split_per_abi": false, + "options": null } \ No newline at end of file diff --git a/{{cookiecutter.out_dir}}/android/app/build.gradle b/{{cookiecutter.out_dir}}/android/app/build.gradle index d7e0010..0788579 100644 --- a/{{cookiecutter.out_dir}}/android/app/build.gradle +++ b/{{cookiecutter.out_dir}}/android/app/build.gradle @@ -31,6 +31,10 @@ android { jniLibs { useLegacyPackaging true } + doNotStrip "*/arm64-v8a/libpython*.so" + doNotStrip "*/armeabi-v7a/libpython*.so" + doNotStrip "*/x86/libpython*.so" + doNotStrip "*/x86_64/libpython*.so" } compileOptions { @@ -53,14 +57,31 @@ android { versionCode flutterVersionCode.toInteger() versionName flutterVersionName +// flet: split_per_abi {% if not cookiecutter.split_per_abi %} ndk { abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86_64' } +// flet: end of split_per_abi {% endif %} } +// flet: android_signing {% if cookiecutter.options.android_signing %} + signingConfigs { + release { + keyAlias System.getenv('FLET_ANDROID_SIGNING_KEY_ALIAS') + keyPassword System.getenv('FLET_ANDROID_SIGNING_KEY_PASSWORD') + storeFile System.getenv('FLET_ANDROID_SIGNING_KEY_STORE') ? file(System.getenv('FLET_ANDROID_SIGNING_KEY_STORE')) : null + storePassword System.getenv('FLET_ANDROID_SIGNING_KEY_STORE_PASSWORD') + } + } +// flet: end of android_signing {% endif %} + buildTypes { release { +// flet: android_signing {% if cookiecutter.options.android_signing %} + signingConfig signingConfigs.release +// {% else %} signingConfig signingConfigs.debug +// flet: end of android_signing {% endif %} } } } diff --git a/{{cookiecutter.out_dir}}/android/app/src/main/AndroidManifest.xml b/{{cookiecutter.out_dir}}/android/app/src/main/AndroidManifest.xml index 69cbc1f..b385170 100644 --- a/{{cookiecutter.out_dir}}/android/app/src/main/AndroidManifest.xml +++ b/{{cookiecutter.out_dir}}/android/app/src/main/AndroidManifest.xml @@ -1,24 +1,11 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + android:name="io.flutter.embedding.android.EnableImpeller" + android:value="false" /> - + + + + + + + + + + @@ -56,4 +53,4 @@ android:name="flutterEmbedding" android:value="2" /> - + \ No newline at end of file diff --git a/{{cookiecutter.out_dir}}/ios/Runner/Info.plist b/{{cookiecutter.out_dir}}/ios/Runner/Info.plist index 5c4ee77..e5e9a75 100644 --- a/{{cookiecutter.out_dir}}/ios/Runner/Info.plist +++ b/{{cookiecutter.out_dir}}/ios/Runner/Info.plist @@ -50,9 +50,31 @@ NSAllowsArbitraryLoads - NSMicrophoneUsageDescription - This app needs access to Audio Recording. - NSLocationWhenInUseUsageDescription - This app needs access to location. + + FlutterDeepLinkingEnabled + + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLName + {{ cookiecutter.options.deep_linking_url.netloc }} + CFBundleURLSchemes + + {{ cookiecutter.options.deep_linking_url.scheme }} + + + + + + {{ k }} + + + + + + {{ v }} + - + \ No newline at end of file diff --git a/{{cookiecutter.out_dir}}/lib/main.dart b/{{cookiecutter.out_dir}}/lib/main.dart index 7216580..9ba340b 100644 --- a/{{cookiecutter.out_dir}}/lib/main.dart +++ b/{{cookiecutter.out_dir}}/lib/main.dart @@ -5,7 +5,9 @@ import 'package:flet/flet.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:package_info_plus/package_info_plus.dart'; import 'package:path/path.dart' as path; +import 'package:path_provider/path_provider.dart' as path_provider; import 'package:serious_python/serious_python.dart'; import 'package:url_strategy/url_strategy.dart'; @@ -161,6 +163,26 @@ Future prepareApp() async { assetsDir = path.join(appDir, "assets"); + // configure apps DATA and TEMP directories + WidgetsFlutterBinding.ensureInitialized(); + + var appTempPath = (await path_provider.getApplicationCacheDirectory()).path; + var appDataPath = + (await path_provider.getApplicationDocumentsDirectory()).path; + + if (defaultTargetPlatform != TargetPlatform.iOS && + defaultTargetPlatform != TargetPlatform.android) { + // append app name to the path and create dir + PackageInfo packageInfo = await PackageInfo.fromPlatform(); + appDataPath = path.join(appDataPath, "flet", packageInfo.packageName); + if (!await Directory(appDataPath).exists()) { + await Directory(appDataPath).create(recursive: true); + } + } + + environmentVariables["FLET_APP_DATA"] = appDataPath; + environmentVariables["FLET_APP_TEMP"] = appTempPath; + environmentVariables["FLET_PLATFORM"] = defaultTargetPlatform.name.toLowerCase(); diff --git a/{{cookiecutter.out_dir}}/macos/Runner/DebugProfile.entitlements b/{{cookiecutter.out_dir}}/macos/Runner/DebugProfile.entitlements index 3ae603a..d224b0e 100644 --- a/{{cookiecutter.out_dir}}/macos/Runner/DebugProfile.entitlements +++ b/{{cookiecutter.out_dir}}/macos/Runner/DebugProfile.entitlements @@ -1,18 +1,13 @@ - - com.apple.security.app-sandbox - - com.apple.security.cs.allow-jit - - com.apple.security.network.server - - com.apple.security.network.client - - com.apple.security.device.audio-input - - com.apple.security.personal-information.location - - - + + + {{ k }} + + + + + + + \ No newline at end of file diff --git a/{{cookiecutter.out_dir}}/macos/Runner/Info.plist b/{{cookiecutter.out_dir}}/macos/Runner/Info.plist index 525e5df..7e273e2 100644 --- a/{{cookiecutter.out_dir}}/macos/Runner/Info.plist +++ b/{{cookiecutter.out_dir}}/macos/Runner/Info.plist @@ -28,9 +28,14 @@ MainMenu NSPrincipalClass NSApplication - NSMicrophoneUsageDescription - This app needs access to Audio Recording. - NSLocationUsageDescription - This app needs access to location. + + {{ k }} + + + + + + {{ v }} + \ No newline at end of file diff --git a/{{cookiecutter.out_dir}}/macos/Runner/Release.entitlements b/{{cookiecutter.out_dir}}/macos/Runner/Release.entitlements index addf330..d224b0e 100644 --- a/{{cookiecutter.out_dir}}/macos/Runner/Release.entitlements +++ b/{{cookiecutter.out_dir}}/macos/Runner/Release.entitlements @@ -1,15 +1,13 @@ - - com.apple.security.app-sandbox - - com.apple.security.network.client - - com.apple.security.device.audio-input - - com.apple.security.personal-information.location - - - - + + + {{ k }} + + + + + + + \ No newline at end of file diff --git a/{{cookiecutter.out_dir}}/pubspec.yaml b/{{cookiecutter.out_dir}}/pubspec.yaml index b5ff0ee..90ddfa2 100644 --- a/{{cookiecutter.out_dir}}/pubspec.yaml +++ b/{{cookiecutter.out_dir}}/pubspec.yaml @@ -11,16 +11,17 @@ dependencies: flutter: sdk: flutter - serious_python: 0.7.1 + serious_python: 0.8.0 flet: 0.24.1 path: ^1.9.0 url_strategy: ^0.2.0 cupertino_icons: ^1.0.6 + path_provider: ^2.1.4 + package_info_plus: ^8.0.2 dependency_overrides: wakelock_plus: ^1.2.5 - package_info_plus: ^8.0.0 web: ^1.0.0 # {% if 'flet_audio_recorder' in cookiecutter.flutter.dependencies %} diff --git a/{{cookiecutter.out_dir}}/web/python-worker.js b/{{cookiecutter.out_dir}}/web/python-worker.js index 7e4e4eb..463c036 100644 --- a/{{cookiecutter.out_dir}}/web/python-worker.js +++ b/{{cookiecutter.out_dir}}/web/python-worker.js @@ -1,4 +1,4 @@ -importScripts("https://cdn.jsdelivr.net/pyodide/v0.25.0/full/pyodide.js"); +importScripts("https://cdn.jsdelivr.net/pyodide/v0.26.2/full/pyodide.js"); self.pythonModuleName = null; self.initialized = false;