add cwtch.aar and make sure is included in apk build from gradle (minor gradle fixes). Start restructuring main.dart to handle gomobile cwtch as well (but not done)
This commit is contained in:
parent
258093903f
commit
8d202cfaeb
|
@ -8,7 +8,7 @@ if (localPropertiesFile.exists()) {
|
||||||
|
|
||||||
def flutterRoot = localProperties.getProperty('flutter.sdk')
|
def flutterRoot = localProperties.getProperty('flutter.sdk')
|
||||||
if (flutterRoot == null) {
|
if (flutterRoot == null) {
|
||||||
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
|
throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
|
||||||
}
|
}
|
||||||
|
|
||||||
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
|
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
|
||||||
|
@ -30,6 +30,7 @@ android {
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main.java.srcDirs += 'src/main/kotlin'
|
main.java.srcDirs += 'src/main/kotlin'
|
||||||
|
main.jniLibs.srcDirs += 'src/main/libs'
|
||||||
}
|
}
|
||||||
|
|
||||||
lintOptions {
|
lintOptions {
|
||||||
|
@ -60,4 +61,5 @@ flutter {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||||
|
implementation project(':cwtch')
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,40 @@
|
||||||
package com.example.flutter_app
|
package com.example.flutter_app
|
||||||
|
|
||||||
import io.flutter.embedding.android.FlutterActivity
|
import io.flutter.embedding.android.FlutterActivity
|
||||||
|
import androidx.annotation.NonNull
|
||||||
|
import io.flutter.embedding.engine.FlutterEngine
|
||||||
|
import io.flutter.plugin.common.MethodChannel
|
||||||
|
import android.content.pm.PackageManager
|
||||||
|
|
||||||
class MainActivity: FlutterActivity() {
|
class MainActivity: FlutterActivity() {
|
||||||
|
|
||||||
|
private val CHANNEL = "test.flutter.dev/applicationInfo"
|
||||||
|
private val CALL_NATIVE_LIB_DIR = "getNativeLibDir"
|
||||||
|
|
||||||
|
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
|
||||||
|
super.configureFlutterEngine(flutterEngine)
|
||||||
|
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler {
|
||||||
|
// Note: this method is invoked on the main thread.
|
||||||
|
call, result ->
|
||||||
|
if (call.method == CALL_NATIVE_LIB_DIR) {
|
||||||
|
val nativeLibDir = getNativeLibDir()
|
||||||
|
|
||||||
|
if (nativeLibDir != "") {
|
||||||
|
result.success(nativeLibDir)
|
||||||
|
} else {
|
||||||
|
result.error("UNAVAILABLE", "nativeLibDir not available.", null)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result.notImplemented()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getNativeLibDir(): String {
|
||||||
|
|
||||||
|
val ainfo = this.applicationContext.packageManager.getApplicationInfo(
|
||||||
|
"com.example.flutter_app", // Must be app name
|
||||||
|
PackageManager.GET_SHARED_LIBRARY_FILES)
|
||||||
|
return ainfo.nativeLibraryDir
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,2 @@
|
||||||
|
configurations.maybeCreate("default")
|
||||||
|
artifacts.add("default", file('cwtch.aar'))
|
Binary file not shown.
|
@ -1,4 +1,4 @@
|
||||||
include ':app'
|
include ':app', ':cwtch'
|
||||||
|
|
||||||
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
|
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
|
||||||
def properties = new Properties()
|
def properties = new Properties()
|
||||||
|
|
|
@ -4,6 +4,27 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'model.dart';
|
import 'model.dart';
|
||||||
import 'views/profilemgrview.dart';
|
import 'views/profilemgrview.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'dart:io' show Platform;
|
||||||
|
import 'package:path/path.dart' as path;
|
||||||
|
import 'package:path_provider/path_provider.dart';
|
||||||
|
import 'model.dart' as model;
|
||||||
|
import 'dart:collection';
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
typedef start_cwtch_function = Void Function(Pointer<Utf8> str, Int32 length);
|
||||||
|
typedef StartCwtchFn = void Function(Pointer<Utf8> dir, int len);
|
||||||
|
|
||||||
|
typedef access_cwtch_eventbus_function = Void Function();
|
||||||
|
typedef NextEventFn = void Function();
|
||||||
|
|
||||||
|
|
||||||
|
typedef get_json_blob_void_function = Pointer<Utf8> Function();
|
||||||
|
typedef GetJsonBlobVoidFn = Pointer<Utf8> Function();
|
||||||
|
|
||||||
|
typedef get_json_blob_string_function = Pointer<Utf8> Function(Pointer<Utf8> str, Int32 length);
|
||||||
|
typedef GetJsonBlobStringFn = Pointer<Utf8> Function(Pointer<Utf8> str,int len);
|
||||||
|
|
||||||
void main() => runApp(Flwtch());
|
void main() => runApp(Flwtch());
|
||||||
|
|
||||||
|
@ -20,16 +41,56 @@ class FlwtchState extends State<Flwtch> {
|
||||||
DynamicLibrary library;
|
DynamicLibrary library;
|
||||||
AppModel appStatus;
|
AppModel appStatus;
|
||||||
|
|
||||||
|
static const appInfoPlatform = const MethodChannel('test.flutter.dev/applicationInfo');
|
||||||
|
var androidLibraryDir = "";
|
||||||
|
var androidHomeDirectory = "";
|
||||||
|
|
||||||
|
@override
|
||||||
|
initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
getApplicationDocumentsDirectory().then((directory) =>
|
||||||
|
{
|
||||||
|
setState(() {
|
||||||
|
print("androidHomeDir = $directory");
|
||||||
|
androidHomeDirectory = directory.path;
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
appInfoPlatform.invokeMethod('getNativeLibDir').then((value) =>
|
||||||
|
{
|
||||||
|
setState(() {
|
||||||
|
print("nativeLibraryDir = $value");
|
||||||
|
androidLibraryDir = value;
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
library = DynamicLibrary.open("libCwtch.so");
|
library = DynamicLibrary.open("libCwtch.so");
|
||||||
appStatus = AppModel(library: library);
|
appStatus = AppModel(library: library);
|
||||||
|
|
||||||
|
String home = "";
|
||||||
|
Map<String, String> envVars = Platform.environment;
|
||||||
|
if (Platform.isMacOS) {
|
||||||
|
home = envVars['HOME'];
|
||||||
|
} else if (Platform.isLinux) {
|
||||||
|
home = envVars['HOME'];
|
||||||
|
} else if (Platform.isWindows) {
|
||||||
|
home = envVars['UserProfile'];
|
||||||
|
} else if (Platform.isAndroid) {
|
||||||
|
home = androidHomeDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
var startCwtchC = library.lookup<NativeFunction<start_cwtch_function>>("StartCwtch");
|
var startCwtchC = library.lookup<NativeFunction<start_cwtch_function>>("StartCwtch");
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
final StartCwtch = startCwtchC.asFunction<StartCwtchFn>();
|
final StartCwtch = startCwtchC.asFunction<StartCwtchFn>();
|
||||||
|
|
||||||
var cwtchDir = "/home/sarah/.cwtch/dev/";
|
var cwtchDir = path.join(home, ".cwtch/dev/");
|
||||||
|
print("cwtchDir $cwtchDir");
|
||||||
StartCwtch(Utf8.toUtf8(cwtchDir), cwtchDir.length);
|
StartCwtch(Utf8.toUtf8(cwtchDir), cwtchDir.length);
|
||||||
|
|
||||||
return Provider<FlwtchState>(
|
return Provider<FlwtchState>(
|
||||||
|
|
86
pubspec.lock
86
pubspec.lock
|
@ -64,6 +64,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.1.3"
|
version: "0.1.3"
|
||||||
|
file:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: file
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "5.2.1"
|
||||||
flutter:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
|
@ -74,6 +81,13 @@ packages:
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
intl:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: intl
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.16.1"
|
||||||
matcher:
|
matcher:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -102,6 +116,62 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.0-nullsafety.3"
|
version: "1.8.0-nullsafety.3"
|
||||||
|
path_provider:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: path_provider
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.6.27"
|
||||||
|
path_provider_linux:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: path_provider_linux
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.0.1+2"
|
||||||
|
path_provider_macos:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: path_provider_macos
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.0.4+8"
|
||||||
|
path_provider_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: path_provider_platform_interface
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.4"
|
||||||
|
path_provider_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: path_provider_windows
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.0.4+3"
|
||||||
|
platform:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: platform
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.2.1"
|
||||||
|
plugin_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: plugin_platform_interface
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.3"
|
||||||
|
process:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: process
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.13"
|
||||||
provider:
|
provider:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -170,6 +240,20 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0-nullsafety.5"
|
version: "2.1.0-nullsafety.5"
|
||||||
|
win32:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: win32
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.7.4"
|
||||||
|
xdg_directories:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: xdg_directories
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.1.2"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.12.0-0.0 <3.0.0"
|
dart: ">=2.12.0-0.0 <3.0.0"
|
||||||
flutter: ">=1.16.0"
|
flutter: ">=1.16.0 <2.0.0"
|
||||||
|
|
|
@ -30,6 +30,7 @@ dependencies:
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
cupertino_icons: ^1.0.0
|
cupertino_icons: ^1.0.0
|
||||||
ffi: ^0.1.3
|
ffi: ^0.1.3
|
||||||
|
path_provider: ^1.6.27
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
Loading…
Reference in New Issue