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
This commit is contained in:
Feodor Fitsner 2024-10-09 12:18:32 -07:00 committed by GitHub
parent 4d4420a369
commit 5b00ffb439
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 127 additions and 64 deletions

View File

@ -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
}

View File

@ -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 %}
}
}
}

View File

@ -1,24 +1,11 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<!-- Media access permissions.
Android 13 or higher.
https://developer.android.com/about/versions/13/behavior-changes-13#granular-media-permissions -->
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<!-- Storage access permissions. Android 12 or lower. -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- Geolocator background/foreground service permissions -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<!-- Google TV -->
<uses-feature android:name="android.software.leanback" android:required="false" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
<!-- flet: permission {% for k, v in cookiecutter.options.android_permissions.items() %} {% if v == True %} -->
<uses-permission android:name="{{ k }}" />
<!-- flet: enf of permission {% endif %} {% endfor %} -->
<!-- flet: feature {% for k, v in cookiecutter.options.android_features.items() %} -->
<uses-feature android:name="{{ k }}" android:required="{% if v == True %}true{% else %}false{% endif %}" />
<!-- flet: end of feature {% endfor %} -->
<application
android:label="{{ cookiecutter.product_name }}"
@ -26,8 +13,8 @@
android:enableOnBackInvokedCallback="true"
android:icon="@mipmap/ic_launcher">
<meta-data
android:name="io.flutter.embedding.android.EnableImpeller"
android:value="false"/>
android:name="io.flutter.embedding.android.EnableImpeller"
android:value="false" />
<activity
android:name=".MainActivity"
android:exported="true"
@ -47,8 +34,18 @@
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER"/> <!-- Google TV -->
<category android:name="android.intent.category.LEANBACK_LAUNCHER" /> <!-- Google TV -->
</intent-filter>
<!-- flet: deep linking {% if cookiecutter.options.deep_linking_url %} -->
<meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="{{ cookiecutter.options.deep_linking_url.scheme }}"
android:host="{{ cookiecutter.options.deep_linking_url.netloc }}" />
</intent-filter>
<!-- flet: end of deep linking {% endif %} -->
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->

View File

@ -50,9 +50,31 @@
<key>NSAllowsArbitraryLoads</key>
<true />
</dict>
<key>NSMicrophoneUsageDescription</key>
<string>This app needs access to Audio Recording.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs access to location.</string>
<!-- flet: deep linking {% if cookiecutter.options.deep_linking_url %} -->
<key>FlutterDeepLinkingEnabled</key>
<true />
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>{{ cookiecutter.options.deep_linking_url.netloc }}</string>
<key>CFBundleURLSchemes</key>
<array>
<string>{{ cookiecutter.options.deep_linking_url.scheme }}</string>
</array>
</dict>
</array>
<!-- flet: end of deep linking {% endif %} -->
<!-- flet: prop {% for k, v in cookiecutter.options.info_plist.items() %} -->
<key>{{ k }}</key>
<!-- flet: True {% if v == True %} -->
<true />
<!-- flet: False {% elif v == False %} -->
<false />
<!-- flet: string value {% else %} -->
<string>{{ v }}</string>
<!-- flet: end of prop {% endif %} {% endfor %} -->
</dict>
</plist>

View File

@ -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();

View File

@ -1,18 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<false/>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.device.audio-input</key>
<true/>
<key>com.apple.security.personal-information.location</key>
<true/>
</dict>
<dict>
<!-- flet: entitlement {% for k, v in cookiecutter.options.macos_entitlements.items() %} -->
<key>{{ k }}</key>
<!-- flet: True {% if v == True %} -->
<true />
<!-- flet: False {% elif v == False %} -->
<false />
<!-- flet: end of entitlement {% endif %} {% endfor %} -->
</dict>
</plist>

View File

@ -28,9 +28,14 @@
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSMicrophoneUsageDescription</key>
<string>This app needs access to Audio Recording.</string>
<key>NSLocationUsageDescription</key>
<string>This app needs access to location.</string>
<!-- flet: prop {% for k, v in cookiecutter.options.info_plist.items() %} -->
<key>{{ k }}</key>
<!-- flet: True {% if v == True %} -->
<true />
<!-- flet: False {% elif v == False %} -->
<false />
<!-- flet: string value {% else %} -->
<string>{{ v }}</string>
<!-- flet: end of prop {% endif %} {% endfor %} -->
</dict>
</plist>

View File

@ -1,15 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<false/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.device.audio-input</key>
<true/>
<key>com.apple.security.personal-information.location</key>
<true/>
</dict>
<dict>
<!-- flet: entitlement {% for k, v in cookiecutter.options.macos_entitlements.items() %} -->
<key>{{ k }}</key>
<!-- flet: True {% if v == True %} -->
<true />
<!-- flet: False {% elif v == False %} -->
<false />
<!-- flet: end of entitlement {% endif %} {% endfor %} -->
</dict>
</plist>

View File

@ -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 %}

View File

@ -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;