From 44c7de72e5b589128b7d5fb8dde24cb8602bbf36 Mon Sep 17 00:00:00 2001 From: M Date: Thu, 24 Feb 2022 14:23:12 +0300 Subject: [PATCH] cw_shared_external --- .gitignore | 2 +- cw_shared_external/.gitignore | 7 + cw_shared_external/.metadata | 10 ++ cw_shared_external/LICENSE | 1 + cw_shared_external/README.md | 7 + cw_shared_external/android/.gitignore | 8 + cw_shared_external/android/build.gradle | 40 +++++ cw_shared_external/android/gradle.properties | 3 + .../gradle/wrapper/gradle-wrapper.properties | 5 + cw_shared_external/android/settings.gradle | 1 + .../android/src/main/AndroidManifest.xml | 3 + .../CwSharedExternalPlugin.kt | 36 +++++ cw_shared_external/ios/.gitignore | 37 +++++ cw_shared_external/ios/Assets/.gitkeep | 0 .../ios/Classes/CwSharedExternalPlugin.h | 4 + .../ios/Classes/CwSharedExternalPlugin.m | 15 ++ .../Classes/SwiftCwSharedExternalPlugin.swift | 14 ++ .../ios/cw_shared_external.podspec | 41 +++++ .../lib/cw_shared_external.dart | 14 ++ cw_shared_external/pubspec.lock | 147 ++++++++++++++++++ cw_shared_external/pubspec.yaml | 26 ++++ 21 files changed, 420 insertions(+), 1 deletion(-) create mode 100644 cw_shared_external/.gitignore create mode 100644 cw_shared_external/.metadata create mode 100644 cw_shared_external/LICENSE create mode 100644 cw_shared_external/README.md create mode 100644 cw_shared_external/android/.gitignore create mode 100644 cw_shared_external/android/build.gradle create mode 100644 cw_shared_external/android/gradle.properties create mode 100644 cw_shared_external/android/gradle/wrapper/gradle-wrapper.properties create mode 100644 cw_shared_external/android/settings.gradle create mode 100644 cw_shared_external/android/src/main/AndroidManifest.xml create mode 100644 cw_shared_external/android/src/main/kotlin/com/cakewallet/cw_shared_external/CwSharedExternalPlugin.kt create mode 100644 cw_shared_external/ios/.gitignore create mode 100644 cw_shared_external/ios/Assets/.gitkeep create mode 100644 cw_shared_external/ios/Classes/CwSharedExternalPlugin.h create mode 100644 cw_shared_external/ios/Classes/CwSharedExternalPlugin.m create mode 100644 cw_shared_external/ios/Classes/SwiftCwSharedExternalPlugin.swift create mode 100644 cw_shared_external/ios/cw_shared_external.podspec create mode 100644 cw_shared_external/lib/cw_shared_external.dart create mode 100644 cw_shared_external/pubspec.lock create mode 100644 cw_shared_external/pubspec.yaml diff --git a/.gitignore b/.gitignore index 38da4670a..d929b12dc 100644 --- a/.gitignore +++ b/.gitignore @@ -111,7 +111,7 @@ ios/build *.sublime-project shared_external/** -cw_shared_external/** +cw_shared_external/ios/External/ # cw_haven/** cw_haven/ios/External/ cw_haven/android/.externalNativeBuild/ diff --git a/cw_shared_external/.gitignore b/cw_shared_external/.gitignore new file mode 100644 index 000000000..e9dc58d3d --- /dev/null +++ b/cw_shared_external/.gitignore @@ -0,0 +1,7 @@ +.DS_Store +.dart_tool/ + +.packages +.pub/ + +build/ diff --git a/cw_shared_external/.metadata b/cw_shared_external/.metadata new file mode 100644 index 000000000..cb1a29e7c --- /dev/null +++ b/cw_shared_external/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: 4d7946a68d26794349189cf21b3f68cc6fe61dcb + channel: stable + +project_type: plugin diff --git a/cw_shared_external/LICENSE b/cw_shared_external/LICENSE new file mode 100644 index 000000000..ba75c69f7 --- /dev/null +++ b/cw_shared_external/LICENSE @@ -0,0 +1 @@ +TODO: Add your license here. diff --git a/cw_shared_external/README.md b/cw_shared_external/README.md new file mode 100644 index 000000000..7de77f1ec --- /dev/null +++ b/cw_shared_external/README.md @@ -0,0 +1,7 @@ +# cw_shared_external + +Part of Cake Wallet. Shared external libraries for cw_monero and cw_haven. +Libraries: +- Boost +- OpenSSL +- Sodium \ No newline at end of file diff --git a/cw_shared_external/android/.gitignore b/cw_shared_external/android/.gitignore new file mode 100644 index 000000000..c6cbe562a --- /dev/null +++ b/cw_shared_external/android/.gitignore @@ -0,0 +1,8 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures diff --git a/cw_shared_external/android/build.gradle b/cw_shared_external/android/build.gradle new file mode 100644 index 000000000..d6cdaf658 --- /dev/null +++ b/cw_shared_external/android/build.gradle @@ -0,0 +1,40 @@ +group 'com.cakewallet.cw_shared_external' +version '1.0-SNAPSHOT' + +buildscript { + ext.kotlin_version = '1.3.50' + repositories { + google() + jcenter() + } + + dependencies { + classpath 'com.android.tools.build:gradle:4.1.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +rootProject.allprojects { + repositories { + google() + jcenter() + } +} + +apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' + +android { + compileSdkVersion 30 + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + defaultConfig { + minSdkVersion 16 + } +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/cw_shared_external/android/gradle.properties b/cw_shared_external/android/gradle.properties new file mode 100644 index 000000000..94adc3a3f --- /dev/null +++ b/cw_shared_external/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/cw_shared_external/android/gradle/wrapper/gradle-wrapper.properties b/cw_shared_external/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..3c9d0852b --- /dev/null +++ b/cw_shared_external/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip diff --git a/cw_shared_external/android/settings.gradle b/cw_shared_external/android/settings.gradle new file mode 100644 index 000000000..f56f3e6e5 --- /dev/null +++ b/cw_shared_external/android/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'cw_shared_external' diff --git a/cw_shared_external/android/src/main/AndroidManifest.xml b/cw_shared_external/android/src/main/AndroidManifest.xml new file mode 100644 index 000000000..87de60b54 --- /dev/null +++ b/cw_shared_external/android/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + diff --git a/cw_shared_external/android/src/main/kotlin/com/cakewallet/cw_shared_external/CwSharedExternalPlugin.kt b/cw_shared_external/android/src/main/kotlin/com/cakewallet/cw_shared_external/CwSharedExternalPlugin.kt new file mode 100644 index 000000000..6066999ff --- /dev/null +++ b/cw_shared_external/android/src/main/kotlin/com/cakewallet/cw_shared_external/CwSharedExternalPlugin.kt @@ -0,0 +1,36 @@ +package com.cakewallet.cw_shared_external + +import androidx.annotation.NonNull + +import io.flutter.embedding.engine.plugins.FlutterPlugin +import io.flutter.plugin.common.MethodCall +import io.flutter.plugin.common.MethodChannel +import io.flutter.plugin.common.MethodChannel.MethodCallHandler +import io.flutter.plugin.common.MethodChannel.Result +import io.flutter.plugin.common.PluginRegistry.Registrar + +/** CwSharedExternalPlugin */ +class CwSharedExternalPlugin: FlutterPlugin, MethodCallHandler { + /// The MethodChannel that will the communication between Flutter and native Android + /// + /// This local reference serves to register the plugin with the Flutter Engine and unregister it + /// when the Flutter Engine is detached from the Activity + private lateinit var channel : MethodChannel + + override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { + channel = MethodChannel(flutterPluginBinding.binaryMessenger, "cw_shared_external") + channel.setMethodCallHandler(this) + } + + override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) { + if (call.method == "getPlatformVersion") { + result.success("Android ${android.os.Build.VERSION.RELEASE}") + } else { + result.notImplemented() + } + } + + override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { + channel.setMethodCallHandler(null) + } +} diff --git a/cw_shared_external/ios/.gitignore b/cw_shared_external/ios/.gitignore new file mode 100644 index 000000000..aa479fd3c --- /dev/null +++ b/cw_shared_external/ios/.gitignore @@ -0,0 +1,37 @@ +.idea/ +.vagrant/ +.sconsign.dblite +.svn/ + +.DS_Store +*.swp +profile + +DerivedData/ +build/ +GeneratedPluginRegistrant.h +GeneratedPluginRegistrant.m + +.generated/ + +*.pbxuser +*.mode1v3 +*.mode2v3 +*.perspectivev3 + +!default.pbxuser +!default.mode1v3 +!default.mode2v3 +!default.perspectivev3 + +xcuserdata + +*.moved-aside + +*.pyc +*sync/ +Icon? +.tags* + +/Flutter/Generated.xcconfig +/Flutter/flutter_export_environment.sh \ No newline at end of file diff --git a/cw_shared_external/ios/Assets/.gitkeep b/cw_shared_external/ios/Assets/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/cw_shared_external/ios/Classes/CwSharedExternalPlugin.h b/cw_shared_external/ios/Classes/CwSharedExternalPlugin.h new file mode 100644 index 000000000..96f5abe6b --- /dev/null +++ b/cw_shared_external/ios/Classes/CwSharedExternalPlugin.h @@ -0,0 +1,4 @@ +#import + +@interface CwSharedExternalPlugin : NSObject +@end diff --git a/cw_shared_external/ios/Classes/CwSharedExternalPlugin.m b/cw_shared_external/ios/Classes/CwSharedExternalPlugin.m new file mode 100644 index 000000000..80f4bfe2f --- /dev/null +++ b/cw_shared_external/ios/Classes/CwSharedExternalPlugin.m @@ -0,0 +1,15 @@ +#import "CwSharedExternalPlugin.h" +#if __has_include() +#import +#else +// Support project import fallback if the generated compatibility header +// is not copied when this plugin is created as a library. +// https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816 +#import "cw_shared_external-Swift.h" +#endif + +@implementation CwSharedExternalPlugin ++ (void)registerWithRegistrar:(NSObject*)registrar { + [SwiftCwSharedExternalPlugin registerWithRegistrar:registrar]; +} +@end diff --git a/cw_shared_external/ios/Classes/SwiftCwSharedExternalPlugin.swift b/cw_shared_external/ios/Classes/SwiftCwSharedExternalPlugin.swift new file mode 100644 index 000000000..213fed6e4 --- /dev/null +++ b/cw_shared_external/ios/Classes/SwiftCwSharedExternalPlugin.swift @@ -0,0 +1,14 @@ +import Flutter +import UIKit + +public class SwiftCwSharedExternalPlugin: NSObject, FlutterPlugin { + public static func register(with registrar: FlutterPluginRegistrar) { + let channel = FlutterMethodChannel(name: "cw_shared_external", binaryMessenger: registrar.messenger()) + let instance = SwiftCwSharedExternalPlugin() + registrar.addMethodCallDelegate(instance, channel: channel) + } + + public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { + result("iOS " + UIDevice.current.systemVersion) + } +} diff --git a/cw_shared_external/ios/cw_shared_external.podspec b/cw_shared_external/ios/cw_shared_external.podspec new file mode 100644 index 000000000..b147dc7df --- /dev/null +++ b/cw_shared_external/ios/cw_shared_external.podspec @@ -0,0 +1,41 @@ +# +# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. +# Run `pod lib lint cw_shared_external.podspec` to validate before publishing. +# +Pod::Spec.new do |s| + s.name = 'cw_shared_external' + s.version = '0.0.1' + s.summary = 'Shared libraries for monero and haven.' + s.description = 'Shared libraries for monero and haven.' + s.homepage = 'http://cakewallet.com' + s.license = { :file => '../LICENSE' } + s.author = { 'Cake Wallet' => 'm@cakewallet.com' } + s.source = { :path => '.' } + s.source_files = 'Classes/**/*' + s.dependency 'Flutter' + s.platform = :ios, '10.0' + + s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS' => 'arm64', 'ENABLE_BITCODE' => 'NO' } + s.swift_version = '5.0' + + s.subspec 'OpenSSL' do |openssl| + openssl.preserve_paths = 'External/ios/include/*.h' + openssl.vendored_libraries = 'External/ios/lib/libcrypto.a', 'External/ios/lib/libssl.a' + openssl.libraries = 'ssl', 'crypto' + openssl.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/External/ios/include/**" } + end + + s.subspec 'Boost' do |boost| + boost.preserve_paths = 'External/ios/include/**/*.h' + boost.vendored_libraries = 'External/ios/lib/libboost.a', + boost.libraries = 'boost' + boost.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/External/ios/include/**" } + end + + s.subspec 'Sodium' do |sodium| + sodium.preserve_paths = 'External/ios/include/**/*.h' + sodium.vendored_libraries = 'External/ios/lib/libsodium.a' + sodium.libraries = 'sodium' + sodium.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/External/ios/include/**" } + end +end diff --git a/cw_shared_external/lib/cw_shared_external.dart b/cw_shared_external/lib/cw_shared_external.dart new file mode 100644 index 000000000..37d0350dd --- /dev/null +++ b/cw_shared_external/lib/cw_shared_external.dart @@ -0,0 +1,14 @@ + +import 'dart:async'; + +import 'package:flutter/services.dart'; + +class CwSharedExternal { + static const MethodChannel _channel = + const MethodChannel('cw_shared_external'); + + static Future get platformVersion async { + final String version = await _channel.invokeMethod('getPlatformVersion'); + return version; + } +} diff --git a/cw_shared_external/pubspec.lock b/cw_shared_external/pubspec.lock new file mode 100644 index 000000000..ef01c9f9a --- /dev/null +++ b/cw_shared_external/pubspec.lock @@ -0,0 +1,147 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + async: + dependency: transitive + description: + name: async + url: "https://pub.dartlang.org" + source: hosted + version: "2.5.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + charcode: + dependency: transitive + description: + name: charcode + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + collection: + dependency: transitive + description: + name: collection + url: "https://pub.dartlang.org" + source: hosted + version: "1.15.0" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + matcher: + dependency: transitive + description: + name: matcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.10" + meta: + dependency: transitive + description: + name: meta + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" + path: + dependency: transitive + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.0" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.10.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + test_api: + dependency: transitive + description: + name: test_api + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.19" + typed_data: + dependency: transitive + description: + name: typed_data + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" + vector_math: + dependency: transitive + description: + name: vector_math + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" +sdks: + dart: ">=2.12.0-0.0 <3.0.0" + flutter: ">=1.20.0" diff --git a/cw_shared_external/pubspec.yaml b/cw_shared_external/pubspec.yaml new file mode 100644 index 000000000..b9a8ca1e0 --- /dev/null +++ b/cw_shared_external/pubspec.yaml @@ -0,0 +1,26 @@ +name: cw_shared_external +description: Shared external libraries for monero and haven +version: 0.0.1 +author: Cake Walelt +homepage: https://cakewallet.com + +environment: + sdk: ">=2.7.0 <3.0.0" + flutter: ">=1.20.0" + +dependencies: + flutter: + sdk: flutter + +dev_dependencies: + flutter_test: + sdk: flutter + +flutter: + plugin: + platforms: + android: + package: com.cakewallet.cw_shared_external + pluginClass: CwSharedExternalPlugin + ios: + pluginClass: CwSharedExternalPlugin \ No newline at end of file